Ignore:
Timestamp:
Jul 3, 2011, 10:59:03 PM (14 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=63879
Reduce code duplication for op_jless, op_jlesseq, op_jnless, op_jnlesseq.

Reviewed by Sam Weinig.

There is a lot of copy & paste code here; we can reduce duplication by making
a shared implementation.

  • assembler/MacroAssembler.h:

(JSC::MacroAssembler::branch32):
(JSC::MacroAssembler::commute):

  • Make these function platform agnostic.
  • assembler/MacroAssemblerX86Common.h:
    • Moved branch32/commute up to MacroAssembler.
  • jit/JIT.h:

(JSC::JIT::emit_op_loop_if_lesseq):
(JSC::JIT::emitSlow_op_loop_if_lesseq):

  • Add an implementation matching that for op_loop_if_less, which just calls op_jless.
  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_jless):
(JSC::JIT::emit_op_jlesseq):
(JSC::JIT::emit_op_jnless):
(JSC::JIT::emit_op_jnlesseq):
(JSC::JIT::emitSlow_op_jless):
(JSC::JIT::emitSlow_op_jlesseq):
(JSC::JIT::emitSlow_op_jnless):
(JSC::JIT::emitSlow_op_jnlesseq):

  • Common implmentations of these methods for JSVALUE64 & JSVALUE32_64.

(JSC::JIT::emit_compareAndJump):
(JSC::JIT::emit_compareAndJumpSlow):

  • Internal implmementation of jless etc for JSVALUE64.
  • jit/JITArithmetic32_64.cpp:

(JSC::JIT::emit_compareAndJump):
(JSC::JIT::emit_compareAndJumpSlow):

  • Internal implmementation of jless etc for JSVALUE32_64.
  • jit/JITOpcodes.cpp:
  • jit/JITOpcodes32_64.cpp:
  • jit/JITStubs.cpp:
  • jit/JITStubs.h:
    • Remove old implementation of emit_op_loop_if_lesseq.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r90237 r90352  
    845845    }
    846846   
    847     Jump branch32(RelationalCondition cond, TrustedImm32 left, RegisterID right)
    848     {
    849         if (((cond == Equal) || (cond == NotEqual)) && !left.m_value)
    850             m_assembler.testl_rr(right, right);
    851         else
    852             m_assembler.cmpl_ir(left.m_value, right);
    853         return Jump(m_assembler.jCC(x86Condition(commute(cond))));
    854     }
    855    
    856847    Jump branch32(RelationalCondition cond, RegisterID left, Address right)
    857848    {
     
    12021193    }
    12031194
    1204     // Commute a relational condition, returns a new condition that will produce
    1205     // the same results given the same inputs but with their positions exchanged.
    1206     static RelationalCondition commute(RelationalCondition cond)
    1207     {
    1208         // Equality is commutative!
    1209         if (cond == Equal || cond == NotEqual)
    1210             return cond;
    1211 
    1212         // Based on the values of x86 condition codes, remap > with < and >= with <=
    1213         if (cond >= LessThan) {
    1214             ASSERT(cond == LessThan || cond == LessThanOrEqual || cond == GreaterThan || cond == GreaterThanOrEqual);
    1215             return static_cast<RelationalCondition>(X86Assembler::ConditionL + X86Assembler::ConditionG - cond);
    1216         }
    1217 
    1218         // As above, for unsigned conditions.
    1219         ASSERT(cond == Below || cond == BelowOrEqual || cond == Above || cond == AboveOrEqual);
    1220         return static_cast<RelationalCondition>(X86Assembler::ConditionB + X86Assembler::ConditionA - cond);
    1221     }
    1222    
    12231195    void nop()
    12241196    {
Note: See TracChangeset for help on using the changeset viewer.