Ignore:
Timestamp:
Nov 18, 2010, 6:35:25 PM (15 years ago)
Author:
[email protected]
Message:

Bug 49708 - Stop recompiling functions to regenerate exception info.

Reviewed by Oliver Hunt.

Instead only hold info as necessary – keep divot info is the inspector
is enabled, line number info is debugging or profiling, and handler
info for functions with try/catch.

JavaScriptCore:

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpStatistics):
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::lineNumberForBytecodeOffset):
(JSC::CodeBlock::expressionRangeForBytecodeOffset):
(JSC::CodeBlock::shrinkToFit):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::bytecodeOffset):
(JSC::CodeBlock::addExpressionInfo):
(JSC::CodeBlock::addLineInfo):
(JSC::CodeBlock::hasExpressionInfo):
(JSC::CodeBlock::hasLineInfo):
(JSC::CodeBlock::needsCallReturnIndices):
(JSC::CodeBlock::callReturnIndexVector):

  • bytecode/SamplingTool.cpp:

(JSC::SamplingTool::dump):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::BytecodeGenerator):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::emitNode):
(JSC::BytecodeGenerator::emitNodeInConditionContext):
(JSC::BytecodeGenerator::emitExpressionInfo):
(JSC::BytecodeGenerator::addLineInfo):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwindCallFrame):
(JSC::appendSourceToError):
(JSC::Interpreter::throwException):
(JSC::Interpreter::privateExecute):
(JSC::Interpreter::retrieveLastCaller):

  • interpreter/Interpreter.h:
  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JITStubs.cpp:

(JSC::jitThrow):
(JSC::DEFINE_STUB_FUNCTION):

  • runtime/Collector.cpp:

(JSC::Heap::markRoots):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):

  • runtime/Executable.h:
  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):

  • runtime/JSGlobalData.h:

(JSC::JSGlobalData::usingAPI):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::supportsRichSourceInfo):
(JSC::JSGlobalObject::globalData):

WebCore:

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::supportsRichSourceInfo):

  • report to JSC whether the inspector is enabled - in which case we will generate better error messages on exceptions.
  • bindings/js/JSDOMWindowBase.h:

WebKitTools:

  • DumpRenderTree/mac/DumpRenderTree.mm:

