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/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();
Note: See TracChangeset for help on using the changeset viewer.