Changeset 155415 in webkit


Ignore:
Timestamp:
Sep 9, 2013 10:37:51 PM (11 years ago)
Author:
msaboff@apple.com
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:
Location:
trunk/Source/JavaScriptCore
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r155413 r155415  
     12013-09-09  Michael Saboff  <msaboff@apple.com>
     2
     3        Add local to/from operand helpers similar to argument to/from operand2
     4        https://bugs.webkit.org/show_bug.cgi?id=121056
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Added localToOperand(), operandToLocal() and operandIsLocal() to Operands.h, very similar to
     9        argumentToOperand(), et al.  Used the new helpers everywhere where an index into a data
     10        structure is intended instead of the actual virtual register offset.  When the stack is
     11        changed to grow down, local register offsets can be negative.  Also added the helper
     12        DFG::SpeculativeJIT::generationInfoFromVirtualRegister() for the common case accessing
     13        m_generationInfo[operandToLocal(val)].
     14
     15        * bytecode/CodeBlock.cpp:
     16        * bytecode/CodeBlock.h:
     17        * bytecode/Operands.h:
     18        (JSC::localToOperand):
     19        (JSC::operandIsLocal):
     20        (JSC::operandToLocal):
     21        * bytecompiler/BytecodeGenerator.h:
     22        * dfg/DFGAbstractInterpreterInlines.h:
     23        * dfg/DFGByteCodeParser.cpp:
     24        * dfg/DFGCFGSimplificationPhase.cpp:
     25        * dfg/DFGCPSRethreadingPhase.cpp:
     26        * dfg/DFGOSREntry.cpp:
     27        * dfg/DFGOSRExitCompiler32_64.cpp:
     28        * dfg/DFGOSRExitCompiler64.cpp:
     29        * dfg/DFGScoreBoard.h:
     30        * dfg/DFGSpeculativeJIT.cpp:
     31        * dfg/DFGSpeculativeJIT.h:
     32        (JSC::DFG::SpeculativeJIT::generationInfoFromVirtualRegister):
     33        * dfg/DFGSpeculativeJIT32_64.cpp:
     34        * dfg/DFGSpeculativeJIT64.cpp:
     35        * dfg/DFGValidate.cpp:
     36        * dfg/DFGVariableEventStream.cpp:
     37        * dfg/DFGVirtualRegisterAllocationPhase.cpp:
     38        * jit/JITInlines.h:
     39        * jit/JITOpcodes.cpp:
     40        * jit/JITOpcodes32_64.cpp:
     41
    1422013-09-09  Filip Pizlo  <fpizlo@apple.com>
    243
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r155159 r155415  
    172172    }
    173173
    174     return toCString("loc", r);
     174    return toCString("loc", operandToLocal(r));
    175175}
    176176
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r155251 r155415  
    368368
    369369        if (inlineCallFrame)
    370             return inlineCallFrame->capturedVars.get(operand);
     370            return inlineCallFrame->capturedVars.get(operandToLocal(operand));
    371371
    372372        // The activation object isn't in the captured region, but it's "captured"
  • trunk/Source/JavaScriptCore/bytecode/Operands.h

    r153296 r155415  
    2929#include "CallFrame.h"
    3030#include "JSObject.h"
     31#include "VirtualRegister.h"
    3132#include <wtf/PrintStream.h>
    3233#include <wtf/Vector.h>
    3334
    3435namespace JSC {
     36
     37inline VirtualRegister localToOperand(int local) { return (VirtualRegister)local; }
     38inline bool operandIsLocal(int operand) { return operand >= 0; }
     39inline int operandToLocal(int operand) { return operand; }
    3540
    3641// argument 0 is 'this'.
     
    144149        }
    145150       
    146         return m_locals[operand];
     151        return m_locals[operandToLocal(operand)];
    147152    }
    148153   
     
    153158        if (operandIsArgument(operand))
    154159            return true;
    155         return static_cast<size_t>(operand) < numberOfLocals();
     160        return static_cast<size_t>(operandToLocal(operand)) < numberOfLocals();
    156161    }
    157162   
     
    164169        }
    165170       
    166         setLocal(operand, value);
     171        setLocal(operandToLocal(operand), value);
    167172    }
    168173   
     
    197202        if (index < numberOfArguments())
    198203            return argumentToOperand(index);
    199         return index - numberOfArguments();
     204        return localToOperand(index - numberOfArguments());
    200205    }
    201206   
     
    207212        }
    208213       
    209         setLocalFirstTime(operand, value);
     214        setLocalFirstTime(operandToLocal(operand), value);
    210215    }
    211216   
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r153763 r155415  
    499499        RegisterID& registerFor(int index)
    500500        {
    501             if (index >= 0)
    502                 return m_calleeRegisters[index];
     501            if (operandIsLocal(index))
     502                return m_calleeRegisters[operandToLocal(index)];
    503503
    504504            if (index == JSStack::Callee)
     
    506506
    507507            ASSERT(m_parameters.size());
    508             return m_parameters[index + m_parameters.size() + JSStack::CallFrameHeaderSize];
     508            return m_parameters[operandToArgument(index)];
    509509        }
    510510
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r155201 r155415  
    155155        forNode(node).makeTop();
    156156        if (!operandIsArgument(node->unlinkedLocal())
    157             && m_graph.m_lazyVars.get(node->unlinkedLocal())) {
     157            && m_graph.m_lazyVars.get(operandToLocal(node->unlinkedLocal()))) {
    158158            // This is kind of pessimistic - we could know in some cases that the
    159159            // DFG code at the point of the OSR had already initialized the lazy
     
    15991599    } else {
    16001600        for (size_t i = m_codeBlock->m_numVars; i--;) {
    1601             if (m_codeBlock->isCaptured(i))
     1601            if (m_codeBlock->isCaptured(localToOperand(i)))
    16021602                m_state.variables().local(i).makeTop();
    16031603        }
  • 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
  • trunk/Source/JavaScriptCore/dfg/DFGCFGSimplificationPhase.cpp

    r155023 r155415  
    329329            keepOperandAlive(block, jettisonedBlock, boundaryCodeOrigin, argumentToOperand(i));
    330330        for (size_t i = 0; i < jettisonedBlock->variablesAtHead.numberOfLocals(); ++i)
    331             keepOperandAlive(block, jettisonedBlock, boundaryCodeOrigin, i);
     331            keepOperandAlive(block, jettisonedBlock, boundaryCodeOrigin, localToOperand(i));
    332332       
    333333        fixJettisonedPredecessors(block, jettisonedBlock);
     
    383383                keepOperandAlive(firstBlock, jettisonedBlock, boundaryCodeOrigin, argumentToOperand(i));
    384384            for (size_t i = 0; i < jettisonedBlock->variablesAtHead.numberOfLocals(); ++i)
    385                 keepOperandAlive(firstBlock, jettisonedBlock, boundaryCodeOrigin, i);
     385                keepOperandAlive(firstBlock, jettisonedBlock, boundaryCodeOrigin, localToOperand(i));
    386386        }
    387387       
  • trunk/Source/JavaScriptCore/dfg/DFGCPSRethreadingPhase.cpp

    r153278 r155415  
    221221            canonicalizeGetLocalFor<ArgumentOperand>(node, variable, operandToArgument(variable->local()));
    222222        else
    223             canonicalizeGetLocalFor<LocalOperand>(node, variable, variable->local());
     223            canonicalizeGetLocalFor<LocalOperand>(node, variable, operandToLocal(variable->local()));
    224224    }
    225225   
     
    289289            canonicalizeFlushOrPhantomLocalFor<nodeType, ArgumentOperand>(node, variable, operandToArgument(variable->local()));
    290290        else
    291             canonicalizeFlushOrPhantomLocalFor<nodeType, LocalOperand>(node, variable, variable->local());
     291            canonicalizeFlushOrPhantomLocalFor<nodeType, LocalOperand>(node, variable, operandToLocal(variable->local()));
    292292    }
    293293   
  • trunk/Source/JavaScriptCore/dfg/DFGOSREntry.cpp

    r155023 r155415  
    140140    for (size_t local = 0; local < entry->m_expectedValues.numberOfLocals(); ++local) {
    141141        if (entry->m_localsForcedDouble.get(local)) {
    142             if (!exec->registers()[local].jsValue().isNumber()) {
     142            if (!exec->registers()[localToOperand(local)].jsValue().isNumber()) {
    143143                if (Options::verboseOSR()) {
    144144                    dataLog(
    145                         "    OSR failed because variable ", local, " is ",
    146                         exec->registers()[local].jsValue(), ", expected number.\n");
     145                        "    OSR failed because variable ", localToOperand(local), " is ",
     146                        exec->registers()[localToOperand(local)].jsValue(), ", expected number.\n");
    147147                }
    148148                return 0;
     
    150150            continue;
    151151        }
    152         if (!entry->m_expectedValues.local(local).validate(exec->registers()[local].jsValue())) {
     152        if (!entry->m_expectedValues.local(local).validate(exec->registers()[localToOperand(local)].jsValue())) {
    153153            if (Options::verboseOSR()) {
    154154                dataLog(
    155                     "    OSR failed because variable ", local, " is ",
    156                     exec->registers()[local].jsValue(), ", expected ",
     155                    "    OSR failed because variable ", localToOperand(local), " is ",
     156                    exec->registers()[localToOperand(local)].jsValue(), ", expected ",
    157157                    entry->m_expectedValues.local(local), ".\n");
    158158            }
     
    180180    for (size_t local = 0; local < entry->m_expectedValues.numberOfLocals(); ++local) {
    181181        if (entry->m_localsForcedDouble.get(local))
    182             *bitwise_cast<double*>(exec->registers() + local) = exec->registers()[local].jsValue().asNumber();
     182            *bitwise_cast<double*>(exec->registers() + localToOperand(local)) = exec->registers()[localToOperand(local)].jsValue().asNumber();
    183183    }
    184184   
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler32_64.cpp

    r153296 r155415  
    200200        case Int32DisplacedInJSStack:
    201201        case CellDisplacedInJSStack:
    202         case BooleanDisplacedInJSStack:
     202        case BooleanDisplacedInJSStack: {
    203203            numberOfDisplacedVirtualRegisters++;
    204             ASSERT((int)recovery.virtualRegister() >= 0);
     204            ASSERT(operandIsLocal(recovery.virtualRegister()));
    205205           
    206206            // See if we might like to store to this virtual register before doing
     
    211211            // to be rare, so the handling of it is optimized for the cases in
    212212            // which it does not happen.
    213             if (recovery.virtualRegister() < (int)operands.numberOfLocals()) {
    214                 switch (operands.local(recovery.virtualRegister()).technique()) {
     213            int local = operandToLocal(recovery.virtualRegister());
     214            if (local < (int)operands.numberOfLocals()) {
     215                switch (operands.local(local).technique()) {
    215216                case InGPR:
    216217                case UnboxedInt32InGPR:
     
    219220                case InPair:
    220221                case InFPR:
    221                     if (!poisonedVirtualRegisters[recovery.virtualRegister()]) {
    222                         poisonedVirtualRegisters[recovery.virtualRegister()] = true;
     222                    if (!poisonedVirtualRegisters[local]) {
     223                        poisonedVirtualRegisters[local] = true;
    223224                        numberOfPoisonedVirtualRegisters++;
    224225                    }
     
    229230            }
    230231            break;
    231            
     232
     233            }
    232234        case UInt32InGPR:
    233235            haveUInt32s = true;
     
    544546            case UnboxedBooleanInGPR: {
    545547                m_jit.load32(reinterpret_cast<char*>(scratchDataBuffer + poisonIndex(virtualRegister)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload), GPRInfo::regT0);
    546                 m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor((VirtualRegister)virtualRegister));
     548                m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor(localToOperand(virtualRegister)));
    547549                uint32_t tag = JSValue::EmptyValueTag;
    548550                if (recovery.technique() == InGPR)
     
    552554                else
    553555                    tag = JSValue::BooleanTag;
    554                 m_jit.store32(AssemblyHelpers::TrustedImm32(tag), AssemblyHelpers::tagFor((VirtualRegister)virtualRegister));
     556                m_jit.store32(AssemblyHelpers::TrustedImm32(tag), AssemblyHelpers::tagFor(localToOperand(virtualRegister)));
    555557                break;
    556558            }
     
    561563                m_jit.load32(reinterpret_cast<char*>(scratchDataBuffer + poisonIndex(virtualRegister)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload), GPRInfo::regT0);
    562564                m_jit.load32(reinterpret_cast<char*>(scratchDataBuffer + poisonIndex(virtualRegister)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag), GPRInfo::regT1);
    563                 m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor((VirtualRegister)virtualRegister));
    564                 m_jit.store32(GPRInfo::regT1, AssemblyHelpers::tagFor((VirtualRegister)virtualRegister));
     565                m_jit.store32(GPRInfo::regT0, AssemblyHelpers::payloadFor(localToOperand(virtualRegister)));
     566                m_jit.store32(GPRInfo::regT1, AssemblyHelpers::tagFor(localToOperand(virtualRegister)));
    565567                break;
    566568               
  • trunk/Source/JavaScriptCore/dfg/DFGOSRExitCompiler64.cpp

    r153296 r155415  
    181181        case Int32DisplacedInJSStack:
    182182        case DoubleDisplacedInJSStack:
    183         case DisplacedInJSStack:
     183        case DisplacedInJSStack: {
    184184            numberOfDisplacedVirtualRegisters++;
    185             ASSERT((int)recovery.virtualRegister() >= 0);
     185            ASSERT(operandIsLocal(recovery.virtualRegister()));
    186186           
    187187            // See if we might like to store to this virtual register before doing
     
    192192            // to be rare, so the handling of it is optimized for the cases in
    193193            // which it does not happen.
    194             if (recovery.virtualRegister() < (int)operands.numberOfLocals()) {
    195                 switch (operands.local(recovery.virtualRegister()).technique()) {
     194            int local = operandToLocal(recovery.virtualRegister());
     195            if (local < (int)operands.numberOfLocals()) {
     196                switch (operands.local(local).technique()) {
    196197                case InGPR:
    197198                case UnboxedInt32InGPR:
    198199                case UInt32InGPR:
    199200                case InFPR:
    200                     if (!poisonedVirtualRegisters[recovery.virtualRegister()]) {
    201                         poisonedVirtualRegisters[recovery.virtualRegister()] = true;
     201                    if (!poisonedVirtualRegisters[local]) {
     202                        poisonedVirtualRegisters[local] = true;
    202203                        numberOfPoisonedVirtualRegisters++;
    203204                    }
     
    208209            }
    209210            break;
    210            
     211            }
    211212        case UnboxedInt32InGPR:
    212213        case AlreadyInJSStackAsUnboxedInt32:
     
    531532            case InFPR:
    532533                m_jit.load64(scratchDataBuffer + poisonIndex(virtualRegister), GPRInfo::regT0);
    533                 m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor((VirtualRegister)virtualRegister));
     534                m_jit.store64(GPRInfo::regT0, AssemblyHelpers::addressFor(localToOperand(virtualRegister)));
    534535                break;
    535536               
  • trunk/Source/JavaScriptCore/dfg/DFGScoreBoard.h

    r141069 r155415  
    9090            ASSERT(!m_used[index]);
    9191            m_highWatermark = std::max(m_highWatermark, static_cast<unsigned>(index) + 1);
    92             return (VirtualRegister)index;
     92            return localToOperand(index);
    9393        }
    9494
     
    9797        m_used.append(0);
    9898        m_highWatermark = std::max(m_highWatermark, static_cast<unsigned>(next) + 1);
    99         return (VirtualRegister)next;
     99        return localToOperand(next);
    100100    }
    101101
    102     // Increment the usecount for the VirtualRegsiter associated with 'child',
    103     // if it reaches the node's refcount, free the VirtualRegsiter.
     102    // Increment the usecount for the VirtualRegister associated with 'child',
     103    // if it reaches the node's refcount, free the VirtualRegister.
    104104    void use(Node* child)
    105105    {
     
    108108
    109109        // Find the virtual register number for this child, increment its use count.
    110         uint32_t index = child->virtualRegister();
     110        uint32_t index = operandToLocal(child->virtualRegister());
    111111        ASSERT(m_used[index] != max());
    112112        if (child->refCount() == ++m_used[index]) {
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r155201 r155415  
    318318SilentRegisterSavePlan SpeculativeJIT::silentSavePlanForGPR(VirtualRegister spillMe, GPRReg source)
    319319{
    320     GenerationInfo& info = m_generationInfo[spillMe];
     320    GenerationInfo& info = generationInfoFromVirtualRegister(spillMe);
    321321    Node* node = info.node();
    322322    DataFormat registerFormat = info.registerFormat();
     
    437437SilentRegisterSavePlan SpeculativeJIT::silentSavePlanForFPR(VirtualRegister spillMe, FPRReg source)
    438438{
    439     GenerationInfo& info = m_generationInfo[spillMe];
     439    GenerationInfo& info = generationInfoFromVirtualRegister(spillMe);
    440440    Node* node = info.node();
    441441    ASSERT(info.registerFormat() == DataFormatDouble);
     
    778778{
    779779    VirtualRegister virtualRegister = edge->virtualRegister();
    780     GenerationInfo& info = m_generationInfo[virtualRegister];
     780    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    781781   
    782782    switch (info.registerFormat()) {
     
    10771077    for (unsigned i = 0; i < m_generationInfo.size(); ++i) {
    10781078        VirtualRegister virtualRegister = (VirtualRegister)i;
    1079         GenerationInfo& info = m_generationInfo[virtualRegister];
     1079        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    10801080        if (!info.alive())
    10811081            continue;
     
    11251125            continue;
    11261126
    1127         GenerationInfo& info = m_generationInfo[virtualRegister];
     1127        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    11281128#if USE(JSVALUE64)
    11291129        if (iter.regID() != info.gpr()) {
     
    11511151            continue;
    11521152
    1153         GenerationInfo& info = m_generationInfo[virtualRegister];
     1153        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    11541154        if (iter.regID() != info.fpr()) {
    11551155            dataLogF("DFG_CONSISTENCY_CHECK failed: name mismatch for fpr %s (virtual register %d).\n", iter.debugName(), virtualRegister);
     
    15491549   
    15501550    VirtualRegister virtualRegister = node->virtualRegister();
    1551     GenerationInfo& info = m_generationInfo[virtualRegister];
     1551    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    15521552   
    15531553    info.noticeOSRBirth(*m_stream, node, virtualRegister);
     
    16821682        m_variables[i] = valueSource;
    16831683        // FIXME: Don't emit SetLocal(Dead). https://bugs.webkit.org/show_bug.cgi?id=108019
    1684         m_stream->appendAndLog(VariableEvent::setLocal(i, valueSource.dataFormat()));
     1684        m_stream->appendAndLog(VariableEvent::setLocal(localToOperand(i), valueSource.dataFormat()));
    16851685    }
    16861686   
     
    21772177#endif
    21782178    VirtualRegister virtualRegister = node->virtualRegister();
    2179     GenerationInfo& info = m_generationInfo[virtualRegister];
     2179    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    21802180
    21812181    switch (info.registerFormat()) {
     
    22912291            Node* childNode = node->child1().node();
    22922292            VirtualRegister virtualRegister = childNode->virtualRegister();
    2293             GenerationInfo& info = m_generationInfo[virtualRegister];
     2293            GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    22942294
    22952295            JSValueOperand op1(this, node->child1(), ManualOperandSpeculation);
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r155201 r155415  
    162162    {
    163163        VirtualRegister virtualRegister = node->virtualRegister();
    164         GenerationInfo& info = m_generationInfo[virtualRegister];
     164        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    165165        return info.canReuse();
    166166    }
     
    190190        if (spillMe != InvalidVirtualRegister) {
    191191#if USE(JSVALUE32_64)
    192             GenerationInfo& info = m_generationInfo[spillMe];
     192            GenerationInfo& info = generationInfoFromVirtualRegister(spillMe);
    193193            RELEASE_ASSERT(info.registerFormat() != DataFormatJSDouble);
    194194            if ((info.registerFormat() & DataFormatJS))
     
    207207        if (spillMe != InvalidVirtualRegister) {
    208208#if USE(JSVALUE32_64)
    209             GenerationInfo& info = m_generationInfo[spillMe];
     209            GenerationInfo& info = generationInfoFromVirtualRegister(spillMe);
    210210            RELEASE_ASSERT(info.registerFormat() != DataFormatJSDouble);
    211211            if ((info.registerFormat() & DataFormatJS))
     
    240240    {
    241241        VirtualRegister virtualRegister = node->virtualRegister();
    242         GenerationInfo& info = m_generationInfo[virtualRegister];
     242        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    243243        return info.registerFormat() != DataFormatNone;
    244244    }
     
    246246    {
    247247        VirtualRegister virtualRegister = node->virtualRegister();
    248         GenerationInfo& info = m_generationInfo[virtualRegister];
     248        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    249249        return info.registerFormat() == DataFormatDouble;
    250250    }
     
    256256            return;
    257257        VirtualRegister virtualRegister = node->virtualRegister();
    258         GenerationInfo& info = m_generationInfo[virtualRegister];
     258        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    259259
    260260        // use() returns true when the value becomes dead, and any
     
    484484    void spill(VirtualRegister spillMe)
    485485    {
    486         GenerationInfo& info = m_generationInfo[spillMe];
     486        GenerationInfo& info = generationInfoFromVirtualRegister(spillMe);
    487487
    488488#if USE(JSVALUE32_64)
     
    797797
    798798        VirtualRegister virtualRegister = node->virtualRegister();
    799         GenerationInfo& info = m_generationInfo[virtualRegister];
     799        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    800800
    801801        if (format == DataFormatInteger) {
     
    831831        VirtualRegister virtualRegister = node->virtualRegister();
    832832        m_gprs.retain(reg, virtualRegister, SpillOrderCell);
    833         GenerationInfo& info = m_generationInfo[virtualRegister];
     833        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    834834        info.initCell(node, node->refCount(), reg);
    835835    }
     
    841841        VirtualRegister virtualRegister = node->virtualRegister();
    842842        m_gprs.retain(reg, virtualRegister, SpillOrderBoolean);
    843         GenerationInfo& info = m_generationInfo[virtualRegister];
     843        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    844844        info.initBoolean(node, node->refCount(), reg);
    845845    }
     
    855855        VirtualRegister virtualRegister = node->virtualRegister();
    856856        m_gprs.retain(reg, virtualRegister, SpillOrderJS);
    857         GenerationInfo& info = m_generationInfo[virtualRegister];
     857        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    858858        info.initJSValue(node, node->refCount(), reg, format);
    859859    }
     
    871871        m_gprs.retain(tag, virtualRegister, SpillOrderJS);
    872872        m_gprs.retain(payload, virtualRegister, SpillOrderJS);
    873         GenerationInfo& info = m_generationInfo[virtualRegister];
     873        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    874874        info.initJSValue(node, node->refCount(), tag, payload, format);
    875875    }
     
    886886        VirtualRegister virtualRegister = node->virtualRegister();
    887887        m_gprs.retain(reg, virtualRegister, SpillOrderStorage);
    888         GenerationInfo& info = m_generationInfo[virtualRegister];
     888        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    889889        info.initStorage(node, node->refCount(), reg);
    890890    }
     
    896896        VirtualRegister virtualRegister = node->virtualRegister();
    897897        m_fprs.retain(reg, virtualRegister, SpillOrderDouble);
    898         GenerationInfo& info = m_generationInfo[virtualRegister];
     898        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    899899        info.initDouble(node, node->refCount(), reg);
    900900    }
     
    902902    {
    903903        ASSERT(isInt32Constant(node) || isNumberConstant(node) || isJSConstant(node));
    904         m_generationInfo[node->virtualRegister()].initConstant(node, node->refCount());
     904        generationInfoFromVirtualRegister(node->virtualRegister()).initConstant(node, node->refCount());
    905905    }
    906906   
     
    18861886
    18871887        VirtualRegister virtualRegister = node->virtualRegister();
    1888         GenerationInfo& info = m_generationInfo[virtualRegister];
     1888        GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    18891889       
    18901890        return info.isJSInteger();
     
    21732173            return m_arguments[argument];
    21742174        }
     2175
     2176        int local = operandToLocal(operand);
     2177        if ((unsigned)local >= m_variables.size())
     2178            m_variables.resize(local + 1);
    21752179       
    2176         if ((unsigned)operand >= m_variables.size())
    2177             m_variables.resize(operand + 1);
    2178        
    2179         return m_variables[operand];
     2180        return m_variables[local];
    21802181    }
    21812182   
     
    21852186        m_stream->appendAndLog(VariableEvent::setLocal(operand, valueSource.dataFormat()));
    21862187    }
    2187    
     2188
     2189    GenerationInfo& generationInfoFromVirtualRegister(VirtualRegister virtualRegister)
     2190    {
     2191        return m_generationInfo[operandToLocal(virtualRegister)];
     2192    }
     2193
    21882194    // The JIT, while also provides MacroAssembler functionality.
    21892195    JITCompiler& m_jit;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r155201 r155415  
    4747   
    4848    VirtualRegister virtualRegister = edge->virtualRegister();
    49     GenerationInfo& info = m_generationInfo[virtualRegister];
     49    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    5050
    5151    if (info.registerFormat() == DataFormatNone) {
     
    123123
    124124    VirtualRegister virtualRegister = edge->virtualRegister();
    125     GenerationInfo& info = m_generationInfo[virtualRegister];
     125    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    126126
    127127    switch (info.registerFormat()) {
     
    866866    m_interpreter.filter(value, SpecInt32);
    867867    VirtualRegister virtualRegister = edge->virtualRegister();
    868     GenerationInfo& info = m_generationInfo[virtualRegister];
     868    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    869869
    870870    switch (info.registerFormat()) {
     
    967967    m_interpreter.filter(value, SpecNumber);
    968968    VirtualRegister virtualRegister = edge->virtualRegister();
    969     GenerationInfo& info = m_generationInfo[virtualRegister];
     969    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    970970
    971971    if (info.registerFormat() == DataFormatNone) {
     
    11041104    m_interpreter.filter(value, SpecCell);
    11051105    VirtualRegister virtualRegister = edge->virtualRegister();
    1106     GenerationInfo& info = m_generationInfo[virtualRegister];
     1106    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    11071107
    11081108    switch (info.registerFormat()) {
     
    11851185    m_interpreter.filter(value, SpecBoolean);
    11861186    VirtualRegister virtualRegister = edge->virtualRegister();
    1187     GenerationInfo& info = m_generationInfo[virtualRegister];
     1187    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    11881188
    11891189    switch (info.registerFormat()) {
     
    20032003            VirtualRegister virtualRegister = node->virtualRegister();
    20042004            m_fprs.retain(result.fpr(), virtualRegister, SpillOrderDouble);
    2005             m_generationInfo[virtualRegister].initDouble(node, node->refCount(), result.fpr());
     2005            generationInfoFromVirtualRegister(virtualRegister).initDouble(node, node->refCount(), result.fpr());
    20062006            break;
    20072007        }
     
    20152015            VirtualRegister virtualRegister = node->virtualRegister();
    20162016            m_gprs.retain(result.gpr(), virtualRegister, SpillOrderInteger);
    2017             m_generationInfo[virtualRegister].initInteger(node, node->refCount(), result.gpr());
     2017            generationInfoFromVirtualRegister(virtualRegister).initInteger(node, node->refCount(), result.gpr());
    20182018            break;
    20192019        }
     
    20272027            VirtualRegister virtualRegister = node->virtualRegister();
    20282028            m_gprs.retain(result.gpr(), virtualRegister, SpillOrderCell);
    2029             m_generationInfo[virtualRegister].initCell(node, node->refCount(), result.gpr());
     2029            generationInfoFromVirtualRegister(virtualRegister).initCell(node, node->refCount(), result.gpr());
    20302030            break;
    20312031        }
     
    20392039            VirtualRegister virtualRegister = node->virtualRegister();
    20402040            m_gprs.retain(result.gpr(), virtualRegister, SpillOrderBoolean);
    2041             m_generationInfo[virtualRegister].initBoolean(node, node->refCount(), result.gpr());
     2041            generationInfoFromVirtualRegister(virtualRegister).initBoolean(node, node->refCount(), result.gpr());
    20422042            break;
    20432043        }
     
    20542054        m_gprs.retain(tag.gpr(), virtualRegister, SpillOrderJS);
    20552055
    2056         m_generationInfo[virtualRegister].initJSValue(node, node->refCount(), tag.gpr(), result.gpr(), DataFormatJS);
     2056        generationInfoFromVirtualRegister(virtualRegister).initJSValue(node, node->refCount(), tag.gpr(), result.gpr(), DataFormatJS);
    20572057        break;
    20582058    }
     
    21022102            }
    21032103            SpeculatedType predictedType = node->variableAccessData()->argumentAwarePrediction();
    2104             if (m_generationInfo[node->child1()->virtualRegister()].registerFormat() == DataFormatDouble) {
     2104            if (generationInfoFromVirtualRegister(node->child1()->virtualRegister()).registerFormat() == DataFormatDouble) {
    21052105                SpeculateDoubleOperand value(this, node->child1(), ManualOperandSpeculation);
    21062106                m_jit.storeDouble(value.fpr(), JITCompiler::addressFor(node->local()));
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r155201 r155415  
    4646   
    4747    VirtualRegister virtualRegister = edge->virtualRegister();
    48     GenerationInfo& info = m_generationInfo[virtualRegister];
     48    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    4949
    5050    if (info.registerFormat() == DataFormatNone) {
     
    124124{
    125125    VirtualRegister virtualRegister = edge->virtualRegister();
    126     GenerationInfo& info = m_generationInfo[virtualRegister];
     126    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    127127   
    128128    switch (info.registerFormat()) {
     
    826826    m_interpreter.filter(value, SpecInt32);
    827827    VirtualRegister virtualRegister = edge->virtualRegister();
    828     GenerationInfo& info = m_generationInfo[virtualRegister];
     828    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    829829
    830830    switch (info.registerFormat()) {
     
    976976    m_interpreter.filter(value, SpecNumber);
    977977    VirtualRegister virtualRegister = edge->virtualRegister();
    978     GenerationInfo& info = m_generationInfo[virtualRegister];
     978    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    979979
    980980    if (info.registerFormat() == DataFormatNone) {
     
    11331133    m_interpreter.filter(value, SpecCell);
    11341134    VirtualRegister virtualRegister = edge->virtualRegister();
    1135     GenerationInfo& info = m_generationInfo[virtualRegister];
     1135    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    11361136
    11371137    switch (info.registerFormat()) {
     
    12151215    m_interpreter.filter(value, SpecBoolean);
    12161216    VirtualRegister virtualRegister = edge->virtualRegister();
    1217     GenerationInfo& info = m_generationInfo[virtualRegister];
     1217    GenerationInfo& info = generationInfoFromVirtualRegister(virtualRegister);
    12181218
    12191219    switch (info.registerFormat()) {
     
    19701970            VirtualRegister virtualRegister = node->virtualRegister();
    19711971            m_fprs.retain(result.fpr(), virtualRegister, SpillOrderDouble);
    1972             m_generationInfo[virtualRegister].initDouble(node, node->refCount(), result.fpr());
     1972            generationInfoFromVirtualRegister(virtualRegister).initDouble(node, node->refCount(), result.fpr());
    19731973            break;
    19741974        }
     
    19821982            VirtualRegister virtualRegister = node->virtualRegister();
    19831983            m_gprs.retain(result.gpr(), virtualRegister, SpillOrderInteger);
    1984             m_generationInfo[virtualRegister].initInteger(node, node->refCount(), result.gpr());
     1984            generationInfoFromVirtualRegister(virtualRegister).initInteger(node, node->refCount(), result.gpr());
    19851985            break;
    19861986        }
     
    20022002            format = DataFormatJS;
    20032003
    2004         m_generationInfo[virtualRegister].initJSValue(node, node->refCount(), result.gpr(), format);
     2004        generationInfoFromVirtualRegister(virtualRegister).initJSValue(node, node->refCount(), result.gpr(), format);
    20052005        break;
    20062006    }
  • trunk/Source/JavaScriptCore/dfg/DFGValidate.cpp

    r153274 r155415  
    7575        // NB. This code is not written for performance, since it is not intended to run
    7676        // in release builds.
    77        
     77
    7878        // Validate that all local variables at the head of the root block are dead.
    7979        BasicBlock* root = m_graph.block(0);
    8080        for (unsigned i = 0; i < root->variablesAtHead.numberOfLocals(); ++i)
    81             V_EQUAL((static_cast<VirtualRegister>(i), 0), static_cast<Node*>(0), root->variablesAtHead.local(i));
     81            V_EQUAL((static_cast<VirtualRegister>(localToOperand(i)), 0), static_cast<Node*>(0), root->variablesAtHead.local(i));
    8282       
    8383        // Validate ref counts and uses.
     
    326326            }
    327327            for (size_t i = 0; i < block->variablesAtHead.numberOfLocals(); ++i) {
    328                 VALIDATE((static_cast<VirtualRegister>(i), block), !block->variablesAtHead.local(i) || block->variablesAtHead.local(i)->hasVariableAccessData(m_graph));
     328                VALIDATE((static_cast<VirtualRegister>(localToOperand(i)), block), !block->variablesAtHead.local(i) || block->variablesAtHead.local(i)->hasVariableAccessData(m_graph));
    329329                if (m_graph.m_form == ThreadedCPS)
    330                     VALIDATE((static_cast<VirtualRegister>(i), block), !block->variablesAtTail.local(i) || block->variablesAtTail.local(i)->hasVariableAccessData(m_graph));
     330                    VALIDATE((static_cast<VirtualRegister>(localToOperand(i)), block), !block->variablesAtTail.local(i) || block->variablesAtTail.local(i)->hasVariableAccessData(m_graph));
    331331
    332332                getLocalPositions.local(i) = notSet;
     
    394394            for (size_t i = 0; i < block->variablesAtHead.numberOfLocals(); ++i) {
    395395                checkOperand(
    396                     block, getLocalPositions, setLocalPositions, i);
     396                    block, getLocalPositions, setLocalPositions, localToOperand(i));
    397397            }
    398398        }
  • trunk/Source/JavaScriptCore/dfg/DFGVariableEventStream.cpp

    r153292 r155415  
    116116    unsigned numVariables;
    117117    if (codeOrigin.inlineCallFrame)
    118         numVariables = baselineCodeBlockForInlineCallFrame(codeOrigin.inlineCallFrame)->m_numCalleeRegisters + codeOrigin.inlineCallFrame->stackOffset;
     118        numVariables = baselineCodeBlockForInlineCallFrame(codeOrigin.inlineCallFrame)->m_numCalleeRegisters + operandToLocal(codeOrigin.inlineCallFrame->stackOffset);
    119119    else
    120120        numVariables = baselineCodeBlock->m_numCalleeRegisters;
     
    310310    for (InlineCallFrame* inlineCallFrame = codeOrigin.inlineCallFrame; inlineCallFrame; inlineCallFrame = inlineCallFrame->caller.inlineCallFrame) {
    311311        for (unsigned i = JSStack::CallFrameHeaderSize; i--;)
    312             valueRecoveries.setLocal(inlineCallFrame->stackOffset - i - 1, ValueRecovery::alreadyInJSStack());
     312            valueRecoveries.setLocal(operandToLocal(inlineCallFrame->stackOffset) - i - 1, ValueRecovery::alreadyInJSStack());
    313313    }
    314314}
  • trunk/Source/JavaScriptCore/dfg/DFGVirtualRegisterAllocationPhase.cpp

    r153267 r155415  
    127127            InlineCallFrame& inlineCallFrame = codeBlock()->inlineCallFrames()[i];
    128128            CodeBlock* codeBlock = baselineCodeBlockForInlineCallFrame(&inlineCallFrame);
    129             unsigned requiredCalleeRegisters = inlineCallFrame.stackOffset + codeBlock->m_numCalleeRegisters;
     129            unsigned requiredCalleeRegisters = operandToLocal(inlineCallFrame.stackOffset) + codeBlock->m_numCalleeRegisters;
    130130            if (requiredCalleeRegisters > calleeRegisters)
    131131                calleeRegisters = requiredCalleeRegisters;
  • trunk/Source/JavaScriptCore/jit/JITInlines.h

    r155399 r155415  
    759759    }
    760760
    761     if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src) && !atJumpTarget()) {
     761    if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(operandToLocal(src)) && !atJumpTarget()) {
    762762        // The argument we want is already stored in eax
    763763        if (dst != cachedResultRegister)
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r154797 r155415  
    837837    size_t count = m_codeBlock->m_numVars;
    838838    for (size_t j = 0; j < count; ++j)
    839         emitInitRegister(j);
     839        emitInitRegister(localToOperand(j));
    840840}
    841841
  • trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp

    r154839 r155415  
    11001100    // object lifetime and increasing GC pressure.
    11011101    for (int i = 0; i < m_codeBlock->m_numVars; ++i)
    1102         emitStore(i, jsUndefined());
     1102        emitStore(localToOperand(i), jsUndefined());
    11031103}
    11041104
Note: See TracChangeset for help on using the changeset viewer.