(shouldEnableDeveloperExtras):

  • always enable the developer tools from DRT, to ensure we produce rich error messages on JavaScript exceptions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.cpp

    r72351 r72360  
    12621262    macro(characterSwitchJumpTables) \
    12631263    macro(stringSwitchJumpTables) \
    1264     macro(functionRegisterInfos)
    1265 
    1266 #define FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(macro) \
     1264    macro(evalCodeCache) \
    12671265    macro(expressionInfo) \
    12681266    macro(lineInfo) \
    1269     macro(getByIdExceptionInfo) \
    1270     macro(pcVector)
     1267    macro(callReturnIndexVector)
    12711268
    12721269template<typename T>
     
    12821279        FOR_EACH_MEMBER_VECTOR(DEFINE_VARS)
    12831280        FOR_EACH_MEMBER_VECTOR_RARE_DATA(DEFINE_VARS)
    1284         FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(DEFINE_VARS)
    12851281    #undef DEFINE_VARS
    12861282
     
    12911287    size_t symbolTableTotalSize = 0;
    12921288
    1293     size_t hasExceptionInfo = 0;
    12941289    size_t hasRareData = 0;
    12951290
     
    13091304            symbolTableIsNotEmpty++;
    13101305            symbolTableTotalSize += (codeBlock->m_symbolTable.capacity() * (sizeof(SymbolTable::KeyType) + sizeof(SymbolTable::MappedType)));
    1311         }
    1312 
    1313         if (codeBlock->m_exceptionInfo) {
    1314             hasExceptionInfo++;
    1315             #define GET_STATS(name) if (!codeBlock->m_exceptionInfo->m_##name.isEmpty()) { name##IsNotEmpty++; name##TotalSize += sizeInBytes(codeBlock->m_exceptionInfo->m_##name); }
    1316                 FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_STATS)
    1317             #undef GET_STATS
    13181306        }
    13191307
     
    13461334        FOR_EACH_MEMBER_VECTOR(GET_TOTAL_SIZE)
    13471335        FOR_EACH_MEMBER_VECTOR_RARE_DATA(GET_TOTAL_SIZE)
    1348         FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(GET_TOTAL_SIZE)
    13491336    #undef GET_TOTAL_SIZE
    13501337
     
    13611348    printf("Number of EvalCode CodeBlocks: %zu (%.3f%%)\n", isEvalCode, static_cast<double>(isEvalCode) * 100.0 / liveCodeBlockSet.size());
    13621349
    1363     printf("Number of CodeBlocks with exception info: %zu (%.3f%%)\n", hasExceptionInfo, static_cast<double>(hasExceptionInfo) * 100.0 / liveCodeBlockSet.size());
    13641350    printf("Number of CodeBlocks with rare data: %zu (%.3f%%)\n", hasRareData, static_cast<double>(hasRareData) * 100.0 / liveCodeBlockSet.size());
    13651351
     
    13671353        FOR_EACH_MEMBER_VECTOR(PRINT_STATS)
    13681354        FOR_EACH_MEMBER_VECTOR_RARE_DATA(PRINT_STATS)
    1369         FOR_EACH_MEMBER_VECTOR_EXCEPTION_INFO(PRINT_STATS)
    13701355    #undef PRINT_STATS
    13711356
     
    14001385    , m_sourceOffset(sourceOffset)
    14011386    , m_symbolTable(symTab)
    1402     , m_exceptionInfo(adoptPtr(new ExceptionInfo))
    14031387{
    14041388    ASSERT(m_source);
     
    15591543}
    15601544
    1561 bool CodeBlock::reparseForExceptionInfoIfNecessary(CallFrame* callFrame)
    1562 {
    1563     if (m_exceptionInfo)
    1564         return true;
    1565 
    1566     ASSERT(!m_rareData || !m_rareData->m_exceptionHandlers.size());
    1567     ScopeChainNode* scopeChain = callFrame->scopeChain();
    1568     if (m_needsFullScopeChain) {
    1569         if (codeType() == FunctionCode && !callFrame->r(activationRegister()).jsValue()) {
    1570             createActivation(callFrame);
    1571             scopeChain = callFrame->scopeChain();
    1572         }
    1573         ScopeChain sc(scopeChain);
    1574         int scopeDelta = sc.localDepth();
    1575         if (m_codeType == EvalCode)
    1576             scopeDelta -= static_cast<EvalCodeBlock*>(this)->baseScopeDepth();
    1577         else if (m_codeType == FunctionCode)
    1578             scopeDelta++; // Compilation of function code assumes activation is not on the scope chain yet.
    1579         ASSERT(scopeDelta >= 0);
    1580         while (scopeDelta--)
    1581             scopeChain = scopeChain->next;
    1582     }
    1583 
    1584     m_exceptionInfo = m_ownerExecutable->reparseExceptionInfo(scopeChain, this);
    1585     return m_exceptionInfo;
    1586 }
    1587 
    15881545HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
    15891546{
     
    16041561}
    16051562
    1606 int CodeBlock::lineNumberForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset)
     1563int CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
    16071564{
    16081565    ASSERT(bytecodeOffset < m_instructionCount);
    16091566
    1610     if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_lineInfo.size())
    1611         return m_ownerExecutable->source().firstLine(); // Empty function or unable to reparse
     1567    if (!m_rareData)
     1568        return m_ownerExecutable->source().firstLine();
     1569
     1570    Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo;
    16121571
    16131572    int low = 0;
    1614     int high = m_exceptionInfo->m_lineInfo.size();
     1573    int high = lineInfo.size();
    16151574    while (low < high) {
    16161575        int mid = low + (high - low) / 2;
    1617         if (m_exceptionInfo->m_lineInfo[mid].instructionOffset <= bytecodeOffset)
     1576        if (lineInfo[mid].instructionOffset <= bytecodeOffset)
    16181577            low = mid + 1;
    16191578        else
    16201579            high = mid;
    16211580    }
    1622    
     1581
    16231582    if (!low)
    16241583        return m_ownerExecutable->source().firstLine();
    1625     return m_exceptionInfo->m_lineInfo[low - 1].lineNumber;
    1626 }
    1627 
    1628 void CodeBlock::expressionRangeForBytecodeOffset(CallFrame* callFrame, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
     1584    return lineInfo[low - 1].lineNumber;
     1585}
     1586
     1587void CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
    16291588{
    16301589    ASSERT(bytecodeOffset < m_instructionCount);
    16311590
    1632     if (!reparseForExceptionInfoIfNecessary(callFrame) || !m_exceptionInfo->m_expressionInfo.size()) {
    1633         // We didn't think anything could throw.  Apparently we were wrong.
    1634         // Alternatively something went wrong when trying to reparse
     1591    if (!m_rareData) {
    16351592        startOffset = 0;
    16361593        endOffset = 0;
     
    16391596    }
    16401597
     1598    Vector<ExpressionRangeInfo>& expressionInfo = m_rareData->m_expressionInfo;
     1599
    16411600    int low = 0;
    1642     int high = m_exceptionInfo->m_expressionInfo.size();
     1601    int high = expressionInfo.size();
    16431602    while (low < high) {
    16441603        int mid = low + (high - low) / 2;
    1645         if (m_exceptionInfo->m_expressionInfo[mid].instructionOffset <= bytecodeOffset)
     1604        if (expressionInfo[mid].instructionOffset <= bytecodeOffset)
    16461605            low = mid + 1;
    16471606        else
     
    16571616    }
    16581617
    1659     startOffset = m_exceptionInfo->m_expressionInfo[low - 1].startOffset;
    1660     endOffset = m_exceptionInfo->m_expressionInfo[low - 1].endOffset;
    1661     divot = m_exceptionInfo->m_expressionInfo[low - 1].divotPoint + m_sourceOffset;
     1618    startOffset = expressionInfo[low - 1].startOffset;
     1619    endOffset = expressionInfo[low - 1].endOffset;
     1620    divot = expressionInfo[low - 1].divotPoint + m_sourceOffset;
    16621621    return;
    16631622}
     
    17261685    m_constantRegisters.shrinkToFit();
    17271686
    1728     if (m_exceptionInfo) {
    1729         m_exceptionInfo->m_expressionInfo.shrinkToFit();
    1730         m_exceptionInfo->m_lineInfo.shrinkToFit();
    1731     }
    1732 
    17331687    if (m_rareData) {
    17341688        m_rareData->m_exceptionHandlers.shrinkToFit();
     
    17371691        m_rareData->m_characterSwitchJumpTables.shrinkToFit();
    17381692        m_rareData->m_stringSwitchJumpTables.shrinkToFit();
     1693        m_rareData->m_expressionInfo.shrinkToFit();
     1694        m_rareData->m_lineInfo.shrinkToFit();
    17391695    }
    17401696}
Note: See TracChangeset for help on using the changeset viewer.