Changeset 72360 in webkit


Ignore:
Timestamp:
Nov 18, 2010 6:35:25 PM (13 years ago)
Author:
barraclough@apple.com
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.
Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r72359 r72360  
     12010-11-18  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 49708 - Stop recompiling functions to regenerate exception info.
     6
     7        Instead only hold info as necessary – keep divot info is the inspector
     8        is enabled, line number info is debugging or profiling, and handler
     9        info for functions with try/catch.
     10
     11        * bytecode/CodeBlock.cpp:
     12        (JSC::CodeBlock::dumpStatistics):
     13        (JSC::CodeBlock::CodeBlock):
     14        (JSC::CodeBlock::lineNumberForBytecodeOffset):
     15        (JSC::CodeBlock::expressionRangeForBytecodeOffset):
     16        (JSC::CodeBlock::shrinkToFit):
     17        * bytecode/CodeBlock.h:
     18        (JSC::CodeBlock::bytecodeOffset):
     19        (JSC::CodeBlock::addExpressionInfo):
     20        (JSC::CodeBlock::addLineInfo):
     21        (JSC::CodeBlock::hasExpressionInfo):
     22        (JSC::CodeBlock::hasLineInfo):
     23        (JSC::CodeBlock::needsCallReturnIndices):
     24        (JSC::CodeBlock::callReturnIndexVector):
     25        * bytecode/SamplingTool.cpp:
     26        (JSC::SamplingTool::dump):
     27        * bytecompiler/BytecodeGenerator.cpp:
     28        (JSC::BytecodeGenerator::generate):
     29        (JSC::BytecodeGenerator::BytecodeGenerator):
     30        * bytecompiler/BytecodeGenerator.h:
     31        (JSC::BytecodeGenerator::emitNode):
     32        (JSC::BytecodeGenerator::emitNodeInConditionContext):
     33        (JSC::BytecodeGenerator::emitExpressionInfo):
     34        (JSC::BytecodeGenerator::addLineInfo):
     35        * interpreter/Interpreter.cpp:
     36        (JSC::Interpreter::unwindCallFrame):
     37        (JSC::appendSourceToError):
     38        (JSC::Interpreter::throwException):
     39        (JSC::Interpreter::privateExecute):
     40        (JSC::Interpreter::retrieveLastCaller):
     41        * interpreter/Interpreter.h:
     42        * jit/JIT.cpp:
     43        (JSC::JIT::privateCompile):
     44        * jit/JITStubs.cpp:
     45        (JSC::jitThrow):
     46        (JSC::DEFINE_STUB_FUNCTION):
     47        * runtime/Collector.cpp:
     48        (JSC::Heap::markRoots):
     49        * runtime/Executable.cpp:
     50        (JSC::EvalExecutable::compileInternal):
     51        (JSC::ProgramExecutable::compileInternal):
     52        (JSC::FunctionExecutable::compileForCallInternal):
     53        (JSC::FunctionExecutable::compileForConstructInternal):
     54        * runtime/Executable.h:
     55        * runtime/JSGlobalData.cpp:
     56        (JSC::JSGlobalData::JSGlobalData):
     57        * runtime/JSGlobalData.h:
     58        (JSC::JSGlobalData::usingAPI):
     59        * runtime/JSGlobalObject.h:
     60        (JSC::JSGlobalObject::supportsRichSourceInfo):
     61        (JSC::JSGlobalObject::globalData):
     62
    1632010-11-18  Adam Roben  <aroben@apple.com>
    264
  • 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}
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r72351 r72360  
    103103        }
    104104
    105         unsigned bytecodeOffset;
    106105        CodeLocationNearCall callReturnLocation;
    107106        CodeLocationDataLabelPtr hotPathBegin;
     
    155154        Structure* cachedStructure;
    156155        Structure* cachedPrototypeStructure;
    157     };
    158 
    159     struct FunctionRegisterInfo {
    160         FunctionRegisterInfo(unsigned bytecodeOffset, int functionRegisterIndex)
    161             : bytecodeOffset(bytecodeOffset)
    162             , functionRegisterIndex(functionRegisterIndex)
    163         {
    164         }
    165 
    166         unsigned bytecodeOffset;
    167         int functionRegisterIndex;
    168156    };
    169157
     
    255243#endif
    256244
    257     struct ExceptionInfo : FastAllocBase {
    258         Vector<ExpressionRangeInfo> m_expressionInfo;
    259         Vector<LineInfo> m_lineInfo;
    260 
    261 #if ENABLE(JIT)
    262         Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector;
    263 #endif
    264     };
    265 
    266245    class CodeBlock : public FastAllocBase {
    267246        friend class JIT;
     
    308287
    309288        HandlerInfo* handlerForBytecodeOffset(unsigned bytecodeOffset);
    310         int lineNumberForBytecodeOffset(CallFrame*, unsigned bytecodeOffset);
    311         void expressionRangeForBytecodeOffset(CallFrame*, unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
     289        int lineNumberForBytecodeOffset(unsigned bytecodeOffset);
     290        void expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset);
    312291
    313292#if ENABLE(JIT)
     
    346325        }
    347326
    348         unsigned bytecodeOffset(CallFrame* callFrame, ReturnAddressPtr returnAddress)
    349         {
    350             if (!reparseForExceptionInfoIfNecessary(callFrame))
     327        unsigned bytecodeOffset(ReturnAddressPtr returnAddress)
     328        {
     329            if (!m_rareData)
    351330                return 1;
    352             return binaryChop<CallReturnOffsetToBytecodeOffset, unsigned, getCallReturnOffset>(callReturnIndexVector().begin(), callReturnIndexVector().size(), getJITCode().offsetOf(returnAddress.value()))->bytecodeOffset;
     331            Vector<CallReturnOffsetToBytecodeOffset>& callIndices = m_rareData->m_callReturnIndexVector;
     332            if (!callIndices.size())
     333                return 1;
     334            return binaryChop<CallReturnOffsetToBytecodeOffset, unsigned, getCallReturnOffset>(callIndices.begin(), callIndices.size(), getJITCode().offsetOf(returnAddress.value()))->bytecodeOffset;
    353335        }
    354336#endif
     
    450432        HandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; }
    451433
    452         bool hasExceptionInfo() const { return m_exceptionInfo; }
    453         void clearExceptionInfo() { m_exceptionInfo.clear(); }
    454         PassOwnPtr<ExceptionInfo> extractExceptionInfo();
    455 
    456         void addExpressionInfo(const ExpressionRangeInfo& expressionInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_expressionInfo.append(expressionInfo); }
    457 
    458         size_t numberOfLineInfos() const { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.size(); }
    459         void addLineInfo(const LineInfo& lineInfo) { ASSERT(m_exceptionInfo); m_exceptionInfo->m_lineInfo.append(lineInfo); }
    460         LineInfo& lastLineInfo() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_lineInfo.last(); }
    461 
    462 #if ENABLE(JIT)
    463         Vector<CallReturnOffsetToBytecodeOffset>& callReturnIndexVector() { ASSERT(m_exceptionInfo); return m_exceptionInfo->m_callReturnIndexVector; }
     434        void addExpressionInfo(const ExpressionRangeInfo& expressionInfo)
     435        {
     436            createRareDataIfNecessary();
     437            m_rareData->m_expressionInfo.append(expressionInfo);
     438        }
     439
     440        void addLineInfo(unsigned bytecodeOffset, int lineNo)
     441        {
     442            createRareDataIfNecessary();
     443            Vector<LineInfo>& lineInfo = m_rareData->m_lineInfo;
     444            if (!lineInfo.size() || lineInfo.last().lineNumber != lineNo) {
     445                LineInfo info = { bytecodeOffset, lineNo };
     446                lineInfo.append(info);
     447            }
     448        }
     449
     450        bool hasExpressionInfo() { return m_rareData && m_rareData->m_expressionInfo.size(); }
     451        bool hasLineInfo() { return m_rareData && m_rareData->m_lineInfo.size(); }
     452        bool needsCallReturnIndices()
     453        {
     454            return m_rareData &&
     455                (m_rareData->m_expressionInfo.size() || m_rareData->m_lineInfo.size() || m_rareData->m_exceptionHandlers.size());
     456        }
     457
     458#if ENABLE(JIT)
     459        Vector<CallReturnOffsetToBytecodeOffset>& callReturnIndexVector()
     460        {
     461            createRareDataIfNecessary();
     462            return m_rareData->m_callReturnIndexVector;
     463        }
    464464#endif
    465465
     
    529529#endif
    530530
    531         bool reparseForExceptionInfoIfNecessary(CallFrame*) WARN_UNUSED_RETURN;
    532 
    533531        void createRareDataIfNecessary()
    534532        {
     
    581579        SymbolTable* m_symbolTable;
    582580
    583         OwnPtr<ExceptionInfo> m_exceptionInfo;
    584 
    585581        struct RareData : FastAllocBase {
    586582            Vector<HandlerInfo> m_exceptionHandlers;
     
    595591
    596592            EvalCodeCache m_evalCodeCache;
     593
     594            // Expression info - present if debugging.
     595            Vector<ExpressionRangeInfo> m_expressionInfo;
     596            // Line info - present if profiling or debugging.
     597            Vector<LineInfo> m_lineInfo;
     598#if ENABLE(JIT)
     599            Vector<CallReturnOffsetToBytecodeOffset> m_callReturnIndexVector;
     600#endif
    597601        };
    598602        OwnPtr<RareData> m_rareData;
     
    669673    };
    670674
    671     inline PassOwnPtr<ExceptionInfo> CodeBlock::extractExceptionInfo()
    672     {
    673         ASSERT(m_exceptionInfo);
    674         return m_exceptionInfo.release();
    675     }
    676 
    677675    inline Register& ExecState::r(int index)
    678676    {
  • trunk/JavaScriptCore/bytecode/SamplingTool.cpp

    r65344 r72360  
    338338        if (blockPercent >= 1) {
    339339            //Instruction* code = codeBlock->instructions().begin();
    340             printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().utf8().data(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent);
     340            printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().utf8().data(), codeBlock->lineNumberForBytecodeOffset(0), record->m_sampleCount, m_sampleCount, blockPercent);
    341341            if (i < 10) {
    342342                HashMap<unsigned,unsigned> lineCounts;
     
    348348                    if (count) {
    349349                        printf("    [% 4d] has sample count: % 4d\n", op, count);
    350                         unsigned line = codeBlock->lineNumberForBytecodeOffset(exec, op);
     350                        unsigned line = codeBlock->lineNumberForBytecodeOffset(op);
    351351                        lineCounts.set(line, (lineCounts.contains(line) ? lineCounts.get(line) : 0) + count);
    352352                    }
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r72351 r72360  
    154154        symbolTable().clear();
    155155
    156 #if !ENABLE(OPCODE_SAMPLING)
    157     if (!m_regeneratingForExceptionInfo && !m_usesExceptions && (m_codeType == FunctionCode || m_codeType == EvalCode))
    158         m_codeBlock->clearExceptionInfo();
    159 #endif
    160 
    161156    m_codeBlock->shrinkToFit();
    162157}
     
    200195}
    201196
    202 BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock)
    203     : m_shouldEmitDebugHooks(!!debugger)
     197BytecodeGenerator::BytecodeGenerator(ProgramNode* programNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, ProgramCodeBlock* codeBlock)
     198    : m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
    204199    , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
     200    , m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
    205201    , m_scopeChain(&scopeChain)
    206202    , m_symbolTable(symbolTable)
     
    218214    , m_firstLazyFunction(0)
    219215    , m_lastLazyFunction(0)
    220     , m_globalData(&scopeChain.globalObject()->globalExec()->globalData())
     216    , m_globalData(&scopeChain.globalObject()->globalData())
    221217    , m_lastOpcodeID(op_end)
    222218#ifndef NDEBUG
     
    294290}
    295291
    296 BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
    297     : m_shouldEmitDebugHooks(!!debugger)
     292BytecodeGenerator::BytecodeGenerator(FunctionBodyNode* functionBody, const ScopeChain& scopeChain, SymbolTable* symbolTable, CodeBlock* codeBlock)
     293    : m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
    298294    , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
     295    , m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
    299296    , m_scopeChain(&scopeChain)
    300297    , m_symbolTable(symbolTable)
     
    311308    , m_firstLazyFunction(0)
    312309    , m_lastLazyFunction(0)
    313     , m_globalData(&scopeChain.globalObject()->globalExec()->globalData())
     310    , m_globalData(&scopeChain.globalObject()->globalData())
    314311    , m_lastOpcodeID(op_end)
    315312#ifndef NDEBUG
     
    388385        }
    389386    }
    390     bool canLazilyCreateFunctions = !functionBody->needsActivationForMoreThanVariables() && !debugger;
     387    bool canLazilyCreateFunctions = !functionBody->needsActivationForMoreThanVariables() && !m_shouldEmitDebugHooks;
    391388    if (!canLazilyCreateFunctions && !m_hasCreatedActivation) {
    392389        m_hasCreatedActivation = true;
     
    420417    }
    421418   
    422     if (debugger)
     419    if (m_shouldEmitDebugHooks)
    423420        codeBlock->m_numCapturedVars = codeBlock->m_numVars;
    424421
     
    458455}
    459456
    460 BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const Debugger* debugger, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
    461     : m_shouldEmitDebugHooks(!!debugger)
     457BytecodeGenerator::BytecodeGenerator(EvalNode* evalNode, const ScopeChain& scopeChain, SymbolTable* symbolTable, EvalCodeBlock* codeBlock)
     458    : m_shouldEmitDebugHooks(scopeChain.globalObject()->debugger())
    462459    , m_shouldEmitProfileHooks(scopeChain.globalObject()->supportsProfiling())
     460    , m_shouldEmitRichSourceInfo(scopeChain.globalObject()->supportsRichSourceInfo())
    463461    , m_scopeChain(&scopeChain)
    464462    , m_symbolTable(symbolTable)
     
    475473    , m_firstLazyFunction(0)
    476474    , m_lastLazyFunction(0)
    477     , m_globalData(&scopeChain.globalObject()->globalExec()->globalData())
     475    , m_globalData(&scopeChain.globalObject()->globalData())
    478476    , m_lastOpcodeID(op_end)
    479477#ifndef NDEBUG
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r72176 r72360  
    9494        static bool dumpsGeneratedCode();
    9595
    96         BytecodeGenerator(ProgramNode*, const Debugger*, const ScopeChain&, SymbolTable*, ProgramCodeBlock*);
    97         BytecodeGenerator(FunctionBodyNode*, const Debugger*, const ScopeChain&, SymbolTable*, CodeBlock*);
    98         BytecodeGenerator(EvalNode*, const Debugger*, const ScopeChain&, SymbolTable*, EvalCodeBlock*);
     96        BytecodeGenerator(ProgramNode*, const ScopeChain&, SymbolTable*, ProgramCodeBlock*);
     97        BytecodeGenerator(FunctionBodyNode*, const ScopeChain&, SymbolTable*, CodeBlock*);
     98        BytecodeGenerator(EvalNode*, const ScopeChain&, SymbolTable*, EvalCodeBlock*);
    9999
    100100        JSGlobalData* globalData() const { return m_globalData; }
     
    208208            // Node::emitCode assumes that dst, if provided, is either a local or a referenced temporary.
    209209            ASSERT(!dst || dst == ignoredResult() || !dst->isTemporary() || dst->refCount());
    210             if (!m_codeBlock->numberOfLineInfos() || m_codeBlock->lastLineInfo().lineNumber != n->lineNo()) {
    211                 LineInfo info = { instructions().size(), n->lineNo() };
    212                 m_codeBlock->addLineInfo(info);
    213             }
     210            addLineInfo(n->lineNo());
     211
    214212            if (m_emitNodeDepth >= s_maxEmitNodeDepth)
    215213                return emitThrowExpressionTooDeepException();
     
    227225        void emitNodeInConditionContext(ExpressionNode* n, Label* trueTarget, Label* falseTarget, bool fallThroughMeansTrue)
    228226        {
    229             if (!m_codeBlock->numberOfLineInfos() || m_codeBlock->lastLineInfo().lineNumber != n->lineNo()) {
    230                 LineInfo info = { instructions().size(), n->lineNo() };
    231                 m_codeBlock->addLineInfo(info);
    232             }
     227            addLineInfo(n->lineNo());
    233228            if (m_emitNodeDepth >= s_maxEmitNodeDepth) {
    234229                emitThrowExpressionTooDeepException();
     
    241236
    242237        void emitExpressionInfo(unsigned divot, unsigned startOffset, unsigned endOffset)
    243         {
     238        {
     239            if (!m_shouldEmitRichSourceInfo)
     240                return;
     241
    244242            divot -= m_codeBlock->sourceOffset();
    245243            if (divot > ExpressionRangeInfo::MaxDivot) {
     
    505503        }
    506504
     505        void addLineInfo(unsigned lineNo)
     506        {
     507#if !ENABLE(OPCODE_SAMPLING)
     508            if (m_shouldEmitRichSourceInfo)
     509#endif
     510                m_codeBlock->addLineInfo(instructions().size(), lineNo);
     511        }
     512
    507513        RegisterID* emitInitLazyRegister(RegisterID*);
    508514
     
    521527        bool m_shouldEmitDebugHooks;
    522528        bool m_shouldEmitProfileHooks;
     529        bool m_shouldEmitRichSourceInfo;
    523530
    524531        const ScopeChain* m_scopeChain;
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r72351 r72360  
    588588#if ENABLE(JIT) && ENABLE(INTERPRETER)
    589589    if (callerFrame->globalData().canUseJIT())
    590         bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     590        bytecodeOffset = codeBlock->bytecodeOffset(callFrame->returnPC());
    591591    else
    592         bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnVPC());
     592        bytecodeOffset = codeBlock->bytecodeOffset(callFrame->returnVPC());
    593593#elif ENABLE(JIT)
    594     bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     594    bytecodeOffset = codeBlock->bytecodeOffset(callFrame->returnPC());
    595595#else
    596     bytecodeOffset = codeBlock->bytecodeOffset(callerFrame, callFrame->returnVPC());
     596    bytecodeOffset = codeBlock->bytecodeOffset(callFrame->returnVPC());
    597597#endif
    598598
     
    605605    exception->clearAppendSourceToMessage();
    606606
     607    if (!callFrame->codeBlock()->hasExpressionInfo())
     608        return;
     609
    607610    int startOffset = 0;
    608611    int endOffset = 0;
     
    610613
    611614    CodeBlock* codeBlock = callFrame->codeBlock();
    612     codeBlock->expressionRangeForBytecodeOffset(callFrame, bytecodeOffset, divotPoint, startOffset, endOffset);
     615    codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divotPoint, startOffset, endOffset);
    613616
    614617    int expressionStart = divotPoint - startOffset;
     
    649652}
    650653
    651 NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset, bool explicitThrow)
     654NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset)
    652655{
    653656    CodeBlock* codeBlock = callFrame->codeBlock();
     
    657660    if (exceptionValue.isObject()) {
    658661        JSObject* exception = asObject(exceptionValue);
    659         if (!explicitThrow && exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)->appendSourceToMessage())
     662
     663        if (exception->isErrorInstance() && static_cast<ErrorInstance*>(exception)->appendSourceToMessage())
    660664            appendSourceToError(callFrame, static_cast<ErrorInstance*>(exception), bytecodeOffset);
    661665
    662         // FIXME: should only really be adding these properties to VM generated exceptions,
    663         // but the inspector currently requires these for all thrown objects.
    664         if (!hasErrorInfo(callFrame, exception))
    665             addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset), codeBlock->ownerExecutable()->source());
     666        // Using hasExpressionInfo to imply we are interested in rich exception info.
     667        if (codeBlock->hasExpressionInfo() && !hasErrorInfo(callFrame, exception)) {
     668            ASSERT(codeBlock->hasLineInfo());
     669
     670            // FIXME: should only really be adding these properties to VM generated exceptions,
     671            // but the inspector currently requires these for all thrown objects.
     672            addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source());
     673        }
    666674
    667675        ComplType exceptionType = exception->exceptionType();
     
    672680        DebuggerCallFrame debuggerCallFrame(callFrame, exceptionValue);
    673681        bool hasHandler = codeBlock->handlerForBytecodeOffset(bytecodeOffset);
    674         debugger->exception(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->lineNumberForBytecodeOffset(callFrame, bytecodeOffset), hasHandler);
     682        debugger->exception(debuggerCallFrame, codeBlock->ownerExecutable()->sourceID(), codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), hasHandler);
    675683    }
    676684
     
    46044612        exceptionValue = callFrame->r(ex).jsValue();
    46054613
    4606         handler = throwException(callFrame, exceptionValue, vPC - codeBlock->instructions().begin(), true);
     4614        handler = throwException(callFrame, exceptionValue, vPC - codeBlock->instructions().begin());
    46074615        if (!handler)
    46084616            return throwError(callFrame, exceptionValue);
     
    47754783            exceptionValue = createInterruptedExecutionException(globalData);
    47764784        }
    4777         handler = throwException(callFrame, exceptionValue, vPC - codeBlock->instructions().begin(), false);
     4785        handler = throwException(callFrame, exceptionValue, vPC - codeBlock->instructions().begin());
    47784786        if (!handler)
    47794787            return throwError(callFrame, exceptionValue);
     
    48504858#if ENABLE(INTERPRETER)
    48514859    if (!callerFrame->globalData().canUseJIT())
    4852         bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnVPC());
     4860        bytecodeOffset = callerCodeBlock->bytecodeOffset(callFrame->returnVPC());
    48534861#if ENABLE(JIT)
    48544862    else
    4855         bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
     4863        bytecodeOffset = callerCodeBlock->bytecodeOffset(callFrame->returnPC());
    48564864#endif
    48574865#else
    4858     bytecodeOffset = callerCodeBlock->bytecodeOffset(callerFrame, callFrame->returnPC());
    4859 #endif
    4860     lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(callerFrame, bytecodeOffset - 1);
     4866    bytecodeOffset = callerCodeBlock->bytecodeOffset(callFrame->returnPC());
     4867#endif
     4868    lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(bytecodeOffset - 1);
    48614869    sourceID = callerCodeBlock->ownerExecutable()->sourceID();
    48624870    sourceURL = callerCodeBlock->ownerExecutable()->sourceURL();
  • trunk/JavaScriptCore/interpreter/Interpreter.h

    r70703 r72360  
    109109
    110110        NEVER_INLINE JSValue callEval(CallFrame*, RegisterFile*, Register* argv, int argc, int registerOffset);
    111         NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset, bool);
     111        NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset);
    112112        NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine);
    113113
  • trunk/JavaScriptCore/jit/JIT.cpp

    r72176 r72360  
    553553    }
    554554
    555     if (m_codeBlock->hasExceptionInfo()) {
     555    if (m_codeBlock->needsCallReturnIndices()) {
    556556        m_codeBlock->callReturnIndexVector().reserveCapacity(m_calls.size());
    557557        for (Vector<CallRecord>::iterator iter = m_calls.begin(); iter != m_calls.end(); ++iter)
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r72176 r72360  
    10681068    CallFrame* callFrame;
    10691069};
    1070 static ExceptionHandler jitThrow(JSGlobalData* globalData, CallFrame* callFrame, JSValue exceptionValue, ReturnAddressPtr faultLocation, bool explicitThrow)
     1070static ExceptionHandler jitThrow(JSGlobalData* globalData, CallFrame* callFrame, JSValue exceptionValue, ReturnAddressPtr faultLocation)
    10711071{
    10721072    ASSERT(exceptionValue);
    10731073
    1074     unsigned vPCIndex = callFrame->codeBlock()->bytecodeOffset(callFrame, faultLocation);
     1074    unsigned vPCIndex = callFrame->codeBlock()->bytecodeOffset(faultLocation);
    10751075    globalData->exception = JSValue();
    1076     HandlerInfo* handler = globalData->interpreter->throwException(callFrame, exceptionValue, vPCIndex, explicitThrow); // This may update callFrame & exceptionValue!
     1076    HandlerInfo* handler = globalData->interpreter->throwException(callFrame, exceptionValue, vPCIndex); // This may update callFrame & exceptionValue!
    10771077    globalData->exception = exceptionValue;
    10781078
     
    13851385        // moved the call frame forward.
    13861386        CallFrame* oldCallFrame = callFrame->callerFrame();
    1387         ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), ReturnAddressPtr(oldCallFrame->returnPC()), false);
     1387        ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), ReturnAddressPtr(oldCallFrame->returnPC()));
    13881388        STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    13891389        callFrame = handler.callFrame;
     
    20072007            // Rewind to the previous call frame because op_call already optimistically
    20082008            // moved the call frame forward.
    2009             ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc, false);
     2009            ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
    20102010            STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    20112011            return handler.callFrame;
     
    20222022            // Rewind to the previous call frame because op_call already optimistically
    20232023            // moved the call frame forward.
    2024             ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc, false);
     2024            ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
    20252025            STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    20262026            return handler.callFrame;
     
    20662066            // Rewind to the previous call frame because op_call already optimistically
    20672067            // moved the call frame forward.
    2068             ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc, false);
     2068            ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
    20692069            STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    20702070            return handler.callFrame;
     
    20812081            // Rewind to the previous call frame because op_call already optimistically
    20822082            // moved the call frame forward.
    2083             ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc, false);
     2083            ExceptionHandler handler = jitThrow(stackFrame.globalData, oldCallFrame, createStackOverflowError(oldCallFrame), pc);
    20842084            STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    20852085            return handler.callFrame;
     
    32393239{
    32403240    STUB_INIT_STACK_FRAME(stackFrame);
    3241     ExceptionHandler handler = jitThrow(stackFrame.globalData, stackFrame.callFrame, stackFrame.args[0].jsValue(), STUB_RETURN_ADDRESS, true);
     3241    ExceptionHandler handler = jitThrow(stackFrame.globalData, stackFrame.callFrame, stackFrame.args[0].jsValue(), STUB_RETURN_ADDRESS);
    32423242    STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    32433243    return handler.callFrame;
     
    35963596    STUB_INIT_STACK_FRAME(stackFrame);
    35973597    JSGlobalData* globalData = stackFrame.globalData;
    3598     ExceptionHandler handler = jitThrow(globalData, stackFrame.callFrame, globalData->exception, globalData->exceptionLocation, false);
     3598    ExceptionHandler handler = jitThrow(globalData, stackFrame.callFrame, globalData->exception, globalData->exceptionLocation);
    35993599    STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
    36003600    return handler.callFrame;
  • trunk/JavaScriptCore/runtime/Collector.cpp

    r70111 r72360  
    10521052    if (m_globalData->exception)
    10531053        markStack.append(m_globalData->exception);
    1054     if (m_globalData->functionCodeBlockBeingReparsed)
    1055         m_globalData->functionCodeBlockBeingReparsed->markAggregate(markStack);
    10561054    if (m_globalData->firstStringifierToMark)
    10571055        JSONObject::markStringifiers(markStack, m_globalData->firstStringifierToMark);
  • trunk/JavaScriptCore/runtime/Executable.cpp

    r70008 r72360  
    109109    ASSERT(!m_evalCodeBlock);
    110110    m_evalCodeBlock = adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth()));
    111     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), globalObject->debugger(), scopeChain, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get())));
     111    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(evalNode.get(), scopeChain, m_evalCodeBlock->symbolTable(), m_evalCodeBlock.get())));
    112112    generator->generate();
    113113   
     
    157157   
    158158    m_programCodeBlock = adoptPtr(new ProgramCodeBlock(this, GlobalCode, globalObject, source().provider()));
    159     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), globalObject->debugger(), scopeChain, &globalObject->symbolTable(), m_programCodeBlock.get())));
     159    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(programNode.get(), scopeChain, &globalObject->symbolTable(), m_programCodeBlock.get())));
    160160    generator->generate();
    161161
     
    194194    ASSERT(!m_codeBlockForCall);
    195195    m_codeBlockForCall = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), false));
    196     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall.get())));
     196    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChain, m_codeBlockForCall->symbolTable(), m_codeBlockForCall.get())));
    197197    generator->generate();
    198198    m_numParametersForCall = m_codeBlockForCall->m_numParameters;
     
    235235    ASSERT(!m_codeBlockForConstruct);
    236236    m_codeBlockForConstruct = adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), true));
    237     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), globalObject->debugger(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct.get())));
     237    OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(body.get(), scopeChain, m_codeBlockForConstruct->symbolTable(), m_codeBlockForConstruct.get())));
    238238    generator->generate();
    239239    m_numParametersForConstruct = m_codeBlockForConstruct->m_numParameters;
     
    263263    if (m_codeBlockForConstruct)
    264264        m_codeBlockForConstruct->markAggregate(markStack);
    265 }
    266 
    267 PassOwnPtr<ExceptionInfo> FunctionExecutable::reparseExceptionInfo(ScopeChainNode* scopeChainNode, CodeBlock* codeBlock)
    268 {
    269     JSObject* exception = 0;
    270     JSGlobalData* globalData = scopeChainNode->globalData;
    271     RefPtr<FunctionBodyNode> newFunctionBody = globalData->parser->parse<FunctionBodyNode>(scopeChainNode->globalObject, 0, 0, m_source, m_parameters.get(), isStrictMode() ? JSParseStrict : JSParseNormal, &exception);
    272     if (!newFunctionBody)
    273         return PassOwnPtr<ExceptionInfo>();
    274     ASSERT(newFunctionBody->isStrictMode() == isStrictMode());
    275     if (m_forceUsesArguments)
    276         newFunctionBody->setUsesArguments();
    277     newFunctionBody->finishParsing(m_parameters, m_name);
    278 
    279     ScopeChain scopeChain(scopeChainNode);
    280     JSGlobalObject* globalObject = scopeChain.globalObject();
    281 
    282     OwnPtr<CodeBlock> newCodeBlock(adoptPtr(new FunctionCodeBlock(this, FunctionCode, globalObject, source().provider(), source().startOffset(), codeBlock->m_isConstructor)));
    283     globalData->functionCodeBlockBeingReparsed = newCodeBlock.get();
    284 
    285     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(newFunctionBody.get(), globalObject->debugger(), scopeChain, newCodeBlock->symbolTable(), newCodeBlock.get())));
    286     generator->setRegeneratingForExceptionInfo(static_cast<FunctionCodeBlock*>(codeBlock));
    287     generator->generate();
    288 
    289     ASSERT(newCodeBlock->instructionCount() == codeBlock->instructionCount());
    290 
    291 #if ENABLE(JIT)
    292     if (globalData->canUseJIT()) {
    293         JITCode newJITCode = JIT::compile(globalData, newCodeBlock.get(), 0, codeBlock->m_isConstructor ? generatedJITCodeForConstruct().start() : generatedJITCodeForCall().start());
    294         ASSERT(codeBlock->m_isConstructor ? newJITCode.size() == generatedJITCodeForConstruct().size() : newJITCode.size() == generatedJITCodeForCall().size());
    295     }
    296 #endif
    297 
    298     globalData->functionCodeBlockBeingReparsed = 0;
    299 
    300     return newCodeBlock->extractExceptionInfo();
    301 }
    302 
    303 PassOwnPtr<ExceptionInfo> EvalExecutable::reparseExceptionInfo(ScopeChainNode* scopeChainNode, CodeBlock* codeBlock)
    304 {
    305     JSObject* exception = 0;
    306     JSGlobalData* globalData = scopeChainNode->globalData;
    307     RefPtr<EvalNode> newEvalBody = globalData->parser->parse<EvalNode>(scopeChainNode->globalObject, 0, 0, m_source, 0, isStrictMode() ? JSParseStrict : JSParseNormal, &exception);
    308     ASSERT(newEvalBody->isStrictMode() == isStrictMode());
    309     if (!newEvalBody)
    310         return PassOwnPtr<ExceptionInfo>();
    311 
    312     ScopeChain scopeChain(scopeChainNode);
    313     JSGlobalObject* globalObject = scopeChain.globalObject();
    314 
    315     OwnPtr<EvalCodeBlock> newCodeBlock(adoptPtr(new EvalCodeBlock(this, globalObject, source().provider(), scopeChain.localDepth())));
    316 
    317     OwnPtr<BytecodeGenerator> generator(adoptPtr(new BytecodeGenerator(newEvalBody.get(), globalObject->debugger(), scopeChain, newCodeBlock->symbolTable(), newCodeBlock.get())));
    318     generator->setRegeneratingForExceptionInfo(static_cast<EvalCodeBlock*>(codeBlock));
    319     generator->generate();
    320 
    321     ASSERT(newCodeBlock->instructionCount() == codeBlock->instructionCount());
    322 
    323 #if ENABLE(JIT)
    324     if (globalData->canUseJIT()) {
    325         JITCode newJITCode = JIT::compile(globalData, newCodeBlock.get(), 0, generatedJITCodeForCall().start());
    326         ASSERT(newJITCode.size() == generatedJITCodeForCall().size());
    327     }
    328 #endif
    329 
    330     return newCodeBlock->extractExceptionInfo();
    331265}
    332266
     
    377311}
    378312
    379 PassOwnPtr<ExceptionInfo> ProgramExecutable::reparseExceptionInfo(ScopeChainNode*, CodeBlock*)
    380 {
    381     // CodeBlocks for program code are transient and therefore do not gain from from throwing out their exception information.
    382     return PassOwnPtr<ExceptionInfo>();
    383 }
    384 
    385 }
     313}
  • trunk/JavaScriptCore/runtime/Executable.h

    r69516 r72360  
    178178        bool isStrictMode() const { return m_features & StrictModeFeature; }
    179179
    180         virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(ScopeChainNode*, CodeBlock*) = 0;
    181 
    182180    protected:
    183181        void recordParse(CodeFeatures features, bool hasCapturedVariables, int firstLine, int lastLine)
     
    230228        JSObject* compileInternal(ExecState*, ScopeChainNode*);
    231229
    232         virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(ScopeChainNode*, CodeBlock*);
    233 
    234230        OwnPtr<EvalCodeBlock> m_evalCodeBlock;
    235231    };
     
    273269        JSObject* compileInternal(ExecState*, ScopeChainNode*);
    274270
    275         virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(ScopeChainNode*, CodeBlock*);
    276 
    277271        OwnPtr<ProgramCodeBlock> m_programCodeBlock;
    278272    };
     
    366360        JSObject* compileForConstructInternal(ExecState*, ScopeChainNode*);
    367361
    368         virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(ScopeChainNode*, CodeBlock*);
    369 
    370362        unsigned m_numCapturedVariables : 31;
    371363        bool m_forceUsesArguments : 1;
  • trunk/JavaScriptCore/runtime/JSGlobalData.cpp

    r72127 r72360  
    142142    , head(0)
    143143    , dynamicGlobalObject(0)
    144     , functionCodeBlockBeingReparsed(0)
    145144    , firstStringifierToMark(0)
    146145    , markStack(jsArrayVPtr)
  • trunk/JavaScriptCore/runtime/JSGlobalData.h

    r72207 r72360  
    117117
    118118        bool isSharedInstance() { return globalDataType == APIShared; }
     119        bool usingAPI() { return globalDataType != Default; }
    119120        static bool sharedInstanceExists();
    120121        static JSGlobalData& sharedInstance();
     
    206207        HashSet<JSObject*> arrayVisitedElements;
    207208
    208         CodeBlock* functionCodeBlockBeingReparsed;
    209209        Stringifier* firstStringifierToMark;
    210210
  • trunk/JavaScriptCore/runtime/JSGlobalObject.h

    r70406 r72360  
    255255        Debugger* debugger() const { return d()->debugger; }
    256256        void setDebugger(Debugger* debugger) { d()->debugger = debugger; }
    257        
     257
    258258        virtual bool supportsProfiling() const { return false; }
    259        
     259        virtual bool supportsRichSourceInfo() const { return true; }
     260
    260261        ScopeChain& globalScopeChain() { return d()->globalScopeChain; }
    261262
     
    277278        void resetPrototype(JSValue prototype);
    278279
    279         JSGlobalData& globalData() { return *d()->globalData.get(); }
     280        JSGlobalData& globalData() const { return *d()->globalData.get(); }
    280281        JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
    281282
  • trunk/WebCore/ChangeLog

    r72358 r72360  
     12010-11-18  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 49708 - Stop recompiling functions to regenerate exception info.
     6
     7        Instead only hold info as necessary – keep divot info is the inspector
     8        is enabled, line number info is debugging or profiling, and handler
     9        info for functions with try/catch.
     10
     11        * bindings/js/JSDOMWindowBase.cpp:
     12        (WebCore::JSDOMWindowBase::supportsRichSourceInfo):
     13            - report to JSC whether the inspector is enabled - in which
     14              case we will generate better error messages on exceptions.
     15        * bindings/js/JSDOMWindowBase.h:
     16
    1172010-11-18  Jian Li  <jianli@chromium.org>
    218
  • trunk/WebCore/bindings/js/JSDOMWindowBase.cpp

    r69798 r72360  
    119119}
    120120
     121bool JSDOMWindowBase::supportsRichSourceInfo() const
     122{
     123#if !ENABLE(JAVASCRIPT_DEBUGGER) || !ENABLE(INSPECTOR)
     124    return false;
     125#else
     126    Frame* frame = impl()->frame();
     127    if (!frame)
     128        return false;
     129
     130    Page* page = frame->page();
     131    if (!page)
     132        return false;
     133
     134    bool enabled = page->inspectorController()->enabled();
     135    ASSERT(enabled || !debugger());
     136    ASSERT(enabled || !supportsProfiling());
     137    return enabled;
     138#endif
     139}
     140
    121141bool JSDOMWindowBase::shouldInterruptScript() const
    122142{
  • trunk/WebCore/bindings/js/JSDOMWindowBase.h

    r69516 r72360  
    6161        virtual JSC::ExecState* globalExec();
    6262        virtual bool supportsProfiling() const;
     63        virtual bool supportsRichSourceInfo() const;
    6364        virtual bool shouldInterruptScript() const;
    6465
  • trunk/WebKitTools/ChangeLog

    r72357 r72360  
     12010-11-18  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Bug 49708 - Stop recompiling functions to regenerate exception info.
     6
     7        Instead only hold info as necessary – keep divot info is the inspector
     8        is enabled, line number info is debugging or profiling, and handler
     9        info for functions with try/catch.
     10
     11        * DumpRenderTree/mac/DumpRenderTree.mm:
     12        (shouldEnableDeveloperExtras):
     13            - always enable the developer tools from DRT, to ensure we
     14              produce rich error messages on JavaScript exceptions.
     15
    1162010-11-18  Kinuko Yasuda  <kinuko@chromium.org>
    217
  • trunk/WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm

    r72164 r72360  
    990990static bool shouldEnableDeveloperExtras(const char* pathOrURL)
    991991{
    992     return shouldOpenWebInspector(pathOrURL) || strstr(pathOrURL, "inspector-enabled/");
     992    return true;
    993993}
    994994
Note: See TracChangeset for help on using the changeset viewer.