Ignore:
Timestamp:
Oct 9, 2009, 5:30:49 PM (16 years ago)
Author:
[email protected]
Message:

Eliminated some legacy bytecode weirdness.

Patch by Geoffrey Garen <[email protected]> on 2009-10-09
Reviewed by Oliver Hunt.

Use vPC[x] subscripting instead of ++vPC to access instruction operands.
This is simpler, and often more efficient.

To support this, and to remove use of hard-coded offsets in bytecode and
JIT code generation and dumping, calculate jump offsets from the beginning
of an instruction, rather than the middle or end.

Also, use OPCODE_LENGTH instead of hard-coded constants for the sizes of
opcodes.

SunSpider reports no change in JIT mode, and a 1.01x speedup in Interpreter
mode.

  • bytecode/CodeBlock.cpp:

(JSC::printConditionalJump):
(JSC::CodeBlock::dump):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitJump):
(JSC::BytecodeGenerator::emitJumpIfTrue):
(JSC::BytecodeGenerator::emitJumpIfFalse):
(JSC::BytecodeGenerator::emitJumpIfNotFunctionCall):
(JSC::BytecodeGenerator::emitJumpIfNotFunctionApply):
(JSC::BytecodeGenerator::emitComplexJumpScopes):
(JSC::BytecodeGenerator::emitJumpScopes):
(JSC::BytecodeGenerator::emitNextPropertyName):
(JSC::BytecodeGenerator::emitCatch):
(JSC::BytecodeGenerator::emitJumpSubroutine):
(JSC::prepareJumpTableForImmediateSwitch):
(JSC::prepareJumpTableForCharacterSwitch):
(JSC::prepareJumpTableForStringSwitch):
(JSC::BytecodeGenerator::endSwitch):

  • bytecompiler/Label.h:

(JSC::Label::setLocation):
(JSC::Label::bind):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::resolve):
(JSC::Interpreter::resolveSkip):
(JSC::Interpreter::resolveGlobal):
(JSC::Interpreter::resolveBase):
(JSC::Interpreter::resolveBaseAndProperty):
(JSC::Interpreter::createExceptionScope):
(JSC::Interpreter::privateExecute):

  • interpreter/Interpreter.h:
  • jit/JIT.cpp:

(JSC::JIT::privateCompile):

  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_jnless):
(JSC::JIT::emitSlow_op_jnless):
(JSC::JIT::emit_op_jnlesseq):
(JSC::JIT::emitSlow_op_jnlesseq):
(JSC::JIT::emitBinaryDoubleOp):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_jmp):
(JSC::JIT::emit_op_loop):
(JSC::JIT::emit_op_loop_if_less):
(JSC::JIT::emitSlow_op_loop_if_less):
(JSC::JIT::emit_op_loop_if_lesseq):
(JSC::JIT::emitSlow_op_loop_if_lesseq):
(JSC::JIT::emit_op_loop_if_true):
(JSC::JIT::emitSlow_op_loop_if_true):
(JSC::JIT::emit_op_jfalse):
(JSC::JIT::emitSlow_op_jfalse):
(JSC::JIT::emit_op_jtrue):
(JSC::JIT::emitSlow_op_jtrue):
(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_next_pname):
(JSC::JIT::emit_op_jmp_scopes):

File:
1 edited

