Ignore:
Timestamp:
Oct 22, 2017, 11:28:16 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC][Baseline] Use linkAllSlowCasesForBytecodeOffset as much as possible to simplify slow cases handling
https://bugs.webkit.org/show_bug.cgi?id=178647

Reviewed by Saam Barati.

There is much code counting slow cases in fast paths to call linkSlowCase carefully. This is really error-prone
since the number of slow cases depends on values of instruction's metadata. We have linkAllSlowCasesForBytecodeOffset,
which drains all slow cases for a specified bytecode offset. In typical cases like just calling a slow path function,
this is enough. We use linkAllSlowCasesForBytecodeOffset as much as possible. It significantly simplifies the code.

  • jit/JIT.h:

(JSC::JIT::linkAllSlowCases):

  • jit/JITArithmetic.cpp:

(JSC::JIT::emitSlow_op_unsigned):
(JSC::JIT::emit_compareAndJump):
(JSC::JIT::emit_compareAndJumpSlow):
(JSC::JIT::emitSlow_op_inc):
(JSC::JIT::emitSlow_op_dec):
(JSC::JIT::emitSlow_op_mod):
(JSC::JIT::emitSlow_op_negate):
(JSC::JIT::emitSlow_op_bitand):
(JSC::JIT::emitSlow_op_bitor):
(JSC::JIT::emitSlow_op_bitxor):
(JSC::JIT::emitSlow_op_lshift):
(JSC::JIT::emitSlow_op_rshift):
(JSC::JIT::emitSlow_op_urshift):
(JSC::JIT::emitSlow_op_add):
(JSC::JIT::emitSlow_op_div):
(JSC::JIT::emitSlow_op_mul):
(JSC::JIT::emitSlow_op_sub):

  • jit/JITArithmetic32_64.cpp:

(JSC::JIT::emit_compareAndJumpSlow):
(JSC::JIT::emitSlow_op_unsigned):
(JSC::JIT::emitSlow_op_inc):
(JSC::JIT::emitSlow_op_dec):
(JSC::JIT::emitSlow_op_mod):

  • jit/JITCall.cpp:

(JSC::JIT::compileCallEvalSlowCase):
(JSC::JIT::compileOpCallSlowCase):

  • jit/JITCall32_64.cpp:

(JSC::JIT::compileCallEvalSlowCase):
(JSC::JIT::compileOpCallSlowCase):

  • jit/JITInlines.h:

(JSC::JIT::linkAllSlowCasesForBytecodeOffset):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emitSlow_op_new_object):
(JSC::JIT::emitSlow_op_create_this):
(JSC::JIT::emitSlow_op_check_tdz):
(JSC::JIT::emitSlow_op_to_this):
(JSC::JIT::emitSlow_op_to_primitive):
(JSC::JIT::emitSlow_op_not):
(JSC::JIT::emitSlow_op_eq):
(JSC::JIT::emitSlow_op_neq):
(JSC::JIT::emitSlow_op_stricteq):
(JSC::JIT::emitSlow_op_nstricteq):
(JSC::JIT::emitSlow_op_instanceof):
(JSC::JIT::emitSlow_op_instanceof_custom):
(JSC::JIT::emitSlow_op_to_number):
(JSC::JIT::emitSlow_op_to_string):
(JSC::JIT::emitSlow_op_loop_hint):
(JSC::JIT::emitSlow_op_check_traps):
(JSC::JIT::emitSlow_op_has_indexed_property):
(JSC::JIT::emitSlow_op_get_direct_pname):
(JSC::JIT::emitSlow_op_has_structure_property):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emitSlow_op_new_object):
(JSC::JIT::emitSlow_op_instanceof):
(JSC::JIT::emitSlow_op_instanceof_custom):
(JSC::JIT::emitSlow_op_to_primitive):
(JSC::JIT::emitSlow_op_not):
(JSC::JIT::emitSlow_op_stricteq):
(JSC::JIT::emitSlow_op_nstricteq):
(JSC::JIT::emitSlow_op_to_number):
(JSC::JIT::emitSlow_op_to_string):
(JSC::JIT::emitSlow_op_create_this):
(JSC::JIT::emitSlow_op_to_this):
(JSC::JIT::emitSlow_op_check_tdz):
(JSC::JIT::emitSlow_op_has_indexed_property):
(JSC::JIT::emitSlow_op_get_direct_pname):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emitSlow_op_try_get_by_id):
(JSC::JIT::emitSlow_op_get_by_id):
(JSC::JIT::emitSlow_op_get_by_id_with_this):
(JSC::JIT::emitSlow_op_put_by_id):
(JSC::JIT::emitSlow_op_resolve_scope):
(JSC::JIT::emitSlow_op_get_from_scope):
(JSC::JIT::emitSlow_op_put_to_scope):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emitSlow_op_try_get_by_id):
(JSC::JIT::emitSlow_op_get_by_id):
(JSC::JIT::emitSlow_op_get_by_id_with_this):
(JSC::JIT::emitSlow_op_put_by_id):
(JSC::JIT::emitSlow_op_resolve_scope):
(JSC::JIT::emitSlow_op_get_from_scope):
(JSC::JIT::emitSlow_op_put_to_scope):

