Changeset 46879 in webkit for trunk/JavaScriptCore/jit/JITStubs.cpp
- Timestamp:
- Aug 6, 2009, 8:05:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jit/JITStubs.cpp
r46831 r46879 635 635 JITThunks::JITThunks(JSGlobalData* globalData) 636 636 { 637 JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_ctiStringLengthTrampoline, &m_ctiVirtualCall PreLink, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk);637 JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_ctiStringLengthTrampoline, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk); 638 638 639 639 #if PLATFORM_ARM_ARCH(7) … … 658 658 #if ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS) 659 659 660 NEVER_INLINE void JITThunks::tryCachePutByID(CallFrame* callFrame, CodeBlock* codeBlock, ReturnAddressPtr returnAddress, JSValue baseValue, const PutPropertySlot& slot )660 NEVER_INLINE void JITThunks::tryCachePutByID(CallFrame* callFrame, CodeBlock* codeBlock, ReturnAddressPtr returnAddress, JSValue baseValue, const PutPropertySlot& slot, StructureStubInfo* stubInfo) 661 661 { 662 662 // The interpreter checks for recursion here; I do not believe this can occur in CTI. … … 684 684 return; 685 685 } 686 687 StructureStubInfo* stubInfo = &codeBlock->getStubInfo(returnAddress);688 686 689 687 // Cache hit: Specialize instruction and ref Structures. … … 706 704 } 707 705 708 NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* codeBlock, ReturnAddressPtr returnAddress, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot )706 NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* codeBlock, ReturnAddressPtr returnAddress, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo* stubInfo) 709 707 { 710 708 // FIXME: Write a test that proves we need to check for recursion here just … … 744 742 return; 745 743 } 746 747 // In the interpreter the last structure is trapped here; in CTI we use the748 // *_second method to achieve a similar (but not quite the same) effect.749 750 StructureStubInfo* stubInfo = &codeBlock->getStubInfo(returnAddress);751 744 752 745 // Cache hit: Specialize instruction and ref Structures. … … 778 771 size_t count = countPrototypeChainEntriesAndCheckForProxies(callFrame, baseValue, slot); 779 772 if (!count) { 780 stubInfo-> opcodeID = op_get_by_id_generic;773 stubInfo->accessType = access_get_by_id_generic; 781 774 return; 782 775 } … … 1077 1070 { 1078 1071 STUB_INIT_STACK_FRAME(stackFrame); 1079 1080 1072 CallFrame* callFrame = stackFrame.callFrame; 1081 1073 Identifier& ident = stackFrame.args[1].identifier(); … … 1084 1076 stackFrame.args[0].jsValue().put(callFrame, ident, stackFrame.args[2].jsValue(), slot); 1085 1077 1086 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_put_by_id_second)); 1087 1088 CHECK_FOR_EXCEPTION_AT_END(); 1089 } 1090 1091 DEFINE_STUB_FUNCTION(void, op_put_by_id_second) 1092 { 1093 STUB_INIT_STACK_FRAME(stackFrame); 1094 1095 PutPropertySlot slot; 1096 stackFrame.args[0].jsValue().put(stackFrame.callFrame, stackFrame.args[1].identifier(), stackFrame.args[2].jsValue(), slot); 1097 JITThunks::tryCachePutByID(stackFrame.callFrame, stackFrame.callFrame->codeBlock(), STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot); 1078 CodeBlock* codeBlock = stackFrame.callFrame->codeBlock(); 1079 StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS); 1080 if (!stubInfo->seenOnce()) 1081 stubInfo->setSeen(); 1082 else 1083 JITThunks::tryCachePutByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, stackFrame.args[0].jsValue(), slot, stubInfo); 1084 1098 1085 CHECK_FOR_EXCEPTION_AT_END(); 1099 1086 } … … 1127 1114 } 1128 1115 1129 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id )1116 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check) 1130 1117 { 1131 1118 STUB_INIT_STACK_FRAME(stackFrame); … … 1137 1124 PropertySlot slot(baseValue); 1138 1125 JSValue result = baseValue.get(callFrame, ident, slot); 1139 1140 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_second));1141 1142 CHECK_FOR_EXCEPTION_AT_END();1143 return JSValue::encode(result);1144 }1145 1146 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check)1147 {1148 STUB_INIT_STACK_FRAME(stackFrame);1149 1150 CallFrame* callFrame = stackFrame.callFrame;1151 Identifier& ident = stackFrame.args[1].identifier();1152 1153 JSValue baseValue = stackFrame.args[0].jsValue();1154 PropertySlot slot(baseValue);1155 JSValue result = baseValue.get(callFrame, ident, slot);1156 1157 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id_method_check_second));1158 1159 CHECK_FOR_EXCEPTION_AT_END();1160 return JSValue::encode(result);1161 }1162 1163 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check_second)1164 {1165 STUB_INIT_STACK_FRAME(stackFrame);1166 1167 CallFrame* callFrame = stackFrame.callFrame;1168 Identifier& ident = stackFrame.args[1].identifier();1169 1170 JSValue baseValue = stackFrame.args[0].jsValue();1171 PropertySlot slot(baseValue);1172 JSValue result = baseValue.get(callFrame, ident, slot);1173 1174 1126 CHECK_FOR_EXCEPTION(); 1127 1128 CodeBlock* codeBlock = stackFrame.callFrame->codeBlock(); 1129 MethodCallLinkInfo& methodCallLinkInfo = codeBlock->getMethodCallLinkInfo(STUB_RETURN_ADDRESS); 1130 1131 if (!methodCallLinkInfo.seenOnce()) { 1132 methodCallLinkInfo.setSeen(); 1133 return JSValue::encode(result); 1134 } 1175 1135 1176 1136 // If we successfully got something, then the base from which it is being accessed must … … 1203 1163 // The result fetched should always be the callee! 1204 1164 ASSERT(result == JSValue(callee)); 1205 MethodCallLinkInfo& methodCallLinkInfo = callFrame->codeBlock()->getMethodCallLinkInfo(STUB_RETURN_ADDRESS);1206 1165 1207 1166 // Check to see if the function is on the object's prototype. Patch up the code to optimize. 1208 if (slot.slotBase() == structure->prototypeForLookup(callFrame)) 1209 JIT::patchMethodCallProto(callFrame->codeBlock(), methodCallLinkInfo, callee, structure, slotBaseObject); 1167 if (slot.slotBase() == structure->prototypeForLookup(callFrame)) { 1168 JIT::patchMethodCallProto(codeBlock, methodCallLinkInfo, callee, structure, slotBaseObject, STUB_RETURN_ADDRESS); 1169 return JSValue::encode(result); 1170 } 1171 1210 1172 // Check to see if the function is on the object itself. 1211 1173 // Since we generate the method-check to check both the structure and a prototype-structure (since this … … 1214 1176 // for now. For now it performs a check on a special object on the global object only used for this 1215 1177 // purpose. The object is in no way exposed, and as such the check will always pass. 1216 else if (slot.slotBase() == baseValue)1217 JIT::patchMethodCallProto(c allFrame->codeBlock(), methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject()->methodCallDummy());1218 1219 // For now let any other case be cached as a normal get_by_id.1178 if (slot.slotBase() == baseValue) { 1179 JIT::patchMethodCallProto(codeBlock, methodCallLinkInfo, callee, structure, callFrame->scopeChain()->globalObject()->methodCallDummy(), STUB_RETURN_ADDRESS); 1180 return JSValue::encode(result); 1181 } 1220 1182 } 1221 1183 1222 1184 // Revert the get_by_id op back to being a regular get_by_id - allow it to cache like normal, if it needs to. 1223 ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id)); 1224 1225 return JSValue::encode(result); 1226 } 1227 1228 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_second) 1229 { 1230 STUB_INIT_STACK_FRAME(stackFrame); 1231 1185 ctiPatchCallByReturnAddress(codeBlock, STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_id)); 1186 return JSValue::encode(result); 1187 } 1188 1189 DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id) 1190 { 1191 STUB_INIT_STACK_FRAME(stackFrame); 1232 1192 CallFrame* callFrame = stackFrame.callFrame; 1233 1193 Identifier& ident = stackFrame.args[1].identifier(); … … 1237 1197 JSValue result = baseValue.get(callFrame, ident, slot); 1238 1198 1239 JITThunks::tryCacheGetByID(callFrame, callFrame->codeBlock(), STUB_RETURN_ADDRESS, baseValue, ident, slot); 1199 CodeBlock* codeBlock = stackFrame.callFrame->codeBlock(); 1200 StructureStubInfo* stubInfo = &codeBlock->getStubInfo(STUB_RETURN_ADDRESS); 1201 if (!stubInfo->seenOnce()) 1202 stubInfo->setSeen(); 1203 else 1204 JITThunks::tryCacheGetByID(callFrame, codeBlock, STUB_RETURN_ADDRESS, baseValue, ident, slot, stubInfo); 1240 1205 1241 1206 CHECK_FOR_EXCEPTION_AT_END(); … … 1269 1234 int listIndex = 1; 1270 1235 1271 if (stubInfo-> opcodeID == op_get_by_id_self) {1236 if (stubInfo->accessType == access_get_by_id_self) { 1272 1237 ASSERT(!stubInfo->stubRoutine); 1273 1238 polymorphicStructureList = new PolymorphicAccessStructureList(CodeLocationLabel(), stubInfo->u.getByIdSelf.baseObjectStructure); … … 1293 1258 listIndex = 1; 1294 1259 1295 switch (stubInfo-> opcodeID) {1296 case op_get_by_id_proto:1260 switch (stubInfo->accessType) { 1261 case access_get_by_id_proto: 1297 1262 prototypeStructureList = new PolymorphicAccessStructureList(stubInfo->stubRoutine, stubInfo->u.getByIdProto.baseObjectStructure, stubInfo->u.getByIdProto.prototypeStructure); 1298 1263 stubInfo->stubRoutine = CodeLocationLabel(); 1299 1264 stubInfo->initGetByIdProtoList(prototypeStructureList, 2); 1300 1265 break; 1301 case op_get_by_id_chain:1266 case access_get_by_id_chain: 1302 1267 prototypeStructureList = new PolymorphicAccessStructureList(stubInfo->stubRoutine, stubInfo->u.getByIdChain.baseObjectStructure, stubInfo->u.getByIdChain.chain); 1303 1268 stubInfo->stubRoutine = CodeLocationLabel(); 1304 1269 stubInfo->initGetByIdProtoList(prototypeStructureList, 2); 1305 1270 break; 1306 case op_get_by_id_proto_list:1271 case access_get_by_id_proto_list: 1307 1272 prototypeStructureList = stubInfo->u.getByIdProtoList.structureList; 1308 1273 listIndex = stubInfo->u.getByIdProtoList.listSize; … … 1571 1536 1572 1537 #if ENABLE(JIT_OPTIMIZE_CALL) 1573 DEFINE_STUB_FUNCTION(void*, vm_dontLazyLinkCall)1574 {1575 STUB_INIT_STACK_FRAME(stackFrame);1576 1577 JSGlobalData* globalData = stackFrame.globalData;1578 JSFunction* callee = asFunction(stackFrame.args[0].jsValue());1579 1580 ctiPatchNearCallByReturnAddress(stackFrame.callFrame->callerFrame()->codeBlock(), stackFrame.args[1].returnAddress(), globalData->jitStubs.ctiVirtualCallLink());1581 1582 return callee->body()->generatedJITCode().addressForCall().executableAddress();1583 }1584 1585 1538 DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall) 1586 1539 { 1587 1540 STUB_INIT_STACK_FRAME(stackFrame); 1588 1589 1541 JSFunction* callee = asFunction(stackFrame.args[0].jsValue()); 1590 1542 JITCode& jitCode = callee->body()->generatedJITCode(); … … 1595 1547 else 1596 1548 codeBlock = &callee->body()->generatedBytecode(); 1597 1598 1549 CallLinkInfo* callLinkInfo = &stackFrame.callFrame->callerFrame()->codeBlock()->getCallLinkInfo(stackFrame.args[1].returnAddress()); 1599 JIT::linkCall(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, jitCode, callLinkInfo, stackFrame.args[2].int32(), stackFrame.globalData); 1550 1551 if (!callLinkInfo->seenOnce()) 1552 callLinkInfo->setSeen(); 1553 else 1554 JIT::linkCall(callee, stackFrame.callFrame->callerFrame()->codeBlock(), codeBlock, jitCode, callLinkInfo, stackFrame.args[2].int32(), stackFrame.globalData); 1600 1555 1601 1556 return jitCode.addressForCall().executableAddress();
Note:
See TracChangeset
for help on using the changeset viewer.