Ignore:
Timestamp:
Apr 6, 2013, 11:24:37 AM (12 years ago)
Author:
[email protected]
Message:

Rolled out 147820 and 147818 because they caused plugins tests to ASSERT
https://bugs.webkit.org/show_bug.cgi?id=114094

Reviewed by Anders Carlsson.

Source/JavaScriptCore:

  • API/JSContextRef.cpp:

(JSContextCreateBacktrace):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitDebugHook):

  • interpreter/Interpreter.cpp:

(JSC):
(JSC::Interpreter::dumpRegisters):
(JSC::Interpreter::unwindCallFrame):
(JSC::getLineNumberForCallFrame):
(JSC::getCallerInfo):
(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::addStackTraceIfNecessary):
(JSC::Interpreter::retrieveCallerFromVMCode):

  • interpreter/Interpreter.h:

(StackFrame):
(JSC::StackFrame::toString):
(JSC::StackFrame::friendlyLineNumber):
(Interpreter):

  • runtime/Error.cpp:

(JSC::throwError):

  • runtime/JSGlobalData.h:

(JSC):
(JSGlobalData):

  • runtime/JSGlobalObject.cpp:

(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope):

Source/WebCore:

  • bindings/js/ScriptCallStackFactory.cpp:

(WebCore::createScriptCallStack):

  • inspector/ScriptCallFrame.cpp:

(WebCore::ScriptCallFrame::isEqual):

  • inspector/ScriptCallFrame.h:

(ScriptCallFrame):
(WebCore::ScriptCallFrame::lineNumber):

