Changeset 92734 in webkit
- Timestamp:
- Aug 9, 2011 5:51:11 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r92732 r92734 1 2011-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 1 42 2011-08-09 Filip Pizlo <fpizlo@apple.com> 2 43 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r92593 r92734 395 395 } 396 396 397 NodeIndex addToGraph(Node::VarArgTag, NodeType op )397 NodeIndex addToGraph(Node::VarArgTag, NodeType op, OpInfo info1, OpInfo info2) 398 398 { 399 399 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)); 401 401 402 402 m_numPassedVarArgs = 0; … … 420 420 for (int argIdx = firstArg; argIdx < firstArg + argCount; argIdx++) 421 421 addVarArgChild(get(argIdx)); 422 NodeIndex call = addToGraph(Node::VarArg, op );422 NodeIndex call = addToGraph(Node::VarArg, op, OpInfo(0), OpInfo(PredictNone)); 423 423 Instruction* putInstruction = currentInstruction + OPCODE_LENGTH(op_call); 424 424 if (interpreter->getOpcodeID(putInstruction->u.opcode) == op_call_put_result) … … 863 863 predictInt32(property); 864 864 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)); 866 866 set(currentInstruction[1].u.operand, getByVal); 867 867 aliases.recordGetByVal(getByVal); … … 892 892 unsigned identifier = getInstruction[3].u.operand; 893 893 894 NodeIndex getMethod = addToGraph(GetMethod, OpInfo(identifier), base);894 NodeIndex getMethod = addToGraph(GetMethod, OpInfo(identifier), OpInfo(PredictNone), base); 895 895 set(getInstruction[1].u.operand, getMethod); 896 896 aliases.recordGetMethod(getMethod); … … 905 905 unsigned identifier = currentInstruction[3].u.operand; 906 906 907 NodeIndex getById = addToGraph(GetById, OpInfo(identifier), base);907 NodeIndex getById = addToGraph(GetById, OpInfo(identifier), OpInfo(PredictNone), base); 908 908 set(currentInstruction[1].u.operand, getById); 909 909 aliases.recordGetById(getById); -
trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp
r92593 r92734 139 139 if (node.hasVarNumber()) 140 140 printf(" predicting %s", predictionToString(getGlobalVarPrediction(node.varNumber()))); 141 if (node.hasPrediction()) 142 printf(" predicting %s", predictionToString(node.getPrediction())); 141 143 142 144 printf("\n"); -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r92593 r92734 45 45 inline bool operandIsArgument(int operand) { return operand < 0; } 46 46 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 NDEBUG81 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 #endif99 100 47 struct PredictionSlot { 101 48 public: … … 218 165 predictGlobalVar(node.varNumber(), prediction); 219 166 break; 167 case GetById: 168 case GetMethod: 169 case GetByVal: 170 case Call: 171 case Construct: 172 node.predict(prediction); 173 break; 220 174 default: 221 175 break; … … 257 211 case GetGlobalVar: 258 212 return getGlobalVarPrediction(nodePtr->varNumber()); 213 case GetById: 214 case GetMethod: 215 case GetByVal: 216 case Call: 217 case Construct: 218 return nodePtr->getPrediction(); 259 219 default: 260 220 return PredictNone; -
trunk/Source/JavaScriptCore/dfg/DFGNode.h
r91607 r92734 185 185 }; 186 186 187 typedef uint8_t PredictedType; 188 static const PredictedType PredictNone = 0; 189 static const PredictedType PredictCell = 0x01; 190 static const PredictedType PredictArray = 0x03; 191 static const PredictedType PredictInt32 = 0x04; 192 static const PredictedType PredictDouble = 0x08; 193 static const PredictedType PredictNumber = 0x0c; 194 195 inline bool isCellPrediction(PredictedType value) 196 { 197 return (value & PredictCell) == PredictCell && !(value & ~PredictArray); 198 } 199 200 inline bool isArrayPrediction(PredictedType value) 201 { 202 return value == PredictArray; 203 } 204 205 inline bool isInt32Prediction(PredictedType value) 206 { 207 return value == PredictInt32; 208 } 209 210 inline bool isDoublePrediction(PredictedType value) 211 { 212 return value == PredictDouble; 213 } 214 215 inline bool isNumberPrediction(PredictedType value) 216 { 217 return !!(value & PredictNumber) && !(value & ~PredictNumber); 218 } 219 220 #ifndef NDEBUG 221 inline 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 187 240 // === Node === 188 241 // … … 233 286 } 234 287 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) 237 290 : op(op) 238 291 , exceptionInfo(exceptionInfo) 239 292 , m_virtualRegister(InvalidVirtualRegister) 240 293 , m_refCount(0) 294 , m_opInfo(imm1.m_value) 295 , m_opInfo2(imm2.m_value) 241 296 { 242 297 ASSERT(op & NodeHasVarArgs); … … 352 407 ASSERT(isBranch()); 353 408 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; 354 435 } 355 436
Note: See TracChangeset
for help on using the changeset viewer.