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/runtime/Executable.cpp

    r60762 r61588  
    120120}
    121121
    122 void FunctionExecutable::compileForCall(ExecState*, ScopeChainNode* scopeChainNode)
     122bool FunctionExecutable::compileForCall(ExecState*, ScopeChainNode* scopeChainNode)
    123123{
    124124    JSGlobalData* globalData = scopeChainNode->globalData;
    125125    RefPtr<FunctionBodyNode> body = globalData->parser->parse<FunctionBodyNode>(globalData, 0, 0, m_source);
     126    if (!body)
     127        return false;
    126128    if (m_forceUsesArguments)
    127129        body->setUsesArguments();
     
    142144
    143145    body->destroyData();
    144 }
    145 
    146 void FunctionExecutable::compileForConstruct(ExecState*, ScopeChainNode* scopeChainNode)
     146    return true;
     147}
     148
     149bool FunctionExecutable::compileForConstruct(ExecState*, ScopeChainNode* scopeChainNode)
    147150{
    148151    JSGlobalData* globalData = scopeChainNode->globalData;
    149152    RefPtr<FunctionBodyNode> body = globalData->parser->parse<FunctionBodyNode>(globalData, 0, 0, m_source);
     153    if (!body)
     154        return false;
    150155    if (m_forceUsesArguments)
    151156        body->setUsesArguments();
     
    166171
    167172    body->destroyData();
     173    return true;
    168174}
    169175
     
    194200void FunctionExecutable::generateJITCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
    195201{
    196     CodeBlock* codeBlock = &bytecodeForCall(exec, scopeChainNode);
     202    CodeBlock* codeBlock = bytecodeForCall(exec, scopeChainNode);
    197203    m_jitCodeForCall = JIT::compile(scopeChainNode->globalData, codeBlock, &m_jitCodeForCallWithArityCheck);
    198204
     
    205211void FunctionExecutable::generateJITCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
    206212{
    207     CodeBlock* codeBlock = &bytecodeForConstruct(exec, scopeChainNode);
     213    CodeBlock* codeBlock = bytecodeForConstruct(exec, scopeChainNode);
    208214    m_jitCodeForConstruct = JIT::compile(scopeChainNode->globalData, codeBlock, &m_jitCodeForConstructWithArityCheck);
    209215
     
    227233{
    228234    RefPtr<FunctionBodyNode> newFunctionBody = globalData->parser->parse<FunctionBodyNode>(globalData, 0, 0, m_source);
     235    if (!newFunctionBody)
     236        return 0;
    229237    if (m_forceUsesArguments)
    230238        newFunctionBody->setUsesArguments();
     
    256264{
    257265    RefPtr<EvalNode> newEvalBody = globalData->parser->parse<EvalNode>(globalData, 0, 0, m_source);
     266    if (!newEvalBody)
     267        return 0;
    258268
    259269    ScopeChain scopeChain(scopeChainNode);
Note: See TracChangeset for help on using the changeset viewer.