Changeset 239009 in webkit


Ignore:
Timestamp:
Dec 8, 2018 6:57:51 AM (5 years ago)
Author:
dinfuehr@igalia.com
Message:

Record right offset with aligned wide instructions
https://bugs.webkit.org/show_bug.cgi?id=192006

Reviewed by Yusuke Suzuki.

Aligning bytecode instructions inserts nops into the instruction stream.
Emitting an instruction did not record the actual start of the instruction with
aligned instructions, but the nop just before the actual instruction. This was
problematic with the StaticPropertyAnalyzer that used the wrong instruction offset.

  • bytecode/InstructionStream.h:

(JSC::InstructionStream::MutableRef::clone):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::alignWideOpcode):
(JSC::BytecodeGenerator::emitCreateThis):
(JSC::BytecodeGenerator::emitNewObject):

  • generator/Opcode.rb:
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r238997 r239009  
     12018-12-08  Dominik Infuehr  <dinfuehr@igalia.com>
     2
     3        Record right offset with aligned wide instructions
     4        https://bugs.webkit.org/show_bug.cgi?id=192006
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        Aligning bytecode instructions inserts nops into the instruction stream.
     9        Emitting an instruction did not record the actual start of the instruction with
     10        aligned instructions, but the nop just before the actual instruction. This was
     11        problematic with the StaticPropertyAnalyzer that used the wrong instruction offset.
     12
     13        * bytecode/InstructionStream.h:
     14        (JSC::InstructionStream::MutableRef::clone):
     15        * bytecompiler/BytecodeGenerator.cpp:
     16        (JSC::BytecodeGenerator::alignWideOpcode):
     17        (JSC::BytecodeGenerator::emitCreateThis):
     18        (JSC::BytecodeGenerator::emitNewObject):
     19        * generator/Opcode.rb:
     20
    1212018-12-07  Tadeu Zagallo  <tzagallo@apple.com>
    222
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r238543 r239009  
    13241324{
    13251325#if CPU(NEEDS_ALIGNED_ACCESS)
    1326     OpcodeID lastOpcodeID = m_lastOpcodeID;
    1327     m_lastOpcodeID = op_end;
    13281326    while ((m_writer.position() + 1) % OpcodeSize::Wide)
    13291327        OpNop::emit<OpcodeSize::Narrow>(this);
    1330     recordOpcode(lastOpcodeID);
    13311328#endif
    13321329}
     
    27852782RegisterID* BytecodeGenerator::emitCreateThis(RegisterID* dst)
    27862783{
    2787     m_staticPropertyAnalyzer.createThis(dst, m_writer.ref());
    2788 
    27892784    OpCreateThis::emit(this, dst, dst, 0);
     2785    m_staticPropertyAnalyzer.createThis(dst, m_lastInstruction);
     2786
    27902787    m_codeBlock->addPropertyAccessInstruction(m_lastInstruction.offset());
    27912788    return dst;
     
    28942891RegisterID* BytecodeGenerator::emitNewObject(RegisterID* dst)
    28952892{
    2896     m_staticPropertyAnalyzer.newObject(dst, m_writer.ref());
    2897 
    28982893    OpNewObject::emit(this, dst, 0);
     2894    m_staticPropertyAnalyzer.newObject(dst, m_lastInstruction);
     2895
    28992896    return dst;
    29002897}
  • trunk/Source/JavaScriptCore/bytecompiler/StaticPropertyAnalyzer.h

    r237547 r239009  
    3636class StaticPropertyAnalyzer {
    3737public:
    38     void createThis(RegisterID* dst, InstructionStream::MutableRef&& instructionRef);
    39     void newObject(RegisterID* dst, InstructionStream::MutableRef&& instructionRef);
     38    void createThis(RegisterID* dst, InstructionStream::MutableRef instructionRef);
     39    void newObject(RegisterID* dst, InstructionStream::MutableRef instructionRef);
    4040    void putById(RegisterID* dst, unsigned propertyIndex); // propertyIndex is an index into a uniqued set of strings.
    4141    void mov(RegisterID* dst, RegisterID* src);
     
    5151};
    5252
    53 inline void StaticPropertyAnalyzer::createThis(RegisterID* dst, InstructionStream::MutableRef&& instructionRef)
     53inline void StaticPropertyAnalyzer::createThis(RegisterID* dst, InstructionStream::MutableRef instructionRef)
    5454{
    5555    AnalysisMap::AddResult addResult = m_analyses.add(
     
    5858}
    5959
    60 inline void StaticPropertyAnalyzer::newObject(RegisterID* dst, InstructionStream::MutableRef&& instructionRef)
     60inline void StaticPropertyAnalyzer::newObject(RegisterID* dst, InstructionStream::MutableRef instructionRef)
    6161{
    6262    RefPtr<StaticPropertyAnalysis> analysis = StaticPropertyAnalysis::create(WTFMove(instructionRef));
  • trunk/Source/JavaScriptCore/generator/Opcode.rb

    r238804 r239009  
    115115    static void emit(BytecodeGenerator* gen#{typed_args})
    116116    {
    117         gen->recordOpcode(opcodeID);#{@metadata.create_emitter_local}
    118         emit<OpcodeSize::Narrow, NoAssert, false>(gen#{untyped_args}#{metadata_arg})
    119             || emit<OpcodeSize::Wide, Assert, false>(gen#{untyped_args}#{metadata_arg});
     117        #{@metadata.create_emitter_local}
     118        emit<OpcodeSize::Narrow, NoAssert, true>(gen#{untyped_args}#{metadata_arg})
     119            || emit<OpcodeSize::Wide, Assert, true>(gen#{untyped_args}#{metadata_arg});
    120120    }
    121121#{%{
     
    129129    static bool emit(BytecodeGenerator* gen#{typed_args}#{metadata_param})
    130130    {
    131         if (recordOpcode)
    132             gen->recordOpcode(opcodeID);
    133         bool didEmit = emitImpl<size>(gen#{untyped_args}#{metadata_arg});
     131        bool didEmit = emitImpl<size, recordOpcode>(gen#{untyped_args}#{metadata_arg});
    134132        if (shouldAssert == Assert)
    135133            ASSERT(didEmit);
     
    138136
    139137private:
    140     template<OpcodeSize size>
     138    template<OpcodeSize size, bool recordOpcode>
    141139    static bool emitImpl(BytecodeGenerator* gen#{typed_args}#{metadata_param})
    142140    {
     
    145143        if (#{map_fields_with_size("", "size", &:fits_check).join "\n            && "}
    146144            && (size == OpcodeSize::Wide ? #{op_wide.fits_check(Size::Narrow)} : true)) {
     145            if (recordOpcode)
     146                gen->recordOpcode(opcodeID);
    147147            if (size == OpcodeSize::Wide)
    148148                #{op_wide.fits_write Size::Narrow}
Note: See TracChangeset for help on using the changeset viewer.