File:
1 edited

Legend:

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

    r223823 r223824  
    248248void JIT::emitSlow_op_unsigned(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    249249{
    250     linkSlowCase(iter);
    251     linkSlowCase(iter);
     250    linkAllSlowCases(iter);
    252251   
    253252    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_unsigned);
     
    285284        int32_t op2imm = getOperandConstantInt(op2);
    286285        addJump(branch32(condition, regT0, Imm32(op2imm)), target);
    287     } else if (isOperandConstantInt(op1)) {
     286        return;
     287    }
     288    if (isOperandConstantInt(op1)) {
    288289        emitGetVirtualRegister(op2, regT1);
    289290        emitJumpSlowCaseIfNotInt(regT1);
    290291        int32_t op1imm = getOperandConstantInt(op1);
    291292        addJump(branch32(commute(condition), regT1, Imm32(op1imm)), target);
    292     } else {
    293         emitGetVirtualRegisters(op1, regT0, op2, regT1);
    294         emitJumpSlowCaseIfNotInt(regT0);
    295         emitJumpSlowCaseIfNotInt(regT1);
    296 
    297         addJump(branch32(condition, regT0, regT1), target);
     293        return;
    298294    }
     295
     296    emitGetVirtualRegisters(op1, regT0, op2, regT1);
     297    emitJumpSlowCaseIfNotInt(regT0);
     298    emitJumpSlowCaseIfNotInt(regT1);
     299
     300    addJump(branch32(condition, regT0, regT1), target);
    299301}
    300302
     
    348350    // - floating-point number to floating-point number.
    349351    if (isOperandConstantChar(op1) || isOperandConstantChar(op2)) {
    350         linkSlowCase(iter);
    351         linkSlowCase(iter);
    352         linkSlowCase(iter);
    353         linkSlowCase(iter);
     352        linkAllSlowCases(iter);
    354353
    355354        emitGetVirtualRegister(op1, argumentGPR0);
     
    361360
    362361    if (isOperandConstantInt(op2)) {
    363         linkSlowCase(iter);
     362        linkAllSlowCases(iter);
    364363
    365364        if (supportsFloatingPoint()) {
     
    383382        callOperation(operation, regT0, regT1);
    384383        emitJumpSlowToHot(branchTest32(invert ? Zero : NonZero, returnValueGPR), target);
    385     } else if (isOperandConstantInt(op1)) {
    386         linkSlowCase(iter);
     384        return;
     385    }
     386
     387    if (isOperandConstantInt(op1)) {
     388        linkAllSlowCases(iter);
    387389
    388390        if (supportsFloatingPoint()) {
     
    406408        callOperation(operation, regT2, regT1);
    407409        emitJumpSlowToHot(branchTest32(invert ? Zero : NonZero, returnValueGPR), target);
    408     } else {
    409         linkSlowCase(iter);
    410 
    411         if (supportsFloatingPoint()) {
    412             Jump fail1 = emitJumpIfNotNumber(regT0);
    413             Jump fail2 = emitJumpIfNotNumber(regT1);
    414             Jump fail3 = emitJumpIfInt(regT1);
    415             add64(tagTypeNumberRegister, regT0);
    416             add64(tagTypeNumberRegister, regT1);
    417             move64ToDouble(regT0, fpRegT0);
    418             move64ToDouble(regT1, fpRegT1);
    419 
    420             emitJumpSlowToHot(branchDouble(condition, fpRegT0, fpRegT1), target);
    421 
    422             emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jless));
    423 
    424             fail1.link(this);
    425             fail2.link(this);
    426             fail3.link(this);
    427         }
    428 
    429         linkSlowCase(iter);
    430         callOperation(operation, regT0, regT1);
    431         emitJumpSlowToHot(branchTest32(invert ? Zero : NonZero, returnValueGPR), target);
     410        return;
    432411    }
     412
     413    linkSlowCase(iter); // LHS is not Int.
     414
     415    if (supportsFloatingPoint()) {
     416        Jump fail1 = emitJumpIfNotNumber(regT0);
     417        Jump fail2 = emitJumpIfNotNumber(regT1);
     418        Jump fail3 = emitJumpIfInt(regT1);
     419        add64(tagTypeNumberRegister, regT0);
     420        add64(tagTypeNumberRegister, regT1);
     421        move64ToDouble(regT0, fpRegT0);
     422        move64ToDouble(regT1, fpRegT1);
     423
     424        emitJumpSlowToHot(branchDouble(condition, fpRegT0, fpRegT1), target);
     425
     426        emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jless));
     427
     428        fail1.link(this);
     429        fail2.link(this);
     430        fail3.link(this);
     431    }
     432
     433    linkSlowCase(iter); // RHS is not Int.
     434    callOperation(operation, regT0, regT1);
     435    emitJumpSlowToHot(branchTest32(invert ? Zero : NonZero, returnValueGPR), target);
    433436}
    434437
     
    446449void JIT::emitSlow_op_inc(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    447450{
    448     linkSlowCase(iter);
    449     linkSlowCase(iter);
     451    linkAllSlowCases(iter);
     452
    450453    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_inc);
    451454    slowPathCall.call();
     
    465468void JIT::emitSlow_op_dec(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    466469{
    467     linkSlowCase(iter);
    468     linkSlowCase(iter);
     470    linkAllSlowCases(iter);
     471
    469472    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_dec);
    470473    slowPathCall.call();
     
    508511void JIT::emitSlow_op_mod(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    509512{
    510     linkSlowCase(iter);
    511     linkSlowCase(iter);
    512     linkSlowCase(iter);
    513     linkSlowCase(iter);
    514     linkSlowCase(iter);
     513    linkAllSlowCases(iter);
     514
    515515    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_mod);
    516516    slowPathCall.call();
     
    546546void JIT::emitSlow_op_negate(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    547547{
    548     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     548    linkAllSlowCases(iter);
    549549
    550550    JITNegIC* negIC = bitwise_cast<JITNegIC*>(m_instructionToMathIC.get(currentInstruction));
     
    604604void JIT::emitSlow_op_bitand(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    605605{
    606     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     606    linkAllSlowCases(iter);
    607607
    608608    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitand);
     
    617617void JIT::emitSlow_op_bitor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    618618{
    619     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     619    linkAllSlowCases(iter);
    620620
    621621    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitor);
     
    630630void JIT::emitSlow_op_bitxor(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    631631{
    632     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     632    linkAllSlowCases(iter);
    633633
    634634    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_bitxor);
     
    643643void JIT::emitSlow_op_lshift(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    644644{
    645     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     645    linkAllSlowCases(iter);
    646646
    647647    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_lshift);
     
    708708void JIT::emitSlow_op_rshift(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    709709{
    710     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     710    linkAllSlowCases(iter);
    711711
    712712    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_rshift);
     
    721721void JIT::emitSlow_op_urshift(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    722722{
    723     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     723    linkAllSlowCases(iter);
    724724
    725725    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_urshift);
     
    742742void JIT::emitSlow_op_add(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    743743{
    744     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     744    linkAllSlowCases(iter);
    745745
    746746    JITAddIC* addIC = bitwise_cast<JITAddIC*>(m_instructionToMathIC.get(currentInstruction));
     
    10491049void JIT::emitSlow_op_div(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    10501050{
    1051     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     1051    linkAllSlowCases(iter);
    10521052
    10531053    JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_div);
     
    10651065void JIT::emitSlow_op_mul(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    10661066{
    1067     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     1067    linkAllSlowCases(iter);
    10681068
    10691069    JITMulIC* mulIC = bitwise_cast<JITMulIC*>(m_instructionToMathIC.get(currentInstruction));
     
    10811081void JIT::emitSlow_op_sub(Instruction* currentInstruction, Vector<SlowCaseEntry>::iterator& iter)
    10821082{
    1083     linkAllSlowCasesForBytecodeOffset(m_slowCases, iter, m_bytecodeOffset);
     1083    linkAllSlowCases(iter);
     1084
    10841085    JITSubIC* subIC = bitwise_cast<JITSubIC*>(m_instructionToMathIC.get(currentInstruction));
    10851086    emitMathICSlow(subIC, currentInstruction, operationValueSubProfiledOptimize, operationValueSubProfiled, operationValueSubOptimize);
Note: See TracChangeset for help on using the changeset viewer.