Ignore:
Timestamp:
Apr 6, 2013, 3:47:56 PM (12 years ago)
Author:
[email protected]
Message:

Unify the many and varied stack trace mechanisms, and make the result sane.
https://bugs.webkit.org/show_bug.cgi?id=114072

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Makes JSC::StackFrame record the bytecode offset and other necessary data
rather than requiring us to perform eager evaluation of the line number, etc.
Then remove most of the users of retrieveLastCaller, as most of them were
using it to create a stack trace in a fairly incomplete and inefficient way.

StackFrame now also has a couple of helpers to get the line and column info.

  • API/JSContextRef.cpp:

(JSContextCreateBacktrace):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitDebugHook):

  • interpreter/Interpreter.cpp:

(JSC):
(JSC::Interpreter::dumpRegisters):
(JSC::Interpreter::unwindCallFrame):
(JSC::getBytecodeOffsetForCallFrame):
(JSC::getCallerInfo):
(JSC::StackFrame::line):
(JSC::StackFrame::column):
(JSC::StackFrame::expressionInfo):
(JSC::StackFrame::toString):
(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::addStackTraceIfNecessary):
(JSC::Interpreter::retrieveCallerFromVMCode):

  • interpreter/Interpreter.h:

(StackFrame):
(Interpreter):

  • runtime/Error.cpp:

(JSC::throwError):

  • runtime/JSGlobalData.h:

(JSC):
(JSGlobalData):

  • runtime/JSGlobalObject.cpp:

(JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope):

Source/WebCore:

Now that we've fleshed out the StackFrames from Interpreter::getStackTrace
WebCore can just ask us for a stack trace rather than implementing its own
stack walking.

  • bindings/js/ScriptCallStackFactory.cpp:

(WebCore::createScriptCallStack):

  • inspector/ScriptCallFrame.cpp:

(WebCore::ScriptCallFrame::isEqual):

  • inspector/ScriptCallFrame.h:

(ScriptCallFrame):
(WebCore::ScriptCallFrame::columnNumber):

Tools:

The commandline jsc executable no longer requires arguments, so
I've made run-jsc work without them.

  • Scripts/run-jsc:
File:
1 edited

Legend:

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

    r147846 r147858  
    8080        StackFrameCodeType codeType;
    8181        Strong<ExecutableBase> executable;
    82         int line;
     82        Strong<UnlinkedCodeBlock> codeBlock;
     83        RefPtr<SourceProvider> code;
     84        int lineOffset;
     85        unsigned characterOffset;
     86        unsigned bytecodeOffset;
    8387        String sourceURL;
    84         String toString(CallFrame* callFrame) const
    85         {
    86             StringBuilder traceBuild;
    87             String functionName = friendlyFunctionName(callFrame);
    88             String sourceURL = friendlySourceURL();
    89             traceBuild.append(functionName);
    90             if (!sourceURL.isEmpty()) {
    91                 if (!functionName.isEmpty())
    92                     traceBuild.append('@');
    93                 traceBuild.append(sourceURL);
    94                 if (line > -1) {
    95                     traceBuild.append(':');
    96                     traceBuild.appendNumber(line);
    97                 }
    98             }
    99             return traceBuild.toString().impl();
    100         }
     88        JS_EXPORT_PRIVATE String toString(CallFrame*);
    10189        String friendlySourceURL() const
    10290        {
     
    138126            return traceLine.isNull() ? emptyString() : traceLine;
    139127        }
    140         unsigned friendlyLineNumber() const
    141         {
    142             return line > -1 ? line : 0;
    143         }
     128        JS_EXPORT_PRIVATE unsigned line();
     129        JS_EXPORT_PRIVATE unsigned column();
     130        JS_EXPORT_PRIVATE void expressionInfo(int& divot, int& startOffset, int& endOffset);
    144131    };
    145132
     
    233220        NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine, int column);
    234221        static const String getTraceLine(CallFrame*, StackFrameCodeType, const String&, int);
    235         JS_EXPORT_PRIVATE static void getStackTrace(JSGlobalData*, Vector<StackFrame>& results);
    236         static void addStackTraceIfNecessary(CallFrame*, JSObject* error);
     222        JS_EXPORT_PRIVATE static void getStackTrace(JSGlobalData*, Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());
     223        static void addStackTraceIfNecessary(CallFrame*, JSValue error);
    237224
    238225        void dumpSampleData(ExecState* exec);
Note: See TracChangeset for help on using the changeset viewer.