diff options
Diffstat (limited to 'JavaScriptCore/interpreter')
| -rw-r--r-- | JavaScriptCore/interpreter/CallFrame.cpp | 6 | ||||
| -rw-r--r-- | JavaScriptCore/interpreter/CallFrame.h | 5 | ||||
| -rw-r--r-- | JavaScriptCore/interpreter/Interpreter.cpp | 67 |
3 files changed, 62 insertions, 16 deletions
diff --git a/JavaScriptCore/interpreter/CallFrame.cpp b/JavaScriptCore/interpreter/CallFrame.cpp index f53e6f4..ff061db 100644 --- a/JavaScriptCore/interpreter/CallFrame.cpp +++ b/JavaScriptCore/interpreter/CallFrame.cpp @@ -42,6 +42,12 @@ void CallFrame::dumpCaller() interpreter()->retrieveLastCaller(this, signedLineNumber, sourceID, urlString, function); printf("Callpoint => %s:%d\n", urlString.ascii(), signedLineNumber); } + +RegisterFile* CallFrame::registerFile() +{ + return &interpreter()->registerFile(); +} + #endif } diff --git a/JavaScriptCore/interpreter/CallFrame.h b/JavaScriptCore/interpreter/CallFrame.h index 723d4ae..7ea59fb 100644 --- a/JavaScriptCore/interpreter/CallFrame.h +++ b/JavaScriptCore/interpreter/CallFrame.h @@ -117,6 +117,7 @@ namespace JSC { CallFrame* callerFrame, int argc, JSObject* callee) { ASSERT(callerFrame); // Use noCaller() rather than 0 for the outer host call frame caller. + ASSERT(callerFrame == noCaller() || callerFrame->removeHostCallFrameFlag()->registerFile()->end() >= this); setCodeBlock(codeBlock); setScopeChain(scopeChain); @@ -155,7 +156,9 @@ namespace JSC { private: static const intptr_t HostCallFrameFlag = 1; - +#ifndef NDEBUG + RegisterFile* registerFile(); +#endif ExecState(); ~ExecState(); }; diff --git a/JavaScriptCore/interpreter/Interpreter.cpp b/JavaScriptCore/interpreter/Interpreter.cpp index 91f5c0a..7c5bc6f 100644 --- a/JavaScriptCore/interpreter/Interpreter.cpp +++ b/JavaScriptCore/interpreter/Interpreter.cpp @@ -456,7 +456,6 @@ void Interpreter::dumpRegisters(CallFrame* callFrame) printf("[ScopeChain] | %10p | %p \n", it, (*it).scopeChain()); ++it; printf("[CallerRegisters] | %10p | %d \n", it, (*it).i()); ++it; printf("[ReturnPC] | %10p | %p \n", it, (*it).vPC()); ++it; - ++it; printf("[ArgumentCount] | %10p | %d \n", it, (*it).i()); ++it; printf("[Callee] | %10p | %p \n", it, (*it).function()); ++it; printf("-----------------------------------------------------------------------------\n"); @@ -643,6 +642,10 @@ JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, S } CodeBlock* codeBlock = &program->bytecode(callFrame, scopeChain); + if (!codeBlock) { + *exception = createStackOverflowError(callFrame); + return jsNull(); + } Register* oldEnd = m_registerFile.end(); Register* newEnd = oldEnd + codeBlock->m_numParameters + RegisterFile::CallFrameHeaderSize + codeBlock->m_numCalleeRegisters; @@ -722,9 +725,12 @@ JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallT if (callType == CallTypeJS) { ScopeChainNode* callDataScopeChain = callData.js.scopeChain; - CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); + CodeBlock* newCodeBlock = callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); - newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount); + if (newCodeBlock) + newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount); + else + newCallFrame = 0; if (UNLIKELY(!newCallFrame)) { *exception = createStackOverflowError(callFrame); m_registerFile.shrink(oldEnd); @@ -811,9 +817,12 @@ JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* construc if (constructType == ConstructTypeJS) { ScopeChainNode* constructDataScopeChain = constructData.js.scopeChain; - CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, constructDataScopeChain); + CodeBlock* newCodeBlock = constructData.js.functionExecutable->bytecodeForConstruct(callFrame, constructDataScopeChain); + if (newCodeBlock) + newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount); + else + newCallFrame = 0; - newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount); if (UNLIKELY(!newCallFrame)) { *exception = createStackOverflowError(callFrame); m_registerFile.shrink(oldEnd); @@ -902,8 +911,11 @@ CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* FunctionE for (int i = 0; i < argc; ++i) newCallFrame->r(++dst) = jsUndefined(); - CodeBlock* codeBlock = &FunctionExecutable->bytecodeForCall(callFrame, scopeChain); - newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc); + CodeBlock* codeBlock = FunctionExecutable->bytecodeForCall(callFrame, scopeChain); + if (codeBlock) + newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc); + else + newCallFrame = 0; if (UNLIKELY(!newCallFrame)) { *exception = createStackOverflowError(callFrame); m_registerFile.shrink(oldEnd); @@ -968,6 +980,10 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSObjec DynamicGlobalObjectScope globalObjectScope(callFrame, scopeChain->globalObject); EvalCodeBlock* codeBlock = &eval->bytecode(callFrame, scopeChain); + if (!codeBlock) { + *exception = createStackOverflowError(callFrame); + return jsNull(); + } JSVariableObject* variableObject; for (ScopeChainNode* node = scopeChain; ; node = node->next) { @@ -3619,11 +3635,13 @@ skip_id_custom_self: if (callType == CallTypeJS) { ScopeChainNode* callDataScopeChain = callData.js.scopeChain; - CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); + CodeBlock* newCodeBlock = callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); CallFrame* previousCallFrame = callFrame; - - callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount); + if (newCodeBlock) + callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount); + else + callFrame = 0; if (UNLIKELY(!callFrame)) { callFrame = previousCallFrame; exceptionValue = createStackOverflowError(callFrame); @@ -3645,6 +3663,11 @@ skip_id_custom_self: if (callType == CallTypeHost) { ScopeChainNode* scopeChain = callFrame->scopeChain(); CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); + if (!registerFile->grow(newCallFrame->registers())) { + exceptionValue = createStackOverflowError(callFrame); + goto vm_throw; + } + newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call), scopeChain, callFrame, argCount, asObject(v)); JSValue returnValue; @@ -3766,11 +3789,13 @@ skip_id_custom_self: if (callType == CallTypeJS) { ScopeChainNode* callDataScopeChain = callData.js.scopeChain; - CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); + CodeBlock* newCodeBlock = callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain); CallFrame* previousCallFrame = callFrame; - - callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount); + if (newCodeBlock) + callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount); + else + callFrame = 0; if (UNLIKELY(!callFrame)) { callFrame = previousCallFrame; exceptionValue = createStackOverflowError(callFrame); @@ -3792,6 +3817,10 @@ skip_id_custom_self: if (callType == CallTypeHost) { ScopeChainNode* scopeChain = callFrame->scopeChain(); CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); + if (!registerFile->grow(newCallFrame->registers())) { + exceptionValue = createStackOverflowError(callFrame); + goto vm_throw; + } newCallFrame->init(0, vPC + OPCODE_LENGTH(op_call_varargs), scopeChain, callFrame, argCount, asObject(v)); JSValue returnValue; @@ -4085,11 +4114,15 @@ skip_id_custom_self: if (constructType == ConstructTypeJS) { ScopeChainNode* callDataScopeChain = constructData.js.scopeChain; - CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, callDataScopeChain); + CodeBlock* newCodeBlock = constructData.js.functionExecutable->bytecodeForConstruct(callFrame, callDataScopeChain); CallFrame* previousCallFrame = callFrame; - callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount); + if (newCodeBlock) + callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount); + else + callFrame = 0; + if (UNLIKELY(!callFrame)) { callFrame = previousCallFrame; exceptionValue = createStackOverflowError(callFrame); @@ -4110,6 +4143,10 @@ skip_id_custom_self: if (constructType == ConstructTypeHost) { ScopeChainNode* scopeChain = callFrame->scopeChain(); CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + registerOffset); + if (!registerFile->grow(newCallFrame->registers())) { + exceptionValue = createStackOverflowError(callFrame); + goto vm_throw; + } newCallFrame->init(0, vPC + OPCODE_LENGTH(op_construct), scopeChain, callFrame, argCount, asObject(v)); JSValue returnValue; |
