Changeset 85432 in webkit


Ignore:
Timestamp:
May 1, 2011 3:20:59 PM (13 years ago)
Author:
barraclough@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=59896
Remove JmpSrc/JmpDst types.

Reviewed by Sam Weinig.

The JmpSrc/JmpDst classes predate the MacroAssembler interface. Having these
object be per-assembler in unhelpful, causes unnecessary code duplication,
and prevents the AssemblerBuffer from providing a richer type for labels.
The limited semantic meaning that they did convey is undermined by the manner
in which their meanings have been overloaded (use of JmpSrc for Call, JmpDst
for data labels).

Jumps on ARMv7 have had additional information added to the object via the
ARMv7 JmpSrc. This data should probably be in the instruction stream. This
patch does not fix the problem, and moves the data (ifdefed) to
AbstractMacroAssembler::Jump (which is effectively where it was before!).
This at least closes the hole such that no further data may be added to JmpSrc,
but this is unfortunate, and should be cleaned up.

  • assembler/ARMAssembler.h:

(JSC::ARMAssembler::blx):
(JSC::ARMAssembler::label):
(JSC::ARMAssembler::align):
(JSC::ARMAssembler::loadBranchTarget):
(JSC::ARMAssembler::jmp):
(JSC::ARMAssembler::linkPointer):
(JSC::ARMAssembler::linkJump):
(JSC::ARMAssembler::linkCall):
(JSC::ARMAssembler::getRelocatedAddress):
(JSC::ARMAssembler::getDifferenceBetweenLabels):
(JSC::ARMAssembler::getCallReturnOffset):

  • assembler/ARMv7Assembler.h:

(JSC::ARMv7Assembler::b):
(JSC::ARMv7Assembler::blx):
(JSC::ARMv7Assembler::bx):
(JSC::ARMv7Assembler::label):
(JSC::ARMv7Assembler::align):
(JSC::ARMv7Assembler::getRelocatedAddress):
(JSC::ARMv7Assembler::getDifferenceBetweenLabels):
(JSC::ARMv7Assembler::getCallReturnOffset):
(JSC::ARMv7Assembler::linkJump):
(JSC::ARMv7Assembler::linkCall):
(JSC::ARMv7Assembler::linkPointer):

  • assembler/AbstractMacroAssembler.h:

(JSC::AbstractMacroAssembler::Label::isSet):
(JSC::AbstractMacroAssembler::Call::Call):
(JSC::AbstractMacroAssembler::Jump::Jump):
(JSC::AbstractMacroAssembler::Jump::link):
(JSC::AbstractMacroAssembler::Jump::linkTo):
(JSC::AbstractMacroAssembler::linkPointer):
(JSC::AbstractMacroAssembler::getLinkerAddress):

  • assembler/AssemblerBuffer.h:

(JSC::AssemblerLabel::AssemblerLabel):
(JSC::AssemblerLabel::isSet):

  • assembler/LinkBuffer.h:

(JSC::LinkBuffer::patch):

  • assembler/MIPSAssembler.h:

(JSC::MIPSAssembler::label):
(JSC::MIPSAssembler::align):
(JSC::MIPSAssembler::getRelocatedAddress):
(JSC::MIPSAssembler::getDifferenceBetweenLabels):
(JSC::MIPSAssembler::getCallReturnOffset):
(JSC::MIPSAssembler::linkJump):
(JSC::MIPSAssembler::linkCall):
(JSC::MIPSAssembler::linkPointer):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::branchDouble):
(JSC::MacroAssemblerARMv7::branchDoubleZeroOrNaN):
(JSC::MacroAssemblerARMv7::jump):
(JSC::MacroAssemblerARMv7::nearCall):
(JSC::MacroAssemblerARMv7::call):
(JSC::MacroAssemblerARMv7::ret):
(JSC::MacroAssemblerARMv7::tailRecursiveCall):
(JSC::MacroAssemblerARMv7::makeBranch):

  • assembler/MacroAssemblerMIPS.h:

(JSC::MacroAssemblerMIPS::nearCall):
(JSC::MacroAssemblerMIPS::call):
(JSC::MacroAssemblerMIPS::tailRecursiveCall):
(JSC::MacroAssemblerMIPS::branchTrue):
(JSC::MacroAssemblerMIPS::branchFalse):
(JSC::MacroAssemblerMIPS::branchEqual):
(JSC::MacroAssemblerMIPS::branchNotEqual):

  • assembler/SH4Assembler.h:

(JSC::SH4Assembler::call):
(JSC::SH4Assembler::jmp):
(JSC::SH4Assembler::jne):
(JSC::SH4Assembler::je):
(JSC::SH4Assembler::label):
(JSC::SH4Assembler::align):
(JSC::SH4Assembler::linkJump):
(JSC::SH4Assembler::linkCall):
(JSC::SH4Assembler::linkPointer):
(JSC::SH4Assembler::getCallReturnOffset):
(JSC::SH4Assembler::getRelocatedAddress):
(JSC::SH4Assembler::getDifferenceBetweenLabels):
(JSC::SH4Assembler::patchPointer):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::call):
(JSC::X86Assembler::jmp):
(JSC::X86Assembler::jmp_r):
(JSC::X86Assembler::jne):
(JSC::X86Assembler::jnz):
(JSC::X86Assembler::je):
(JSC::X86Assembler::jz):
(JSC::X86Assembler::jl):
(JSC::X86Assembler::jb):
(JSC::X86Assembler::jle):
(JSC::X86Assembler::jbe):
(JSC::X86Assembler::jge):
(JSC::X86Assembler::jg):
(JSC::X86Assembler::ja):
(JSC::X86Assembler::jae):
(JSC::X86Assembler::jo):
(JSC::X86Assembler::jp):
(JSC::X86Assembler::js):
(JSC::X86Assembler::jCC):
(JSC::X86Assembler::label):
(JSC::X86Assembler::labelFor):
(JSC::X86Assembler::align):
(JSC::X86Assembler::linkJump):
(JSC::X86Assembler::linkCall):
(JSC::X86Assembler::linkPointer):
(JSC::X86Assembler::getCallReturnOffset):
(JSC::X86Assembler::getRelocatedAddress):
(JSC::X86Assembler::getDifferenceBetweenLabels):
(JSC::X86Assembler::rewindToLabel):
(JSC::X86Assembler::X86InstructionFormatter::immediateRel32):
(JSC::X86Assembler::X86InstructionFormatter::rewindToLabel):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):

  • jit/JIT.h:
  • jit/JITInlineMethods.h:

(JSC::JIT::atJumpTarget):
(JSC::JIT::emitGetVirtualRegister):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_jmp):
(JSC::JIT::emit_op_jfalse):
(JSC::JIT::emit_op_jeq_null):
(JSC::JIT::emit_op_jneq_null):
(JSC::JIT::emit_op_jneq_ptr):
(JSC::JIT::emit_op_jsr):
(JSC::JIT::emit_op_jtrue):
(JSC::JIT::emit_op_jmp_scopes):

