Changeset 93755 in webkit
- Timestamp:
- Aug 24, 2011 6:25:38 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r93710 r93755 1 2011-08-24 Juan C. Montemayor <jmont@apple.com> 2 3 Keep track of topCallFrame for Stack traces 4 https://bugs.webkit.org/show_bug.cgi?id=66571 5 6 Reviewed by Geoffrey Garen. 7 8 This patch adds a TopCallFrame to JSC in order to have that information 9 when an error is thrown to create a stack trace. The TopCallFrame is 10 updated throughout select points in the Interpreter and the JSC. 11 12 * interpreter/Interpreter.cpp: 13 (JSC::Interpreter::unwindCallFrame): 14 (JSC::Interpreter::throwException): 15 (JSC::Interpreter::execute): 16 (JSC::Interpreter::executeCall): 17 (JSC::Interpreter::executeConstruct): 18 (JSC::Interpreter::privateExecute): 19 * interpreter/Interpreter.h: 20 (JSC::TopCallFrameSetter::TopCallFrameSetter): 21 (JSC::TopCallFrameSetter::~TopCallFrameSetter): 22 * jit/JIT.h: 23 * jit/JITInlineMethods.h: 24 (JSC::JIT::updateTopCallFrame): 25 * jit/JITStubCall.h: 26 (JSC::JITStubCall::call): 27 * jit/JITStubs.cpp: 28 (JSC::throwExceptionFromOpCall): 29 (JSC::DEFINE_STUB_FUNCTION): 30 (JSC::arityCheckFor): 31 * runtime/JSGlobalData.cpp: 32 (JSC::JSGlobalData::JSGlobalData): 33 * runtime/JSGlobalData.h: 34 1 35 2011-08-24 Filip Pizlo <fpizlo@apple.com> 2 36 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r92797 r93755 609 609 610 610 CallFrame* callerFrame = callFrame->callerFrame(); 611 callFrame->globalData().topCallFrame = callerFrame; 611 612 if (callerFrame->hasHostCallFrameFlag()) 612 613 return false; … … 882 883 newCallFrame->init(codeBlock, 0, scopeChain, CallFrame::noCaller(), codeBlock->m_numParameters, 0); 883 884 newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = JSValue(thisObj); 885 TopCallFrameSetter topCallFrame(callFrame->globalData(), newCallFrame); 884 886 885 887 Profiler** profiler = Profiler::enabledProfilerReference(); … … 955 957 newCallFrame->init(newCodeBlock, 0, callDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, function); 956 958 959 TopCallFrameSetter topCallFrame(callFrame->globalData(), newCallFrame); 960 957 961 Profiler** profiler = Profiler::enabledProfilerReference(); 958 962 if (*profiler) … … 984 988 newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset); 985 989 newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, function); 990 991 TopCallFrameSetter topCallFrame(callFrame->globalData(), newCallFrame); 986 992 987 993 DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); … … 1049 1055 newCallFrame->init(newCodeBlock, 0, constructDataScopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor); 1050 1056 1057 TopCallFrameSetter topCallFrame(callFrame->globalData(), newCallFrame); 1058 1051 1059 Profiler** profiler = Profiler::enabledProfilerReference(); 1052 1060 if (*profiler) … … 1081 1089 newCallFrame = CallFrame::create(newCallFrame->registers() + registerOffset); 1082 1090 newCallFrame->init(0, 0, scopeChain, callFrame->addHostCallFrameFlag(), argCount, constructor); 1091 1092 TopCallFrameSetter topCallFrame(callFrame->globalData(), newCallFrame); 1083 1093 1084 1094 DynamicGlobalObjectScope globalObjectScope(*scopeChain->globalData, scopeChain->globalObject.get()); … … 1144 1154 } 1145 1155 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), argc, function); 1156 scopeChain->globalData->topCallFrame = newCallFrame; 1146 1157 CallFrameClosure result = { callFrame, newCallFrame, function, FunctionExecutable, scopeChain->globalData, oldEnd, scopeChain, codeBlock->m_numParameters, argc }; 1147 1158 return result; … … 1157 1168 if (*profiler) 1158 1169 (*profiler)->willExecute(closure.oldCallFrame, closure.function); 1159 1170 1171 TopCallFrameSetter topCallFrame(*closure.globalData, closure.newCallFrame); 1172 1160 1173 JSValue result; 1161 1174 { … … 1177 1190 m_reentryDepth--; 1178 1191 } 1179 1192 1180 1193 if (*profiler) 1181 1194 (*profiler)->didExecute(closure.oldCallFrame, closure.function); … … 1185 1198 void Interpreter::endRepeatCall(CallFrameClosure& closure) 1186 1199 { 1200 closure.globalData->topCallFrame = closure.oldCallFrame; 1187 1201 m_registerFile.shrink(closure.oldEnd); 1188 1202 } … … 1263 1277 newCallFrame->init(codeBlock, 0, scopeChain, callFrame->addHostCallFrameFlag(), codeBlock->m_numParameters, 0); 1264 1278 newCallFrame->uncheckedR(newCallFrame->hostThisRegister()) = thisValue; 1279 1280 TopCallFrameSetter topCallFrame(callFrame->globalData(), newCallFrame); 1265 1281 1266 1282 Profiler** profiler = Profiler::enabledProfilerReference(); … … 1590 1606 #else 1591 1607 1608 ASSERT(callFrame->globalData().topCallFrame == callFrame); 1609 1592 1610 JSGlobalData* globalData = &callFrame->globalData(); 1593 1611 JSValue exceptionValue; 1594 1612 HandlerInfo* handler = 0; 1613 CallFrame** topCallFrameSlot = &globalData->topCallFrame; 1595 1614 1596 1615 CodeBlock* codeBlock = callFrame->codeBlock(); … … 4206 4225 codeBlock = newCodeBlock; 4207 4226 ASSERT(codeBlock == callFrame->codeBlock()); 4227 *topCallFrameSlot = callFrame; 4208 4228 vPC = newCodeBlock->instructions().begin(); 4209 4229 … … 4224 4244 4225 4245 newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call), scopeChain, callFrame, argCount, asObject(v)); 4226 4227 4246 JSValue returnValue; 4228 4247 { 4248 *topCallFrameSlot = newCallFrame; 4229 4249 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 4230 4250 returnValue = JSValue::decode(callData.native.function(newCallFrame)); 4251 *topCallFrameSlot = callFrame; 4231 4252 } 4232 4253 CHECK_FOR_EXCEPTION(); … … 4374 4395 codeBlock = newCodeBlock; 4375 4396 ASSERT(codeBlock == callFrame->codeBlock()); 4397 *topCallFrameSlot = callFrame; 4376 4398 vPC = newCodeBlock->instructions().begin(); 4377 4399 … … 4394 4416 JSValue returnValue; 4395 4417 { 4418 *topCallFrameSlot = newCallFrame; 4396 4419 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 4397 4420 returnValue = JSValue::decode(callData.native.function(newCallFrame)); 4421 *topCallFrameSlot = callFrame; 4398 4422 } 4399 4423 CHECK_FOR_EXCEPTION(); … … 4477 4501 vPC = callFrame->returnVPC(); 4478 4502 callFrame = callFrame->callerFrame(); 4479 4503 4480 4504 if (callFrame->hasHostCallFrameFlag()) 4481 4505 return returnValue; 4482 4506 4507 *topCallFrameSlot = callFrame; 4483 4508 functionReturnValue = returnValue; 4484 4509 codeBlock = callFrame->codeBlock(); … … 4522 4547 return returnValue; 4523 4548 4549 *topCallFrameSlot = callFrame; 4524 4550 functionReturnValue = returnValue; 4525 4551 codeBlock = callFrame->codeBlock(); … … 4695 4721 callFrame->init(newCodeBlock, vPC + OPCODE_LENGTH(op_construct), callDataScopeChain, previousCallFrame, argCount, asFunction(v)); 4696 4722 codeBlock = newCodeBlock; 4723 *topCallFrameSlot = callFrame; 4697 4724 vPC = newCodeBlock->instructions().begin(); 4698 4725 #if ENABLE(OPCODE_STATS) … … 4714 4741 JSValue returnValue; 4715 4742 { 4743 *topCallFrameSlot = newCallFrame; 4716 4744 SamplingTool::HostCallRecord callRecord(m_sampler.get()); 4717 4745 returnValue = JSValue::decode(constructData.native.function(newCallFrame)); 4746 *topCallFrameSlot = callFrame; 4718 4747 } 4719 4748 CHECK_FOR_EXCEPTION(); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r91095 r93755 61 61 WillLeaveCallFrame, 62 62 WillExecuteStatement 63 }; 64 65 class TopCallFrameSetter { 66 public: 67 TopCallFrameSetter(JSGlobalData& global, CallFrame* callFrame) 68 : globalData(global) 69 , oldCallFrame(global.topCallFrame) 70 { 71 global.topCallFrame = callFrame; 72 } 73 74 ~TopCallFrameSetter() 75 { 76 globalData.topCallFrame = oldCallFrame; 77 } 78 private: 79 JSGlobalData& globalData; 80 CallFrame* oldCallFrame; 63 81 }; 64 82 -
trunk/Source/JavaScriptCore/jit/JIT.h
r93698 r93755 371 371 static const int patchOffsetGetByIdSlowCaseCall = 37; 372 372 #else 373 static const int patchOffsetGetByIdSlowCaseCall = 27;373 static const int patchOffsetGetByIdSlowCaseCall = 33; 374 374 #endif 375 375 static const int patchOffsetOpCallCompareToJump = 6; … … 429 429 #error "OPCODE_SAMPLING is not yet supported" 430 430 #else 431 static const int patchOffsetGetByIdSlowCaseCall = 30;431 static const int patchOffsetGetByIdSlowCaseCall = 40; 432 432 #endif 433 433 static const int patchOffsetOpCallCompareToJump = 16; … … 607 607 static const int patchOffsetGetByIdSlowCaseCall = 64; 608 608 #else 609 static const int patchOffsetGetByIdSlowCaseCall = 41;609 static const int patchOffsetGetByIdSlowCaseCall = 54; 610 610 #endif 611 611 static const int patchOffsetOpCallCompareToJump = 9; … … 962 962 void restoreArgumentReference(); 963 963 void restoreArgumentReferenceForTrampoline(); 964 void updateTopCallFrame(); 964 965 965 966 Call emitNakedCall(CodePtr function = CodePtr()); -
trunk/Source/JavaScriptCore/jit/JITInlineMethods.h
r93466 r93755 254 254 } 255 255 256 ALWAYS_INLINE void JIT::updateTopCallFrame() 257 { 258 storePtr(callFrameRegister, &m_globalData->topCallFrame); 259 } 260 256 261 ALWAYS_INLINE void JIT::restoreArgumentReferenceForTrampoline() 257 262 { -
trunk/Source/JavaScriptCore/jit/JITStubCall.h
r82130 r93755 173 173 174 174 m_jit->restoreArgumentReference(); 175 m_jit->updateTopCallFrame(); 175 176 JIT::Call call = m_jit->call(); 176 177 m_jit->m_calls.append(CallRecord(call, m_jit->m_bytecodeOffset, m_stub.value())); -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r92797 r93755 1047 1047 } 1048 1048 1049 // Helper function for JIT stubs that may throw an exception in the middle of 1050 // processing a function call. This function rolls back the register file to 1051 // our caller, so exception processing can proceed from a valid state. 1052 static ALWAYS_INLINE ExceptionHandler throwExceptionFromOpCall(CallFrame* oldCallFrame, CallFrame* newCallFrame) 1053 { 1054 oldCallFrame->globalData().topCallFrame = oldCallFrame; 1055 return jitThrow(&oldCallFrame->globalData(), oldCallFrame, createStackOverflowError(oldCallFrame), ReturnAddressPtr(newCallFrame->returnPC())); 1056 } 1057 1049 1058 #if CPU(ARM_THUMB2) && COMPILER(GCC) 1050 1059 … … 1351 1360 1352 1361 if (UNLIKELY(!stackFrame.registerFile->grow(&callFrame->registers()[callFrame->codeBlock()->m_numCalleeRegisters]))) { 1353 // Rewind to the previous call frame because op_call already optimistically 1354 // moved the call frame forward. 1355 CallFrame* oldCallFrame = callFrame->callerFrame(); 1356 ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), ReturnAddressPtr(callFrame->returnPC())); 1362 ExceptionHandler handler = throwExceptionFromOpCall(callFrame->callerFrame(), callFrame); 1357 1363 STUB_SET_RETURN_ADDRESS(handler.catchRoutine); 1358 1364 callFrame = handler.callFrame; … … 1951 1957 Register* newEnd = r + newCodeBlock->m_numCalleeRegisters; 1952 1958 if (!stackFrame.registerFile->grow(newEnd)) { 1953 // Rewind to the previous call frame because op_call already optimistically 1954 // moved the call frame forward. 1955 ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc); 1959 ExceptionHandler handler = throwExceptionFromOpCall(oldCallFrame, callFrame); 1956 1960 stubReturnAddress = ReturnAddressPtr(handler.catchRoutine); 1957 1961 return handler.callFrame; … … 1966 1970 Register* newEnd = r + newCodeBlock->m_numCalleeRegisters; 1967 1971 if (!stackFrame.registerFile->grow(newEnd)) { 1968 // Rewind to the previous call frame because op_call already optimistically 1969 // moved the call frame forward. 1970 ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc); 1972 ExceptionHandler handler = throwExceptionFromOpCall(oldCallFrame, callFrame); 1971 1973 stubReturnAddress = ReturnAddressPtr(handler.catchRoutine); 1972 1974 return handler.callFrame; -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp
r93688 r93755 163 163 : globalDataType(globalDataType) 164 164 , clientData(0) 165 , topCallFrame(CallFrame::noCaller()) 165 166 , arrayConstructorTable(fastNew<HashTable>(JSC::arrayConstructorTable)) 166 167 , arrayPrototypeTable(fastNew<HashTable>(JSC::arrayPrototypeTable)) -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.h
r93688 r93755 136 136 GlobalDataType globalDataType; 137 137 ClientData* clientData; 138 CallFrame* topCallFrame; 138 139 139 140 const HashTable* arrayConstructorTable;
Note: See TracChangeset
for help on using the changeset viewer.