Legend:

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

    r48938 r49409  
    9999        emitLoad(op2, regT3, regT2);
    100100        notInt32Op2.append(branch32(NotEqual, regT3, Imm32(JSValue::Int32Tag)));
    101         addJump(branch32(LessThanOrEqual, regT2, Imm32(getConstantOperand(op1).asInt32())), target + 3);
     101        addJump(branch32(LessThanOrEqual, regT2, Imm32(getConstantOperand(op1).asInt32())), target);
    102102    } else if (isOperandConstantImmediateInt(op2)) {
    103103        emitLoad(op1, regT1, regT0);
    104104        notInt32Op1.append(branch32(NotEqual, regT1, Imm32(JSValue::Int32Tag)));
    105         addJump(branch32(GreaterThanOrEqual, regT0, Imm32(getConstantOperand(op2).asInt32())), target + 3);
     105        addJump(branch32(GreaterThanOrEqual, regT0, Imm32(getConstantOperand(op2).asInt32())), target);
    106106    } else {
    107107        emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
    108108        notInt32Op1.append(branch32(NotEqual, regT1, Imm32(JSValue::Int32Tag)));
    109109        notInt32Op2.append(branch32(NotEqual, regT3, Imm32(JSValue::Int32Tag)));
    110         addJump(branch32(GreaterThanOrEqual, regT0, regT2), target + 3);
     110        addJump(branch32(GreaterThanOrEqual, regT0, regT2), target);
    111111    }
    112112
     
    146146    stubCall.addArgument(op2);
    147147    stubCall.call();
    148     emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     148    emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    149149}
    150150
     
    162162        emitLoad(op2, regT3, regT2);
    163163        notInt32Op2.append(branch32(NotEqual, regT3, Imm32(JSValue::Int32Tag)));
    164         addJump(branch32(LessThan, regT2, Imm32(getConstantOperand(op1).asInt32())), target + 3);
     164        addJump(branch32(LessThan, regT2, Imm32(getConstantOperand(op1).asInt32())), target);
    165165    } else if (isOperandConstantImmediateInt(op2)) {
    166166        emitLoad(op1, regT1, regT0);
    167167        notInt32Op1.append(branch32(NotEqual, regT1, Imm32(JSValue::Int32Tag)));
    168         addJump(branch32(GreaterThan, regT0, Imm32(getConstantOperand(op2).asInt32())), target + 3);
     168        addJump(branch32(GreaterThan, regT0, Imm32(getConstantOperand(op2).asInt32())), target);
    169169    } else {
    170170        emitLoad2(op1, regT1, regT0, op2, regT3, regT2);
    171171        notInt32Op1.append(branch32(NotEqual, regT1, Imm32(JSValue::Int32Tag)));
    172172        notInt32Op2.append(branch32(NotEqual, regT3, Imm32(JSValue::Int32Tag)));
    173         addJump(branch32(GreaterThan, regT0, regT2), target + 3);
     173        addJump(branch32(GreaterThan, regT0, regT2), target);
    174174    }
    175175
     
    209209    stubCall.addArgument(op2);
    210210    stubCall.call();
    211     emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     211    emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    212212}
    213213
     
    830830            case op_jnless:
    831831                emitLoadDouble(op1, fpRegT2);
    832                 addJump(branchDouble(DoubleLessThanOrEqual, fpRegT0, fpRegT2), dst + 3);
     832                addJump(branchDouble(DoubleLessThanOrEqual, fpRegT0, fpRegT2), dst);
    833833                break;
    834834            case op_jnlesseq:
    835835                emitLoadDouble(op1, fpRegT2);
    836                 addJump(branchDouble(DoubleLessThan, fpRegT0, fpRegT2), dst + 3);
     836                addJump(branchDouble(DoubleLessThan, fpRegT0, fpRegT2), dst);
    837837                break;
    838838            default:
     
    883883            case op_jnless:
    884884                emitLoadDouble(op2, fpRegT1);
    885                 addJump(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), dst + 3);
     885                addJump(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), dst);
    886886                break;
    887887            case op_jnlesseq:
    888888                emitLoadDouble(op2, fpRegT1);
    889                 addJump(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), dst + 3);
     889                addJump(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), dst);
    890890                break;
    891891            default:
     
    13141314        int32_t op2imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)));
    13151315#endif
    1316         addJump(branch32(GreaterThanOrEqual, regT0, Imm32(op2imm)), target + 3);
     1316        addJump(branch32(GreaterThanOrEqual, regT0, Imm32(op2imm)), target);
    13171317    } else if (isOperandConstantImmediateInt(op1)) {
    13181318        emitGetVirtualRegister(op2, regT1);
     
    13231323        int32_t op1imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op1)));
    13241324#endif
    1325         addJump(branch32(LessThanOrEqual, regT1, Imm32(op1imm)), target + 3);
     1325        addJump(branch32(LessThanOrEqual, regT1, Imm32(op1imm)), target);
    13261326    } else {
    13271327        emitGetVirtualRegisters(op1, regT0, op2, regT1);
     
    13291329        emitJumpSlowCaseIfNotImmediateInteger(regT1);
    13301330
    1331         addJump(branch32(GreaterThanOrEqual, regT0, regT1), target + 3);
     1331        addJump(branch32(GreaterThanOrEqual, regT0, regT1), target);
    13321332    }
    13331333}
     
    13661366            convertInt32ToDouble(regT1, fpRegT1);
    13671367
    1368             emitJumpSlowToHot(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), target + 3);
     1368            emitJumpSlowToHot(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), target);
    13691369
    13701370            emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jnless));
     
    13831383        stubCall.addArgument(op2, regT2);
    13841384        stubCall.call();
    1385         emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     1385        emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    13861386
    13871387    } else if (isOperandConstantImmediateInt(op1)) {
     
    14071407            convertInt32ToDouble(regT0, fpRegT0);
    14081408
    1409             emitJumpSlowToHot(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), target + 3);
     1409            emitJumpSlowToHot(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), target);
    14101410
    14111411            emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jnless));
     
    14241424        stubCall.addArgument(regT1);
    14251425        stubCall.call();
    1426         emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     1426        emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    14271427
    14281428    } else {
     
    14531453#endif
    14541454
    1455             emitJumpSlowToHot(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), target + 3);
     1455            emitJumpSlowToHot(branchDouble(DoubleLessThanOrEqual, fpRegT1, fpRegT0), target);
    14561456
    14571457            emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jnless));
     
    14761476        stubCall.addArgument(regT1);
    14771477        stubCall.call();
    1478         emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     1478        emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    14791479    }
    14801480}
     
    14991499        int32_t op2imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op2)));
    15001500#endif
    1501         addJump(branch32(GreaterThan, regT0, Imm32(op2imm)), target + 3);
     1501        addJump(branch32(GreaterThan, regT0, Imm32(op2imm)), target);
    15021502    } else if (isOperandConstantImmediateInt(op1)) {
    15031503        emitGetVirtualRegister(op2, regT1);
     
    15081508        int32_t op1imm = static_cast<int32_t>(JSImmediate::rawValue(getConstantOperand(op1)));
    15091509#endif
    1510         addJump(branch32(LessThan, regT1, Imm32(op1imm)), target + 3);
     1510        addJump(branch32(LessThan, regT1, Imm32(op1imm)), target);
    15111511    } else {
    15121512        emitGetVirtualRegisters(op1, regT0, op2, regT1);
     
    15141514        emitJumpSlowCaseIfNotImmediateInteger(regT1);
    15151515
    1516         addJump(branch32(GreaterThan, regT0, regT1), target + 3);
     1516        addJump(branch32(GreaterThan, regT0, regT1), target);
    15171517    }
    15181518}
     
    15511551            convertInt32ToDouble(regT1, fpRegT1);
    15521552
    1553             emitJumpSlowToHot(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), target + 3);
     1553            emitJumpSlowToHot(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), target);
    15541554
    15551555            emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jnlesseq));
     
    15681568        stubCall.addArgument(op2, regT2);
    15691569        stubCall.call();
    1570         emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     1570        emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    15711571
    15721572    } else if (isOperandConstantImmediateInt(op1)) {
     
    15921592            convertInt32ToDouble(regT0, fpRegT0);
    15931593
    1594             emitJumpSlowToHot(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), target + 3);
     1594            emitJumpSlowToHot(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), target);
    15951595
    15961596            emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jnlesseq));
     
    16091609        stubCall.addArgument(regT1);
    16101610        stubCall.call();
    1611         emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     1611        emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    16121612
    16131613    } else {
     
    16381638#endif
    16391639
    1640             emitJumpSlowToHot(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), target + 3);
     1640            emitJumpSlowToHot(branchDouble(DoubleLessThan, fpRegT1, fpRegT0), target);
    16411641
    16421642            emitJumpSlowToHot(jump(), OPCODE_LENGTH(op_jnlesseq));
     
    16611661        stubCall.addArgument(regT1);
    16621662        stubCall.call();
    1663         emitJumpSlowToHot(branchTest32(Zero, regT0), target + 3);
     1663        emitJumpSlowToHot(branchTest32(Zero, regT0), target);
    16641664    }
    16651665}
Note: See TracChangeset for help on using the changeset viewer.