Changeset 95136 in webkit


Ignore:
Timestamp:
Sep 14, 2011 4:06:04 PM (13 years ago)
Author:
fpizlo@apple.com
Message:

DFG JIT should not speculate integer if the value is always going to be
used as a double anyway
https://bugs.webkit.org/show_bug.cgi?id=68127

Reviewed by Oliver Hunt.

Added a ValueToDouble node, which is a variant of ValueToNumber that
hints that it will only be used as a double and never as an integer.
Thus, it turns off integer speculation even if the value profiler
told us that the value source is an int. The logic for converting a
ValueToNumber into a ValueToDouble is found in Propagator.

This appears to be a 22% speed-up in imaging-darkroom.

  • dfg/DFGNode.h:
  • dfg/DFGNonSpeculativeJIT.cpp:

(JSC::DFG::NonSpeculativeJIT::compile):

  • dfg/DFGPropagator.cpp:

(JSC::DFG::Propagator::fixpoint):
(JSC::DFG::Propagator::toDouble):
(JSC::DFG::Propagator::fixupNode):
(JSC::DFG::Propagator::fixup):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compile):
(JSC::DFG::SpeculativeJIT::computeValueRecoveryFor):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95134 r95136  
     12011-09-14  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG JIT should not speculate integer if the value is always going to be
     4        used as a double anyway
     5        https://bugs.webkit.org/show_bug.cgi?id=68127
     6
     7        Reviewed by Oliver Hunt.
     8       
     9        Added a ValueToDouble node, which is a variant of ValueToNumber that
     10        hints that it will only be used as a double and never as an integer.
     11        Thus, it turns off integer speculation even if the value profiler
     12        told us that the value source is an int. The logic for converting a
     13        ValueToNumber into a ValueToDouble is found in Propagator.
     14       
     15        This appears to be a 22% speed-up in imaging-darkroom.
     16
     17        * dfg/DFGNode.h:
     18        * dfg/DFGNonSpeculativeJIT.cpp:
     19        (JSC::DFG::NonSpeculativeJIT::compile):
     20        * dfg/DFGPropagator.cpp:
     21        (JSC::DFG::Propagator::fixpoint):
     22        (JSC::DFG::Propagator::toDouble):
     23        (JSC::DFG::Propagator::fixupNode):
     24        (JSC::DFG::Propagator::fixup):
     25        * dfg/DFGSpeculativeJIT.cpp:
     26        (JSC::DFG::SpeculativeJIT::compile):
     27        (JSC::DFG::SpeculativeJIT::computeValueRecoveryFor):
     28
    1292011-09-14  Filip Pizlo  <fpizlo@apple.com>
    230
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r95115 r95136  
    159159    macro(ValueToNumber, NodeResultNumber | NodeMustGenerate) \
    160160    \
     161    /* A variant of ValueToNumber, which a hint that the parents will always use this as a double. */\
     162    macro(ValueToDouble, NodeResultNumber | NodeMustGenerate) \
     163    \
    161164    /* Add of values may either be arithmetic, or result in string concatenation. */\
    162165    macro(ValueAdd, NodeResultJS | NodeMustGenerate) \
  • trunk/Source/JavaScriptCore/dfg/DFGNonSpeculativeJIT.cpp

    r95127 r95136  
    596596    }
    597597
    598     case ValueToNumber: {
     598    case ValueToNumber:
     599    case ValueToDouble: {
    599600        ASSERT(!isInt32Constant(node.child1()));
    600601        ASSERT(!isNumberConstant(node.child1()));
  • trunk/Source/JavaScriptCore/dfg/DFGPropagator.cpp

    r95115 r95136  
    8686            propagateBackward();
    8787        } while (m_changed);
     88       
     89        fixup();
    8890    }
    8991   
     
    322324    }
    323325   
     326    void toDouble(NodeIndex nodeIndex)
     327    {
     328        if (m_graph[nodeIndex].op == ValueToNumber) {
     329#if ENABLE(DFG_DEBUG_VERBOSE)
     330            printf("  @%u -> ValueToDouble", nodeIndex);
     331#endif
     332            m_graph[nodeIndex].op = ValueToDouble;
     333        }
     334    }
     335   
     336    void fixupNode(Node& node)
     337    {
     338        if (!node.shouldGenerate())
     339            return;
     340       
     341        NodeType op = node.op;
     342
     343#if ENABLE(DFG_DEBUG_VERBOSE)
     344        printf("   %s[%u]: ", Graph::opName(op), m_compileIndex);
     345#endif
     346       
     347        switch (op) {
     348        case ValueAdd: {
     349            PredictedType left = m_predictions[node.child1()];
     350            PredictedType right = m_predictions[node.child2()];
     351           
     352            if (isStrongPrediction(left) && isStrongPrediction(right) && isNumberPrediction(left) && isNumberPrediction(right)) {
     353                if (left & PredictDouble)
     354                    toDouble(node.child2());
     355                if (right & PredictDouble)
     356                    toDouble(node.child1());
     357            }
     358            break;
     359        }
     360           
     361        case ArithAdd:
     362        case ArithSub:
     363        case ArithMul: {
     364            PredictedType left = m_predictions[node.child1()];
     365            PredictedType right = m_predictions[node.child2()];
     366           
     367            if (isStrongPrediction(left) && isStrongPrediction(right)) {
     368                if (left & PredictDouble)
     369                    toDouble(node.child2());
     370                if (right & PredictDouble)
     371                    toDouble(node.child1());
     372            }
     373            break;
     374        }
     375           
     376        case ArithDiv: {
     377            toDouble(node.child1());
     378            toDouble(node.child2());
     379            break;
     380        }
     381           
     382        default:
     383            break;
     384        }
     385
     386#if ENABLE(DFG_DEBUG_VERBOSE)
     387        printf("\n");
     388#endif
     389    }
     390   
     391    void fixup()
     392    {
     393#if ENABLE(DFG_DEBUG_VERBOSE)
     394        printf("Performing Fixup\n");
     395#endif
     396        for (m_compileIndex = 0; m_compileIndex < m_graph.size(); ++m_compileIndex)
     397            fixupNode(m_graph[m_compileIndex]);
     398    }
     399   
    324400    Graph& m_graph;
    325401    JSGlobalData& m_globalData;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r95127 r95136  
    864864            break;
    865865        }
     866        SpeculateDoubleOperand op1(this, node.child1());
     867        FPRTemporary result(this, op1);
     868        m_jit.moveDouble(op1.fpr(), result.fpr());
     869        doubleResult(result.fpr(), m_compileIndex);
     870        break;
     871    }
     872
     873    case ValueToDouble: {
    866874        SpeculateDoubleOperand op1(this, node.child1());
    867875        FPRTemporary result(this, op1);
     
    16951703                switch (node.op) {
    16961704                case ValueToNumber:
     1705                case ValueToDouble:
    16971706                    valueToNumberIndex = info.nodeIndex();
    16981707                    break;
Note: See TracChangeset for help on using the changeset viewer.