Changeset 182167 in webkit


Ignore:
Timestamp:
Mar 30, 2015 5:43:49 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

REGRESSION (r181993): inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html crashes.
<https://webkit.org/b/143105>

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

With r181993, the DFG and FTL may elide the storing of the scope register. As a result,
on OSR exits from DFG / FTL frames where this elision has take place, we may get baseline
JIT frames that may have its scope register not set. The Debugger's current implementation
which relies on the scope register is not happy about this. For example, this results in a
crash in the layout test inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html.

The fix is to disable inlining when the debugger is in use. Also, we add Flush nodes to
ensure that the scope register value is flushed to the register in the stack frame.

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::ByteCodeParser):
(JSC::DFG::ByteCodeParser::setLocal):
(JSC::DFG::ByteCodeParser::flush):

  • Add code to flush the scope register.

(JSC::DFG::ByteCodeParser::inliningCost):

  • Pretend that all codeBlocks are too expensive to inline if the debugger is in use, thereby disabling inlining whenever the debugger is in use.
  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::Graph):

  • dfg/DFGGraph.h:

(JSC::DFG::Graph::hasDebuggerEnabled):

  • dfg/DFGStackLayoutPhase.cpp:

(JSC::DFG::StackLayoutPhase::run):

  • Update the DFG codeBlock's scopeRegister since it can be moved during stack layout.
  • ftl/FTLCompile.cpp:

(JSC::FTL::mmAllocateDataSection):

  • Update the FTL codeBlock's scopeRegister since it can be moved during stack layout.

