Ignore:
Timestamp:
Sep 9, 2013, 10:37:51 PM (12 years ago)
Author:
[email protected]
Message:

Add local to/from operand helpers similar to argument to/from operand2
https://bugs.webkit.org/show_bug.cgi?id=121056

Reviewed by Geoffrey Garen.

Added localToOperand(), operandToLocal() and operandIsLocal() to Operands.h, very similar to
argumentToOperand(), et al. Used the new helpers everywhere where an index into a data
structure is intended instead of the actual virtual register offset. When the stack is
changed to grow down, local register offsets can be negative. Also added the helper
DFG::SpeculativeJIT::generationInfoFromVirtualRegister() for the common case accessing
m_generationInfo[operandToLocal(val)].

  • bytecode/CodeBlock.cpp:
  • bytecode/CodeBlock.h:
  • bytecode/Operands.h:

(JSC::localToOperand):
(JSC::operandIsLocal):
(JSC::operandToLocal):

  • bytecompiler/BytecodeGenerator.h:
  • dfg/DFGAbstractInterpreterInlines.h:
  • dfg/DFGByteCodeParser.cpp:
  • dfg/DFGCFGSimplificationPhase.cpp:
  • dfg/DFGCPSRethreadingPhase.cpp:
  • dfg/DFGOSREntry.cpp:
  • dfg/DFGOSRExitCompiler32_64.cpp:
  • dfg/DFGOSRExitCompiler64.cpp:
  • dfg/DFGScoreBoard.h:
  • dfg/DFGSpeculativeJIT.cpp:
  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::generationInfoFromVirtualRegister):

  • dfg/DFGSpeculativeJIT32_64.cpp:
  • dfg/DFGSpeculativeJIT64.cpp:
  • dfg/DFGValidate.cpp:
  • dfg/DFGVariableEventStream.cpp:
  • dfg/DFGVirtualRegisterAllocationPhase.cpp:
  • jit/JITInlines.h:
  • jit/JITOpcodes.cpp:
  • jit/JITOpcodes32_64.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r155201 r155415  
    262262    Node* getLocal(unsigned operand)
    263263    {
    264         Node* node = m_currentBlock->variablesAtTail.local(operand);
     264        unsigned local = operandToLocal(operand);
     265        Node* node = m_currentBlock->variablesAtTail.local(local);
    265266        bool isCaptured = m_codeBlock->isCaptured(operand, inlineCallFrame());
    266267       
     
    288289            }
    289290        } else {
    290             m_preservedVars.set(operand);
     291            m_preservedVars.set(local);
    291292            variable = newVariableAccessData(operand, isCaptured);
    292293        }
    293294       
    294295        node = injectLazyOperandSpeculation(addToGraph(GetLocal, OpInfo(variable)));
    295         m_currentBlock->variablesAtTail.local(operand) = node;
     296        m_currentBlock->variablesAtTail.local(local) = node;
    296297        return node;
    297298    }
    298299    void setLocal(unsigned operand, Node* value, SetMode setMode = NormalSet)
    299300    {
     301        unsigned local = operandToLocal(operand);
    300302        bool isCaptured = m_codeBlock->isCaptured(operand, inlineCallFrame());
    301303       
     
    312314            m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadIndexingType));
    313315        Node* node = addToGraph(SetLocal, OpInfo(variableAccessData), value);
    314         m_currentBlock->variablesAtTail.local(operand) = node;
     316        m_currentBlock->variablesAtTail.local(local) = node;
    315317    }
    316318
     
    432434       
    433435        if (!operandIsArgument(operand))
    434             m_preservedVars.set(operand);
     436            m_preservedVars.set(operandToLocal(operand));
    435437       
    436438        Node* node = m_currentBlock->variablesAtTail.operand(operand);
     
    460462            flushDirect(inlineStackEntry->remapOperand(argumentToOperand(argument)));
    461463        for (int local = 0; local < inlineStackEntry->m_codeBlock->m_numVars; ++local) {
    462             if (!inlineStackEntry->m_codeBlock->isCaptured(local))
     464            if (!inlineStackEntry->m_codeBlock->isCaptured(localToOperand(local)))
    463465                continue;
    464             flushDirect(inlineStackEntry->remapOperand(local));
     466            flushDirect(inlineStackEntry->remapOperand(localToOperand(local)));
    465467        }
    466468    }
     
    12811283   
    12821284    // Make sure that the area used by the call frame is reserved.
    1283     for (int arg = inlineCallFrameStart + JSStack::CallFrameHeaderSize + codeBlock->m_numVars; arg-- > inlineCallFrameStart;)
     1285    for (int arg = operandToLocal(inlineCallFrameStart) + JSStack::CallFrameHeaderSize + codeBlock->m_numVars; arg-- > operandToLocal(inlineCallFrameStart);)
    12841286        m_preservedVars.set(arg);
    12851287   
    12861288    // Make sure that we have enough locals.
    1287     unsigned newNumLocals = inlineCallFrameStart + JSStack::CallFrameHeaderSize + codeBlock->m_numCalleeRegisters;
     1289    unsigned newNumLocals = operandToLocal(inlineCallFrameStart) + JSStack::CallFrameHeaderSize + codeBlock->m_numCalleeRegisters;
    12881290    if (newNumLocals > m_numLocals) {
    12891291        m_numLocals = newNumLocals;
     
    18851887            // Initialize all locals to undefined.
    18861888            for (int i = 0; i < m_inlineStackTop->m_codeBlock->m_numVars; ++i)
    1887                 set(i, constantUndefined(), SetOnEntry);
     1889                set(localToOperand(i), constantUndefined(), SetOnEntry);
    18881890            NEXT_OPCODE(op_enter);
    18891891
     
    31523154        case op_init_lazy_reg: {
    31533155            set(currentInstruction[1].u.operand, getJSConstantForValue(JSValue()));
    3154             ASSERT(currentInstruction[1].u.operand >= 0);
    3155             m_graph.m_lazyVars.set(currentInstruction[1].u.operand);
     3156            ASSERT(operandIsLocal(currentInstruction[1].u.operand));
     3157            m_graph.m_lazyVars.set(operandToLocal(currentInstruction[1].u.operand));
    31563158            NEXT_OPCODE(op_init_lazy_reg);
    31573159        }
     
    33823384        else {
    33833385            for (int i = byteCodeParser->m_codeBlock->m_numVars; i--;) {
    3384                 if (byteCodeParser->m_codeBlock->isCaptured(i))
     3386                if (byteCodeParser->m_codeBlock->isCaptured(localToOperand(i)))
    33853387                    inlineCallFrame.capturedVars.set(i);
    33863388            }
     
    33893391        for (int i = argumentCountIncludingThis; i--;) {
    33903392            if (codeBlock->isCaptured(argumentToOperand(i)))
    3391                 inlineCallFrame.capturedVars.set(argumentToOperand(i) + inlineCallFrame.stackOffset);
     3393                inlineCallFrame.capturedVars.set(operandToLocal(argumentToOperand(i) + inlineCallFrame.stackOffset));
    33923394        }
    33933395        for (size_t i = codeBlock->m_numVars; i--;) {
    3394             if (codeBlock->isCaptured(i))
    3395                 inlineCallFrame.capturedVars.set(i + inlineCallFrame.stackOffset);
     3396            int localOperand = localToOperand(i);
     3397            if (codeBlock->isCaptured(localOperand))
     3398                inlineCallFrame.capturedVars.set(operandToLocal(localOperand + inlineCallFrame.stackOffset));
    33963399        }
    33973400
Note: See TracChangeset for help on using the changeset viewer.