Location:
trunk/Source/JavaScriptCore
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r85429 r85432  
     12011-05-01  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=59896
     6        Remove JmpSrc/JmpDst types.
     7
     8        The JmpSrc/JmpDst classes predate the MacroAssembler interface. Having these
     9        object be per-assembler in unhelpful, causes unnecessary code duplication,
     10        and prevents the AssemblerBuffer from providing a richer type for labels.
     11        The limited semantic meaning that they did convey is undermined by the manner
     12        in which their meanings have been overloaded (use of JmpSrc for Call, JmpDst
     13        for data labels).
     14
     15        Jumps on ARMv7 have had additional information added to the object via the
     16        ARMv7 JmpSrc. This data should probably be in the instruction stream. This
     17        patch does not fix the problem, and moves the data (ifdefed) to
     18        AbstractMacroAssembler::Jump (which is effectively where it was before!).
     19        This at least closes the hole such that no further data may be added to JmpSrc,
     20        but this is unfortunate, and should be cleaned up.
     21
     22        * assembler/ARMAssembler.h:
     23        (JSC::ARMAssembler::blx):
     24        (JSC::ARMAssembler::label):
     25        (JSC::ARMAssembler::align):
     26        (JSC::ARMAssembler::loadBranchTarget):
     27        (JSC::ARMAssembler::jmp):
     28        (JSC::ARMAssembler::linkPointer):
     29        (JSC::ARMAssembler::linkJump):
     30        (JSC::ARMAssembler::linkCall):
     31        (JSC::ARMAssembler::getRelocatedAddress):
     32        (JSC::ARMAssembler::getDifferenceBetweenLabels):
     33        (JSC::ARMAssembler::getCallReturnOffset):
     34        * assembler/ARMv7Assembler.h:
     35        (JSC::ARMv7Assembler::b):
     36        (JSC::ARMv7Assembler::blx):
     37        (JSC::ARMv7Assembler::bx):
     38        (JSC::ARMv7Assembler::label):
     39        (JSC::ARMv7Assembler::align):
     40        (JSC::ARMv7Assembler::getRelocatedAddress):
     41        (JSC::ARMv7Assembler::getDifferenceBetweenLabels):
     42        (JSC::ARMv7Assembler::getCallReturnOffset):
     43        (JSC::ARMv7Assembler::linkJump):
     44        (JSC::ARMv7Assembler::linkCall):
     45        (JSC::ARMv7Assembler::linkPointer):
     46        * assembler/AbstractMacroAssembler.h:
     47        (JSC::AbstractMacroAssembler::Label::isSet):
     48        (JSC::AbstractMacroAssembler::Call::Call):
     49        (JSC::AbstractMacroAssembler::Jump::Jump):
     50        (JSC::AbstractMacroAssembler::Jump::link):
     51        (JSC::AbstractMacroAssembler::Jump::linkTo):
     52        (JSC::AbstractMacroAssembler::linkPointer):
     53        (JSC::AbstractMacroAssembler::getLinkerAddress):
     54        * assembler/AssemblerBuffer.h:
     55        (JSC::AssemblerLabel::AssemblerLabel):
     56        (JSC::AssemblerLabel::isSet):
     57        * assembler/LinkBuffer.h:
     58        (JSC::LinkBuffer::patch):
     59        * assembler/MIPSAssembler.h:
     60        (JSC::MIPSAssembler::label):
     61        (JSC::MIPSAssembler::align):
     62        (JSC::MIPSAssembler::getRelocatedAddress):
     63        (JSC::MIPSAssembler::getDifferenceBetweenLabels):
     64        (JSC::MIPSAssembler::getCallReturnOffset):
     65        (JSC::MIPSAssembler::linkJump):
     66        (JSC::MIPSAssembler::linkCall):
     67        (JSC::MIPSAssembler::linkPointer):
     68        * assembler/MacroAssemblerARMv7.h:
     69        (JSC::MacroAssemblerARMv7::branchDouble):
     70        (JSC::MacroAssemblerARMv7::branchDoubleZeroOrNaN):
     71        (JSC::MacroAssemblerARMv7::jump):
     72        (JSC::MacroAssemblerARMv7::nearCall):
     73        (JSC::MacroAssemblerARMv7::call):
     74        (JSC::MacroAssemblerARMv7::ret):
     75        (JSC::MacroAssemblerARMv7::tailRecursiveCall):
     76        (JSC::MacroAssemblerARMv7::makeBranch):
     77        * assembler/MacroAssemblerMIPS.h:
     78        (JSC::MacroAssemblerMIPS::nearCall):
     79        (JSC::MacroAssemblerMIPS::call):
     80        (JSC::MacroAssemblerMIPS::tailRecursiveCall):
     81        (JSC::MacroAssemblerMIPS::branchTrue):
     82        (JSC::MacroAssemblerMIPS::branchFalse):
     83        (JSC::MacroAssemblerMIPS::branchEqual):
     84        (JSC::MacroAssemblerMIPS::branchNotEqual):
     85        * assembler/SH4Assembler.h:
     86        (JSC::SH4Assembler::call):
     87        (JSC::SH4Assembler::jmp):
     88        (JSC::SH4Assembler::jne):
     89        (JSC::SH4Assembler::je):
     90        (JSC::SH4Assembler::label):
     91        (JSC::SH4Assembler::align):
     92        (JSC::SH4Assembler::linkJump):
     93        (JSC::SH4Assembler::linkCall):
     94        (JSC::SH4Assembler::linkPointer):
     95        (JSC::SH4Assembler::getCallReturnOffset):
     96        (JSC::SH4Assembler::getRelocatedAddress):
     97        (JSC::SH4Assembler::getDifferenceBetweenLabels):
     98        (JSC::SH4Assembler::patchPointer):
     99        * assembler/X86Assembler.h:
     100        (JSC::X86Assembler::call):
     101        (JSC::X86Assembler::jmp):
     102        (JSC::X86Assembler::jmp_r):
     103        (JSC::X86Assembler::jne):
     104        (JSC::X86Assembler::jnz):
     105        (JSC::X86Assembler::je):
     106        (JSC::X86Assembler::jz):
     107        (JSC::X86Assembler::jl):
     108        (JSC::X86Assembler::jb):
     109        (JSC::X86Assembler::jle):
     110        (JSC::X86Assembler::jbe):
     111        (JSC::X86Assembler::jge):
     112        (JSC::X86Assembler::jg):
     113        (JSC::X86Assembler::ja):
     114        (JSC::X86Assembler::jae):
     115        (JSC::X86Assembler::jo):
     116        (JSC::X86Assembler::jp):
     117        (JSC::X86Assembler::js):
     118        (JSC::X86Assembler::jCC):
     119        (JSC::X86Assembler::label):
     120        (JSC::X86Assembler::labelFor):
     121        (JSC::X86Assembler::align):
     122        (JSC::X86Assembler::linkJump):
     123        (JSC::X86Assembler::linkCall):
     124        (JSC::X86Assembler::linkPointer):
     125        (JSC::X86Assembler::getCallReturnOffset):
     126        (JSC::X86Assembler::getRelocatedAddress):
     127        (JSC::X86Assembler::getDifferenceBetweenLabels):
     128        (JSC::X86Assembler::rewindToLabel):
     129        (JSC::X86Assembler::X86InstructionFormatter::immediateRel32):
     130        (JSC::X86Assembler::X86InstructionFormatter::rewindToLabel):
     131        * jit/JIT.cpp:
     132        (JSC::JIT::privateCompileMainPass):
     133        * jit/JIT.h:
     134        * jit/JITInlineMethods.h:
     135        (JSC::JIT::atJumpTarget):
     136        (JSC::JIT::emitGetVirtualRegister):
     137        * jit/JITOpcodes.cpp:
     138        (JSC::JIT::emit_op_jmp):
     139        (JSC::JIT::emit_op_jfalse):
     140        (JSC::JIT::emit_op_jeq_null):
     141        (JSC::JIT::emit_op_jneq_null):
     142        (JSC::JIT::emit_op_jneq_ptr):
     143        (JSC::JIT::emit_op_jsr):
     144        (JSC::JIT::emit_op_jtrue):
     145        (JSC::JIT::emit_op_jmp_scopes):
     146
    11472011-05-01  Chao-ying Fu  <fu@mips.com>
    2148
  • trunk/Source/JavaScriptCore/assembler/ARMAssembler.h

    r85403 r85432  
    214214        static const int DefaultPrefetching = 2;
    215215
    216         class JmpSrc {
    217             friend class ARMAssembler;
    218         public:
    219             JmpSrc()
    220                 : m_offset(-1)
    221             {
    222             }
    223 
    224         private:
    225             JmpSrc(int offset)
    226                 : m_offset(offset)
    227             {
    228             }
    229 
    230             int m_offset;
    231         };
    232 
    233         class JmpDst {
    234             friend class ARMAssembler;
    235         public:
    236             JmpDst()
    237                 : m_offset(-1)
    238                 , m_used(false)
    239             {
    240             }
    241 
    242             bool isUsed() const { return m_used; }
    243             bool isSet() const { return (m_offset != -1); }
    244             void used() { m_used = true; }
    245         private:
    246             JmpDst(int offset)
    247                 : m_offset(offset)
    248                 , m_used(false)
    249             {
    250                 ASSERT(m_offset == offset);
    251             }
    252 
    253             signed int m_offset : 31;
    254             int m_used : 1;
    255         };
    256 
    257216        // Instruction formating
    258217
     
    623582        }
    624583
    625         JmpSrc blx(int rm, Condition cc = AL)
     584        AssemblerLabel blx(int rm, Condition cc = AL)
    626585        {
    627586#if WTF_ARM_ARCH_AT_LEAST(5)
     
    633592            bx(rm, cc);
    634593#endif
    635             return JmpSrc(m_buffer.label());
     594            return AssemblerLabel(m_buffer.label());
    636595        }
    637596
     
    695654        }
    696655
    697         JmpDst label()
     656        AssemblerLabel label()
    698657        {
    699658            m_buffer.ensureSpaceForAnyOneInstruction();
    700             return JmpDst(m_buffer.label());
    701         }
    702 
    703         JmpDst align(int alignment)
     659            return AssemblerLabel(m_buffer.label());
     660        }
     661
     662        AssemblerLabel align(int alignment)
    704663        {
    705664            while (!m_buffer.isAligned(alignment))
     
    709668        }
    710669
    711         JmpSrc loadBranchTarget(int rd, Condition cc = AL, int useConstantPool = 0)
     670        AssemblerLabel loadBranchTarget(int rd, Condition cc = AL, int useConstantPool = 0)
    712671        {
    713672            ensureSpace(sizeof(ARMWord), sizeof(ARMWord));
    714673            m_jumps.append(m_buffer.label() | (useConstantPool & 0x1));
    715674            ldr_un_imm(rd, InvalidBranchTarget, cc);
    716             return JmpSrc(m_buffer.label());
    717         }
    718 
    719         JmpSrc jmp(Condition cc = AL, int useConstantPool = 0)
     675            return AssemblerLabel(m_buffer.label());
     676        }
     677
     678        AssemblerLabel jmp(Condition cc = AL, int useConstantPool = 0)
    720679        {
    721680            return loadBranchTarget(ARMRegisters::pc, cc, useConstantPool);
     
    777736        // Patch pointers
    778737
    779         static void linkPointer(void* code, JmpDst from, void* to)
     738        static void linkPointer(void* code, AssemblerLabel from, void* to)
    780739        {
    781740            patchPointerInternal(reinterpret_cast<intptr_t>(code) + from.m_offset, to);
     
    798757        }
    799758
    800         void linkJump(JmpSrc from, JmpDst to)
     759        void linkJump(AssemblerLabel from, AssemblerLabel to)
    801760        {
    802761            ARMWord* insn = reinterpret_cast<ARMWord*>(getAbsoluteJumpAddress(m_buffer.data(), from.m_offset));
     
    805764        }
    806765
    807         static void linkJump(void* code, JmpSrc from, void* to)
     766        static void linkJump(void* code, AssemblerLabel from, void* to)
    808767        {
    809768            patchPointerInternal(getAbsoluteJumpAddress(code, from.m_offset), to);
     
    815774        }
    816775
    817         static void linkCall(void* code, JmpSrc from, void* to)
     776        static void linkCall(void* code, AssemblerLabel from, void* to)
    818777        {
    819778            patchPointerInternal(getAbsoluteJumpAddress(code, from.m_offset), to);
     
    827786        // Address operations
    828787
    829         static void* getRelocatedAddress(void* code, JmpSrc jump)
    830         {
    831             return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + jump.m_offset);
    832         }
    833 
    834         static void* getRelocatedAddress(void* code, JmpDst label)
     788        static void* getRelocatedAddress(void* code, AssemblerLabel label)
    835789        {
    836790            return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset);
     
    839793        // Address differences
    840794
    841         static int getDifferenceBetweenLabels(JmpDst from, JmpSrc to)
    842         {
    843             return to.m_offset - from.m_offset;
    844         }
    845 
    846         static int getDifferenceBetweenLabels(JmpDst from, JmpDst to)
    847         {
    848             return to.m_offset - from.m_offset;
    849         }
    850 
    851         static unsigned getCallReturnOffset(JmpSrc call)
     795        static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
     796        {
     797            return b.m_offset - a.m_offset;
     798        }
     799
     800        static unsigned getCallReturnOffset(AssemblerLabel call)
    852801        {
    853802            return call.m_offset;
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r85403 r85432  
    472472        JumpLinkType m_linkType : 4;
    473473        Condition m_condition : 16;
    474     };
    475    
    476     class JmpSrc {
    477         friend class ARMv7Assembler;
    478         friend class ARMInstructionFormatter;
    479         friend class LinkBuffer;
    480     public:
    481         JmpSrc()
    482             : m_offset(-1)
    483         {
    484         }
    485 
    486     private:
    487         JmpSrc(int offset, JumpType type)
    488             : m_offset(offset)
    489             , m_condition(ConditionInvalid)
    490             , m_type(type)
    491         {
    492             ASSERT(m_type == JumpFixed || m_type == JumpNoCondition || m_type == JumpNoConditionFixedSize);
    493         }
    494 
    495         JmpSrc(int offset, JumpType type, Condition condition)
    496             : m_offset(offset)
    497             , m_condition(condition)
    498             , m_type(type)
    499         {
    500             ASSERT(m_type == JumpFixed || m_type == JumpCondition || m_type == JumpConditionFixedSize);
    501         }
    502 
    503         int m_offset;
    504         Condition m_condition : 16;
    505         JumpType m_type : 16;
    506        
    507     };
    508    
    509     class JmpDst {
    510         friend class ARMv7Assembler;
    511         friend class ARMInstructionFormatter;
    512         friend class LinkBuffer;
    513     public:
    514         JmpDst()
    515             : m_offset(-1)
    516             , m_used(false)
    517         {
    518         }
    519 
    520         bool isUsed() const { return m_used; }
    521         bool isSet() const { return (m_offset != -1); }
    522         void used() { m_used = true; }
    523     private:
    524         JmpDst(int offset)
    525             : m_offset(offset)
    526             , m_used(false)
    527         {
    528             ASSERT(m_offset == offset);
    529         }
    530 
    531         signed int m_offset : 31;
    532         int m_used : 1;
    533474    };
    534475
     
    883824   
    884825    // Only allowed in IT (if then) block if last instruction.
    885     JmpSrc b(JumpType type)
     826    AssemblerLabel b()
    886827    {
    887828        m_formatter.twoWordOp16Op16(OP_B_T4a, OP_B_T4b);
    888         return JmpSrc(m_formatter.label(), type);
     829        return AssemblerLabel(m_formatter.label());
    889830    }
    890831   
    891832    // Only allowed in IT (if then) block if last instruction.
    892     JmpSrc blx(RegisterID rm, JumpType type)
     833    AssemblerLabel blx(RegisterID rm)
    893834    {
    894835        ASSERT(rm != ARMRegisters::pc);
    895836        m_formatter.oneWordOp8RegReg143(OP_BLX, rm, (RegisterID)8);
    896         return JmpSrc(m_formatter.label(), type);
     837        return AssemblerLabel(m_formatter.label());
    897838    }
    898839
    899840    // Only allowed in IT (if then) block if last instruction.
    900     JmpSrc bx(RegisterID rm, JumpType type, Condition condition)
     841    AssemblerLabel bx(RegisterID rm)
    901842    {
    902843        m_formatter.oneWordOp8RegReg143(OP_BX, rm, (RegisterID)0);
    903         return JmpSrc(m_formatter.label(), type, condition);
    904     }
    905 
    906     JmpSrc bx(RegisterID rm, JumpType type)
    907     {
    908         m_formatter.oneWordOp8RegReg143(OP_BX, rm, (RegisterID)0);
    909         return JmpSrc(m_formatter.label(), type);
     844        return AssemblerLabel(m_formatter.label());
    910845    }
    911846
     
    15921527    }
    15931528
    1594     JmpDst label()
    1595     {
    1596         return JmpDst(m_formatter.label());
    1597     }
    1598    
    1599     JmpDst align(int alignment)
     1529    AssemblerLabel label()
     1530    {
     1531        return AssemblerLabel(m_formatter.label());
     1532    }
     1533   
     1534    AssemblerLabel align(int alignment)
    16001535    {
    16011536        while (!m_formatter.isAligned(alignment))
     
    16051540    }
    16061541   
    1607     static void* getRelocatedAddress(void* code, JmpSrc jump)
    1608     {
    1609         ASSERT(jump.m_offset != -1);
    1610 
    1611         return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + jump.m_offset);
    1612     }
    1613    
    1614     static void* getRelocatedAddress(void* code, JmpDst destination)
    1615     {
    1616         ASSERT(destination.m_offset != -1);
    1617 
    1618         return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + destination.m_offset);
    1619     }
    1620    
    1621     static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst)
    1622     {
    1623         return dst.m_offset - src.m_offset;
    1624     }
    1625    
    1626     static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst)
    1627     {
    1628         return dst.m_offset - src.m_offset;
    1629     }
    1630    
    1631     static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst)
    1632     {
    1633         return dst.m_offset - src.m_offset;
     1542    static void* getRelocatedAddress(void* code, AssemblerLabel label)
     1543    {
     1544        ASSERT(label.isSet());
     1545        return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + label.m_offset);
     1546    }
     1547   
     1548    static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
     1549    {
     1550        return b.m_offset - a.m_offset;
    16341551    }
    16351552
     
    17651682    size_t codeSize() const { return m_formatter.codeSize(); }
    17661683
    1767     static unsigned getCallReturnOffset(JmpSrc call)
    1768     {
    1769         ASSERT(call.m_offset >= 0);
     1684    static unsigned getCallReturnOffset(AssemblerLabel call)
     1685    {
     1686        ASSERT(call.isSet());
    17701687        return call.m_offset;
    17711688    }
     
    17791696    // pool the 'repatch' and 'relink' methods should be used.
    17801697
    1781     void linkJump(JmpSrc from, JmpDst to)
    1782     {
    1783         ASSERT(to.m_offset != -1);
    1784         ASSERT(from.m_offset != -1);
    1785         m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, from.m_type, from.m_condition));
    1786     }
    1787 
    1788     static void linkJump(void* code, JmpSrc from, void* to)
    1789     {
    1790         ASSERT(from.m_offset != -1);
     1698    void linkJump(AssemblerLabel from, AssemblerLabel to, JumpType type, Condition condition)
     1699    {
     1700        ASSERT(to.isSet());
     1701        ASSERT(from.isSet());
     1702        m_jumpsToLink.append(LinkRecord(from.m_offset, to.m_offset, type, condition));
     1703    }
     1704
     1705    static void linkJump(void* code, AssemblerLabel from, void* to)
     1706    {
     1707        ASSERT(from.isSet());
    17911708       
    17921709        uint16_t* location = reinterpret_cast<uint16_t*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
     
    17941711    }
    17951712
    1796     // bah, this mathod should really be static, since it is used by the LinkBuffer.
    1797     // return a bool saying whether the link was successful?
    1798     static void linkCall(void* code, JmpSrc from, void* to)
     1713    static void linkCall(void* code, AssemblerLabel from, void* to)
    17991714    {
    18001715        ASSERT(!(reinterpret_cast<intptr_t>(code) & 1));
    1801         ASSERT(from.m_offset != -1);
     1716        ASSERT(from.isSet());
    18021717        ASSERT(reinterpret_cast<intptr_t>(to) & 1);
    18031718
     
    18051720    }
    18061721
    1807     static void linkPointer(void* code, JmpDst where, void* value)
     1722    static void linkPointer(void* code, AssemblerLabel where, void* value)
    18081723    {
    18091724        setPointer(reinterpret_cast<char*>(code) + where.m_offset, value);
  • trunk/Source/JavaScriptCore/assembler/AbstractMacroAssembler.h

    r85403 r85432  
    5050
    5151    typedef typename AssemblerType::RegisterID RegisterID;
    52     typedef typename AssemblerType::JmpSrc JmpSrc;
    53     typedef typename AssemblerType::JmpDst JmpDst;
    54 
    5552
    5653    // Section 1: MacroAssembler operand types
     
    261258        }
    262259       
    263         bool isUsed() const { return m_label.isUsed(); }
    264260        bool isSet() const { return m_label.isSet(); }
    265         void used() { m_label.used(); }
    266261    private:
    267         JmpDst m_label;
     262        AssemblerLabel m_label;
    268263    };
    269264
     
    289284       
    290285    private:
    291         JmpDst m_label;
     286        AssemblerLabel m_label;
    292287    };
    293288
     
    311306
    312307    private:
    313         JmpDst m_label;
     308        AssemblerLabel m_label;
    314309    };
    315310
     
    337332        }
    338333       
    339         Call(JmpSrc jmp, Flags flags)
     334        Call(AssemblerLabel jmp, Flags flags)
    340335            : m_jmp(jmp)
    341336            , m_flags(flags)
     
    353348        }
    354349
    355         JmpSrc m_jmp;
     350        AssemblerLabel m_jmp;
    356351    private:
    357352        Flags m_flags;
     
    374369        }
    375370       
    376         Jump(JmpSrc jmp)   
     371#if CPU(ARMv7)
     372        // Fixme: this information should be stored in the instruction stream, not in the Jump object.
     373        Jump(AssemblerLabel jmp, ARMv7Assembler::JumpType type, ARMv7Assembler::Condition condition = ARMv7Assembler::ConditionInvalid)
    377374            : m_jmp(jmp)
    378         {
    379         }
    380        
     375            , m_type(type)
     376            , m_condition(condition)
     377        {
     378        }
     379#else
     380        Jump(AssemblerLabel jmp)   
     381            : m_jmp(jmp)
     382        {
     383        }
     384#endif
     385
    381386        void link(AbstractMacroAssembler<AssemblerType>* masm) const
    382387        {
     388#if CPU(ARMv7)
     389            masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label(), m_type, m_condition);
     390#else
    383391            masm->m_assembler.linkJump(m_jmp, masm->m_assembler.label());
     392#endif
    384393        }
    385394       
    386395        void linkTo(Label label, AbstractMacroAssembler<AssemblerType>* masm) const
    387396        {
     397#if CPU(ARMv7)
     398            masm->m_assembler.linkJump(m_jmp, label.m_label, m_jmp.m_type, m_jmp.m_condition);
     399#else
    388400            masm->m_assembler.linkJump(m_jmp, label.m_label);
     401#endif
    389402        }
    390403
     
    392405
    393406    private:
    394         JmpSrc m_jmp;
     407        AssemblerLabel m_jmp;
     408#if CPU(ARMv7)
     409        ARMv7Assembler::JumpType m_type;
     410        ARMv7Assembler::Condition m_condition;
     411#endif
    395412    };
    396413
     
    523540    }
    524541
    525     static void linkPointer(void* code, typename AssemblerType::JmpDst label, void* value)
     542    static void linkPointer(void* code, AssemblerLabel label, void* value)
    526543    {
    527544        AssemblerType::linkPointer(code, label, value);
    528545    }
    529546
    530     static void* getLinkerAddress(void* code, typename AssemblerType::JmpSrc label)
     547    static void* getLinkerAddress(void* code, AssemblerLabel label)
    531548    {
    532549        return AssemblerType::getRelocatedAddress(code, label);
    533550    }
    534551
    535     static void* getLinkerAddress(void* code, typename AssemblerType::JmpDst label)
    536     {
    537         return AssemblerType::getRelocatedAddress(code, label);
    538     }
    539 
    540552    static unsigned getLinkerCallReturnOffset(Call call)
    541553    {
  • trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h

    r85403 r85432  
    3838namespace JSC {
    3939
     40    struct AssemblerLabel {
     41        AssemblerLabel(uint32_t offset = std::numeric_limits<uint32_t>::max())
     42            : m_offset(offset)
     43        {
     44        }
     45
     46        bool isSet() const { return (m_offset != std::numeric_limits<uint32_t>::max()); }
     47
     48        uint32_t m_offset;
     49    };
     50
    4051    class AssemblerBuffer {
    4152        static const int inlineCapacity = 128 - sizeof(char*) - 2 * sizeof(int);
  • trunk/Source/JavaScriptCore/assembler/LinkBuffer.h

    r85403 r85432  
    6161    typedef MacroAssembler::DataLabel32 DataLabel32;
    6262    typedef MacroAssembler::DataLabelPtr DataLabelPtr;
    63     typedef MacroAssembler::JmpDst JmpDst;
    6463#if ENABLE(BRANCH_COMPACTION)
    6564    typedef MacroAssembler::LinkRecord LinkRecord;
     
    120119    void patch(DataLabelPtr label, void* value)
    121120    {
    122         JmpDst target = applyOffset(label.m_label);
     121        AssemblerLabel target = applyOffset(label.m_label);
    123122        MacroAssembler::linkPointer(code(), target, value);
    124123    }
     
    126125    void patch(DataLabelPtr label, CodeLocationLabel value)
    127126    {
    128         JmpDst target = applyOffset(label.m_label);
     127        AssemblerLabel target = applyOffset(label.m_label);
    129128        MacroAssembler::linkPointer(code(), target, value.executableAddress());
    130129    }
  • trunk/Source/JavaScriptCore/assembler/MIPSAssembler.h

    r85429 r85432  
    167167    };
    168168
    169     class JmpSrc {
    170         friend class MIPSAssembler;
    171     public:
    172         JmpSrc()
    173             : m_offset(-1)
    174         {
    175         }
    176 
    177     private:
    178         JmpSrc(int offset)
    179             : m_offset(offset)
    180         {
    181         }
    182 
    183         int m_offset;
    184     };
    185 
    186     class JmpDst {
    187         friend class MIPSAssembler;
    188     public:
    189         JmpDst()
    190             : m_offset(-1)
    191             , m_used(false)
    192         {
    193         }
    194 
    195         bool isUsed() const { return m_used; }
    196         bool isSet() const { return (m_offset != -1); }
    197         void used() { m_used = true; }
    198     private:
    199         JmpDst(int offset)
    200             : m_offset(offset)
    201             , m_used(false)
    202         {
    203             ASSERT(m_offset == offset);
    204         }
    205 
    206         int m_offset : 31;
    207         int m_used : 1;
    208     };
    209 
    210169    void emitInst(MIPSWord op)
    211170    {
     
    503462    }
    504463
    505     JmpSrc newJmpSrc()
    506     {
    507         return JmpSrc(m_buffer.label());
    508     }
    509 
    510464    void appendJump()
    511465    {
     
    662616    // General helpers
    663617
    664     JmpDst label()
    665     {
    666         return JmpDst(m_buffer.label());
    667     }
    668 
    669     JmpDst align(int alignment)
     618    AssemblerLabel label()
     619    {
     620        return AssemblerLabel(m_buffer.label());
     621    }
     622
     623    AssemblerLabel align(int alignment)
    670624    {
    671625        while (!m_buffer.isAligned(alignment))
     
    675629    }
    676630
    677     static void* getRelocatedAddress(void* code, JmpSrc jump)
    678     {
    679         ASSERT(jump.m_offset != -1);
    680         void* b = reinterpret_cast<void*>((reinterpret_cast<intptr_t>(code)) + jump.m_offset);
    681         return b;
    682     }
    683 
    684     static void* getRelocatedAddress(void* code, JmpDst label)
    685     {
    686         void* b = reinterpret_cast<void*>((reinterpret_cast<intptr_t>(code)) + label.m_offset);
    687         return b;
    688     }
    689 
    690     static int getDifferenceBetweenLabels(JmpDst from, JmpDst to)
    691     {
    692         return to.m_offset - from.m_offset;
    693     }
    694 
    695     static int getDifferenceBetweenLabels(JmpDst from, JmpSrc to)
    696     {
    697         return to.m_offset - from.m_offset;
    698     }
    699 
    700     static int getDifferenceBetweenLabels(JmpSrc from, JmpDst to)
    701     {
    702         return to.m_offset - from.m_offset;
     631    static void* getRelocatedAddress(void* code, AssemblerLabel label)
     632    {
     633        return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset);
     634    }
     635
     636    static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
     637    {
     638        return b.m_offset - a.m_offset;
    703639    }
    704640
     
    724660#endif
    725661
    726     static unsigned getCallReturnOffset(JmpSrc call)
     662    static unsigned getCallReturnOffset(AssemblerLabel call)
    727663    {
    728664        // The return address is after a call and a delay slot instruction
     
    738674    // pool the 'repatch' and 'relink' methods should be used.
    739675
    740     void linkJump(JmpSrc from, JmpDst to)
    741     {
    742         ASSERT(to.m_offset != -1);
    743         ASSERT(from.m_offset != -1);
     676    void linkJump(AssemblerLabel from, AssemblerLabel to)
     677    {
     678        ASSERT(to.isSet());
     679        ASSERT(from.isSet());
    744680        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(m_buffer.data()) + from.m_offset);
    745681        MIPSWord* toPos = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(m_buffer.data()) + to.m_offset);
     
    750686    }
    751687
    752     static void linkJump(void* code, JmpSrc from, void* to)
    753     {
    754         ASSERT(from.m_offset != -1);
     688    static void linkJump(void* code, AssemblerLabel from, void* to)
     689    {
     690        ASSERT(from.isSet());
    755691        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
    756692
     
    760696    }
    761697
    762     static void linkCall(void* code, JmpSrc from, void* to)
     698    static void linkCall(void* code, AssemblerLabel from, void* to)
    763699    {
    764700        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
     
    766702    }
    767703
    768     static void linkPointer(void* code, JmpDst from, void* to)
     704    static void linkPointer(void* code, AssemblerLabel from, void* to)
    769705    {
    770706        MIPSWord* insn = reinterpret_cast<MIPSWord*>(reinterpret_cast<intptr_t>(code) + from.m_offset);
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r84399 r85432  
    674674            unordered.link(this);
    675675            // We get here if either unordered or equal.
    676             Jump result = makeJump();
     676            Jump result = jump();
    677677            notEqual.link(this);
    678678            return result;
     
    722722        unordered.link(this);
    723723        // We get here if either unordered or equal.
    724         Jump result = makeJump();
     724        Jump result = jump();
    725725        notEqual.link(this);
    726726        return result;
     
    996996    }
    997997
    998     Jump jump()
    999     {
    1000         return Jump(makeJump());
    1001     }
    1002 
    1003998    void jump(RegisterID target)
    1004999    {
    1005         m_assembler.bx(target, ARMv7Assembler::JumpFixed);
     1000        m_assembler.bx(target);
    10061001    }
    10071002
     
    10101005    {
    10111006        load32(address, dataTempRegister);
    1012         m_assembler.bx(dataTempRegister, ARMv7Assembler::JumpFixed);
     1007        m_assembler.bx(dataTempRegister);
    10131008    }
    10141009
     
    11121107    {
    11131108        moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    1114         return Call(m_assembler.blx(dataTempRegister, ARMv7Assembler::JumpFixed), Call::LinkableNear);
     1109        return Call(m_assembler.blx(dataTempRegister), Call::LinkableNear);
    11151110    }
    11161111
     
    11181113    {
    11191114        moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    1120         return Call(m_assembler.blx(dataTempRegister, ARMv7Assembler::JumpFixed), Call::Linkable);
     1115        return Call(m_assembler.blx(dataTempRegister), Call::Linkable);
    11211116    }
    11221117
    11231118    Call call(RegisterID target)
    11241119    {
    1125         return Call(m_assembler.blx(target, ARMv7Assembler::JumpFixed), Call::None);
     1120        return Call(m_assembler.blx(target), Call::None);
    11261121    }
    11271122
     
    11291124    {
    11301125        load32(address, dataTempRegister);
    1131         return Call(m_assembler.blx(dataTempRegister, ARMv7Assembler::JumpFixed), Call::None);
     1126        return Call(m_assembler.blx(dataTempRegister), Call::None);
    11321127    }
    11331128
    11341129    void ret()
    11351130    {
    1136         m_assembler.bx(linkRegister, ARMv7Assembler::JumpFixed);
     1131        m_assembler.bx(linkRegister);
    11371132    }
    11381133
     
    12191214        // Like a normal call, but don't link.
    12201215        moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    1221         return Call(m_assembler.bx(dataTempRegister, ARMv7Assembler::JumpFixed), Call::Linkable);
     1216        return Call(m_assembler.bx(dataTempRegister), Call::Linkable);
    12221217    }
    12231218
     
    12401235    }
    12411236
    1242     ARMv7Assembler::JmpSrc makeJump()
     1237    Jump jump()
    12431238    {
    12441239        moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    1245         return m_assembler.bx(dataTempRegister, inUninterruptedSequence() ? ARMv7Assembler::JumpNoConditionFixedSize : ARMv7Assembler::JumpNoCondition);
    1246     }
    1247 
    1248     ARMv7Assembler::JmpSrc makeBranch(ARMv7Assembler::Condition cond)
     1240        return Jump(m_assembler.bx(dataTempRegister), inUninterruptedSequence() ? ARMv7Assembler::JumpNoConditionFixedSize : ARMv7Assembler::JumpNoCondition);
     1241    }
     1242
     1243    Jump makeBranch(ARMv7Assembler::Condition cond)
    12491244    {
    12501245        m_assembler.it(cond, true, true);
    12511246        moveFixedWidthEncoding(TrustedImm32(0), dataTempRegister);
    1252         return m_assembler.bx(dataTempRegister, inUninterruptedSequence() ? ARMv7Assembler::JumpConditionFixedSize : ARMv7Assembler::JumpCondition, cond);
    1253     }
    1254     ARMv7Assembler::JmpSrc makeBranch(RelationalCondition cond) { return makeBranch(armV7Condition(cond)); }
    1255     ARMv7Assembler::JmpSrc makeBranch(ResultCondition cond) { return makeBranch(armV7Condition(cond)); }
    1256     ARMv7Assembler::JmpSrc makeBranch(DoubleCondition cond) { return makeBranch(armV7Condition(cond)); }
     1247        return Jump(m_assembler.bx(dataTempRegister), inUninterruptedSequence() ? ARMv7Assembler::JumpConditionFixedSize : ARMv7Assembler::JumpCondition, cond);
     1248    }
     1249    Jump makeBranch(RelationalCondition cond) { return makeBranch(armV7Condition(cond)); }
     1250    Jump makeBranch(ResultCondition cond) { return makeBranch(armV7Condition(cond)); }
     1251    Jump makeBranch(DoubleCondition cond) { return makeBranch(armV7Condition(cond)); }
    12571252
    12581253    ArmAddress setupArmAddress(BaseIndex address)
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h

    r85429 r85432  
    12911291        m_assembler.jal();
    12921292        m_assembler.nop();
    1293         return Call(m_assembler.newJmpSrc(), Call::LinkableNear);
     1293        return Call(m_assembler.label(), Call::LinkableNear);
    12941294    }
    12951295
     
    13001300        m_assembler.jalr(MIPSRegisters::t9);
    13011301        m_assembler.nop();
    1302         return Call(m_assembler.newJmpSrc(), Call::Linkable);
     1302        return Call(m_assembler.label(), Call::Linkable);
    13031303    }
    13041304
     
    13071307        m_assembler.jalr(target);
    13081308        m_assembler.nop();
    1309         return Call(m_assembler.newJmpSrc(), Call::None);
     1309        return Call(m_assembler.label(), Call::None);
    13101310    }
    13111311
     
    13171317        m_assembler.nop();
    13181318        m_fixedWidth = false;
    1319         return Call(m_assembler.newJmpSrc(), Call::None);
     1319        return Call(m_assembler.label(), Call::None);
    13201320    }
    13211321
     
    14621462        m_assembler.nop();
    14631463        m_fixedWidth = false;
    1464         return Call(m_assembler.newJmpSrc(), Call::Linkable);
     1464        return Call(m_assembler.label(), Call::Linkable);
    14651465    }
    14661466
     
    16261626        m_assembler.nop();
    16271627        insertRelaxationWords();
    1628         return Jump(m_assembler.newJmpSrc());
     1628        return Jump(m_assembler.label());
    16291629    }
    16301630
     
    16351635        m_assembler.nop();
    16361636        insertRelaxationWords();
    1637         return Jump(m_assembler.newJmpSrc());
     1637        return Jump(m_assembler.label());
    16381638    }
    16391639
     
    16441644        m_assembler.nop();
    16451645        insertRelaxationWords();
    1646         return Jump(m_assembler.newJmpSrc());
     1646        return Jump(m_assembler.label());
    16471647    }
    16481648
     
    16531653        m_assembler.nop();
    16541654        insertRelaxationWords();
    1655         return Jump(m_assembler.newJmpSrc());
     1655        return Jump(m_assembler.label());
    16561656    }
    16571657
  • trunk/Source/JavaScriptCore/assembler/SH4Assembler.h

    r85403 r85432  
    352352    // Opaque label types
    353353public:
    354     class JmpSrc {
    355         friend class SH4Assembler;
    356     public:
    357         JmpSrc()
    358             : m_offset(-1)
    359         {
    360         }
    361 
    362     private:
    363         JmpSrc(int offset)
    364             : m_offset(offset)
    365         {
    366         }
    367 
    368         int m_offset;
    369     };
    370 
    371     class JmpDst {
    372         friend class SH4Assembler;
    373     public:
    374         JmpDst()
    375             : m_offset(-1)
    376             , m_used(false)
    377         {
    378         }
    379 
    380         bool isUsed() const { return m_used; }
    381         bool isSet() const { return (m_offset != -1); }
    382         void used() { m_used = true; }
    383 
    384     private:
    385         JmpDst(int offset)
    386             : m_offset(offset)
    387             , m_used(false)
    388         {
    389             ASSERT(m_offset == offset);
    390         }
    391 
    392         int m_offset : 31;
    393         int m_used : 1;
    394     };
    395 
    396354    bool isImmediate(int constant)
    397355    {
     
    11851143    // Flow control
    11861144
    1187     JmpSrc call()
     1145    AssemblerLabel call()
    11881146    {
    11891147        RegisterID scr = claimScratch();
     
    11931151        nop();
    11941152        releaseScratch(scr);
    1195         return JmpSrc(m_buffer.label());
    1196     }
    1197 
    1198     JmpSrc call(RegisterID dst)
     1153        return AssemblerLabel(m_buffer.label());
     1154    }
     1155
     1156    AssemblerLabel call(RegisterID dst)
    11991157    {
    12001158        m_buffer.ensureSpace(maxInstructionSize + 2);
    12011159        branch(JSR_OPCODE, dst);
    12021160        nop();
    1203         return JmpSrc(m_buffer.label());
    1204     }
    1205 
    1206     JmpSrc jmp()
     1161        return AssemblerLabel(m_buffer.label());
     1162    }
     1163
     1164    AssemblerLabel jmp()
    12071165    {
    12081166        RegisterID scr = claimScratch();
     
    12131171        nop();
    12141172        releaseScratch(scr);
    1215         return JmpSrc(m_size);
    1216     }
    1217 
    1218     JmpSrc jmp(RegisterID dst)
     1173        return AssemblerLabel(m_size);
     1174    }
     1175
     1176    AssemblerLabel jmp(RegisterID dst)
    12191177    {
    12201178        jmpReg(dst);
    1221         return JmpSrc(m_buffer.label());
     1179        return AssemblerLabel(m_buffer.label());
    12221180    }
    12231181
     
    12291187    }
    12301188
    1231     JmpSrc jne()
     1189    AssemblerLabel jne()
    12321190    {
    12331191        int m_size = m_buffer.label();
    12341192        branch(BF_OPCODE, 0);
    1235         return JmpSrc(m_size);
    1236     }
    1237 
    1238     JmpSrc je()
     1193        return AssemblerLabel(m_size);
     1194    }
     1195
     1196    AssemblerLabel je()
    12391197    {
    12401198        int m_size = m_buffer.label();
    12411199        branch(BT_OPCODE, 0);
    1242         return JmpSrc(m_size);
     1200        return AssemblerLabel(m_size);
    12431201    }
    12441202
     
    12491207    }
    12501208
    1251     JmpDst label()
     1209    AssemblerLabel label()
    12521210    {
    12531211        m_buffer.ensureSpaceForAnyOneInstruction();
    1254         return JmpDst(m_buffer.label());
     1212        return AssemblerLabel(m_buffer.label());
    12551213    }
    12561214
     
    12601218    }
    12611219
    1262     JmpDst align(int alignment)
     1220    AssemblerLabel align(int alignment)
    12631221    {
    12641222        m_buffer.ensureSpace(maxInstructionSize + 2);
     
    12811239    }
    12821240
    1283     static void linkJump(void* code, JmpSrc from, void* to)
    1284     {
    1285         ASSERT(from.m_offset != -1);
     1241    static void linkJump(void* code, AssemblerLabel from, void* to)
     1242    {
     1243        ASSERT(from.isSet());
    12861244
    12871245        uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset);
     
    13231281    }
    13241282
    1325     static void linkCall(void* code, JmpSrc from, void* to)
     1283    static void linkCall(void* code, AssemblerLabel from, void* to)
    13261284    {
    13271285        uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset);
     
    13301288    }
    13311289
    1332     static void linkPointer(void* code, JmpDst where, void* value)
     1290    static void linkPointer(void* code, AssemblerLabel where, void* value)
    13331291    {
    13341292        uint16_t* instructionPtr = getInstructionPtr(code, where.m_offset);
     
    13361294    }
    13371295
    1338     static unsigned getCallReturnOffset(JmpSrc call)
    1339     {
    1340         ASSERT(call.m_offset >= 0);
     1296    static unsigned getCallReturnOffset(AssemblerLabel call)
     1297    {
     1298        ASSERT(call.isSet());
    13411299        return call.m_offset;
    13421300    }
     
    14331391    // Linking & patching
    14341392
    1435     void linkJump(JmpSrc from, JmpDst to)
    1436     {
    1437         ASSERT(to.m_offset != -1);
    1438         ASSERT(from.m_offset != -1);
     1393    void linkJump(AssemblerLabel from, AssemblerLabel to)
     1394    {
     1395        ASSERT(to.isSet());
     1396        ASSERT(from.isSet());
    14391397
    14401398        uint16_t* instructionPtr = getInstructionPtr(data(), from.m_offset);
     
    14871445    }
    14881446
    1489     static void* getRelocatedAddress(void* code, JmpSrc jump)
    1490     {
    1491         return reinterpret_cast<void*>(reinterpret_cast<uint32_t>(code) + jump.m_offset);
    1492     }
    1493 
    1494     static void* getRelocatedAddress(void* code, JmpDst destination)
    1495     {
    1496         ASSERT(destination.m_offset != -1);
    1497         return reinterpret_cast<void*>(reinterpret_cast<uint32_t>(code) + destination.m_offset);
    1498     }
    1499 
    1500     static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst)
    1501     {
    1502         return dst.m_offset - src.m_offset;
    1503     }
    1504 
    1505     static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst)
    1506     {
    1507         return dst.m_offset - src.m_offset;
    1508     }
    1509 
    1510     static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst)
    1511     {
    1512         return dst.m_offset - src.m_offset;
    1513     }
    1514 
    1515     static void patchPointer(void* code, JmpDst where, void* value)
     1447    static void* getRelocatedAddress(void* code, AssemblerLabel label)
     1448    {
     1449        return reinterpret_cast<void*>(reinterpret_cast<char*>(code) + label.m_offset);
     1450    }
     1451
     1452    static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
     1453    {
     1454        return b.m_offset - a.m_offset;
     1455    }
     1456
     1457    static void patchPointer(void* code, AssemblerLabel where, void* value)
    15161458    {
    15171459        patchPointer(reinterpret_cast<uint32_t*>(code) + where.m_offset, value);
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r85403 r85432  
    221221public:
    222222
    223     class JmpSrc {
    224         friend class X86Assembler;
    225         friend class X86InstructionFormatter;
    226     public:
    227         JmpSrc()
    228             : m_offset(-1)
    229         {
    230         }
    231 
    232         bool isSet() const { return (m_offset != -1); }
    233 
    234     private:
    235         JmpSrc(int offset)
    236             : m_offset(offset)
    237         {
    238         }
    239 
    240         int m_offset;
    241     };
    242    
    243     class JmpDst {
    244         friend class X86Assembler;
    245         friend class X86InstructionFormatter;
    246     public:
    247         JmpDst()
    248             : m_offset(-1)
    249             , m_used(false)
    250         {
    251         }
    252 
    253         bool isUsed() const { return m_used; }
    254         bool isSet() const { return (m_offset != -1); }
    255         void used() { m_used = true; }
    256     private:
    257         JmpDst(int offset)
    258             : m_offset(offset)
    259             , m_used(false)
    260         {
    261             ASSERT(m_offset == offset);
    262         }
    263 
    264         int m_offset : 31;
    265         bool m_used : 1;
    266     };
    267 
    268223    X86Assembler()
    269224    {
     
    12141169    // Flow control:
    12151170
    1216     JmpSrc call()
     1171    AssemblerLabel call()
    12171172    {
    12181173        m_formatter.oneByteOp(OP_CALL_rel32);
     
    12201175    }
    12211176   
    1222     JmpSrc call(RegisterID dst)
     1177    AssemblerLabel call(RegisterID dst)
    12231178    {
    12241179        m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_CALLN, dst);
    1225         return JmpSrc(m_formatter.label());
     1180        return AssemblerLabel(m_formatter.label());
    12261181    }
    12271182   
     
    12311186    }
    12321187
    1233     JmpSrc jmp()
     1188    AssemblerLabel jmp()
    12341189    {
    12351190        m_formatter.oneByteOp(OP_JMP_rel32);
     
    12371192    }
    12381193   
    1239     // Return a JmpSrc so we have a label to the jump, so we can use this
     1194    // Return a AssemblerLabel so we have a label to the jump, so we can use this
    12401195    // To make a tail recursive call on x86-64.  The MacroAssembler
    12411196    // really shouldn't wrap this as a Jump, since it can't be linked. :-/
    1242     JmpSrc jmp_r(RegisterID dst)
     1197    AssemblerLabel jmp_r(RegisterID dst)
    12431198    {
    12441199        m_formatter.oneByteOp(OP_GROUP5_Ev, GROUP5_OP_JMPN, dst);
    1245         return JmpSrc(m_formatter.label());
     1200        return AssemblerLabel(m_formatter.label());
    12461201    }
    12471202   
     
    12511206    }
    12521207
    1253     JmpSrc jne()
     1208    AssemblerLabel jne()
    12541209    {
    12551210        m_formatter.twoByteOp(jccRel32(ConditionNE));
     
    12571212    }
    12581213   
    1259     JmpSrc jnz()
     1214    AssemblerLabel jnz()
    12601215    {
    12611216        return jne();
    12621217    }
    12631218
    1264     JmpSrc je()
     1219    AssemblerLabel je()
    12651220    {
    12661221        m_formatter.twoByteOp(jccRel32(ConditionE));
     
    12681223    }
    12691224   
    1270     JmpSrc jz()
     1225    AssemblerLabel jz()
    12711226    {
    12721227        return je();
    12731228    }
    12741229
    1275     JmpSrc jl()
     1230    AssemblerLabel jl()
    12761231    {
    12771232        m_formatter.twoByteOp(jccRel32(ConditionL));
     
    12791234    }
    12801235   
    1281     JmpSrc jb()
     1236    AssemblerLabel jb()
    12821237    {
    12831238        m_formatter.twoByteOp(jccRel32(ConditionB));
     
    12851240    }
    12861241   
    1287     JmpSrc jle()
     1242    AssemblerLabel jle()
    12881243    {
    12891244        m_formatter.twoByteOp(jccRel32(ConditionLE));
     
    12911246    }
    12921247   
    1293     JmpSrc jbe()
     1248    AssemblerLabel jbe()
    12941249    {
    12951250        m_formatter.twoByteOp(jccRel32(ConditionBE));
     
    12971252    }
    12981253   
    1299     JmpSrc jge()
     1254    AssemblerLabel jge()
    13001255    {
    13011256        m_formatter.twoByteOp(jccRel32(ConditionGE));
     
    13031258    }
    13041259
    1305     JmpSrc jg()
     1260    AssemblerLabel jg()
    13061261    {
    13071262        m_formatter.twoByteOp(jccRel32(ConditionG));
     
    13091264    }
    13101265
    1311     JmpSrc ja()
     1266    AssemblerLabel ja()
    13121267    {
    13131268        m_formatter.twoByteOp(jccRel32(ConditionA));
     
    13151270    }
    13161271   
    1317     JmpSrc jae()
     1272    AssemblerLabel jae()
    13181273    {
    13191274        m_formatter.twoByteOp(jccRel32(ConditionAE));
     
    13211276    }
    13221277   
    1323     JmpSrc jo()
     1278    AssemblerLabel jo()
    13241279    {
    13251280        m_formatter.twoByteOp(jccRel32(ConditionO));
     
    13271282    }
    13281283
    1329     JmpSrc jp()
     1284    AssemblerLabel jp()
    13301285    {
    13311286        m_formatter.twoByteOp(jccRel32(ConditionP));
     
    13331288    }
    13341289   
    1335     JmpSrc js()
     1290    AssemblerLabel js()
    13361291    {
    13371292        m_formatter.twoByteOp(jccRel32(ConditionS));
     
    13391294    }
    13401295
    1341     JmpSrc jCC(Condition cond)
     1296    AssemblerLabel jCC(Condition cond)
    13421297    {
    13431298        m_formatter.twoByteOp(jccRel32(cond));
     
    15221477    }
    15231478
    1524     JmpDst label()
    1525     {
    1526         return JmpDst(m_formatter.label());
    1527     }
    1528    
    1529     static JmpDst labelFor(JmpSrc jump, intptr_t offset = 0)
    1530     {
    1531         return JmpDst(jump.m_offset + offset);
    1532     }
    1533    
    1534     JmpDst align(int alignment)
     1479    AssemblerLabel label()
     1480    {
     1481        return AssemblerLabel(m_formatter.label());
     1482    }
     1483   
     1484    static AssemblerLabel labelFor(AssemblerLabel jump, intptr_t offset = 0)
     1485    {
     1486        return AssemblerLabel(jump.m_offset + offset);
     1487    }
     1488   
     1489    AssemblerLabel align(int alignment)
    15351490    {
    15361491        while (!m_formatter.isAligned(alignment))
     
    15481503    // pool the 'repatch' and 'relink' methods should be used.
    15491504
    1550     void linkJump(JmpSrc from, JmpDst to)
    1551     {
    1552         ASSERT(from.m_offset != -1);
    1553         ASSERT(to.m_offset != -1);
     1505    void linkJump(AssemblerLabel from, AssemblerLabel to)
     1506    {
     1507        ASSERT(from.isSet());
     1508        ASSERT(to.isSet());
    15541509
    15551510        char* code = reinterpret_cast<char*>(m_formatter.data());
     
    15581513    }
    15591514   
    1560     static void linkJump(void* code, JmpSrc from, void* to)
    1561     {
    1562         ASSERT(from.m_offset != -1);
     1515    static void linkJump(void* code, AssemblerLabel from, void* to)
     1516    {
     1517        ASSERT(from.isSet());
    15631518
    15641519        setRel32(reinterpret_cast<char*>(code) + from.m_offset, to);
    15651520    }
    15661521
    1567     static void linkCall(void* code, JmpSrc from, void* to)
    1568     {
    1569         ASSERT(from.m_offset != -1);
     1522    static void linkCall(void* code, AssemblerLabel from, void* to)
     1523    {
     1524        ASSERT(from.isSet());
    15701525
    15711526        setRel32(reinterpret_cast<char*>(code) + from.m_offset, to);
    15721527    }
    15731528
    1574     static void linkPointer(void* code, JmpDst where, void* value)
    1575     {
    1576         ASSERT(where.m_offset != -1);
     1529    static void linkPointer(void* code, AssemblerLabel where, void* value)
     1530    {
     1531        ASSERT(where.isSet());
    15771532
    15781533        setPointer(reinterpret_cast<char*>(code) + where.m_offset, value);
     
    15991554    }
    16001555
    1601     static unsigned getCallReturnOffset(JmpSrc call)
    1602     {
    1603         ASSERT(call.m_offset >= 0);
     1556    static unsigned getCallReturnOffset(AssemblerLabel call)
     1557    {
     1558        ASSERT(call.isSet());
    16041559        return call.m_offset;
    16051560    }
    16061561
    1607     static void* getRelocatedAddress(void* code, JmpSrc jump)
    1608     {
    1609         ASSERT(jump.m_offset != -1);
    1610 
    1611         return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + jump.m_offset);
    1612     }
    1613    
    1614     static void* getRelocatedAddress(void* code, JmpDst destination)
    1615     {
    1616         ASSERT(destination.m_offset != -1);
    1617 
    1618         return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + destination.m_offset);
    1619     }
    1620    
    1621     static int getDifferenceBetweenLabels(JmpDst src, JmpDst dst)
    1622     {
    1623         return dst.m_offset - src.m_offset;
    1624     }
    1625    
    1626     static int getDifferenceBetweenLabels(JmpDst src, JmpSrc dst)
    1627     {
    1628         return dst.m_offset - src.m_offset;
    1629     }
    1630    
    1631     static int getDifferenceBetweenLabels(JmpSrc src, JmpDst dst)
    1632     {
    1633         return dst.m_offset - src.m_offset;
     1562    static void* getRelocatedAddress(void* code, AssemblerLabel label)
     1563    {
     1564        ASSERT(label.isSet());
     1565        return reinterpret_cast<void*>(reinterpret_cast<ptrdiff_t>(code) + label.m_offset);
     1566    }
     1567   
     1568    static int getDifferenceBetweenLabels(AssemblerLabel a, AssemblerLabel b)
     1569    {
     1570        return b.m_offset - a.m_offset;
    16341571    }
    16351572   
     
    16391576    }
    16401577
    1641     void rewindToLabel(JmpDst rewindTo) { m_formatter.rewindToLabel(rewindTo); }
     1578    void rewindToLabel(AssemblerLabel rewindTo) { m_formatter.rewindToLabel(rewindTo); }
    16421579
    16431580#ifndef NDEBUG
     
    19311868        }
    19321869
    1933         JmpSrc immediateRel32()
     1870        AssemblerLabel immediateRel32()
    19341871        {
    19351872            m_buffer.putIntUnchecked(0);
    1936             return JmpSrc(label());
     1873            return AssemblerLabel(label());
    19371874        }
    19381875
     
    19491886        }
    19501887
    1951         void rewindToLabel(JmpDst rewindTo) { m_buffer.rewindToOffset(rewindTo.m_offset); }
     1888        void rewindToLabel(AssemblerLabel rewindTo) { m_buffer.rewindToOffset(rewindTo.m_offset); }
    19521889
    19531890#ifndef NDEBUG
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r85403 r85432  
    184184
    185185#if USE(JSVALUE64)
    186         if (m_labels[m_bytecodeOffset].isUsed())
     186        if (atJumpTarget())
    187187            killLastResultRegister();
    188188#endif
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r85372 r85432  
    908908        bool isOperandConstantImmediateChar(unsigned src);
    909909
     910        bool atJumpTarget();
     911
    910912        Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
    911913        {
     
    985987#else
    986988        int m_lastResultBytecodeRegister;
     989#endif
    987990        unsigned m_jumpTargetsPosition;
    988 #endif
    989991
    990992#ifndef NDEBUG
  • trunk/Source/JavaScriptCore/jit/JITInlineMethods.h

    r84445 r85432  
    110110}
    111111
     112ALWAYS_INLINE bool JIT::atJumpTarget()
     113{
     114    while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= m_bytecodeOffset) {
     115        if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == m_bytecodeOffset)
     116            return true;
     117        ++m_jumpTargetsPosition;
     118    }
     119    return false;
     120}
     121
    112122#if defined(ASSEMBLER_HAS_CONSTANT_POOL) && ASSEMBLER_HAS_CONSTANT_POOL
    113123
     
    652662    }
    653663
    654     if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src)) {
    655         bool atJumpTarget = false;
    656         while (m_jumpTargetsPosition < m_codeBlock->numberOfJumpTargets() && m_codeBlock->jumpTarget(m_jumpTargetsPosition) <= m_bytecodeOffset) {
    657             if (m_codeBlock->jumpTarget(m_jumpTargetsPosition) == m_bytecodeOffset)
    658                 atJumpTarget = true;
    659             ++m_jumpTargetsPosition;
    660         }
    661 
    662         if (!atJumpTarget) {
    663             // The argument we want is already stored in eax
    664             if (dst != cachedResultRegister)
    665                 move(cachedResultRegister, dst);
    666             killLastResultRegister();
    667             return;
    668         }
     664    if (src == m_lastResultBytecodeRegister && m_codeBlock->isTemporaryRegisterIndex(src) && !atJumpTarget()) {
     665        // The argument we want is already stored in eax
     666        if (dst != cachedResultRegister)
     667            move(cachedResultRegister, dst);
     668        killLastResultRegister();
     669        return;
    669670    }
    670671
  • trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp

    r85403 r85432  
    4242#if USE(JSVALUE64)
    4343
    44 #define RECORD_JUMP_TARGET(targetOffset) \
    45    do { m_labels[m_bytecodeOffset + (targetOffset)].used(); } while (false)
    46 
    4744void JIT::privateCompileCTIMachineTrampolines(RefPtr<ExecutablePool>* executablePool, JSGlobalData* globalData, TrampolineStructure *trampolines)
    4845{
     
    341338    unsigned target = currentInstruction[1].u.operand;
    342339    addJump(jump(), target);
    343     RECORD_JUMP_TARGET(target);
    344340}
    345341
     
    719715
    720716    isNonZero.link(this);
    721     RECORD_JUMP_TARGET(target);
    722717}
    723718
     
    741736
    742737    wasNotImmediate.link(this);
    743     RECORD_JUMP_TARGET(target);
    744738};
    745739void JIT::emit_op_jneq_null(Instruction* currentInstruction)
     
    762756
    763757    wasNotImmediate.link(this);
    764     RECORD_JUMP_TARGET(target);
    765758}
    766759
     
    773766    emitGetVirtualRegister(src, regT0);
    774767    addJump(branchPtr(NotEqual, regT0, TrustedImmPtr(JSValue::encode(JSValue(ptr)))), target);           
    775 
    776     RECORD_JUMP_TARGET(target);
    777768}
    778769
     
    785776    m_jsrSites.append(JSRInfo(storeLocation, label()));
    786777    killLastResultRegister();
    787     RECORD_JUMP_TARGET(target);
    788778}
    789779
     
    839829
    840830    isZero.link(this);
    841     RECORD_JUMP_TARGET(target);
    842831}
    843832
     
    10771066    stubCall.call();
    10781067    addJump(jump(), currentInstruction[2].u.operand);
    1079     RECORD_JUMP_TARGET(currentInstruction[2].u.operand);
    10801068}
    10811069
Note: See TracChangeset for help on using the changeset viewer.