Ignore:
Timestamp:
Oct 1, 2013, 4:28:51 PM (12 years ago)
Author:
[email protected]
Message:

Variable event stream (for DFG OSR exit) should be explicit about where on the stack a SetLocal put a value
https://bugs.webkit.org/show_bug.cgi?id=122178

Reviewed by Geoffrey Garen.

Now if the DFG stores the value of a variable into the stack explicitly via a SetLocal,
it will record where on the stack it stored the value in addition to recording where on
the stack the bytecode would have done the SetLocal. Previously it just recorded the
format and the bytecode variable. Recording just the bytecode variable is currently fine
since the DFG always executes SetLocal's to the same stack location that the bytecode
would have used. But that prevents stack compression (webkit.org/b/122024) so this patch
allows the SetLocal to say both the bytecode variable that we're speaking of and the
actual stack location to which the SetLocal stored the value.

This had to touch a lot of code, so I took the opportunity to also resolve
webkit.org/b/108019.

  • bytecode/Operands.h:

(JSC::Operands::hasOperand):

  • dfg/DFGFlushFormat.h:

(JSC::DFG::dataFormatFor):

  • dfg/DFGMinifiedID.h:

(JSC::DFG::MinifiedID::bits):
(JSC::DFG::MinifiedID::invalidID):
(JSC::DFG::MinifiedID::otherInvalidID):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileMovHint):
(JSC::DFG::SpeculativeJIT::compileInlineStart):
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::recordSetLocal):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGValueSource.cpp:

(JSC::DFG::ValueSource::dump):

  • dfg/DFGValueSource.h:

(JSC::DFG::ValueSource::ValueSource):
(JSC::DFG::ValueSource::forFlushFormat):
(JSC::DFG::ValueSource::forDataFormat):
(JSC::DFG::ValueSource::isSet):
(JSC::DFG::ValueSource::kind):
(JSC::DFG::ValueSource::valueRecovery):
(JSC::DFG::ValueSource::id):
(JSC::DFG::ValueSource::virtualRegister):

  • dfg/DFGVariableEvent.cpp:

(JSC::DFG::VariableEvent::dump):
(JSC::DFG::VariableEvent::dumpSpillInfo):

  • dfg/DFGVariableEvent.h:

(JSC::DFG::VariableEvent::fillGPR):
(JSC::DFG::VariableEvent::fillPair):
(JSC::DFG::VariableEvent::fillFPR):
(JSC::DFG::VariableEvent::spill):
(JSC::DFG::VariableEvent::death):
(JSC::DFG::VariableEvent::setLocal):
(JSC::DFG::VariableEvent::movHint):
(JSC::DFG::VariableEvent::id):
(JSC::DFG::VariableEvent::gpr):
(JSC::DFG::VariableEvent::tagGPR):
(JSC::DFG::VariableEvent::payloadGPR):
(JSC::DFG::VariableEvent::fpr):
(JSC::DFG::VariableEvent::spillRegister):
(JSC::DFG::VariableEvent::bytecodeRegister):
(JSC::DFG::VariableEvent::machineRegister):
(JSC::DFG::VariableEvent::variableRepresentation):

  • dfg/DFGVariableEventStream.cpp:

