Ignore:
Timestamp:
Jul 24, 2013, 9:02:44 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: The baseline jit and LLint should use common slow paths
https://bugs.webkit.org/show_bug.cgi?id=116889

Reviewed by Filip Pizlo.

Moved the llint_slow_paths that return JSValue along with several others to CommonSlowPaths.cpp.
Eliminated the related JIT stubs. Changes the baseline JIT to call these new common stubs.
Added a simple slow path call class that uses argument registers or the stack instead of
JITStackFrame. Changes the exception mechanism for to check for an exception after making
a slowpath call instead of returning to the handler directly form the slowpath function.

(JSC::JIT::privateCompileMainPass):

  • jit/JIT.h:

(JIT):

  • jit/JITArithmetic.cpp:

(JSC::JIT::emitSlow_op_negate):
(JSC::JIT::emitSlow_op_lshift):
(JSC::JIT::emitSlow_op_rshift):
(JSC::JIT::emitSlow_op_urshift):
(JSC::JIT::emitSlow_op_bitand):
(JSC::JIT::emitSlow_op_inc):
(JSC::JIT::emitSlow_op_dec):
(JSC::JIT::emitSlow_op_mod):
(JSC::JIT::emit_op_mod):
(JSC::JIT::compileBinaryArithOpSlowCase):
(JSC::JIT::emit_op_add):
(JSC::JIT::emitSlow_op_add):
(JSC::JIT::emitSlow_op_mul):
(JSC::JIT::emitSlow_op_div):
(JSC::JIT::emitSlow_op_sub):

  • jit/JITArithmetic32_64.cpp:

(JSC::JIT::emitSlow_op_negate):
(JSC::JIT::emitSlow_op_lshift):
(JSC::JIT::emitRightShiftSlowCase):
(JSC::JIT::emitSlow_op_bitand):
(JSC::JIT::emitSlow_op_bitor):
(JSC::JIT::emitSlow_op_bitxor):
(JSC::JIT::emitSlow_op_inc):
(JSC::JIT::emitSlow_op_dec):
(JSC::JIT::emit_op_add):
(JSC::JIT::emitSlow_op_add):
(JSC::JIT::emitSlow_op_sub):
(JSC::JIT::emitSlow_op_mul):
(JSC::JIT::emitSlow_op_div):
(JSC::JIT::emit_op_mod):
(JSC::JIT::emitSlow_op_mod):

  • jit/JITExceptions.cpp:

(JSC::getExceptionLocation):
(JSC::genericThrow):
(JSC::jitThrowNew):

  • jit/JITExceptions.h:

(ExceptionHandler):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_strcat):
(JSC::JIT::emitSlow_op_create_this):
(JSC::JIT::emitSlow_op_to_this):
(JSC::JIT::emitSlow_op_to_primitive):
(JSC::JIT::emitSlow_op_not):
(JSC::JIT::emitSlow_op_bitxor):
(JSC::JIT::emitSlow_op_bitor):
(JSC::JIT::emitSlow_op_stricteq):
(JSC::JIT::emitSlow_op_nstricteq):
(JSC::JIT::emitSlow_op_to_number):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::privateCompileCTINativeCall):
(JSC::JIT::emitSlow_op_to_primitive):
(JSC::JIT::emit_op_strcat):
(JSC::JIT::emitSlow_op_not):
(JSC::JIT::emitSlow_op_stricteq):
(JSC::JIT::emitSlow_op_nstricteq):
(JSC::JIT::emitSlow_op_to_number):
(JSC::JIT::emit_op_create_arguments):
(JSC::JIT::emitSlow_op_create_this):
(JSC::JIT::emitSlow_op_to_this):
(JSC::JIT::emitSlow_op_get_argument_by_val):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):
(JSC::cti_vm_throw_slowpath):

  • jit/JITStubs.h:
  • jit/JITStubsARM.h:
  • jit/JITStubsARMv7.h:
  • jit/JITStubsMIPS.h:
  • jit/JITStubsSH4.h:
  • jit/JITStubsX86.h:
  • jit/JITStubsX86_64.h:
  • jit/JSInterfaceJIT.h:

