Changeset 120974 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Jun 21, 2012, 3:55:42 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r120970 r120974 1 2012-06-20 Filip Pizlo <[email protected]> 2 3 DFG should inline 'new Array()' 4 https://bugs.webkit.org/show_bug.cgi?id=89632 5 6 Reviewed by Geoffrey Garen. 7 8 This adds support for treating InternalFunction like intrinsics. The code 9 to do so is actually quite clean, so I don't feel bad about perpetuating 10 the InternalFunction vs. JSFunction-with-NativeExecutable dichotomy. 11 12 Currently this newfound power is only used to inline 'new Array()'. 13 14 * dfg/DFGByteCodeParser.cpp: 15 (ByteCodeParser): 16 (JSC::DFG::ByteCodeParser::handleCall): 17 (JSC::DFG::ByteCodeParser::handleConstantInternalFunction): 18 (DFG): 19 * dfg/DFGGraph.h: 20 (JSC::DFG::Graph::isInternalFunctionConstant): 21 (JSC::DFG::Graph::valueOfInternalFunctionConstant): 22 1 23 2012-06-21 Mark Hahnenberg <[email protected]> 2 24 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r120897 r120974 29 29 #if ENABLE(DFG_JIT) 30 30 31 #include "ArrayConstructor.h" 31 32 #include "CallLinkStatus.h" 32 33 #include "CodeBlock.h" … … 96 97 // Handle intrinsic functions. Return true if it succeeded, false if we need to plant a call. 97 98 bool handleIntrinsic(bool usesResult, int resultOperand, Intrinsic, int registerOffset, int argumentCountIncludingThis, SpeculatedType prediction); 99 bool handleConstantInternalFunction(bool usesResult, int resultOperand, InternalFunction*, int registerOffset, int argumentCountIncludingThis, SpeculatedType prediction, CodeSpecializationKind); 98 100 void handleGetByOffset( 99 101 int destinationOperand, SpeculatedType, NodeIndex base, unsigned identifierNumber, … … 1129 1131 1130 1132 NodeIndex callTarget = get(currentInstruction[1].u.operand); 1131 enum { ConstantFunction, LinkedFunction, UnknownFunction } callType; 1133 enum { 1134 ConstantFunction, 1135 ConstantInternalFunction, 1136 LinkedFunction, 1137 UnknownFunction 1138 } callType; 1132 1139 1133 1140 CallLinkStatus callLinkStatus = CallLinkStatus::computeFor( … … 1151 1158 m_graph.valueOfFunctionConstant(callTarget), 1152 1159 m_graph.valueOfFunctionConstant(callTarget)->executable()); 1160 #endif 1161 } else if (m_graph.isInternalFunctionConstant(callTarget)) { 1162 callType = ConstantInternalFunction; 1163 #if DFG_ENABLE(DEBUG_VERBOSE) 1164 dataLog("Call at [@%lu, bc#%u] has an internal function constant: %p.\n", 1165 m_graph.size(), m_currentIndex, 1166 m_graph.valueOfInternalFunctionConstant(callTarget)); 1153 1167 #endif 1154 1168 } else if (callLinkStatus.isSet() && !callLinkStatus.couldTakeSlowPath() … … 1184 1198 nextOffset += OPCODE_LENGTH(op_call_put_result); 1185 1199 } 1200 1201 if (callType == ConstantInternalFunction) { 1202 if (handleConstantInternalFunction(usesResult, resultOperand, m_graph.valueOfInternalFunctionConstant(callTarget), registerOffset, argumentCountIncludingThis, prediction, kind)) 1203 return; 1204 1205 // Can only handle this using the generic call handler. 1206 addCall(interpreter, currentInstruction, op); 1207 return; 1208 } 1209 1186 1210 JSFunction* expectedFunction; 1187 1211 Intrinsic intrinsic; … … 1215 1239 return; 1216 1240 } 1217 1241 1218 1242 addCall(interpreter, currentInstruction, op); 1219 1243 } … … 1570 1594 return false; 1571 1595 } 1596 } 1597 1598 bool ByteCodeParser::handleConstantInternalFunction( 1599 bool usesResult, int resultOperand, InternalFunction* function, int registerOffset, 1600 int argumentCountIncludingThis, SpeculatedType prediction, CodeSpecializationKind kind) 1601 { 1602 // If we ever find that we have a lot of internal functions that we specialize for, 1603 // then we should probably have some sort of hashtable dispatch, or maybe even 1604 // dispatch straight through the MethodTable of the InternalFunction. But for now, 1605 // it seems that this case is hit infrequently enough, and the number of functions 1606 // we know about is small enough, that having just a linear cascade of if statements 1607 // is good enough. 1608 1609 UNUSED_PARAM(registerOffset); // Remove this once we do more things to the arguments. 1610 UNUSED_PARAM(prediction); // Remove this once we do more things. 1611 UNUSED_PARAM(kind); // Remove this once we do more things. 1612 1613 if (function->classInfo() == &ArrayConstructor::s_info) { 1614 // We could handle this but don't for now. 1615 if (argumentCountIncludingThis != 1) 1616 return false; 1617 1618 setIntrinsicResult( 1619 usesResult, resultOperand, 1620 addToGraph(Node::VarArg, NewArray, OpInfo(0), OpInfo(0))); 1621 return true; 1622 } 1623 1624 return false; 1572 1625 } 1573 1626 -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r120834 r120974 278 278 return true; 279 279 } 280 bool isInternalFunctionConstant(NodeIndex nodeIndex) 281 { 282 if (!isJSConstant(nodeIndex)) 283 return false; 284 JSValue value = valueOfJSConstant(nodeIndex); 285 if (!value.isCell() || !value) 286 return false; 287 JSCell* cell = value.asCell(); 288 if (!cell->inherits(&InternalFunction::s_info)) 289 return false; 290 return true; 291 } 280 292 // Helper methods get constant values from nodes. 281 293 JSValue valueOfJSConstant(NodeIndex nodeIndex) … … 300 312 ASSERT(function); 301 313 return jsCast<JSFunction*>(function); 314 } 315 InternalFunction* valueOfInternalFunctionConstant(NodeIndex nodeIndex) 316 { 317 return jsCast<InternalFunction*>(valueOfJSConstant(nodeIndex).asCell()); 302 318 } 303 319
Note:
See TracChangeset
for help on using the changeset viewer.