Ignore:
Timestamp:
Apr 26, 2017, 8:38:12 PM (8 years ago)
Author:
[email protected]
Message:

Print Wasm function index in stack trace
https://bugs.webkit.org/show_bug.cgi?id=171349

Reviewed by JF Bastien.

JSTests:

  • wasm/function-tests/stack-trace.js: Added.

(import.Builder.from.string_appeared_here.assert):
(let.imp):

  • wasm/function-tests/trap-after-cross-instance-call.js:

(wasmFrameCountFromError):

  • wasm/function-tests/trap-load-2.js:

(wasmFrameCountFromError):

  • wasm/function-tests/trap-load.js:

(wasmFrameCountFromError):

Source/JavaScriptCore:

This patch prints a Callee's index in the function index
space in Error.stack.

This will lead to stack traces that have lines of text like:
wasm function index: 4@[wasm code]

We don't ascribe indices to everything in wasm. Specifically, the
Wasm->JS call stub callee does not get a name, and neither does
the JS -> Wasm entrypoint.

  • interpreter/Interpreter.cpp:

(JSC::GetStackTraceFunctor::operator()):

  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::readNonInlinedFrame):
(JSC::StackVisitor::Frame::functionName):

  • interpreter/StackVisitor.h:

(JSC::StackVisitor::Frame::wasmFunctionIndex):

  • runtime/StackFrame.cpp:

(JSC::StackFrame::functionName):

  • runtime/StackFrame.h:

(JSC::StackFrame::StackFrame):
(JSC::StackFrame::wasm):
(JSC::StackFrame::hasBytecodeOffset):
(JSC::StackFrame::bytecodeOffset):

  • wasm/WasmBBQPlanInlines.h:

(JSC::Wasm::BBQPlan::initializeCallees):

  • wasm/WasmCallee.cpp:

(JSC::Wasm::Callee::Callee):

  • wasm/WasmCallee.h:

(JSC::Wasm::Callee::create):
(JSC::Wasm::Callee::index):

  • wasm/WasmOMGPlan.cpp:

(JSC::Wasm::OMGPlan::work):

Location:
trunk/Source/JavaScriptCore/interpreter
Files:
3 edited

Legend:

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

    r215779 r215854  
    480480
    481481        if (m_remainingCapacityForFrameCapture) {
    482             if (visitor->isWasmFrame())
    483                 m_results.append(StackFrame::wasm());
    484             else if (!!visitor->codeBlock() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
     482            if (visitor->isWasmFrame()) {
     483                std::optional<unsigned> wasmFunctionIndex = visitor->wasmFunctionIndex();
     484                m_results.append(StackFrame::wasm(wasmFunctionIndex ? *wasmFunctionIndex : StackFrame::invalidWasmIndex));
     485            } else if (!!visitor->codeBlock() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
    485486                m_results.append(
    486487                    StackFrame(m_vm, visitor->callee().asCell(), visitor->codeBlock(), visitor->bytecodeOffset()));
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r214905 r215854  
    164164        m_frame.m_codeBlock = nullptr;
    165165        m_frame.m_bytecodeOffset = 0;
     166#if ENABLE(WEBASSEMBLY)
     167        CalleeBits bits = callFrame->callee();
     168        if (bits.isWasm())
     169            m_frame.m_wasmFunctionIndex = bits.asWasmCallee()->index();
     170#endif
    166171    } else {
    167172        m_frame.m_codeBlock = callFrame->codeBlock();
     
    279284    switch (codeType()) {
    280285    case CodeType::Wasm:
    281         traceLine = ASCIILiteral("wasm code");
     286        if (m_wasmFunctionIndex)
     287            traceLine = makeString("wasm function index: ", String::number(*m_wasmFunctionIndex));
     288        else
     289            traceLine = ASCIILiteral("wasm function");
    282290        break;
    283291    case CodeType::Eval:
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.h

    r214905 r215854  
    7878        bool isInlinedFrame() const { return !!inlineCallFrame(); }
    7979        bool isWasmFrame() const;
     80        std::optional<unsigned> const wasmFunctionIndex()
     81        {
     82            ASSERT(isWasmFrame());
     83            return m_wasmFunctionIndex;
     84        }
    8085
    8186        JS_EXPORT_PRIVATE String functionName() const;
     
    117122        size_t m_argumentCountIncludingThis;
    118123        unsigned m_bytecodeOffset;
     124        std::optional<unsigned> m_wasmFunctionIndex;
    119125        bool m_callerIsVMEntryFrame : 1;
    120126        bool m_isWasmFrame : 1;
Note: See TracChangeset for help on using the changeset viewer.