Ignore:
Timestamp:
May 11, 2009, 6:06:58 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-11 Sam Weinig <[email protected]>

Reviewed by Geoffrey Garen.

Start re-factoring JIT code generation to move op_code generation
to helper functions outside the main switch-statement and gave those
helper functions standardized names. This patch only covers the main
pass and all the arithmetic opcodes in the slow path.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases):
  • jit/JIT.h:
  • jit/JITArithmetic.cpp:
  • jit/JITOpcodes.cpp: Copied from jit/JIT.cpp.
  • jit/JITPropertyAccess.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITArithmetic.cpp

    r43441 r43531  
    9494namespace JSC {
    9595
    96 void JIT::compileFastArith_op_lshift(unsigned result, unsigned op1, unsigned op2)
    97 {
     96void JIT::emit_op_lshift(Instruction* currentInstruction)
     97{
     98    unsigned result = currentInstruction[1].u.operand;
     99    unsigned op1 = currentInstruction[2].u.operand;
     100    unsigned op2 = currentInstruction[3].u.operand;
     101
    98102    emitGetVirtualRegisters(op1, regT0, op2, regT2);
    99103    // FIXME: would we be better using 'emitJumpSlowCaseIfNotImmediateIntegers'? - we *probably* ought to be consistent.
     
    115119    emitPutVirtualRegister(result);
    116120}
    117 void JIT::compileFastArithSlow_op_lshift(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator& iter)
    118 {
     121void JIT::emitSlow_op_lshift(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     122{
     123    unsigned result = currentInstruction[1].u.operand;
     124    unsigned op1 = currentInstruction[2].u.operand;
     125    unsigned op2 = currentInstruction[3].u.operand;
     126
    119127#if USE(ALTERNATE_JSIMMEDIATE)
    120128    UNUSED_PARAM(op1);
     
    137145}
    138146
    139 void JIT::compileFastArith_op_rshift(unsigned result, unsigned op1, unsigned op2)
    140 {
     147void JIT::emit_op_rshift(Instruction* currentInstruction)
     148{
     149    unsigned result = currentInstruction[1].u.operand;
     150    unsigned op1 = currentInstruction[2].u.operand;
     151    unsigned op2 = currentInstruction[3].u.operand;
     152
    141153    if (isOperandConstantImmediateInt(op2)) {
    142154        emitGetVirtualRegister(op1, regT0);
     
    190202}
    191203
    192 void JIT::compileFastArithSlow_op_rshift(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator& iter)
    193 {
     204void JIT::emitSlow_op_rshift(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     205{
     206    unsigned result = currentInstruction[1].u.operand;
     207    unsigned op1 = currentInstruction[2].u.operand;
     208    unsigned op2 = currentInstruction[3].u.operand;
     209
    194210    linkSlowCase(iter);
    195211    JITStubCall stubCall(this, JITStubs::cti_op_rshift);
     
    224240}
    225241
    226 void JIT::compileFastArith_op_jnless(unsigned op1, unsigned op2, unsigned target)
    227 {
     242void JIT::emit_op_jnless(Instruction* currentInstruction)
     243{
     244    unsigned op1 = currentInstruction[1].u.operand;
     245    unsigned op2 = currentInstruction[2].u.operand;
     246    unsigned target = currentInstruction[3].u.operand;
     247
    228248    // We generate inline code for the following cases in the fast path:
    229249    // - int immediate to constant int immediate
     
    257277    }
    258278}
    259 void JIT::compileFastArithSlow_op_jnless(unsigned op1, unsigned op2, unsigned target, Vector<SlowCaseEntry>::iterator& iter)
    260 {
     279void JIT::emitSlow_op_jnless(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     280{
     281    unsigned op1 = currentInstruction[1].u.operand;
     282    unsigned op2 = currentInstruction[2].u.operand;
     283    unsigned target = currentInstruction[3].u.operand;
     284
    261285    // We generate inline code for the following cases in the slow path:
    262286    // - floating-point number to constant int immediate
     
    403427}
    404428
    405 void JIT::compileFastArith_op_jnlesseq(unsigned op1, unsigned op2, unsigned target)
    406 {
     429void JIT::emit_op_jnlesseq(Instruction* currentInstruction)
     430{
     431    unsigned op1 = currentInstruction[1].u.operand;
     432    unsigned op2 = currentInstruction[2].u.operand;
     433    unsigned target = currentInstruction[3].u.operand;
     434
    407435    // We generate inline code for the following cases in the fast path:
    408436    // - int immediate to constant int immediate
     
    436464    }
    437465}
    438 void JIT::compileFastArithSlow_op_jnlesseq(unsigned op1, unsigned op2, unsigned target, Vector<SlowCaseEntry>::iterator& iter)
    439 {
     466void JIT::emitSlow_op_jnlesseq(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     467{
     468    unsigned op1 = currentInstruction[1].u.operand;
     469    unsigned op2 = currentInstruction[2].u.operand;
     470    unsigned target = currentInstruction[3].u.operand;
     471
    440472    // We generate inline code for the following cases in the slow path:
    441473    // - floating-point number to constant int immediate
     
    582614}
    583615
    584 void JIT::compileFastArith_op_bitand(unsigned result, unsigned op1, unsigned op2)
    585 {
     616void JIT::emit_op_bitand(Instruction* currentInstruction)
     617{
     618    unsigned result = currentInstruction[1].u.operand;
     619    unsigned op1 = currentInstruction[2].u.operand;
     620    unsigned op2 = currentInstruction[3].u.operand;
     621
    586622    if (isOperandConstantImmediateInt(op1)) {
    587623        emitGetVirtualRegister(op2, regT0);
     
    613649    emitPutVirtualRegister(result);
    614650}
    615 void JIT::compileFastArithSlow_op_bitand(unsigned result, unsigned op1, unsigned op2, Vector<SlowCaseEntry>::iterator& iter)
    616 {
     651void JIT::emitSlow_op_bitand(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     652{
     653    unsigned result = currentInstruction[1].u.operand;
     654    unsigned op1 = currentInstruction[2].u.operand;
     655    unsigned op2 = currentInstruction[3].u.operand;
     656
    617657    linkSlowCase(iter);
    618658    if (isOperandConstantImmediateInt(op1)) {
     
    635675
    636676#if PLATFORM(X86) || PLATFORM(X86_64)
    637 void JIT::compileFastArith_op_mod(unsigned result, unsigned op1, unsigned op2)
    638 {
     677void JIT::emit_op_mod(Instruction* currentInstruction)
     678{
     679    unsigned result = currentInstruction[1].u.operand;
     680    unsigned op1 = currentInstruction[2].u.operand;
     681    unsigned op2 = currentInstruction[3].u.operand;
     682
    639683    emitGetVirtualRegisters(op1, X86::eax, op2, X86::ecx);
    640684    emitJumpSlowCaseIfNotImmediateInteger(X86::eax);
     
    654698    emitPutVirtualRegister(result);
    655699}
    656 void JIT::compileFastArithSlow_op_mod(unsigned result, unsigned, unsigned, Vector<SlowCaseEntry>::iterator& iter)
    657 {
     700void JIT::emitSlow_op_mod(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     701{
     702    unsigned result = currentInstruction[1].u.operand;
     703
    658704#if USE(ALTERNATE_JSIMMEDIATE)
    659705    linkSlowCase(iter);
     
    675721}
    676722#else
    677 void JIT::compileFastArith_op_mod(unsigned result, unsigned op1, unsigned op2)
    678 {
     723void JIT::emit_op_mod(Instruction* currentInstruction)
     724{
     725    unsigned result = currentInstruction[1].u.operand;
     726    unsigned op1 = currentInstruction[2].u.operand;
     727    unsigned op2 = currentInstruction[3].u.operand;
     728
    679729    JITStubCall stubCall(this, JITStubs::cti_op_mod);
    680730    stubCall.addArgument(op1, regT2);
     
    682732    stubCall.call(result);
    683733}
    684 void JIT::compileFastArithSlow_op_mod(unsigned, unsigned, unsigned, Vector<SlowCaseEntry>::iterator&)
     734void JIT::emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&)
    685735{
    686736    ASSERT_NOT_REACHED();
     
    688738#endif
    689739
    690 void JIT::compileFastArith_op_post_inc(unsigned result, unsigned srcDst)
    691 {
     740void JIT::emit_op_post_inc(Instruction* currentInstruction)
     741{
     742    unsigned result = currentInstruction[1].u.operand;
     743    unsigned srcDst = currentInstruction[2].u.operand;
     744
    692745    emitGetVirtualRegister(srcDst, regT0);
    693746    move(regT0, regT1);
     
    704757}
    705758
    706 void JIT::compileFastArithSlow_op_post_inc(unsigned result, unsigned srcDst, Vector<SlowCaseEntry>::iterator& iter)
    707 {
     759void JIT::emitSlow_op_post_inc(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     760{
     761    unsigned result = currentInstruction[1].u.operand;
     762    unsigned srcDst = currentInstruction[2].u.operand;
     763
    708764    linkSlowCase(iter);
    709765    linkSlowCase(iter);
     
    714770}
    715771
    716 void JIT::compileFastArith_op_post_dec(unsigned result, unsigned srcDst)
    717 {
     772void JIT::emit_op_post_dec(Instruction* currentInstruction)
     773{
     774    unsigned result = currentInstruction[1].u.operand;
     775    unsigned srcDst = currentInstruction[2].u.operand;
     776
    718777    emitGetVirtualRegister(srcDst, regT0);
    719778    move(regT0, regT1);
     
    729788    emitPutVirtualRegister(result);
    730789}
    731 void JIT::compileFastArithSlow_op_post_dec(unsigned result, unsigned srcDst, Vector<SlowCaseEntry>::iterator& iter)
    732 {
     790void JIT::emitSlow_op_post_dec(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     791{
     792    unsigned result = currentInstruction[1].u.operand;
     793    unsigned srcDst = currentInstruction[2].u.operand;
     794
    733795    linkSlowCase(iter);
    734796    linkSlowCase(iter);
     
    739801}
    740802
    741 void JIT::compileFastArith_op_pre_inc(unsigned srcDst)
    742 {
     803void JIT::emit_op_pre_inc(Instruction* currentInstruction)
     804{
     805    unsigned srcDst = currentInstruction[1].u.operand;
     806
    743807    emitGetVirtualRegister(srcDst, regT0);
    744808    emitJumpSlowCaseIfNotImmediateInteger(regT0);
     
    752816    emitPutVirtualRegister(srcDst);
    753817}
    754 void JIT::compileFastArithSlow_op_pre_inc(unsigned srcDst, Vector<SlowCaseEntry>::iterator& iter)
    755 {
     818void JIT::emitSlow_op_pre_inc(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     819{
     820    unsigned srcDst = currentInstruction[1].u.operand;
     821
    756822    Jump notImm = getSlowCase(iter);
    757823    linkSlowCase(iter);
     
    763829}
    764830
    765 void JIT::compileFastArith_op_pre_dec(unsigned srcDst)
    766 {
     831void JIT::emit_op_pre_dec(Instruction* currentInstruction)
     832{
     833    unsigned srcDst = currentInstruction[1].u.operand;
     834
    767835    emitGetVirtualRegister(srcDst, regT0);
    768836    emitJumpSlowCaseIfNotImmediateInteger(regT0);
     
    776844    emitPutVirtualRegister(srcDst);
    777845}
    778 void JIT::compileFastArithSlow_op_pre_dec(unsigned srcDst, Vector<SlowCaseEntry>::iterator& iter)
    779 {
     846void JIT::emitSlow_op_pre_dec(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     847{
     848    unsigned srcDst = currentInstruction[1].u.operand;
     849
    780850    Jump notImm = getSlowCase(iter);
    781851    linkSlowCase(iter);
     
    790860#if !ENABLE(JIT_OPTIMIZE_ARITHMETIC)
    791861
    792 void JIT::compileFastArith_op_add(Instruction* currentInstruction)
     862void JIT::emit_op_add(Instruction* currentInstruction)
    793863{
    794864    unsigned result = currentInstruction[1].u.operand;
     
    802872}
    803873
    804 void JIT::compileFastArithSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&)
     874void JIT::emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&)
    805875{
    806876    ASSERT_NOT_REACHED();
    807877}
    808878
    809 void JIT::compileFastArith_op_mul(Instruction* currentInstruction)
     879void JIT::emit_op_mul(Instruction* currentInstruction)
    810880{
    811881    unsigned result = currentInstruction[1].u.operand;
     
    819889}
    820890
    821 void JIT::compileFastArithSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&)
     891void JIT::emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&)
    822892{
    823893    ASSERT_NOT_REACHED();
    824894}
    825895
    826 void JIT::compileFastArith_op_sub(Instruction* currentInstruction)
     896void JIT::emit_op_sub(Instruction* currentInstruction)
    827897{
    828898    unsigned result = currentInstruction[1].u.operand;
     
    836906}
    837907
    838 void JIT::compileFastArithSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&)
     908void JIT::emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&)
    839909{
    840910    ASSERT_NOT_REACHED();
     
    917987}
    918988
    919 void JIT::compileFastArith_op_add(Instruction* currentInstruction)
     989void JIT::emit_op_add(Instruction* currentInstruction)
    920990{
    921991    unsigned result = currentInstruction[1].u.operand;
     
    9471017    emitPutVirtualRegister(result);
    9481018}
    949 void JIT::compileFastArithSlow_op_add(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1019void JIT::emitSlow_op_add(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    9501020{
    9511021    unsigned result = currentInstruction[1].u.operand;
     
    9641034}
    9651035
    966 void JIT::compileFastArith_op_mul(Instruction* currentInstruction)
     1036void JIT::emit_op_mul(Instruction* currentInstruction)
    9671037{
    9681038    unsigned result = currentInstruction[1].u.operand;
     
    9881058    emitPutVirtualRegister(result);
    9891059}
    990 void JIT::compileFastArithSlow_op_mul(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1060void JIT::emitSlow_op_mul(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    9911061{
    9921062    unsigned result = currentInstruction[1].u.operand;
     
    10081078}
    10091079
    1010 void JIT::compileFastArith_op_sub(Instruction* currentInstruction)
     1080void JIT::emit_op_sub(Instruction* currentInstruction)
    10111081{
    10121082    unsigned result = currentInstruction[1].u.operand;
     
    10191089    emitPutVirtualRegister(result);
    10201090}
    1021 void JIT::compileFastArithSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1091void JIT::emitSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    10221092{
    10231093    unsigned result = currentInstruction[1].u.operand;
     
    12221292}
    12231293
    1224 void JIT::compileFastArith_op_add(Instruction* currentInstruction)
     1294void JIT::emit_op_add(Instruction* currentInstruction)
    12251295{
    12261296    unsigned result = currentInstruction[1].u.operand;
     
    12531323}
    12541324
    1255 void JIT::compileFastArithSlow_op_add(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1325void JIT::emitSlow_op_add(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    12561326{
    12571327    unsigned result = currentInstruction[1].u.operand;
     
    12841354}
    12851355
    1286 void JIT::compileFastArith_op_mul(Instruction* currentInstruction)
     1356void JIT::emit_op_mul(Instruction* currentInstruction)
    12871357{
    12881358    unsigned result = currentInstruction[1].u.operand;
     
    13111381        compileBinaryArithOp(op_mul, result, op1, op2, OperandTypes::fromInt(currentInstruction[4].u.operand));
    13121382}
    1313 void JIT::compileFastArithSlow_op_mul(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1383
     1384void JIT::emitSlow_op_mul(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    13141385{
    13151386    unsigned result = currentInstruction[1].u.operand;
     
    13301401}
    13311402
    1332 void JIT::compileFastArith_op_sub(Instruction* currentInstruction)
     1403void JIT::emit_op_sub(Instruction* currentInstruction)
    13331404{
    13341405    compileBinaryArithOp(op_sub, currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, OperandTypes::fromInt(currentInstruction[4].u.operand));
    13351406}
    1336 void JIT::compileFastArithSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
     1407void JIT::emitSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    13371408{
    13381409    compileBinaryArithOpSlowCase(op_sub, iter, currentInstruction[1].u.operand, currentInstruction[2].u.operand, currentInstruction[3].u.operand, OperandTypes::fromInt(currentInstruction[4].u.operand));
Note: See TracChangeset for help on using the changeset viewer.