(JSC::DFG::VariableEventStream::reconstruct):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGVariableEvent.h

    r156511 r156747  
    6262    MovHintEvent,
    6363   
    64     // A SetLocalEvent means that a node's value has actually been stored into the
    65     // bytecode operand that it's associated with.
     64    // A SetLocalEvent means that a node's value has been stored into the stack.
    6665    SetLocalEvent,
    6766   
     
    105104#endif
    106105        VariableEvent event;
    107         event.m_id = id;
    108         event.u.gpr = gpr;
     106        event.m_which.id = id.bits();
     107        event.m_representation.gpr = gpr;
    109108        event.m_kind = kind;
    110109        event.m_dataFormat = dataFormat;
     
    117116        ASSERT(kind == BirthToFill || kind == Fill);
    118117        VariableEvent event;
    119         event.m_id = id;
    120         event.u.pair.tagGPR = tagGPR;
    121         event.u.pair.payloadGPR = payloadGPR;
     118        event.m_which.id = id.bits();
     119        event.m_representation.pair.tagGPR = tagGPR;
     120        event.m_representation.pair.payloadGPR = payloadGPR;
    122121        event.m_kind = kind;
    123122        event.m_dataFormat = DataFormatJS;
     
    130129        ASSERT(kind == BirthToFill || kind == Fill);
    131130        VariableEvent event;
    132         event.m_id = id;
    133         event.u.fpr = fpr;
     131        event.m_which.id = id.bits();
     132        event.m_representation.fpr = fpr;
    134133        event.m_kind = kind;
    135134        event.m_dataFormat = DataFormatDouble;
     
    141140        ASSERT(kind == BirthToSpill || kind == Spill);
    142141        VariableEvent event;
    143         event.m_id = id;
    144         event.u.virtualReg = virtualRegister.offset();
     142        event.m_which.id = id.bits();
     143        event.m_representation.virtualReg = virtualRegister.offset();
    145144        event.m_kind = kind;
    146145        event.m_dataFormat = format;
     
    151150    {
    152151        VariableEvent event;
    153         event.m_id = id;
     152        event.m_which.id = id.bits();
    154153        event.m_kind = Death;
    155154        return event;
    156155    }
    157156   
    158     static VariableEvent setLocal(VirtualRegister virtualRegister, DataFormat format)
    159     {
    160         VariableEvent event;
    161         event.u.virtualReg = virtualRegister.offset();
     157    static VariableEvent setLocal(
     158        VirtualRegister bytecodeReg, VirtualRegister machineReg, DataFormat format)
     159    {
     160        VariableEvent event;
     161        event.m_which.virtualReg = machineReg.offset();
     162        event.m_representation.virtualReg = bytecodeReg.offset();
    162163        event.m_kind = SetLocalEvent;
    163164        event.m_dataFormat = format;
     
    165166    }
    166167   
    167     static VariableEvent movHint(MinifiedID id, int operand)
    168     {
    169         VariableEvent event;
    170         event.m_id = id;
    171         event.u.virtualReg = operand;
     168    static VariableEvent movHint(MinifiedID id, VirtualRegister bytecodeReg)
     169    {
     170        VariableEvent event;
     171        event.m_which.id = id.bits();
     172        event.m_representation.virtualReg = bytecodeReg.offset();
    172173        event.m_kind = MovHintEvent;
    173174        return event;
     
    184185               || m_kind == BirthToSpill || m_kind == Spill
    185186               || m_kind == Death || m_kind == MovHintEvent);
    186         return m_id;
     187        return MinifiedID::fromBits(m_which.id);
    187188    }
    188189   
     
    203204        ASSERT(!(m_dataFormat & DataFormatJS));
    204205#endif
    205         return u.gpr;
     206        return m_representation.gpr;
    206207    }
    207208   
     
    211212        ASSERT(m_kind == BirthToFill || m_kind == Fill);
    212213        ASSERT(m_dataFormat & DataFormatJS);
    213         return u.pair.tagGPR;
     214        return m_representation.pair.tagGPR;
    214215    }
    215216    MacroAssembler::RegisterID payloadGPR() const
     
    217218        ASSERT(m_kind == BirthToFill || m_kind == Fill);
    218219        ASSERT(m_dataFormat & DataFormatJS);
    219         return u.pair.payloadGPR;
     220        return m_representation.pair.payloadGPR;
    220221    }
    221222#endif // USE(JSVALUE32_64)
     
    225226        ASSERT(m_kind == BirthToFill || m_kind == Fill);
    226227        ASSERT(m_dataFormat == DataFormatDouble);
    227         return u.fpr;
    228     }
    229    
    230     VirtualRegister virtualRegister() const
     228        return m_representation.fpr;
     229    }
     230   
     231    VirtualRegister spillRegister() const
    231232    {
    232233        ASSERT(m_kind == BirthToSpill || m_kind == Spill);
    233         return static_cast<VirtualRegister>(u.virtualReg);
    234     }
    235    
    236     int operand() const
     234        return VirtualRegister(m_representation.virtualReg);
     235    }
     236   
     237    VirtualRegister bytecodeRegister() const
    237238    {
    238239        ASSERT(m_kind == SetLocalEvent || m_kind == MovHintEvent);
    239         return u.virtualReg;
    240     }
    241    
    242     const VariableRepresentation& variableRepresentation() const { return u; }
     240        return VirtualRegister(m_representation.virtualReg);
     241    }
     242   
     243    VirtualRegister machineRegister() const
     244    {
     245        ASSERT(m_kind == SetLocalEvent);
     246        return VirtualRegister(m_which.virtualReg);
     247    }
     248   
     249    const VariableRepresentation& variableRepresentation() const { return m_representation; }
    243250   
    244251    void dump(PrintStream&) const;
     
    248255    void dumpSpillInfo(const char* name, PrintStream&) const;
    249256   
    250     MinifiedID m_id;
     257    union {
     258        int virtualReg;
     259        uintptr_t id;
     260    } m_which;
    251261   
    252262    // For BirthToFill, Fill:
     
    258268    // For Death:
    259269    //   - Unused.
    260     VariableRepresentation u;
     270    VariableRepresentation m_representation;
    261271   
    262272    int8_t m_kind;
Note: See TracChangeset for help on using the changeset viewer.