Tools:

  • Scripts/run-jsc:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r147820 r147846  
    200200
    201201
    202 static CallFrame* getCallerInfo(JSGlobalData*, CallFrame*, unsigned& bytecodeOffset, CodeBlock*& callerOut);
     202static CallFrame* getCallerInfo(JSGlobalData*, CallFrame*, int& lineNumber, unsigned& bytecodeOffset, CodeBlock*& callerOut);
    203203
    204204// Returns the depth of the scope chain within a given call frame.
     
    423423    unsigned bytecodeOffset = 0;
    424424    int line = 0;
    425     CodeBlock* callerCodeBlock = 0;
    426     getCallerInfo(&callFrame->globalData(), callFrame, bytecodeOffset, callerCodeBlock);
    427     line = callerCodeBlock->lineNumberForBytecodeOffset(bytecodeOffset);
     425    CodeBlock* unusedCallerCodeBlock = 0;
     426    getCallerInfo(&callFrame->globalData(), callFrame, line, bytecodeOffset, unusedCallerCodeBlock);
    428427    dataLogF("[ReturnVPC]                | %10p | %d (line %d)\n", it, bytecodeOffset, line);
    429428    ++it;
     
    509508    if (callerFrame->hasHostCallFrameFlag())
    510509        return false;
    511     callFrame = getCallerInfo(&callFrame->globalData(), callFrame, bytecodeOffset, codeBlock);
     510    int unusedLineNumber = 0;
     511    callFrame = getCallerInfo(&callFrame->globalData(), callFrame, unusedLineNumber, bytecodeOffset, codeBlock);
    512512    return true;
    513513}
     
    565565}
    566566
    567 static unsigned getBytecodeOffsetForCallFrame(CallFrame* callFrame)
    568 {
     567static int getLineNumberForCallFrame(JSGlobalData* globalData, CallFrame* callFrame)
     568{
     569    UNUSED_PARAM(globalData);
    569570    callFrame = callFrame->removeHostCallFrameFlag();
    570571    CodeBlock* codeBlock = callFrame->codeBlock();
    571572    if (!codeBlock)
    572         return 0;
    573 #if ENABLE(JIT)
     573        return -1;
     574#if ENABLE(JIT) || ENABLE(LLINT)
    574575#if ENABLE(DFG_JIT)
    575576    if (codeBlock->getJITType() == JITCode::DFGJIT)
    576         return codeBlock->codeOrigin(callFrame->codeOriginIndexForDFG()).bytecodeIndex;
    577 #endif
    578     return callFrame->bytecodeOffsetForNonDFGCode();
    579 #endif
    580 }
    581 
    582 static CallFrame* getCallerInfo(JSGlobalData* globalData, CallFrame* callFrame, unsigned& bytecodeOffset, CodeBlock*& caller)
     577        return codeBlock->lineNumberForBytecodeOffset(codeBlock->codeOrigin(callFrame->codeOriginIndexForDFG()).bytecodeIndex);
     578#endif
     579    return codeBlock->lineNumberForBytecodeOffset(callFrame->bytecodeOffsetForNonDFGCode());
     580#endif
     581}
     582
     583static CallFrame* getCallerInfo(JSGlobalData* globalData, CallFrame* callFrame, int& lineNumber, unsigned& bytecodeOffset, CodeBlock*& caller)
    583584{
    584585    ASSERT_UNUSED(globalData, globalData);
    585586    bytecodeOffset = 0;
     587    lineNumber = -1;
    586588    ASSERT(!callFrame->hasHostCallFrameFlag());
    587589    CallFrame* callerFrame = callFrame->codeBlock() ? callFrame->trueCallerFrame() : callFrame->callerFrame()->removeHostCallFrameFlag();
     
    653655    RELEASE_ASSERT(callerCodeBlock);
    654656    caller = callerCodeBlock;
     657    lineNumber = callerCodeBlock->lineNumberForBytecodeOffset(bytecodeOffset);
    655658    return callerFrame;
    656659}
     
    678681}
    679682
    680 unsigned StackFrame::line()
    681 {
    682     return codeBlock ? codeBlock->lineNumberForBytecodeOffset(bytecodeOffset) + lineOffset : 0;
    683 }
    684 
    685 unsigned StackFrame::column()
    686 {
    687     if (!code)
    688         return 0;
    689     int divot = 0;
    690     int unusedStartOffset = 0;
    691     int unusedEndOffset = 0;
    692     expressionInfo(divot, unusedStartOffset, unusedEndOffset);
    693     return code->charPositionToColumnNumber(divot);
    694 }
    695 
    696 void StackFrame::expressionInfo(int& divot, int& startOffset, int& endOffset)
    697 {
    698     codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset);
    699     divot += startOffset;
    700 }
    701 
    702 String StackFrame::toString(CallFrame* callFrame)
    703 {
    704     StringBuilder traceBuild;
    705     String functionName = friendlyFunctionName(callFrame);
    706     String sourceURL = friendlySourceURL();
    707     traceBuild.append(functionName);
    708     if (!sourceURL.isEmpty()) {
    709         if (!functionName.isEmpty())
    710             traceBuild.append('@');
    711         traceBuild.append(sourceURL);
    712         if (codeType != StackFrameNativeCode) {
    713             traceBuild.append(':');
    714             traceBuild.appendNumber(line());
    715         }
    716     }
    717     return traceBuild.toString().impl();
    718 }
    719 
    720 void Interpreter::getStackTrace(JSGlobalData* globalData, Vector<StackFrame>& results, size_t maxStackSize)
     683void Interpreter::getStackTrace(JSGlobalData* globalData, Vector<StackFrame>& results)
    721684{
    722685    CallFrame* callFrame = globalData->topCallFrame->removeHostCallFrameFlag();
    723686    if (!callFrame || callFrame == CallFrame::noCaller())
    724687        return;
    725     unsigned bytecodeOffset = getBytecodeOffsetForCallFrame(callFrame);
     688    int line = getLineNumberForCallFrame(globalData, callFrame);
     689
    726690    callFrame = callFrame->trueCallFrameFromVMCode();
    727691    if (!callFrame)
    728692        return;
    729     CodeBlock* callerCodeBlock = callFrame->codeBlock();
    730 
    731     while (callFrame && callFrame != CallFrame::noCaller() && maxStackSize--) {
     693
     694    while (callFrame && callFrame != CallFrame::noCaller()) {
    732695        String sourceURL;
    733         if (callerCodeBlock) {
     696        if (callFrame->codeBlock()) {
    734697            sourceURL = getSourceURLFromCallFrame(callFrame);
    735             StackFrame s = {
    736                 Strong<JSObject>(*globalData, callFrame->callee()),
    737                 getStackFrameCodeType(callFrame),
    738                 Strong<ExecutableBase>(*globalData, callerCodeBlock->ownerExecutable()),
    739                 Strong<UnlinkedCodeBlock>(*globalData, callerCodeBlock->unlinkedCodeBlock()),
    740                 callerCodeBlock->source(),
    741                 callerCodeBlock->ownerExecutable()->lineNo(),
    742                 callerCodeBlock->sourceOffset(),
    743                 bytecodeOffset,
    744                 sourceURL
    745             };
     698            StackFrame s = { Strong<JSObject>(*globalData, callFrame->callee()), getStackFrameCodeType(callFrame), Strong<ExecutableBase>(*globalData, callFrame->codeBlock()->ownerExecutable()), line, sourceURL};
    746699            results.append(s);
    747700        } else {
    748             StackFrame s = { Strong<JSObject>(*globalData, callFrame->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String()};
     701            StackFrame s = { Strong<JSObject>(*globalData, callFrame->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), -1, String()};
    749702            results.append(s);
    750703        }
    751         callFrame = getCallerInfo(globalData, callFrame, bytecodeOffset, callerCodeBlock);
    752     }
    753 }
    754 
    755 void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSValue error)
     704        unsigned unusedBytecodeOffset = 0;
     705        CodeBlock* unusedCallerCodeBlock = 0;
     706        callFrame = getCallerInfo(globalData, callFrame, line, unusedBytecodeOffset, unusedCallerCodeBlock);
     707    }
     708}
     709
     710void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSObject* error)
    756711{
    757712    JSGlobalData* globalData = &callFrame->globalData();
    758713    ASSERT(callFrame == globalData->topCallFrame || callFrame == callFrame->lexicalGlobalObject()->globalExec() || callFrame == callFrame->dynamicGlobalObject()->globalExec());
     714    if (error->hasProperty(callFrame, globalData->propertyNames->stack))
     715        return;
    759716
    760717    Vector<StackFrame> stackTrace;
    761718    getStackTrace(&callFrame->globalData(), stackTrace);
    762719   
    763     if (stackTrace.isEmpty() || !error.isObject())
     720    if (stackTrace.isEmpty())
    764721        return;
    765     JSObject* errorObject = asObject(error);
     722   
    766723    JSGlobalObject* globalObject = 0;
    767724    if (isTerminatedExecutionException(error) || isInterruptedExecutionException(error))
    768725        globalObject = globalData->dynamicGlobalObject;
    769726    else
    770         globalObject = errorObject->globalObject();
     727        globalObject = error->globalObject();
    771728
    772729    // FIXME: JSStringJoiner could be more efficient than StringBuilder here.
     
    777734            builder.append('\n');
    778735    }
    779 
    780     if (errorObject->hasProperty(callFrame, globalData->propertyNames->stack))
    781         return;
    782     errorObject->putDirect(*globalData, globalData->propertyNames->stack, jsString(globalData, builder.toString()), ReadOnly | DontDelete);
     736   
     737    error->putDirect(*globalData, globalData->propertyNames->stack, jsString(globalData, builder.toString()), ReadOnly | DontDelete);
    783738}
    784739
     
    14231378        return jsNull();
    14241379   
     1380    int lineNumber;
    14251381    unsigned bytecodeOffset;
    14261382    CodeBlock* unusedCallerCodeBlock = 0;
    1427     CallFrame* callerFrame = getCallerInfo(&callFrame->globalData(), functionCallFrame, bytecodeOffset, unusedCallerCodeBlock);
     1383    CallFrame* callerFrame = getCallerInfo(&callFrame->globalData(), functionCallFrame, lineNumber, bytecodeOffset, unusedCallerCodeBlock);
    14281384    if (!callerFrame)
    14291385        return jsNull();
     
    14351391    ASSERT(caller.isObject());
    14361392    while (asObject(caller)->inherits(&JSBoundFunction::s_info)) {
    1437         callerFrame = getCallerInfo(&callFrame->globalData(), callerFrame, bytecodeOffset, unusedCallerCodeBlock);
     1393        callerFrame = getCallerInfo(&callFrame->globalData(), callerFrame, lineNumber, bytecodeOffset, unusedCallerCodeBlock);
    14381394        if (!callerFrame)
    14391395            return jsNull();
Note: See TracChangeset for help on using the changeset viewer.