Changeset 61588 in webkit for trunk/JavaScriptCore/interpreter


Ignore:
Timestamp:
Jun 21, 2010, 4:17:48 PM (15 years ago)
Author:
[email protected]
Message:

2010-06-21 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

Make JSC more resilient in the face of parse failures
https://bugs.webkit.org/show_bug.cgi?id=40951

A number of recent bugs have occurred due to issues like miscounting
BOMs, etc which lead to interesting crashes later on. Adding this
logic hardens JSC in the face of these errors, and has no impact on
performance (32bit jit actually gets 0.7% faster but I put that down
to cache effects).

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset):
  • bytecode/CodeBlock.h: (JSC::CodeBlock::bytecodeOffset):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::execute): (JSC::Interpreter::executeCall): (JSC::Interpreter::executeConstruct): (JSC::Interpreter::prepareForRepeatCall): (JSC::Interpreter::privateExecute):
  • jit/JITOpcodes.cpp: (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JITOpcodes32_64.cpp: (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
  • runtime/ArrayPrototype.cpp: (JSC::isNumericCompareFunction):
  • runtime/Executable.cpp: (JSC::FunctionExecutable::compileForCall): (JSC::FunctionExecutable::compileForConstruct): (JSC::FunctionExecutable::generateJITCodeForCall): (JSC::FunctionExecutable::generateJITCodeForConstruct): (JSC::FunctionExecutable::reparseExceptionInfo): (JSC::EvalExecutable::reparseExceptionInfo):
  • runtime/Executable.h: (JSC::FunctionExecutable::bytecodeForCall): (JSC::FunctionExecutable::bytecodeForConstruct):
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::numericCompareFunction):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r61553 r61588  
    644644
    645645    CodeBlock* codeBlock = &program->bytecode(callFrame, scopeChain);
     646    if (!codeBlock) {
     647        *exception = createStackOverflowError(callFrame);
     648        return jsNull();
     649    }
    646650
    647651    Register* oldEnd = m_registerFile.end();
     
    723727    if (callType == CallTypeJS) {
    724728        ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    725         CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
    726 
    727         newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount);
     729        CodeBlock* newCodeBlock = callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
     730
     731        if (newCodeBlock)
     732            newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount);
     733        else
     734            newCallFrame = 0;
    728735        if (UNLIKELY(!newCallFrame)) {
    729736            *exception = createStackOverflowError(callFrame);
     
    812819    if (constructType == ConstructTypeJS) {
    813820        ScopeChainNode* constructDataScopeChain = constructData.js.scopeChain;
    814         CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, constructDataScopeChain);
    815 
    816         newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount);
     821        CodeBlock* newCodeBlock = constructData.js.functionExecutable->bytecodeForConstruct(callFrame, constructDataScopeChain);
     822        if (newCodeBlock)
     823            newCallFrame = slideRegisterWindowForCall(newCodeBlock, &m_registerFile, newCallFrame, registerOffset, argCount);
     824        else
     825            newCallFrame = 0;
     826
    817827        if (UNLIKELY(!newCallFrame)) {
    818828            *exception = createStackOverflowError(callFrame);
     
    903913        newCallFrame->r(++dst) = jsUndefined();
    904914   
    905     CodeBlock* codeBlock = &FunctionExecutable->bytecodeForCall(callFrame, scopeChain);
    906     newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
     915    CodeBlock* codeBlock = FunctionExecutable->bytecodeForCall(callFrame, scopeChain);
     916    if (codeBlock)
     917        newCallFrame = slideRegisterWindowForCall(codeBlock, &m_registerFile, newCallFrame, argc + RegisterFile::CallFrameHeaderSize, argc);
     918    else
     919        newCallFrame = 0;
    907920    if (UNLIKELY(!newCallFrame)) {
    908921        *exception = createStackOverflowError(callFrame);
     
    969982
    970983    EvalCodeBlock* codeBlock = &eval->bytecode(callFrame, scopeChain);
     984    if (!codeBlock) {
     985        *exception = createStackOverflowError(callFrame);
     986        return jsNull();
     987    }
    971988
    972989    JSVariableObject* variableObject;
     
    36203637        if (callType == CallTypeJS) {
    36213638            ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    3622             CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
     3639            CodeBlock* newCodeBlock = callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
    36233640
    36243641            CallFrame* previousCallFrame = callFrame;
    3625 
    3626             callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount);
     3642            if (newCodeBlock)
     3643                callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount);
     3644            else
     3645                callFrame = 0;
    36273646            if (UNLIKELY(!callFrame)) {
    36283647                callFrame = previousCallFrame;
     
    37723791        if (callType == CallTypeJS) {
    37733792            ScopeChainNode* callDataScopeChain = callData.js.scopeChain;
    3774             CodeBlock* newCodeBlock = &callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
     3793            CodeBlock* newCodeBlock = callData.js.functionExecutable->bytecodeForCall(callFrame, callDataScopeChain);
    37753794           
    37763795            CallFrame* previousCallFrame = callFrame;
    3777            
    3778             callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount);
     3796            if (newCodeBlock)
     3797                callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount);
     3798            else
     3799                callFrame = 0;
    37793800            if (UNLIKELY(!callFrame)) {
    37803801                callFrame = previousCallFrame;
     
    40954116        if (constructType == ConstructTypeJS) {
    40964117            ScopeChainNode* callDataScopeChain = constructData.js.scopeChain;
    4097             CodeBlock* newCodeBlock = &constructData.js.functionExecutable->bytecodeForConstruct(callFrame, callDataScopeChain);
     4118            CodeBlock* newCodeBlock = constructData.js.functionExecutable->bytecodeForConstruct(callFrame, callDataScopeChain);
    40984119
    40994120            CallFrame* previousCallFrame = callFrame;
    41004121
    4101             callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount);
     4122            if (newCodeBlock)
     4123                callFrame = slideRegisterWindowForCall(newCodeBlock, registerFile, callFrame, registerOffset, argCount);
     4124            else
     4125                callFrame = 0;
     4126
    41024127            if (UNLIKELY(!callFrame)) {
    41034128                callFrame = previousCallFrame;
Note: See TracChangeset for help on using the changeset viewer.