Changeset 92734 in webkit


Ignore:
Timestamp:
Aug 9, 2011 5:51:11 PM (13 years ago)
Author:
fpizlo@apple.com
Message:

DFG JIT has no way of propagating predictions to loads and calls
https://bugs.webkit.org/show_bug.cgi?id=65883

Reviewed by Gavin Barraclough.

This introduces the capability to store predictions on graph
nodes. To save space while being somewhat consistent, the
prediction is always stored in the second OpInfo slot (since
a GetById will use the first one for the identifier). This
change is a natural extension of r92593 (global variable
prediction).

This is a 1.5% win on V8 in the arithmetic mean, and a 0.6%
win on V8 in the geometric mean. It is neutral on SunSpider
and Kraken. Interestingly, on V8 it regresses crypto by 3%
while progressing deltablue and richards by 2.6% and 4.3%,
respectively.

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::addToGraph):
(JSC::DFG::ByteCodeParser::addCall):
(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::dump):

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::predict):
(JSC::DFG::Graph::getPrediction):

  • dfg/DFGNode.h:

(JSC::DFG::isCellPrediction):
(JSC::DFG::isArrayPrediction):
(JSC::DFG::isInt32Prediction):
(JSC::DFG::isDoublePrediction):
(JSC::DFG::isNumberPrediction):
(JSC::DFG::predictionToString):
(JSC::DFG::Node::Node):
(JSC::DFG::Node::hasPrediction):
(JSC::DFG::Node::getPrediction):
(JSC::DFG::Node::predict):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r92732 r92734  
     12011-08-09  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG JIT has no way of propagating predictions to loads and calls
     4        https://bugs.webkit.org/show_bug.cgi?id=65883
     5
     6        Reviewed by Gavin Barraclough.
     7       
     8        This introduces the capability to store predictions on graph
     9        nodes.  To save space while being somewhat consistent, the
     10        prediction is always stored in the second OpInfo slot (since
     11        a GetById will use the first one for the identifier).  This
     12        change is a natural extension of r92593 (global variable
     13        prediction).
     14       
     15        This is a 1.5% win on V8 in the arithmetic mean, and a 0.6%
     16        win on V8 in the geometric mean.  It is neutral on SunSpider
     17        and Kraken.  Interestingly, on V8 it regresses crypto by 3%
     18        while progressing deltablue and richards by 2.6% and 4.3%,
     19        respectively.
     20
     21        * dfg/DFGByteCodeParser.cpp:
     22        (JSC::DFG::ByteCodeParser::addToGraph):
     23        (JSC::DFG::ByteCodeParser::addCall):
     24        (JSC::DFG::ByteCodeParser::parseBlock):
     25        * dfg/DFGGraph.cpp:
     26        (JSC::DFG::Graph::dump):
     27        * dfg/DFGGraph.h:
     28        (JSC::DFG::Graph::predict):
     29        (JSC::DFG::Graph::getPrediction):
     30        * dfg/DFGNode.h:
     31        (JSC::DFG::isCellPrediction):
     32        (JSC::DFG::isArrayPrediction):
     33        (JSC::DFG::isInt32Prediction):
     34        (JSC::DFG::isDoublePrediction):
     35        (JSC::DFG::isNumberPrediction):
     36        (JSC::DFG::predictionToString):
     37        (JSC::DFG::Node::Node):
     38        (JSC::DFG::Node::hasPrediction):
     39        (JSC::DFG::Node::getPrediction):
     40        (JSC::DFG::Node::predict):
     41
    1422011-08-09  Filip Pizlo  <fpizlo@apple.com>
    243
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r92593 r92734  
    395395    }
    396396   
    397     NodeIndex addToGraph(Node::VarArgTag, NodeType op)
     397    NodeIndex addToGraph(Node::VarArgTag, NodeType op, OpInfo info1, OpInfo info2)
    398398    {
    399399        NodeIndex resultIndex = (NodeIndex)m_graph.size();
    400         m_graph.append(Node(Node::VarArg, op, m_currentIndex, m_graph.m_varArgChildren.size() - m_numPassedVarArgs, m_numPassedVarArgs));
     400        m_graph.append(Node(Node::VarArg, op, m_currentIndex, info1, info2, m_graph.m_varArgChildren.size() - m_numPassedVarArgs, m_numPassedVarArgs));
    401401       
    402402        m_numPassedVarArgs = 0;
     
    420420        for (int argIdx = firstArg; argIdx < firstArg + argCount; argIdx++)
    421421            addVarArgChild(get(argIdx));
    422         NodeIndex call = addToGraph(Node::VarArg, op);
     422        NodeIndex call = addToGraph(Node::VarArg, op, OpInfo(0), OpInfo(PredictNone));
    423423        Instruction* putInstruction = currentInstruction + OPCODE_LENGTH(op_call);
    424424        if (interpreter->getOpcodeID(putInstruction->u.opcode) == op_call_put_result)
     
    863863            predictInt32(property);
    864864
    865             NodeIndex getByVal = addToGraph(GetByVal, base, property, aliases.lookupGetByVal(base, property));
     865            NodeIndex getByVal = addToGraph(GetByVal, OpInfo(0), OpInfo(PredictNone), base, property, aliases.lookupGetByVal(base, property));
    866866            set(currentInstruction[1].u.operand, getByVal);
    867867            aliases.recordGetByVal(getByVal);
     
    892892            unsigned identifier = getInstruction[3].u.operand;
    893893           
    894             NodeIndex getMethod = addToGraph(GetMethod, OpInfo(identifier), base);
     894            NodeIndex getMethod = addToGraph(GetMethod, OpInfo(identifier), OpInfo(PredictNone), base);
    895895            set(getInstruction[1].u.operand, getMethod);
    896896            aliases.recordGetMethod(getMethod);
     
    905905            unsigned identifier = currentInstruction[3].u.operand;
    906906           
    907             NodeIndex getById = addToGraph(GetById, OpInfo(identifier), base);
     907            NodeIndex getById = addToGraph(GetById, OpInfo(identifier), OpInfo(PredictNone), base);
    908908            set(currentInstruction[1].u.operand, getById);
    909909            aliases.recordGetById(getById);
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r92593 r92734  
    139139    if (node.hasVarNumber())
    140140        printf("  predicting %s", predictionToString(getGlobalVarPrediction(node.varNumber())));
     141    if (node.hasPrediction())
     142        printf("  predicting %s", predictionToString(node.getPrediction()));
    141143   
    142144    printf("\n");
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.h

    r92593 r92734  
    4545inline bool operandIsArgument(int operand) { return operand < 0; }
    4646
    47 typedef uint8_t PredictedType;
    48 static const PredictedType PredictNone   = 0;
    49 static const PredictedType PredictCell   = 0x01;
    50 static const PredictedType PredictArray  = 0x03;
    51 static const PredictedType PredictInt32  = 0x04;
    52 static const PredictedType PredictDouble = 0x08;
    53 static const PredictedType PredictNumber = 0x0c;
    54 
    55 inline bool isCellPrediction(PredictedType value)
    56 {
    57     return (value & PredictCell) == PredictCell && !(value & ~PredictArray);
    58 }
    59 
    60 inline bool isArrayPrediction(PredictedType value)
    61 {
    62     return value == PredictArray;
    63 }
    64 
    65 inline bool isInt32Prediction(PredictedType value)
    66 {
    67     return value == PredictInt32;
    68 }
    69 
    70 inline bool isDoublePrediction(PredictedType value)
    71 {
    72     return value == PredictDouble;
    73 }
    74 
    75 inline bool isNumberPrediction(PredictedType value)
    76 {
    77     return !!(value & PredictNumber) && !(value & ~PredictNumber);
    78 }
    79 
    80 #ifndef NDEBUG
    81 inline const char* predictionToString(PredictedType value)
    82 {
    83     switch (value) {
    84     case PredictNone:
    85         return "p-bottom";
    86     case PredictCell:
    87         return "p-cell";
    88     case PredictArray:
    89         return "p-array";
    90     case PredictInt32:
    91         return "p-int32";
    92     case PredictNumber:
    93         return "p-number";
    94     default:
    95         return "p-top";
    96     }
    97 }
    98 #endif
    99 
    10047struct PredictionSlot {
    10148public:
     
    218165            predictGlobalVar(node.varNumber(), prediction);
    219166            break;
     167        case GetById:
     168        case GetMethod:
     169        case GetByVal:
     170        case Call:
     171        case Construct:
     172            node.predict(prediction);
     173            break;
    220174        default:
    221175            break;
     
    257211        case GetGlobalVar:
    258212            return getGlobalVarPrediction(nodePtr->varNumber());
     213        case GetById:
     214        case GetMethod:
     215        case GetByVal:
     216        case Call:
     217        case Construct:
     218            return nodePtr->getPrediction();
    259219        default:
    260220            return PredictNone;
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r91607 r92734  
    185185};
    186186
     187typedef uint8_t PredictedType;
     188static const PredictedType PredictNone   = 0;
     189static const PredictedType PredictCell   = 0x01;
     190static const PredictedType PredictArray  = 0x03;
     191static const PredictedType PredictInt32  = 0x04;
     192static const PredictedType PredictDouble = 0x08;
     193static const PredictedType PredictNumber = 0x0c;
     194
     195inline bool isCellPrediction(PredictedType value)
     196{
     197    return (value & PredictCell) == PredictCell && !(value & ~PredictArray);
     198}
     199
     200inline bool isArrayPrediction(PredictedType value)
     201{
     202    return value == PredictArray;
     203}
     204
     205inline bool isInt32Prediction(PredictedType value)
     206{
     207    return value == PredictInt32;
     208}
     209
     210inline bool isDoublePrediction(PredictedType value)
     211{
     212    return value == PredictDouble;
     213}
     214
     215inline bool isNumberPrediction(PredictedType value)
     216{
     217    return !!(value & PredictNumber) && !(value & ~PredictNumber);
     218}
     219
     220#ifndef NDEBUG
     221inline const char* predictionToString(PredictedType value)
     222{
     223    switch (value) {
     224    case PredictNone:
     225        return "p-bottom";
     226    case PredictCell:
     227        return "p-cell";
     228    case PredictArray:
     229        return "p-array";
     230    case PredictInt32:
     231        return "p-int32";
     232    case PredictNumber:
     233        return "p-number";
     234    default:
     235        return "p-top";
     236    }
     237}
     238#endif
     239
    187240// === Node ===
    188241//
     
    233286    }
    234287   
    235     // Construct a node with a variable number of children and no immediate values.
    236     Node(VarArgTag, NodeType op, ExceptionInfo exceptionInfo, unsigned firstChild, unsigned numChildren)
     288    // Construct a node with a variable number of children and two immediate values.
     289    Node(VarArgTag, NodeType op, ExceptionInfo exceptionInfo, OpInfo imm1, OpInfo imm2, unsigned firstChild, unsigned numChildren)
    237290        : op(op)
    238291        , exceptionInfo(exceptionInfo)
    239292        , m_virtualRegister(InvalidVirtualRegister)
    240293        , m_refCount(0)
     294        , m_opInfo(imm1.m_value)
     295        , m_opInfo2(imm2.m_value)
    241296    {
    242297        ASSERT(op & NodeHasVarArgs);
     
    352407        ASSERT(isBranch());
    353408        return m_opInfo2;
     409    }
     410   
     411    bool hasPrediction()
     412    {
     413        switch (op) {
     414        case GetById:
     415        case GetMethod:
     416        case GetByVal:
     417        case Call:
     418        case Construct:
     419            return true;
     420        default:
     421            return false;
     422        }
     423    }
     424   
     425    PredictedType getPrediction()
     426    {
     427        ASSERT(hasPrediction());
     428        return static_cast<PredictedType>(m_opInfo2);
     429    }
     430   
     431    void predict(PredictedType prediction)
     432    {
     433        ASSERT(hasPrediction());
     434        m_opInfo2 |= prediction;
    354435    }
    355436
Note: See TracChangeset for help on using the changeset viewer.