LayoutTests:

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r182157 r182167  
     12015-03-30  Mark Lam  <mark.lam@apple.com>
     2
     3        REGRESSION (r181993): inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html crashes.
     4        <https://webkit.org/b/143105>
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * TestExpectations:
     9        - Undid test skipped in r182072.
     10
    1112015-03-30  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/LayoutTests/TestExpectations

    r182147 r182167  
    128128
    129129webkit.org/b/128736 inspector-protocol/debugger/setBreakpoint-dfg.html [ Failure Pass ]
    130 webkit.org/b/143105 inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html [ Skip ] # Crashing
     130webkit.org/b/134982 inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html [ Failure Pass ]
    131131
    132132# CSS Font Loading is not yet enabled on all platforms
  • trunk/Source/JavaScriptCore/ChangeLog

    r182158 r182167  
     12015-03-30  Mark Lam  <mark.lam@apple.com>
     2
     3        REGRESSION (r181993): inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html crashes.
     4        <https://webkit.org/b/143105>
     5
     6        Reviewed by Filip Pizlo.
     7
     8        With r181993, the DFG and FTL may elide the storing of the scope register.  As a result,
     9        on OSR exits from DFG / FTL frames where this elision has take place, we may get baseline
     10        JIT frames that may have its scope register not set.  The Debugger's current implementation
     11        which relies on the scope register is not happy about this.  For example, this results in a
     12        crash in the layout test inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html.
     13
     14        The fix is to disable inlining when the debugger is in use.  Also, we add Flush nodes to
     15        ensure that the scope register value is flushed to the register in the stack frame.
     16
     17        * dfg/DFGByteCodeParser.cpp:
     18        (JSC::DFG::ByteCodeParser::ByteCodeParser):
     19        (JSC::DFG::ByteCodeParser::setLocal):
     20        (JSC::DFG::ByteCodeParser::flush):
     21        - Add code to flush the scope register.
     22        (JSC::DFG::ByteCodeParser::inliningCost):
     23        - Pretend that all codeBlocks are too expensive to inline if the debugger is in use, thereby
     24          disabling inlining whenever the debugger is in use.
     25        * dfg/DFGGraph.cpp:
     26        (JSC::DFG::Graph::Graph):
     27        * dfg/DFGGraph.h:
     28        (JSC::DFG::Graph::hasDebuggerEnabled):
     29        * dfg/DFGStackLayoutPhase.cpp:
     30        (JSC::DFG::StackLayoutPhase::run):
     31        - Update the DFG codeBlock's scopeRegister since it can be moved during stack layout.
     32        * ftl/FTLCompile.cpp:
     33        (JSC::FTL::mmAllocateDataSection):
     34        - Update the FTL codeBlock's scopeRegister since it can be moved during stack layout.
     35
    1362015-03-30  Michael Saboff  <msaboff@apple.com>
    237
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r181993 r182167  
    148148        , m_haveBuiltOperandMaps(false)
    149149        , m_currentInstruction(0)
     150        , m_hasDebuggerEnabled(graph.hasDebuggerEnabled())
    150151    {
    151152        ASSERT(m_profiledBlock);
     
    386387            if (argumentPosition)
    387388                flushDirect(operand, argumentPosition);
     389            else if (m_hasDebuggerEnabled && operand == m_codeBlock->scopeRegister())
     390                flush(operand);
    388391        }
    389392
     
    523526        int numArguments;
    524527        if (InlineCallFrame* inlineCallFrame = inlineStackEntry->m_inlineCallFrame) {
     528            ASSERT(!m_hasDebuggerEnabled);
    525529            numArguments = inlineCallFrame->arguments.size();
    526530            if (inlineCallFrame->isClosureCall)
     
    532536        for (unsigned argument = numArguments; argument-- > 1;)
    533537            flushDirect(inlineStackEntry->remapOperand(virtualRegisterForArgument(argument)));
     538        if (m_hasDebuggerEnabled)
     539            flush(m_codeBlock->scopeRegister());
    534540    }
    535541
     
    9981004   
    9991005    Instruction* m_currentInstruction;
     1006    bool m_hasDebuggerEnabled;
    10001007};
    10011008
     
    11691176        dataLog("Considering inlining ", callee, " into ", currentCodeOrigin(), "\n");
    11701177   
     1178    if (m_hasDebuggerEnabled) {
     1179        if (verbose)
     1180            dataLog("    Failing because the debugger is in use.\n");
     1181        return UINT_MAX;
     1182    }
     1183
    11711184    FunctionExecutable* executable = callee.functionExecutable();
    11721185    if (!executable) {
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r181993 r182167  
    7575    for (unsigned i = m_mustHandleValues.size(); i--;)
    7676        m_mustHandleValues[i] = freezeFragile(plan.mustHandleValues[i]);
     77
     78    m_hasDebuggerEnabled = m_profiledBlock->globalObject()->hasDebugger()
     79        || Options::forceDebuggerBytecodeGeneration();
    7780}
    7881
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.h

    r181993 r182167  
    710710        BasicBlock*, const char* file, int line, const char* function,
    711711        const char* assertion);
    712    
     712
     713    bool hasDebuggerEnabled() const { return m_hasDebuggerEnabled; }
     714
    713715    VM& m_vm;
    714716    Plan& m_plan;
     
    792794    PlanStage m_planStage { PlanStage::Initial };
    793795    RefCountState m_refCountState;
     796    bool m_hasDebuggerEnabled;
    794797private:
    795798   
  • trunk/Source/JavaScriptCore/dfg/DFGStackLayoutPhase.cpp

    r181993 r182167  
    176176        // This register is never valid for DFG code blocks.
    177177        codeBlock()->setActivationRegister(VirtualRegister());
    178         codeBlock()->setScopeRegister(VirtualRegister());
     178        if (LIKELY(!m_graph.hasDebuggerEnabled()))
     179            codeBlock()->setScopeRegister(VirtualRegister());
     180        else
     181            codeBlock()->setScopeRegister(assign(allocation, codeBlock()->scopeRegister()));
    179182
    180183        for (unsigned i = m_graph.m_inlineVariableData.size(); i--;) {
  • trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp

    r182004 r182167  
    323323                inlineCallFrame->calleeRecovery.withLocalsOffset(localsOffset);
    324324        }
     325
     326        if (graph.hasDebuggerEnabled())
     327            codeBlock->setScopeRegister(codeBlock->scopeRegister() + localsOffset);
    325328    }
    326329   
Note: See TracChangeset for help on using the changeset viewer.