(JSInterfaceJIT):

  • jit/SlowPathCall.h: Added.

(JITSlowPathCall):
(JSC::JITSlowPathCall::JITSlowPathCall):
(JSC::JITSlowPathCall::call):

  • jit/ThunkGenerators.cpp:

(JSC::nativeForGenerator):

  • llint/LLIntSlowPaths.cpp:

(LLInt):

  • llint/LLIntSlowPaths.h:

(LLInt):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter.cpp:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/CommonSlowPaths.cpp: Added.

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:

(SlowPathReturnType):
(JSC::encodeResult):
(JSC::decodeResult):

  • runtime/JSCJSValue.h:

(JSValue):

File:
1 edited

Legend:

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

    r149247 r153222  
    3939#include "ResultType.h"
    4040#include "SamplingTool.h"
     41#include "SlowPathCall.h"
    4142
    4243#ifndef NDEBUG
     
    220221void JIT::emitSlow_op_negate(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    221222{
    222     unsigned dst = currentInstruction[1].u.operand;
     223    unsigned result = currentInstruction[1].u.operand;
    223224
    224225    linkSlowCase(iter); // 0x7fffffff check
    225226    linkSlowCase(iter); // double check
    226227
    227     JITStubCall stubCall(this, cti_op_negate);
    228     stubCall.addArgument(regT0);
    229     stubCall.call(dst);
     228    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_negate);
     229    slowPathCall.call();
     230    emitGetVirtualRegister(result, regT0);
    230231}
    231232
     
    250251{
    251252    unsigned result = currentInstruction[1].u.operand;
    252     unsigned op1 = currentInstruction[2].u.operand;
    253     unsigned op2 = currentInstruction[3].u.operand;
    254 
    255     UNUSED_PARAM(op1);
    256     UNUSED_PARAM(op2);
    257     linkSlowCase(iter);
    258     linkSlowCase(iter);
    259     JITStubCall stubCall(this, cti_op_lshift);
    260     stubCall.addArgument(regT0);
    261     stubCall.addArgument(regT2);
    262     stubCall.call(result);
     253
     254    linkSlowCase(iter);
     255    linkSlowCase(iter);
     256    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_lshift);
     257    slowPathCall.call();
     258    emitGetVirtualRegister(result, regT0);
    263259}
    264260
     
    304300    unsigned op2 = currentInstruction[3].u.operand;
    305301
    306     JITStubCall stubCall(this, cti_op_rshift);
    307 
    308     if (isOperandConstantImmediateInt(op2)) {
     302    UNUSED_PARAM(op1);
     303
     304    if (isOperandConstantImmediateInt(op2))
    309305        linkSlowCase(iter);
    310         stubCall.addArgument(regT0);
    311         stubCall.addArgument(op2, regT2);
    312     } else {
     306
     307    else {
    313308        if (supportsFloatingPointTruncate()) {
    314309            linkSlowCase(iter);
    315310            linkSlowCase(iter);
    316311            linkSlowCase(iter);
    317             // We're reloading op1 to regT0 as we can no longer guarantee that
    318             // we have not munged the operand.  It may have already been shifted
    319             // correctly, but it still will not have been tagged.
    320             stubCall.addArgument(op1, regT0);
    321             stubCall.addArgument(regT2);
    322312        } else {
    323313            linkSlowCase(iter);
    324314            linkSlowCase(iter);
    325             stubCall.addArgument(regT0);
    326             stubCall.addArgument(regT2);
    327315        }
    328316    }
    329317
    330     stubCall.call(result);
     318    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_rshift);
     319    slowPathCall.call();
     320    emitGetVirtualRegister(result, regT0);
    331321}
    332322
     
    419409    }
    420410   
    421     JITStubCall stubCall(this, cti_op_urshift);
    422     stubCall.addArgument(op1, regT0);
    423     stubCall.addArgument(op2, regT1);
    424     stubCall.call(dst);
     411    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_urshift);
     412    slowPathCall.call();
     413    emitGetVirtualRegister(dst, regT0);
    425414}
    426415
     
    608597{
    609598    unsigned result = currentInstruction[1].u.operand;
    610     unsigned op1 = currentInstruction[2].u.operand;
    611     unsigned op2 = currentInstruction[3].u.operand;
    612 
    613     linkSlowCase(iter);
    614     if (isOperandConstantImmediateInt(op1)) {
    615         JITStubCall stubCall(this, cti_op_bitand);
    616         stubCall.addArgument(op1, regT2);
    617         stubCall.addArgument(regT0);
    618         stubCall.call(result);
    619     } else if (isOperandConstantImmediateInt(op2)) {
    620         JITStubCall stubCall(this, cti_op_bitand);
    621         stubCall.addArgument(regT0);
    622         stubCall.addArgument(op2, regT2);
    623         stubCall.call(result);
    624     } else {
    625         JITStubCall stubCall(this, cti_op_bitand);
    626         stubCall.addArgument(op1, regT2);
    627         stubCall.addArgument(regT1);
    628         stubCall.call(result);
    629     }
     599
     600    linkSlowCase(iter);
     601
     602    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitand);
     603    slowPathCall.call();
     604    emitGetVirtualRegister(result, regT0);
    630605}
    631606
     
    645620    unsigned srcDst = currentInstruction[1].u.operand;
    646621
    647     Jump notImm = getSlowCase(iter);
    648     linkSlowCase(iter);
     622    linkSlowCase(iter);
     623    linkSlowCase(iter);
     624    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_inc);
     625    slowPathCall.call();
    649626    emitGetVirtualRegister(srcDst, regT0);
    650     notImm.link(this);
    651     JITStubCall stubCall(this, cti_op_inc);
    652     stubCall.addArgument(regT0);
    653     stubCall.call(srcDst);
    654627}
    655628
     
    669642    unsigned srcDst = currentInstruction[1].u.operand;
    670643
    671     Jump notImm = getSlowCase(iter);
    672     linkSlowCase(iter);
     644    linkSlowCase(iter);
     645    linkSlowCase(iter);
     646    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_dec);
     647    slowPathCall.call();
    673648    emitGetVirtualRegister(srcDst, regT0);
    674     notImm.link(this);
    675     JITStubCall stubCall(this, cti_op_dec);
    676     stubCall.addArgument(regT0);
    677     stubCall.call(srcDst);
    678649}
    679650
     
    720691    linkSlowCase(iter);
    721692    linkSlowCase(iter);
    722     JITStubCall stubCall(this, cti_op_mod);
    723     stubCall.addArgument(regT3);
    724     stubCall.addArgument(regT2);
    725     stubCall.call(result);
     693    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_mod);
     694    slowPathCall.call();
     695    emitGetVirtualRegister(result, regT0);
    726696}
    727697
     
    734704    unsigned op2 = currentInstruction[3].u.operand;
    735705
    736     JITStubCall stubCall(this, cti_op_mod);
    737     stubCall.addArgument(op1, regT2);
    738     stubCall.addArgument(op2, regT2);
    739     stubCall.call(result);
     706    UNUSED_PARAM(op1);
     707    UNUSED_PARAM(op2);
     708
     709    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_mod);
     710    slowPathCall.call();
     711    emitGetVirtualRegister(result, regT0);
    740712}
    741713
     
    797769}
    798770
    799 void JIT::compileBinaryArithOpSlowCase(OpcodeID opcodeID, Vector<SlowCaseEntry>::iterator& iter, unsigned result, unsigned op1, unsigned op2, OperandTypes types, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase)
     771void JIT::compileBinaryArithOpSlowCase(Instruction* currentInstruction, OpcodeID opcodeID, Vector<SlowCaseEntry>::iterator& iter, unsigned result, unsigned op1, unsigned op2, OperandTypes types, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase)
    800772{
    801773    // We assume that subtracting TagTypeNumber is equivalent to adding DoubleEncodeOffset.
     
    816788    if (opcodeID == op_mul && !op1HasImmediateIntFastCase && !op2HasImmediateIntFastCase) // op_mul has an extra slow case to handle 0 * negative number.
    817789        linkSlowCase(iter);
    818     emitGetVirtualRegister(op1, regT0);
    819790
    820791    Label stubFunctionCall(this);
    821     JITStubCall stubCall(this, opcodeID == op_add ? cti_op_add : opcodeID == op_sub ? cti_op_sub : cti_op_mul);
    822     if (op1HasImmediateIntFastCase || op2HasImmediateIntFastCase) {
    823         emitGetVirtualRegister(op1, regT0);
    824         emitGetVirtualRegister(op2, regT1);
    825     }
    826     stubCall.addArgument(regT0);
    827     stubCall.addArgument(regT1);
    828     stubCall.call(result);
     792
     793    JITSlowPathCall slowPathCall(this, currentInstruction, opcodeID == op_add ? slow_path_add : opcodeID == op_sub ? slow_path_sub : slow_path_mul);
     794    slowPathCall.call();
     795    emitGetVirtualRegister(result, regT0);
    829796    Jump end = jump();
    830797
     
    895862    if (!types.first().mightBeNumber() || !types.second().mightBeNumber()) {
    896863        addSlowCase();
    897         JITStubCall stubCall(this, cti_op_add);
    898         stubCall.addArgument(op1, regT2);
    899         stubCall.addArgument(op2, regT2);
    900         stubCall.call(result);
     864        JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
     865        slowPathCall.call();
    901866        return;
    902867    }
     
    932897    bool op1HasImmediateIntFastCase = isOperandConstantImmediateInt(op1);
    933898    bool op2HasImmediateIntFastCase = !op1HasImmediateIntFastCase && isOperandConstantImmediateInt(op2);
    934     compileBinaryArithOpSlowCase(op_add, iter, result, op1, op2, types, op1HasImmediateIntFastCase, op2HasImmediateIntFastCase);
     899    compileBinaryArithOpSlowCase(currentInstruction, op_add, iter, result, op1, op2, types, op1HasImmediateIntFastCase, op2HasImmediateIntFastCase);
    935900}
    936901
     
    977942    bool op1HasImmediateIntFastCase = isOperandConstantImmediateInt(op1) && getConstantOperandImmediateInt(op1) > 0;
    978943    bool op2HasImmediateIntFastCase = !op1HasImmediateIntFastCase && isOperandConstantImmediateInt(op2) && getConstantOperandImmediateInt(op2) > 0;
    979     compileBinaryArithOpSlowCase(op_mul, iter, result, op1, op2, types, op1HasImmediateIntFastCase, op2HasImmediateIntFastCase);
     944    compileBinaryArithOpSlowCase(currentInstruction, op_mul, iter, result, op1, op2, types, op1HasImmediateIntFastCase, op2HasImmediateIntFastCase);
    980945}
    981946
     
    10831048    }
    10841049    // There is an extra slow case for (op1 * -N) or (-N * op2), to check for 0 since this should produce a result of -0.
    1085     JITStubCall stubCall(this, cti_op_div);
    1086     stubCall.addArgument(op1, regT2);
    1087     stubCall.addArgument(op2, regT2);
    1088     stubCall.call(result);
     1050    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_div);
     1051    slowPathCall.call();
     1052    emitGetVirtualRegister(result, regT0);
    10891053}
    10901054
     
    11071071    OperandTypes types = OperandTypes::fromInt(currentInstruction[4].u.operand);
    11081072
    1109     compileBinaryArithOpSlowCase(op_sub, iter, result, op1, op2, types, false, false);
     1073    compileBinaryArithOpSlowCase(currentInstruction, op_sub, iter, result, op1, op2, types, false, false);
    11101074}
    11111075
Note: See TracChangeset for help on using the changeset viewer.