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/bytecode/CodeBlock.cpp

    r61430 r61588  
    15201520}
    15211521
    1522 void CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
     1522bool CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
    15231523{
    15241524    if (m_exceptionInfo)
    1525         return;
     1525        return true;
    15261526
    15271527    ASSERT(!m_rareData || !m_rareData->m_exceptionHandlers.size());
     
    15401540
    15411541    m_exceptionInfo.set(m_ownerExecutable->reparseExceptionInfo(m_globalData, scopeChain, this));
     1542    return m_exceptionInfo;
    15421543}
    15431544
     
    15641565    ASSERT(bytecodeOffset < m_instructionCount);
    15651566
    1566     reparseForExceptionInfoIfNecessary(callFrame);
    1567     ASSERT(m_exceptionInfo);
    1568 
    1569     if (!m_exceptionInfo->m_lineInfo.size())
    1570         return m_ownerExecutable->source().firstLine(); // Empty function
     1567    if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_lineInfo.size())
     1568        return m_ownerExecutable->source().firstLine(); // Empty function or unable to reparse
    15711569
    15721570    int low = 0;
     
    15891587    ASSERT(bytecodeOffset < m_instructionCount);
    15901588
    1591     reparseForExceptionInfoIfNecessary(callFrame);
    1592     ASSERT(m_exceptionInfo);
    1593 
    1594     if (!m_exceptionInfo->m_expressionInfo.size()) {
     1589    if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_expressionInfo.size()) {
    15951590        // We didn't think anything could throw.  Apparently we were wrong.
     1591        // Alternatively something went wrong when trying to reparse
    15961592        startOffset = 0;
    15971593        endOffset = 0;
     
    16281624    ASSERT(bytecodeOffset < m_instructionCount);
    16291625
    1630     reparseForExceptionInfoIfNecessary(callFrame);
    1631     ASSERT(m_exceptionInfo);       
    1632 
    1633     if (!m_exceptionInfo->m_getByIdExceptionInfo.size())
     1626    if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_getByIdExceptionInfo.size())
    16341627        return false;
    16351628
Note: See TracChangeset for help on using the changeset viewer.