Changeset 114317 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Apr 16, 2012, 4:37:40 PM (13 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out r114309.
http://trac.webkit.org/changeset/114309
https://bugs.webkit.org/show_bug.cgi?id=84097

it broke everything (Requested by olliej on #webkit).

Patch by Sheriff Bot <[email protected]> on 2012-04-16

Source/JavaScriptCore:

  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • bytecode/CodeBlock.h:
  • dfg/DFGOperations.cpp:
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::throwException):

  • interpreter/Interpreter.h:

(Interpreter):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • jsc.cpp:

(functionJSCStack):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::handleHostCall):

  • parser/Parser.h:

(JSC::::parse):

  • runtime/Error.cpp:

(JSC::addErrorInfo):
(JSC::throwError):

  • runtime/Error.h:

(JSC):

LayoutTests:

  • fast/js/exception-properties-expected.txt:
  • fast/js/script-tests/exception-properties.js:
  • fast/js/script-tests/stack-trace.js:

(selfRecursive1):

  • fast/js/stack-trace-expected.txt:
Location:
trunk/Source/JavaScriptCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r114309 r114317  
     12012-04-16  Sheriff Bot  <[email protected]>
     2
     3        Unreviewed, rolling out r114309.
     4        http://trac.webkit.org/changeset/114309
     5        https://bugs.webkit.org/show_bug.cgi?id=84097
     6
     7        it broke everything (Requested by olliej on #webkit).
     8
     9        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     10        * bytecode/CodeBlock.h:
     11        * dfg/DFGOperations.cpp:
     12        * interpreter/Interpreter.cpp:
     13        (JSC::Interpreter::getStackTrace):
     14        (JSC::Interpreter::throwException):
     15        * interpreter/Interpreter.h:
     16        (Interpreter):
     17        * jit/JITStubs.cpp:
     18        (JSC::DEFINE_STUB_FUNCTION):
     19        * jsc.cpp:
     20        (functionJSCStack):
     21        * llint/LLIntSlowPaths.cpp:
     22        (JSC::LLInt::handleHostCall):
     23        * parser/Parser.h:
     24        (JSC::::parse):
     25        * runtime/Error.cpp:
     26        (JSC::addErrorInfo):
     27        (JSC::throwError):
     28        * runtime/Error.h:
     29        (JSC):
     30
    1312012-04-16  Oliver Hunt  <[email protected]>
    232
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r114309 r114317  
    213213    ?getPropertyNames@JSObject@JSC@@SAXPAV12@PAVExecState@2@AAVPropertyNameArray@2@W4EnumerationMode@2@@Z
    214214    ?getSlice@ArgList@JSC@@QBEXHAAV12@@Z
    215     ?getStackTrace@Interpreter@JSC@@SAXPAVJSGlobalData@2@AAV?$Vector@UStackFrame@JSC@@$0A@@WTF@@@Z
     215    ?getStackTrace@Interpreter@JSC@@SAXPAVJSGlobalData@2@HAAV?$Vector@UStackFrame@JSC@@$0A@@WTF@@@Z
    216216    ?getString@JSCell@JSC@@QBE?AVUString@2@PAVExecState@2@@Z
    217217    ?getString@JSCell@JSC@@QBE_NPAVExecState@2@AAVUString@2@@Z
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r114309 r114317  
    711711        }
    712712       
    713         int codeOriginIndexForReturn(ReturnAddressPtr returnAddress)
    714         {
    715             ASSERT(hasCodeOrigins());
    716             unsigned offset = getJITCode().offsetOf(returnAddress.value());
    717             CodeOriginAtCallReturnOffset* entry = binarySearch<CodeOriginAtCallReturnOffset, unsigned, getCallReturnOffsetForCodeOrigin>(codeOrigins().begin(), codeOrigins().size(), offset, WTF::KeyMustNotBePresentInArray);
    718             return entry - codeOrigins().begin();
    719         }
    720        
    721713        CodeOrigin codeOrigin(unsigned index)
    722714        {
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r114309 r114317  
    793793   
    794794        if (callType == CallTypeHost) {
    795             execCallee->setCallee(asObject(callee));
    796795            globalData->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
    797796            if (globalData->exception)
     
    814813   
    815814    if (constructType == ConstructTypeHost) {
    816         execCallee->setCallee(asObject(callee));
    817815        globalData->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
    818816        if (globalData->exception)
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r114309 r114317  
    6666#include <stdio.h>
    6767#include <wtf/Threading.h>
    68 #include <wtf/text/StringBuilder.h>
    6968
    7069#if ENABLE(JIT)
     
    954953}
    955954
    956 void Interpreter::getStackTrace(JSGlobalData* globalData, Vector<StackFrame>& results)
     955void Interpreter::getStackTrace(JSGlobalData* globalData, int line, Vector<StackFrame>& results)
    957956{
    958     CallFrame* callFrame = globalData->topCallFrame->removeHostCallFrameFlag();
     957    CallFrame* callFrame = globalData->topCallFrame->removeHostCallFrameFlag()->trueCallFrameFromVMCode();
    959958    if (!callFrame || callFrame == CallFrame::noCaller())
    960959        return;
    961     int line = getLineNumberForCallFrame(globalData, callFrame);
    962 
    963     callFrame = callFrame->trueCallFrameFromVMCode();
     960
     961    if (line == -1)
     962        line = getLineNumberForCallFrame(globalData, callFrame);
    964963
    965964    while (callFrame && callFrame != CallFrame::noCaller()) {
     
    977976}
    978977
    979 void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSObject* error)
    980 {
    981     JSGlobalData* globalData = &callFrame->globalData();
    982     if (error->hasProperty(callFrame, globalData->propertyNames->stack))
    983         return;
    984 
    985     Vector<StackFrame> stackTrace;
    986     getStackTrace(&callFrame->globalData(), stackTrace);
    987    
    988     if (stackTrace.isEmpty())
    989         return;
    990    
    991     JSGlobalObject* globalObject = 0;
    992     if (isTerminatedExecutionException(error) || isInterruptedExecutionException(error))
    993         globalObject = globalData->dynamicGlobalObject;
    994     else
    995         globalObject = error->globalObject();
    996     StringBuilder builder;
    997     for (unsigned i = 0; i < stackTrace.size(); i++) {
    998         builder.append(String(stackTrace[i].toString(globalObject->globalExec()).impl()));
    999         if (i != stackTrace.size() - 1)
    1000             builder.append('\n');
    1001     }
    1002    
    1003     error->putDirect(*globalData, globalData->propertyNames->stack, jsString(globalData, UString(builder.toString().impl())), ReadOnly | DontDelete);
    1004 }
    1005 
    1006978NEVER_INLINE HandlerInfo* Interpreter::throwException(CallFrame*& callFrame, JSValue& exceptionValue, unsigned bytecodeOffset)
    1007979{
     
    1019991        if (codeBlock->hasExpressionInfo() && !hasErrorInfo(callFrame, exception)) {
    1020992            ASSERT(codeBlock->hasLineInfo());
     993
    1021994            // FIXME: should only really be adding these properties to VM generated exceptions,
    1022995            // but the inspector currently requires these for all thrown objects.
    1023             addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source());
     996            Vector<StackFrame> stackTrace;
     997            getStackTrace(&callFrame->globalData(), codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), stackTrace);
     998            addErrorInfo(callFrame, exception, codeBlock->lineNumberForBytecodeOffset(bytecodeOffset), codeBlock->ownerExecutable()->source(), stackTrace);
    1024999        }
    10251000
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.h

    r114309 r114317  
    223223        NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine);
    224224        static const UString getTraceLine(CallFrame*, StackFrameCodeType, const UString&, int);
    225         JS_EXPORT_PRIVATE static void getStackTrace(JSGlobalData*, Vector<StackFrame>& results);
    226         static void addStackTraceIfNecessary(CallFrame*, JSObject* error);
     225        JS_EXPORT_PRIVATE static void getStackTrace(JSGlobalData*, int line, Vector<StackFrame>& results);
    227226
    228227        void dumpSampleData(ExecState* exec);
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r114309 r114317  
    35193519    STUB_INIT_STACK_FRAME(stackFrame);
    35203520    JSGlobalData* globalData = stackFrame.globalData;
    3521     // It's possible for us to reach this point with incorrect origin metadata
    3522     // if a native function throws an exception after being planted in certain
    3523     // code paths as the native thunk doesn't can't unwind itself as if it were
    3524     // a JS function. So we redetermine the correct data here just to be safe.
    3525     if (CodeBlock* codeBlock = stackFrame.callFrame->codeBlock()) {
    3526 #if ENABLE(DFG_JIT)
    3527         if (codeBlock->hasCodeOrigins())
    3528             stackFrame.callFrame->setBytecodeOffsetForNonDFGCode(codeBlock->codeOriginIndexForReturn(globalData->exceptionLocation));
    3529         else
    3530 #endif
    3531             if (codeBlock->getJITType() == JITCode::BaselineJIT)
    3532             stackFrame.callFrame->setBytecodeOffsetForNonDFGCode(codeBlock->bytecodeOffset(stackFrame.callFrame, globalData->exceptionLocation));
    3533     }
    35343521    ExceptionHandler handler = jitThrow(globalData, stackFrame.callFrame, globalData->exception, globalData->exceptionLocation);
    35353522    STUB_SET_RETURN_ADDRESS(handler.catchRoutine);
  • trunk/Source/JavaScriptCore/jsc.cpp

    r114309 r114317  
    278278    String trace = "--> Stack trace:\n";
    279279    Vector<StackFrame> stackTrace;
    280     Interpreter::getStackTrace(&exec->globalData(), stackTrace);
     280    Interpreter::getStackTrace(&exec->globalData(), -1, stackTrace);
    281281    int i = 0;
    282282
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r114309 r114317  
    12421242   
    12431243        if (callType == CallTypeHost) {
    1244             execCallee->setCallee(asObject(callee));
    12451244            globalData.hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
    12461245           
     
    12641263   
    12651264    if (constructType == ConstructTypeHost) {
    1266         execCallee->setCallee(asObject(callee));
    12671265        globalData.hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
    12681266
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r114309 r114317  
    994994            *exception = createSyntaxError(lexicalGlobalObject, errMsg);
    995995        else
    996             *exception = addErrorInfo(lexicalGlobalObject->globalExec(), createSyntaxError(lexicalGlobalObject, errMsg), errLine, *m_source);
     996            *exception = addErrorInfo(&lexicalGlobalObject->globalData(), createSyntaxError(lexicalGlobalObject, errMsg), errLine, *m_source, Vector<StackFrame>());
    997997    }
    998998
  • trunk/Source/JavaScriptCore/runtime/Error.cpp

    r114309 r114317  
    121121}
    122122
    123 JSObject* addErrorInfo(CallFrame* callFrame, JSObject* error, int line, const SourceCode& source)
     123JSObject* addErrorInfo(JSGlobalData* globalData, JSObject* error, int line, const SourceCode& source, const Vector<StackFrame>& stackTrace)
    124124{
    125     JSGlobalData* globalData = &callFrame->globalData();
    126125    const UString& sourceURL = source.provider()->url();
    127126
     
    130129    if (!sourceURL.isNull())
    131130        error->putDirect(*globalData, Identifier(globalData, sourceURLPropertyName), jsString(globalData, sourceURL), ReadOnly | DontDelete);
     131    if (!stackTrace.isEmpty()) {
     132        JSGlobalObject* globalObject = 0;
     133        if (isTerminatedExecutionException(error) || isInterruptedExecutionException(error))
     134            globalObject = globalData->dynamicGlobalObject;
     135        else
     136            globalObject = error->globalObject();
     137        StringBuilder builder;
     138        for (unsigned i = 0; i < stackTrace.size(); i++) {
     139            builder.append(String(stackTrace[i].toString(globalObject->globalExec()).impl()));
     140            if (i != stackTrace.size() - 1)
     141                builder.append('\n');
     142        }
    132143
    133     globalData->interpreter->addStackTraceIfNecessary(callFrame, error);
     144        error->putDirect(*globalData, globalData->propertyNames->stack, jsString(globalData, UString(builder.toString().impl())), ReadOnly | DontDelete);
     145    }
    134146
    135147    return error;
    136148}
    137149
     150JSObject* addErrorInfo(ExecState* exec, JSObject* error, int line, const SourceCode& source, const Vector<StackFrame>& stackTrace)
     151{
     152    return addErrorInfo(&exec->globalData(), error, line, source, stackTrace);
     153}
    138154
    139155bool hasErrorInfo(ExecState* exec, JSObject* error)
     
    145161JSValue throwError(ExecState* exec, JSValue error)
    146162{
    147     if (error.isObject())
    148         return throwError(exec, asObject(error));
    149163    exec->globalData().exception = error;
    150164    return error;
     
    153167JSObject* throwError(ExecState* exec, JSObject* error)
    154168{
    155     Interpreter::addStackTraceIfNecessary(exec, error);
    156169    exec->globalData().exception = error;
    157170    return error;
  • trunk/Source/JavaScriptCore/runtime/Error.h

    r114309 r114317  
    5858    // Methods to add
    5959    bool hasErrorInfo(ExecState*, JSObject* error);
     60    JSObject* addErrorInfo(JSGlobalData*, JSObject* error, int line, const SourceCode&, const Vector<StackFrame>&);
    6061    // ExecState wrappers.
    61     JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&);
     62    JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&, const Vector<StackFrame>&);
    6263
    6364    // Methods to throw Errors.
Note: See TracChangeset for help on using the changeset viewer.