Changeset 214296 in webkit


Ignore:
Timestamp:
Mar 22, 2017 11:01:39 PM (7 years ago)
Author:
Yusuke Suzuki
Message:

[JSC][DFG] Propagate AnyIntAsDouble information carefully to utilize it in fixup
https://bugs.webkit.org/show_bug.cgi?id=169914

Reviewed by Saam Barati.

JSTests:

  • stress/any-int-as-double-add.js: Added.

(shouldBe):
(test):

  • stress/to-this-numbers.js: Added.

(shouldBe):
(Number.prototype.toThis):

Source/JavaScriptCore:

In DFG prediction propagation phase, we pollute the prediction of GetByVal for Array::Double
as SpecDoubleReal even if the heap prediction says the proper prediction is SpecAnyIntAsDouble.
Thus, the following nodes just see the result of GetByVal(Array::Double) as double value,
and select suboptimal edge filters in fixup phase. For example, if the result of GetByVal is
SpecAnyIntAsDouble, we can see the node like ArithAdd(SpecAnyIntAsDouble, Int52) and we should
have a chance to make it ArithAdd(Check:Int52, Int52) instead of ArithAdd(Double, Double).

This patch propagates SpecAnyIntAsDouble in GetByVal(Array::Double) properly. And ValueAdd,
ArithAdd and ArithSub select AnyInt edge filters for SpecAnyIntAsDouble values. It finally
produces a Int52 specialized DFG node. And subsequent nodes using the produced one also
become Int52 specialized.

One considerable problem is that the heap prediction misses the non any int doubles. In that case,
if Int52 edge filter is used, BadType exit will occur. It updates the prediction of the value profile
of GetByVal. So, in the next time, GetByVal(Array::Double) produces more conservative predictions
and avoids exit-and-recompile loop correctly.

This change is very sensitive to the correct AI and appropriate predictions. Thus, this patch finds
and fixes some related issues. One is incorrect prediction of ToThis and another is incorrect
AI logic for Int52Rep.

This change dramatically improves kraken benchmarks' crypto-pbkdf2 and crypto-sha256-iterative
by 42.0% and 30.7%, respectively.

baseline patched

Kraken:
ai-astar 158.851+-4.132 ? 159.433+-5.176 ?
audio-beat-detection 53.193+-1.621 ? 53.391+-2.072 ?
audio-dft 103.589+-2.277 ? 104.902+-1.924 ? might be 1.0127x slower
audio-fft 40.491+-1.102 39.854+-0.755 might be 1.0160x faster
audio-oscillator 68.504+-1.721 ? 68.957+-1.725 ?
imaging-darkroom 118.367+-2.171 ? 119.581+-2.310 ? might be 1.0103x slower
imaging-desaturate 71.443+-1.461 ? 72.398+-1.918 ? might be 1.0134x slower
imaging-gaussian-blur 110.648+-4.035 109.184+-3.373 might be 1.0134x faster
json-parse-financial 60.363+-1.628 ? 61.936+-1.585 ? might be 1.0261x slower
json-stringify-tinderbox 37.903+-0.869 ? 39.559+-1.607 ? might be 1.0437x slower
stanford-crypto-aes 56.313+-1.512 ? 56.675+-1.715 ?
stanford-crypto-ccm 51.564+-1.900 ? 53.456+-2.548 ? might be 1.0367x slower
stanford-crypto-pbkdf2 129.546+-2.738 91.214+-2.027 definitely 1.4202x faster
stanford-crypto-sha256-iterative 43.515+-0.730 33.292+-0.653 definitely 1.3071x faster

