Changeset 157164 in webkit
- Timestamp:
- Oct 9, 2013 6:29:00 AM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r157161 r157164 1 2013-10-08 Michael Saboff <msaboff@apple.com> 2 3 Transition call and construct JITStubs to CCallHelper functions 4 https://bugs.webkit.org/show_bug.cgi?id=122453 5 6 Reviewed by Geoffrey Garen. 7 8 Transitioned cti_op_call_eval to operationCallEval. Migrated baseline JIT to use the same 9 call thunks as the DFG. Eliminated all of the "oldStyle" thunks and related functions. 10 11 * bytecode/CallLinkInfo.cpp: 12 (JSC::CallLinkInfo::unlink): 13 * jit/JIT.cpp: 14 (JSC::JIT::linkFor): 15 (JSC::JIT::linkSlowCall): 16 * jit/JIT.h: 17 * jit/JITCall.cpp: 18 (JSC::JIT::compileCallEval): 19 (JSC::JIT::compileCallEvalSlowCase): 20 (JSC::JIT::compileOpCallSlowCase): 21 (JSC::JIT::privateCompileClosureCall): 22 * jit/JITCall32_64.cpp: 23 (JSC::JIT::compileCallEval): 24 (JSC::JIT::compileCallEvalSlowCase): 25 (JSC::JIT::compileOpCallSlowCase): 26 (JSC::JIT::privateCompileClosureCall): 27 * jit/JITInlines.h: 28 (JSC::JIT::callOperationWithCallFrameRollbackOnException): 29 * jit/JITOperations.cpp: 30 * jit/JITOperations.h: 31 * jit/JITStubs.cpp: 32 * jit/JITStubs.h: 33 * jit/ThunkGenerators.cpp: 34 * jit/ThunkGenerators.h: 35 1 36 2013-10-09 Julien Brianceau <jbriance@cisco.com> 2 37 -
trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp
r156490 r157164 46 46 #endif 47 47 } else 48 repatchBuffer.relink(callReturnLocation, callType == Construct ? vm.getCTIStub( oldStyleLinkConstructGenerator).code() : vm.getCTIStub(oldStyleLinkCallGenerator).code());48 repatchBuffer.relink(callReturnLocation, callType == Construct ? vm.getCTIStub(linkConstructThunkGenerator).code() : vm.getCTIStub(linkCallThunkGenerator).code()); 49 49 hasSeenShouldRepatch = false; 50 50 callee.clear(); -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r157050 r157164 803 803 || callLinkInfo->callType == CallLinkInfo::CallVarargs); 804 804 if (callLinkInfo->callType == CallLinkInfo::Call) { 805 repatchBuffer.relink(callLinkInfo->callReturnLocation, vm->getCTIStub( oldStyleLinkClosureCallGenerator).code());805 repatchBuffer.relink(callLinkInfo->callReturnLocation, vm->getCTIStub(linkClosureCallThunkGenerator).code()); 806 806 return; 807 807 } 808 808 809 repatchBuffer.relink(callLinkInfo->callReturnLocation, vm->getCTIStub( oldStyleVirtualCallGenerator).code());809 repatchBuffer.relink(callLinkInfo->callReturnLocation, vm->getCTIStub(virtualCallThunkGenerator).code()); 810 810 return; 811 811 } 812 812 813 813 ASSERT(kind == CodeForConstruct); 814 repatchBuffer.relink(callLinkInfo->callReturnLocation, vm->getCTIStub( oldStyleVirtualConstructGenerator).code());814 repatchBuffer.relink(callLinkInfo->callReturnLocation, vm->getCTIStub(virtualConstructThunkGenerator).code()); 815 815 } 816 816 … … 819 819 RepatchBuffer repatchBuffer(callerCodeBlock); 820 820 821 repatchBuffer.relink(callLinkInfo->callReturnLocation, callerCodeBlock->vm()->getCTIStub( oldStyleVirtualCallGenerator).code());821 repatchBuffer.relink(callLinkInfo->callReturnLocation, callerCodeBlock->vm()->getCTIStub(virtualCallThunkGenerator).code()); 822 822 } 823 823 -
trunk/Source/JavaScriptCore/jit/JIT.h
r157050 r157164 869 869 MacroAssembler::Call callOperation(J_JITOperation_E, int); 870 870 MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*); 871 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(J_JITOperation_E); 871 872 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb, CodeBlock*); 872 873 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(Z_JITOperation_E); -
trunk/Source/JavaScriptCore/jit/JITCall.cpp
r156511 r157164 132 132 void JIT::compileCallEval(Instruction* instruction) 133 133 { 134 JITStubCall stubCall(this, cti_op_call_eval); // Initializes ScopeChain; ReturnPC; CodeBlock. 135 stubCall.call(); 134 callOperationWithCallFrameRollbackOnException(operationCallEval); 136 135 addSlowCase(branch64(Equal, regT0, TrustedImm64(JSValue::encode(JSValue())))); 137 136 emitGetFromCallFrameHeaderPtr(JSStack::CallerFrame, callFrameRegister); … … 147 146 148 147 emitGetFromCallFrameHeader64(JSStack::Callee, regT0); 149 emitNakedCall(m_vm->getCTIStub( oldStyleVirtualCallGenerator).code());148 emitNakedCall(m_vm->getCTIStub(virtualCallThunkGenerator).code()); 150 149 151 150 sampleCodeBlock(m_codeBlock); … … 233 232 234 233 linkSlowCase(iter); 235 236 m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_vm->getCTIStub( oldStyleLinkConstructGenerator).code() : m_vm->getCTIStub(oldStyleLinkCallGenerator).code());234 235 m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_vm->getCTIStub(linkConstructThunkGenerator).code() : m_vm->getCTIStub(linkCallThunkGenerator).code()); 237 236 238 237 sampleCodeBlock(m_codeBlock); … … 264 263 patchBuffer.link(call, FunctionPtr(codePtr.executableAddress())); 265 264 patchBuffer.link(done, callLinkInfo->hotPathOther.labelAtOffset(0)); 266 patchBuffer.link(slow, CodeLocationLabel(m_vm->getCTIStub( oldStyleVirtualCallGenerator).code()));265 patchBuffer.link(slow, CodeLocationLabel(m_vm->getCTIStub(virtualCallThunkGenerator).code())); 267 266 268 267 RefPtr<ClosureCallStubRoutine> stubRoutine = adoptRef(new ClosureCallStubRoutine( … … 282 281 RepatchBuffer::startOfBranchPtrWithPatchOnRegister(callLinkInfo->hotPathBegin), 283 282 CodeLocationLabel(stubRoutine->code().code())); 284 repatchBuffer.relink(callLinkInfo->callReturnLocation, m_vm->getCTIStub( oldStyleVirtualCallGenerator).code());285 283 repatchBuffer.relink(callLinkInfo->callReturnLocation, m_vm->getCTIStub(virtualCallThunkGenerator).code()); 284 286 285 callLinkInfo->stub = stubRoutine.release(); 287 286 } -
trunk/Source/JavaScriptCore/jit/JITCall32_64.cpp
r156511 r157164 203 203 void JIT::compileCallEval(Instruction* instruction) 204 204 { 205 JITStubCall stubCall(this, cti_op_call_eval); // Initializes ScopeChain; ReturnPC; CodeBlock. 206 stubCall.call(); 205 callOperationWithCallFrameRollbackOnException(operationCallEval); 207 206 addSlowCase(branch32(Equal, regT1, TrustedImm32(JSValue::EmptyValueTag))); 208 207 emitGetFromCallFrameHeaderPtr(JSStack::CallerFrame, callFrameRegister); … … 218 217 219 218 emitLoad(JSStack::Callee, regT1, regT0); 220 emitNakedCall(m_vm->getCTIStub( oldStyleVirtualCallGenerator).code());219 emitNakedCall(m_vm->getCTIStub(virtualCallThunkGenerator).code()); 221 220 222 221 sampleCodeBlock(m_codeBlock); … … 306 305 linkSlowCase(iter); 307 306 linkSlowCase(iter); 308 309 m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_vm->getCTIStub( oldStyleLinkConstructGenerator).code() : m_vm->getCTIStub(oldStyleLinkCallGenerator).code());307 308 m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_vm->getCTIStub(linkConstructThunkGenerator).code() : m_vm->getCTIStub(linkCallThunkGenerator).code()); 310 309 311 310 sampleCodeBlock(m_codeBlock); … … 336 335 patchBuffer.link(call, FunctionPtr(codePtr.executableAddress())); 337 336 patchBuffer.link(done, callLinkInfo->hotPathOther.labelAtOffset(0)); 338 patchBuffer.link(slow, CodeLocationLabel(m_vm->getCTIStub( oldStyleVirtualCallGenerator).code()));337 patchBuffer.link(slow, CodeLocationLabel(m_vm->getCTIStub(virtualCallThunkGenerator).code())); 339 338 340 339 RefPtr<ClosureCallStubRoutine> stubRoutine = adoptRef(new ClosureCallStubRoutine( … … 354 353 RepatchBuffer::startOfBranchPtrWithPatchOnRegister(callLinkInfo->hotPathBegin), 355 354 CodeLocationLabel(stubRoutine->code().code())); 356 repatchBuffer.relink(callLinkInfo->callReturnLocation, m_vm->getCTIStub( oldStyleVirtualCallGenerator).code());355 repatchBuffer.relink(callLinkInfo->callReturnLocation, m_vm->getCTIStub(virtualCallThunkGenerator).code()); 357 356 358 357 callLinkInfo->stub = stubRoutine.release(); -
trunk/Source/JavaScriptCore/jit/JITInlines.h
r157050 r157164 244 244 } 245 245 246 ALWAYS_INLINE MacroAssembler::Call JIT::callOperationWithCallFrameRollbackOnException(J_JITOperation_E operation) 247 { 248 setupArgumentsExecState(); 249 return appendCallWithCallFrameRollbackOnException(operation); 250 } 251 246 252 ALWAYS_INLINE MacroAssembler::Call JIT::callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb operation, CodeBlock* pointer) 247 253 { -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r157147 r157164 33 33 #include "HostCallReturnValue.h" 34 34 #include "JITOperationWrappers.h" 35 #include "JSGlobalObjectFunctions.h" 35 36 #include "Operations.h" 36 37 #include "Repatch.h" … … 39 40 40 41 extern "C" { 42 43 #if COMPILER(MSVC) 44 void * _ReturnAddress(void); 45 #pragma intrinsic(_ReturnAddress) 46 47 #define OUR_RETURN_ADDRESS _ReturnAddress() 48 #else 49 #define OUR_RETURN_ADDRESS __builtin_return_address(0) 50 #endif 51 52 #if ENABLE(OPCODE_SAMPLING) 53 #define CTI_SAMPLER vm->interpreter->sampler() 54 #else 55 #define CTI_SAMPLER 0 56 #endif 57 41 58 42 59 void JIT_OPERATION operationStackCheck(ExecState* exec, CodeBlock* codeBlock) … … 444 461 base->setStructureAndReallocateStorageIfNecessary(vm, structure); 445 462 base->putDirect(vm, offset, JSValue::decode(value)); 463 } 464 465 EncodedJSValue JIT_OPERATION operationCallEval(ExecState* execCallee) 466 { 467 CallFrame* callerFrame = execCallee->callerFrame(); 468 ASSERT(execCallee->callerFrame()->codeBlock()->codeType() != FunctionCode 469 || !execCallee->callerFrame()->codeBlock()->needsFullScopeChain() 470 || execCallee->callerFrame()->uncheckedR(execCallee->callerFrame()->codeBlock()->activationRegister().offset()).jsValue()); 471 472 execCallee->setScope(callerFrame->scope()); 473 execCallee->setReturnPC(static_cast<Instruction*>(OUR_RETURN_ADDRESS)); 474 execCallee->setCodeBlock(0); 475 476 if (!isHostFunction(execCallee->calleeAsValue(), globalFuncEval)) 477 return JSValue::encode(JSValue()); 478 479 VM* vm = &execCallee->vm(); 480 JSValue result = eval(execCallee); 481 if (vm->exception()) 482 return EncodedJSValue(); 483 484 return JSValue::encode(result); 446 485 } 447 486 … … 514 553 MacroAssemblerCodePtr codePtr; 515 554 CodeBlock* codeBlock = 0; 555 CallLinkInfo& callLinkInfo = exec->codeBlock()->getCallLinkInfo(execCallee->returnPC()); 516 556 if (executable->isHostFunction()) 517 557 codePtr = executable->generatedJITCodeFor(kind)->addressForCall(); … … 524 564 } 525 565 codeBlock = functionExecutable->codeBlockFor(kind); 526 if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()) )566 if (execCallee->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters()) || callLinkInfo.callType == CallLinkInfo::CallVarargs) 527 567 codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind); 528 568 else 529 569 codePtr = functionExecutable->generatedJITCodeFor(kind)->addressForCall(); 530 570 } 531 CallLinkInfo& callLinkInfo = exec->codeBlock()->getCallLinkInfo(execCallee->returnPC());532 571 if (!callLinkInfo.seenOnce()) 533 572 callLinkInfo.setSeen(); -
trunk/Source/JavaScriptCore/jit/JITOperations.h
r157050 r157164 200 200 void JIT_OPERATION operationPutByIdDirectNonStrictBuildList(ExecState*, EncodedJSValue encodedValue, JSCell* base, StringImpl*) WTF_INTERNAL; 201 201 void JIT_OPERATION operationReallocateStorageAndFinishPut(ExecState*, JSObject*, Structure*, PropertyOffset, EncodedJSValue) WTF_INTERNAL; 202 EncodedJSValue JIT_OPERATION operationCallEval(ExecState*) WTF_INTERNAL; 202 203 char* JIT_OPERATION operationVirtualCall(ExecState*) WTF_INTERNAL; 203 204 char* JIT_OPERATION operationLinkCall(ExecState*) WTF_INTERNAL; -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r157050 r157164 1148 1148 } 1149 1149 1150 inline void* jitCompileFor(CallFrame* callFrame, CodeSpecializationKind kind)1151 {1152 // This function is called by cti_op_call_jitCompile() and1153 // cti_op_construct_jitCompile() JIT glue trampolines to compile the1154 // callee function that we want to call. Both cti glue trampolines are1155 // called by JIT'ed code which has pushed a frame and initialized most of1156 // the frame content except for the codeBlock.1157 //1158 // Normally, the prologue of the callee is supposed to set the frame's cb1159 // pointer to the cb of the callee. But in this case, the callee code does1160 // not exist yet until it is compiled below. The compilation process will1161 // allocate memory which may trigger a GC. The GC, in turn, will scan the1162 // JSStack, and will expect the frame's cb to either be valid or 0. If1163 // we don't initialize it, the GC will be accessing invalid memory and may1164 // crash.1165 //1166 // Hence, we should nullify it here before proceeding with the compilation.1167 callFrame->setCodeBlock(0);1168 1169 JSFunction* function = jsCast<JSFunction*>(callFrame->callee());1170 ASSERT(!function->isHostFunction());1171 FunctionExecutable* executable = function->jsExecutable();1172 JSScope* callDataScopeChain = function->scope();1173 JSObject* error = executable->prepareForExecution(callFrame, callDataScopeChain, kind);1174 if (!error)1175 return function;1176 callFrame->vm().throwException(callFrame, error);1177 return 0;1178 }1179 1180 DEFINE_STUB_FUNCTION(void*, op_call_jitCompile)1181 {1182 STUB_INIT_STACK_FRAME(stackFrame);1183 1184 #if !ASSERT_DISABLED1185 CallData callData;1186 ASSERT(stackFrame.callFrame->callee()->methodTable()->getCallData(stackFrame.callFrame->callee(), callData) == CallTypeJS);1187 #endif1188 1189 CallFrame* callFrame = stackFrame.callFrame;1190 void* result = jitCompileFor(callFrame, CodeForCall);1191 if (!result)1192 return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1193 1194 return result;1195 }1196 1197 DEFINE_STUB_FUNCTION(void*, op_construct_jitCompile)1198 {1199 STUB_INIT_STACK_FRAME(stackFrame);1200 1201 #if !ASSERT_DISABLED1202 ConstructData constructData;1203 ASSERT(jsCast<JSFunction*>(stackFrame.callFrame->callee())->methodTable()->getConstructData(stackFrame.callFrame->callee(), constructData) == ConstructTypeJS);1204 #endif1205 1206 CallFrame* callFrame = stackFrame.callFrame;1207 void* result = jitCompileFor(callFrame, CodeForConstruct);1208 if (!result)1209 return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1210 1211 return result;1212 }1213 1214 inline void* lazyLinkFor(CallFrame* callFrame, CodeSpecializationKind kind)1215 {1216 JSFunction* callee = jsCast<JSFunction*>(callFrame->callee());1217 ExecutableBase* executable = callee->executable();1218 1219 MacroAssemblerCodePtr codePtr;1220 CodeBlock* codeBlock = 0;1221 CallLinkInfo* callLinkInfo = &callFrame->callerFrame()->codeBlock()->getCallLinkInfo(callFrame->returnPC());1222 1223 // This function is called by cti_vm_lazyLinkCall() and1224 // cti_lazyLinkConstruct JIT glue trampolines to link the callee function1225 // that we want to call. Both cti glue trampolines are called by JIT'ed1226 // code which has pushed a frame and initialized most of the frame content1227 // except for the codeBlock.1228 //1229 // Normally, the prologue of the callee is supposed to set the frame's cb1230 // field to the cb of the callee. But in this case, the callee may not1231 // exist yet, and if not, it will be generated in the compilation below.1232 // The compilation will allocate memory which may trigger a GC. The GC, in1233 // turn, will scan the JSStack, and will expect the frame's cb to be valid1234 // or 0. If we don't initialize it, the GC will be accessing invalid1235 // memory and may crash.1236 //1237 // Hence, we should nullify it here before proceeding with the compilation.1238 callFrame->setCodeBlock(0);1239 1240 if (executable->isHostFunction())1241 codePtr = executable->generatedJITCodeFor(kind)->addressForCall();1242 else {1243 FunctionExecutable* functionExecutable = static_cast<FunctionExecutable*>(executable);1244 if (JSObject* error = functionExecutable->prepareForExecution(callFrame, callee->scope(), kind)) {1245 callFrame->vm().throwException(callFrame, error);1246 return 0;1247 }1248 codeBlock = functionExecutable->codeBlockFor(kind);1249 if (callFrame->argumentCountIncludingThis() < static_cast<size_t>(codeBlock->numParameters())1250 || callLinkInfo->callType == CallLinkInfo::CallVarargs)1251 codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(kind);1252 else1253 codePtr = functionExecutable->generatedJITCodeFor(kind)->addressForCall();1254 }1255 1256 ConcurrentJITLocker locker(callFrame->callerFrame()->codeBlock()->m_lock);1257 if (!callLinkInfo->seenOnce())1258 callLinkInfo->setSeen();1259 else1260 JIT::linkFor(callFrame->callerFrame(), callee, callFrame->callerFrame()->codeBlock(), codeBlock, codePtr, callLinkInfo, &callFrame->vm(), kind);1261 1262 return codePtr.executableAddress();1263 }1264 1265 DEFINE_STUB_FUNCTION(void*, vm_lazyLinkCall)1266 {1267 STUB_INIT_STACK_FRAME(stackFrame);1268 1269 CallFrame* callFrame = stackFrame.callFrame;1270 void* result = lazyLinkFor(callFrame, CodeForCall);1271 if (!result)1272 return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1273 1274 return result;1275 }1276 1277 DEFINE_STUB_FUNCTION(void*, vm_lazyLinkClosureCall)1278 {1279 STUB_INIT_STACK_FRAME(stackFrame);1280 1281 CallFrame* callFrame = stackFrame.callFrame;1282 1283 CodeBlock* callerCodeBlock = callFrame->callerFrame()->codeBlock();1284 VM* vm = callerCodeBlock->vm();1285 CallLinkInfo* callLinkInfo = &callerCodeBlock->getCallLinkInfo(callFrame->returnPC());1286 JSFunction* callee = jsCast<JSFunction*>(callFrame->callee());1287 ExecutableBase* executable = callee->executable();1288 Structure* structure = callee->structure();1289 1290 ASSERT(callLinkInfo->callType == CallLinkInfo::Call);1291 ASSERT(callLinkInfo->isLinked());1292 ASSERT(callLinkInfo->callee);1293 ASSERT(callee != callLinkInfo->callee.get());1294 1295 bool shouldLink = false;1296 CodeBlock* calleeCodeBlock = 0;1297 MacroAssemblerCodePtr codePtr;1298 1299 if (executable == callLinkInfo->callee.get()->executable()1300 && structure == callLinkInfo->callee.get()->structure()) {1301 1302 shouldLink = true;1303 1304 ASSERT(executable->hasJITCodeForCall());1305 codePtr = executable->generatedJITCodeForCall()->addressForCall();1306 if (!callee->executable()->isHostFunction()) {1307 calleeCodeBlock = jsCast<FunctionExecutable*>(executable)->codeBlockForCall();1308 if (callFrame->argumentCountIncludingThis() < static_cast<size_t>(calleeCodeBlock->numParameters())) {1309 shouldLink = false;1310 codePtr = executable->generatedJITCodeWithArityCheckFor(CodeForCall);1311 }1312 }1313 } else if (callee->isHostFunction())1314 codePtr = executable->generatedJITCodeForCall()->addressForCall();1315 else {1316 // Need to clear the code block before compilation, because compilation can GC.1317 callFrame->setCodeBlock(0);1318 1319 FunctionExecutable* functionExecutable = jsCast<FunctionExecutable*>(executable);1320 JSScope* scopeChain = callee->scope();1321 JSObject* error = functionExecutable->prepareForExecution(callFrame, scopeChain, CodeForCall);1322 if (error) {1323 callFrame->vm().throwException(callFrame, error);1324 return 0;1325 }1326 1327 codePtr = functionExecutable->generatedJITCodeWithArityCheckFor(CodeForCall);1328 }1329 1330 if (shouldLink) {1331 ASSERT(codePtr);1332 ConcurrentJITLocker locker(callerCodeBlock->m_lock);1333 JIT::compileClosureCall(vm, callLinkInfo, callerCodeBlock, calleeCodeBlock, structure, executable, codePtr);1334 callLinkInfo->hasSeenClosure = true;1335 } else1336 JIT::linkSlowCall(callerCodeBlock, callLinkInfo);1337 1338 return codePtr.executableAddress();1339 }1340 1341 DEFINE_STUB_FUNCTION(void*, vm_lazyLinkConstruct)1342 {1343 STUB_INIT_STACK_FRAME(stackFrame);1344 1345 CallFrame* callFrame = stackFrame.callFrame;1346 void* result = lazyLinkFor(callFrame, CodeForConstruct);1347 if (!result)1348 return throwExceptionFromOpCall<void*>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1349 1350 return result;1351 }1352 1353 1150 DEFINE_STUB_FUNCTION(JSObject*, op_push_activation) 1354 1151 { … … 1358 1155 stackFrame.callFrame->setScope(activation); 1359 1156 return activation; 1360 }1361 1362 DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_NotJSFunction)1363 {1364 STUB_INIT_STACK_FRAME(stackFrame);1365 1366 CallFrame* callFrame = stackFrame.callFrame;1367 1368 JSValue callee = callFrame->calleeAsValue();1369 1370 CallData callData;1371 CallType callType = getCallData(callee, callData);1372 1373 ASSERT(callType != CallTypeJS);1374 if (callType != CallTypeHost) {1375 ASSERT(callType == CallTypeNone);1376 ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAFunctionError, callee);1377 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);1378 }1379 1380 EncodedJSValue returnValue;1381 {1382 SamplingTool::CallRecord callRecord(CTI_SAMPLER, true);1383 returnValue = callData.native.function(callFrame);1384 }1385 1386 if (stackFrame.vm->exception())1387 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1388 1389 return returnValue;1390 1157 } 1391 1158 … … 1455 1222 1456 1223 return constructArray(stackFrame.callFrame, stackFrame.args[2].arrayAllocationProfile(), stackFrame.callFrame->codeBlock()->constantBuffer(stackFrame.args[0].int32()), stackFrame.args[1].int32()); 1457 }1458 1459 DEFINE_STUB_FUNCTION(EncodedJSValue, op_construct_NotJSConstruct)1460 {1461 STUB_INIT_STACK_FRAME(stackFrame);1462 1463 CallFrame* callFrame = stackFrame.callFrame;1464 JSValue callee = callFrame->calleeAsValue();1465 1466 ConstructData constructData;1467 ConstructType constructType = getConstructData(callee, constructData);1468 1469 ASSERT(constructType != ConstructTypeJS);1470 if (constructType != ConstructTypeHost) {1471 ASSERT(constructType == ConstructTypeNone);1472 ErrorWithExecAndCalleeFunctor functor = ErrorWithExecAndCalleeFunctor(createNotAConstructorError, callee);1473 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS, &functor);1474 }1475 1476 EncodedJSValue returnValue;1477 {1478 SamplingTool::CallRecord callRecord(CTI_SAMPLER, true);1479 returnValue = constructData.native.function(callFrame);1480 }1481 1482 if (stackFrame.vm->exception())1483 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1484 1485 return returnValue;1486 1224 } 1487 1225 … … 1898 1636 } 1899 1637 1900 DEFINE_STUB_FUNCTION(EncodedJSValue, op_call_eval)1901 {1902 STUB_INIT_STACK_FRAME(stackFrame);1903 1904 CallFrame* callFrame = stackFrame.callFrame;1905 CallFrame* callerFrame = callFrame->callerFrame();1906 ASSERT(callFrame->callerFrame()->codeBlock()->codeType() != FunctionCode1907 || !callFrame->callerFrame()->codeBlock()->needsFullScopeChain()1908 || callFrame->callerFrame()->uncheckedR(callFrame->callerFrame()->codeBlock()->activationRegister().offset()).jsValue());1909 1910 callFrame->setScope(callerFrame->scope());1911 callFrame->setReturnPC(static_cast<Instruction*>((STUB_RETURN_ADDRESS).value()));1912 callFrame->setCodeBlock(0);1913 1914 if (!isHostFunction(callFrame->calleeAsValue(), globalFuncEval))1915 return JSValue::encode(JSValue());1916 1917 JSValue result = eval(callFrame);1918 if (stackFrame.vm->exception())1919 return throwExceptionFromOpCall<EncodedJSValue>(stackFrame, callFrame, STUB_RETURN_ADDRESS);1920 1921 return JSValue::encode(result);1922 }1923 1924 1638 DEFINE_STUB_FUNCTION(void*, op_throw) 1925 1639 { -
trunk/Source/JavaScriptCore/jit/JITStubs.h
r157050 r157164 331 331 332 332 extern "C" { 333 EncodedJSValue JIT_STUB cti_op_call_NotJSFunction(STUB_ARGS_DECLARATION) WTF_INTERNAL;334 EncodedJSValue JIT_STUB cti_op_call_eval(STUB_ARGS_DECLARATION) WTF_INTERNAL;335 EncodedJSValue JIT_STUB cti_op_construct_NotJSConstruct(STUB_ARGS_DECLARATION) WTF_INTERNAL;336 333 EncodedJSValue JIT_STUB cti_op_check_has_instance(STUB_ARGS_DECLARATION) WTF_INTERNAL; 337 334 EncodedJSValue JIT_STUB cti_op_create_arguments(STUB_ARGS_DECLARATION) WTF_INTERNAL; … … 393 390 void JIT_STUB cti_optimize(STUB_ARGS_DECLARATION) WTF_INTERNAL; 394 391 #endif 395 void* JIT_STUB cti_op_call_jitCompile(STUB_ARGS_DECLARATION) WTF_INTERNAL;396 void* JIT_STUB cti_op_construct_jitCompile(STUB_ARGS_DECLARATION) WTF_INTERNAL;397 392 void* JIT_STUB cti_op_switch_char(STUB_ARGS_DECLARATION) WTF_INTERNAL; 398 393 void* JIT_STUB cti_op_switch_imm(STUB_ARGS_DECLARATION) WTF_INTERNAL; 399 394 void* JIT_STUB cti_op_switch_string(STUB_ARGS_DECLARATION) WTF_INTERNAL; 400 395 void* JIT_STUB cti_op_throw(STUB_ARGS_DECLARATION) WTF_INTERNAL; 401 void* JIT_STUB cti_vm_lazyLinkCall(STUB_ARGS_DECLARATION) WTF_INTERNAL;402 void* JIT_STUB cti_vm_lazyLinkClosureCall(STUB_ARGS_DECLARATION) WTF_INTERNAL;403 void* JIT_STUB cti_vm_lazyLinkConstruct(STUB_ARGS_DECLARATION) WTF_INTERNAL;404 396 void* JIT_STUB cti_vm_throw(STUB_ARGS_DECLARATION) REFERENCED_FROM_ASM WTF_INTERNAL; 405 397 -
trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp
r156490 r157164 39 39 40 40 namespace JSC { 41 42 static JSInterfaceJIT::Call oldStyleGenerateSlowCaseFor(VM* vm, JSInterfaceJIT& jit)43 {44 jit.emitGetFromCallFrameHeaderPtr(JSStack::CallerFrame, JSInterfaceJIT::regT2);45 jit.emitGetFromCallFrameHeaderPtr(JSStack::ScopeChain, JSInterfaceJIT::regT2, JSInterfaceJIT::regT2);46 jit.emitPutCellToCallFrameHeader(JSInterfaceJIT::regT2, JSStack::ScopeChain);47 48 // Also initialize ReturnPC and CodeBlock, like a JS function would.49 jit.preserveReturnAddressAfterCall(JSInterfaceJIT::regT3);50 jit.emitPutToCallFrameHeader(JSInterfaceJIT::regT3, JSStack::ReturnPC);51 jit.emitPutImmediateToCallFrameHeader(0, JSStack::CodeBlock);52 53 jit.storePtr(JSInterfaceJIT::callFrameRegister, &vm->topCallFrame);54 jit.restoreArgumentReference();55 JSInterfaceJIT::Call callNotJSFunction = jit.call();56 jit.emitGetFromCallFrameHeaderPtr(JSStack::CallerFrame, JSInterfaceJIT::callFrameRegister);57 jit.restoreReturnAddressBeforeReturn(JSInterfaceJIT::regT3);58 jit.ret();59 60 return callNotJSFunction;61 }62 63 static MacroAssemblerCodeRef oldStyleLinkForGenerator(VM* vm, FunctionPtr lazyLink, FunctionPtr notJSFunction, const char* name)64 {65 JSInterfaceJIT jit(vm);66 67 JSInterfaceJIT::JumpList slowCase;68 69 #if USE(JSVALUE64)70 slowCase.append(jit.emitJumpIfNotJSCell(JSInterfaceJIT::regT0));71 slowCase.append(jit.emitJumpIfNotType(JSInterfaceJIT::regT0, JSInterfaceJIT::regT1, JSFunctionType));72 #else // USE(JSVALUE64)73 slowCase.append(jit.branch32(JSInterfaceJIT::NotEqual, JSInterfaceJIT::regT1, JSInterfaceJIT::TrustedImm32(JSValue::CellTag)));74 slowCase.append(jit.emitJumpIfNotType(JSInterfaceJIT::regT0, JSInterfaceJIT::regT1, JSFunctionType));75 #endif // USE(JSVALUE64)76 77 // Finish canonical initialization before JS function call.78 jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT0, JSFunction::offsetOfScopeChain()), JSInterfaceJIT::regT1);79 jit.emitPutCellToCallFrameHeader(JSInterfaceJIT::regT1, JSStack::ScopeChain);80 81 // Also initialize ReturnPC for use by lazy linking and exceptions.82 jit.preserveReturnAddressAfterCall(JSInterfaceJIT::regT3);83 jit.emitPutToCallFrameHeader(JSInterfaceJIT::regT3, JSStack::ReturnPC);84 85 jit.storePtr(JSInterfaceJIT::callFrameRegister, &vm->topCallFrame);86 jit.restoreArgumentReference();87 JSInterfaceJIT::Call callLazyLink = jit.call();88 jit.restoreReturnAddressBeforeReturn(JSInterfaceJIT::regT3);89 jit.jump(JSInterfaceJIT::regT0);90 91 slowCase.link(&jit);92 JSInterfaceJIT::Call callNotJSFunction = oldStyleGenerateSlowCaseFor(vm, jit);93 94 LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);95 patchBuffer.link(callLazyLink, lazyLink);96 patchBuffer.link(callNotJSFunction, notJSFunction);97 98 return FINALIZE_CODE(patchBuffer, ("link %s trampoline", name));99 }100 101 MacroAssemblerCodeRef oldStyleLinkCallGenerator(VM* vm)102 {103 return oldStyleLinkForGenerator(vm, FunctionPtr(cti_vm_lazyLinkCall), FunctionPtr(cti_op_call_NotJSFunction), "call");104 }105 106 MacroAssemblerCodeRef oldStyleLinkConstructGenerator(VM* vm)107 {108 return oldStyleLinkForGenerator(vm, FunctionPtr(cti_vm_lazyLinkConstruct), FunctionPtr(cti_op_construct_NotJSConstruct), "construct");109 }110 111 MacroAssemblerCodeRef oldStyleLinkClosureCallGenerator(VM* vm)112 {113 return oldStyleLinkForGenerator(vm, FunctionPtr(cti_vm_lazyLinkClosureCall), FunctionPtr(cti_op_call_NotJSFunction), "closure call");114 }115 116 static MacroAssemblerCodeRef oldStyleVirtualForGenerator(VM* vm, FunctionPtr compile, FunctionPtr notJSFunction, const char* name, CodeSpecializationKind kind)117 {118 JSInterfaceJIT jit(vm);119 120 JSInterfaceJIT::JumpList slowCase;121 122 #if USE(JSVALUE64)123 slowCase.append(jit.emitJumpIfNotJSCell(JSInterfaceJIT::regT0));124 #else // USE(JSVALUE64)125 slowCase.append(jit.branch32(JSInterfaceJIT::NotEqual, JSInterfaceJIT::regT1, JSInterfaceJIT::TrustedImm32(JSValue::CellTag)));126 #endif // USE(JSVALUE64)127 slowCase.append(jit.emitJumpIfNotType(JSInterfaceJIT::regT0, JSInterfaceJIT::regT1, JSFunctionType));128 129 // Finish canonical initialization before JS function call.130 jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT0, JSFunction::offsetOfScopeChain()), JSInterfaceJIT::regT1);131 jit.emitPutCellToCallFrameHeader(JSInterfaceJIT::regT1, JSStack::ScopeChain);132 133 jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT0, JSFunction::offsetOfExecutable()), JSInterfaceJIT::regT2);134 JSInterfaceJIT::Jump hasCodeBlock1 = jit.branch32(JSInterfaceJIT::GreaterThanOrEqual, JSInterfaceJIT::Address(JSInterfaceJIT::regT2, FunctionExecutable::offsetOfNumParametersFor(kind)), JSInterfaceJIT::TrustedImm32(0));135 jit.preserveReturnAddressAfterCall(JSInterfaceJIT::regT3);136 jit.storePtr(JSInterfaceJIT::callFrameRegister, &vm->topCallFrame);137 jit.restoreArgumentReference();138 JSInterfaceJIT::Call callCompile = jit.call();139 jit.restoreReturnAddressBeforeReturn(JSInterfaceJIT::regT3);140 jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT0, JSFunction::offsetOfExecutable()), JSInterfaceJIT::regT2);141 142 hasCodeBlock1.link(&jit);143 jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT2, FunctionExecutable::offsetOfJITCodeWithArityCheckFor(kind)), JSInterfaceJIT::regT0);144 #if !ASSERT_DISABLED145 JSInterfaceJIT::Jump ok = jit.branchTestPtr(JSInterfaceJIT::NonZero, JSInterfaceJIT::regT0);146 jit.breakpoint();147 ok.link(&jit);148 #endif149 jit.jump(JSInterfaceJIT::regT0);150 151 slowCase.link(&jit);152 JSInterfaceJIT::Call callNotJSFunction = oldStyleGenerateSlowCaseFor(vm, jit);153 154 LinkBuffer patchBuffer(*vm, &jit, GLOBAL_THUNK_ID);155 patchBuffer.link(callCompile, compile);156 patchBuffer.link(callNotJSFunction, notJSFunction);157 158 return FINALIZE_CODE(patchBuffer, ("virtual %s trampoline", name));159 }160 161 MacroAssemblerCodeRef oldStyleVirtualCallGenerator(VM* vm)162 {163 return oldStyleVirtualForGenerator(vm, FunctionPtr(cti_op_call_jitCompile), FunctionPtr(cti_op_call_NotJSFunction), "call", CodeForCall);164 }165 166 MacroAssemblerCodeRef oldStyleVirtualConstructGenerator(VM* vm)167 {168 return oldStyleVirtualForGenerator(vm, FunctionPtr(cti_op_construct_jitCompile), FunctionPtr(cti_op_construct_NotJSConstruct), "construct", CodeForConstruct);169 }170 41 171 42 inline void emitPointerValidation(CCallHelpers& jit, GPRReg pointerGPR) -
trunk/Source/JavaScriptCore/jit/ThunkGenerators.h
r156490 r157164 32 32 namespace JSC { 33 33 34 MacroAssemblerCodeRef oldStyleLinkCallGenerator(VM*);35 MacroAssemblerCodeRef oldStyleLinkConstructGenerator(VM*);36 MacroAssemblerCodeRef oldStyleLinkClosureCallGenerator(VM*);37 MacroAssemblerCodeRef oldStyleVirtualCallGenerator(VM*);38 MacroAssemblerCodeRef oldStyleVirtualConstructGenerator(VM*);39 40 34 MacroAssemblerCodeRef throwExceptionFromCallSlowPathGenerator(VM*); 41 35
Note: See TracChangeset
for help on using the changeset viewer.