<arithmetic> 78.878+-0.528 75.988+-0.621 definitely 1.0380x faster

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::addShouldSpeculateAnyInt):

  • dfg/DFGPredictionPropagationPhase.cpp:
  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileArithNegate):

Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r214289 r214296  
     12017-03-22  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC][DFG] Propagate AnyIntAsDouble information carefully to utilize it in fixup
     4        https://bugs.webkit.org/show_bug.cgi?id=169914
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/any-int-as-double-add.js: Added.
     9        (shouldBe):
     10        (test):
     11        * stress/to-this-numbers.js: Added.
     12        (shouldBe):
     13        (Number.prototype.toThis):
     14
    1152017-03-22  Mark Lam  <mark.lam@apple.com>
    216
  • trunk/Source/JavaScriptCore/ChangeLog

    r214289 r214296  
     12017-03-22  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC][DFG] Propagate AnyIntAsDouble information carefully to utilize it in fixup
     4        https://bugs.webkit.org/show_bug.cgi?id=169914
     5
     6        Reviewed by Saam Barati.
     7
     8        In DFG prediction propagation phase, we pollute the prediction of GetByVal for Array::Double
     9        as SpecDoubleReal even if the heap prediction says the proper prediction is SpecAnyIntAsDouble.
     10        Thus, the following nodes just see the result of GetByVal(Array::Double) as double value,
     11        and select suboptimal edge filters in fixup phase. For example, if the result of GetByVal is
     12        SpecAnyIntAsDouble, we can see the node like ArithAdd(SpecAnyIntAsDouble, Int52) and we should
     13        have a chance to make it ArithAdd(Check:Int52, Int52) instead of ArithAdd(Double, Double).
     14
     15        This patch propagates SpecAnyIntAsDouble in GetByVal(Array::Double) properly. And ValueAdd,
     16        ArithAdd and ArithSub select AnyInt edge filters for SpecAnyIntAsDouble values. It finally
     17        produces a Int52 specialized DFG node. And subsequent nodes using the produced one also
     18        become Int52 specialized.
     19
     20        One considerable problem is that the heap prediction misses the non any int doubles. In that case,
     21        if Int52 edge filter is used, BadType exit will occur. It updates the prediction of the value profile
     22        of GetByVal. So, in the next time, GetByVal(Array::Double) produces more conservative predictions
     23        and avoids exit-and-recompile loop correctly.
     24
     25        This change is very sensitive to the correct AI and appropriate predictions. Thus, this patch finds
     26        and fixes some related issues. One is incorrect prediction of ToThis and another is incorrect
     27        AI logic for Int52Rep.
     28
     29        This change dramatically improves kraken benchmarks' crypto-pbkdf2 and crypto-sha256-iterative
     30        by 42.0% and 30.7%, respectively.
     31
     32                                                     baseline                  patched
     33        Kraken:
     34        ai-astar                                  158.851+-4.132      ?     159.433+-5.176         ?
     35        audio-beat-detection                       53.193+-1.621      ?      53.391+-2.072         ?
     36        audio-dft                                 103.589+-2.277      ?     104.902+-1.924         ? might be 1.0127x slower
     37        audio-fft                                  40.491+-1.102             39.854+-0.755           might be 1.0160x faster
     38        audio-oscillator                           68.504+-1.721      ?      68.957+-1.725         ?
     39        imaging-darkroom                          118.367+-2.171      ?     119.581+-2.310         ? might be 1.0103x slower
     40        imaging-desaturate                         71.443+-1.461      ?      72.398+-1.918         ? might be 1.0134x slower
     41        imaging-gaussian-blur                     110.648+-4.035            109.184+-3.373           might be 1.0134x faster
     42        json-parse-financial                       60.363+-1.628      ?      61.936+-1.585         ? might be 1.0261x slower
     43        json-stringify-tinderbox                   37.903+-0.869      ?      39.559+-1.607         ? might be 1.0437x slower
     44        stanford-crypto-aes                        56.313+-1.512      ?      56.675+-1.715         ?
     45        stanford-crypto-ccm                        51.564+-1.900      ?      53.456+-2.548         ? might be 1.0367x slower
     46        stanford-crypto-pbkdf2                    129.546+-2.738      ^      91.214+-2.027         ^ definitely 1.4202x faster
     47        stanford-crypto-sha256-iterative           43.515+-0.730      ^      33.292+-0.653         ^ definitely 1.3071x faster
     48
     49        <arithmetic>                               78.878+-0.528      ^      75.988+-0.621         ^ definitely 1.0380x faster
     50
     51        * dfg/DFGAbstractInterpreterInlines.h:
     52        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     53        * dfg/DFGGraph.h:
     54        (JSC::DFG::Graph::addShouldSpeculateAnyInt):
     55        * dfg/DFGPredictionPropagationPhase.cpp:
     56        * ftl/FTLLowerDFGToB3.cpp:
     57        (JSC::FTL::DFG::LowerDFGToB3::compileArithNegate):
     58
    1592017-03-22  Mark Lam  <mark.lam@apple.com>
    260
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r214219 r214296  
    476476        }
    477477       
    478         forNode(node).setType(SpecInt32Only);
     478        forNode(node).setType(SpecAnyInt);
    479479        break;
    480480    }
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.h

    r212365 r214296  
    294294        Node* right = add->child2().node();
    295295
    296         bool speculation = Node::shouldSpeculateAnyInt(left, right);
    297         return speculation && !hasExitSite(add, Int52Overflow);
     296        auto isAnyIntSpeculationForAdd = [](SpeculatedType value) {
     297            return !!value && (value & (SpecAnyInt | SpecAnyIntAsDouble)) == value;
     298        };
     299
     300        return isAnyIntSpeculationForAdd(left->prediction())
     301            && isAnyIntSpeculationForAdd(right->prediction())
     302            && !hasExitSite(add, Int52Overflow);
    298303    }
    299304   
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r214219 r214296  
    355355                if (arrayMode.isOutOfBounds())
    356356                    changed |= mergePrediction(node->getHeapPrediction() | SpecDoubleReal);
     357                else if (node->getHeapPrediction() & SpecNonIntAsDouble)
     358                    changed |= mergePrediction(SpecDoubleReal);
    357359                else
    358                     changed |= mergePrediction(SpecDoubleReal);
     360                    changed |= mergePrediction(SpecAnyIntAsDouble);
    359361                break;
    360362            case Array::Float32Array:
     
    404406
    405407                if (node->child1()->shouldSpeculateNumber()) {
    406                     changed |= mergePrediction(SpecAnyInt);
     408                    changed |= mergePrediction(SpecBytecodeNumber);
    407409                    break;
    408410                }
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r214219 r214296  
    25652565            CheckValue* result = m_out.speculateSub(m_out.int64Zero, value);
    25662566            blessSpeculation(result, Int52Overflow, noValue(), nullptr, m_origin);
    2567             speculate(NegativeZero, noValue(), 0, m_out.isZero64(result));
     2567            if (shouldCheckNegativeZero(m_node->arithMode()))
     2568                speculate(NegativeZero, noValue(), 0, m_out.isZero64(result));
    25682569            setInt52(result);
    25692570            break;
Note: See TracChangeset for help on using the changeset viewer.