Ignore:
Timestamp:
Dec 10, 2019, 11:41:40 AM (6 years ago)
Author:
Tadeu Zagallo
Message:

Reduce JSC's binary size
https://bugs.webkit.org/show_bug.cgi?id=204549

Reviewed by Saam Barati.

The Wasm interpreter landed in r251886 and significantly increased JSC's binary size. To try and
offset that, here and some easy fixes that get us ~200kb back:

  • We were generating 2 instances of dumpBytecode, at 30kb each. I changed the generator to emit a cpp file instead, avoiding the duplication.
  • We had 3 instances of computeUsesForBytecodeIndex at 11kb each. I kept the work that depended on the template type in the template function and moved the massive switch into computeUsesForBytecodeIndexImpl. I also did the same for computeDefsForBytecodeIndex.
  • We had 8 instances of emit_compareAndJump(Slow) at 8kb (7kb for Slow) each. I kept the code that extracts the data from the bytecode in the template, but moved the bulk of the function into emit_compareAndJump(Slow)Impl.
  • CMakeLists.txt:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Sources.txt:
  • bytecode/BytecodeDumper.cpp:

(JSC::BytecodeDumperBase::printLocationAndOp):
(JSC::BytecodeDumperBase::dumpValue):

  • bytecode/BytecodeDumper.h:

(JSC::BytecodeDumperBase::~BytecodeDumperBase):
(JSC::BytecodeDumperBase::dumpValue):
(JSC::BytecodeDumperBase::BytecodeDumperBase):
(JSC::BytecodeDumper::BytecodeDumper):

  • bytecode/BytecodeUseDef.cpp: Copied from Source/JavaScriptCore/bytecode/BytecodeUseDef.h.

(JSC::computeUsesForBytecodeIndexImpl):
(JSC::computeDefsForBytecodeIndexImpl):

  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeIndex):
(JSC::computeDefsForBytecodeIndex):

  • generator/DSL.rb:
  • generator/Opcode.rb:
  • generator/Options.rb:
  • jit/JIT.h:
  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_compareAndJump):
(JSC::JIT::emit_compareAndJumpImpl):
(JSC::JIT::emit_compareUnsignedAndJump):
(JSC::JIT::emit_compareUnsignedAndJumpImpl):
(JSC::JIT::emit_compareUnsigned):
(JSC::JIT::emit_compareUnsignedImpl):
(JSC::JIT::emit_compareAndJumpSlow):
(JSC::JIT::emit_compareAndJumpSlowImpl):

File:
1 edited

Legend:

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

    r252422 r253335  
    172172void JIT::emit_compareAndJump(const Instruction* instruction, RelationalCondition condition)
    173173{
     174    auto bytecode = instruction->as<Op>();
     175    int op1 = bytecode.m_lhs.offset();
     176    int op2 = bytecode.m_rhs.offset();
     177    unsigned target = jumpTarget(instruction, bytecode.m_targetLabel);
     178    emit_compareAndJumpImpl(op1, op2, target, condition);
     179}
     180
     181void JIT::emit_compareAndJumpImpl(int op1, int op2, unsigned target, RelationalCondition condition)
     182{
    174183    // We generate inline code for the following cases in the fast path:
    175184    // - int immediate to constant int immediate
     
    177186    // - int immediate to int immediate
    178187
    179     auto bytecode = instruction->as<Op>();
    180     int op1 = bytecode.m_lhs.offset();
    181     int op2 = bytecode.m_rhs.offset();
    182     unsigned target = jumpTarget(instruction, bytecode.m_targetLabel);
    183188    bool disallowAllocation = false;
    184189    if (isOperandConstantChar(op1)) {
     
    229234    int op2 = bytecode.m_rhs.offset();
    230235    unsigned target = jumpTarget(instruction, bytecode.m_targetLabel);
     236    emit_compareUnsignedAndJumpImpl(op1, op2, target, condition);
     237}
     238
     239void JIT::emit_compareUnsignedAndJumpImpl(int op1, int op2, unsigned target, RelationalCondition condition)
     240{
    231241    if (isOperandConstantInt(op2)) {
    232242        emitGetVirtualRegister(op1, regT0);
     
    250260    int op1 = bytecode.m_lhs.offset();
    251261    int op2 = bytecode.m_rhs.offset();
     262    emit_compareUnsignedImpl(dst, op1, op2, condition);
     263}
     264
     265void JIT::emit_compareUnsignedImpl(int dst, int op1, int op2, RelationalCondition condition)
     266{
    252267    if (isOperandConstantInt(op2)) {
    253268        emitGetVirtualRegister(op1, regT0);
     
    273288    int op2 = bytecode.m_rhs.offset();
    274289    unsigned target = jumpTarget(instruction, bytecode.m_targetLabel);
     290    emit_compareAndJumpSlowImpl(op1, op2, target, instruction->size(), condition, operation, invert, iter);
     291}
     292
     293void JIT::emit_compareAndJumpSlowImpl(int op1, int op2, unsigned target, size_t instructionSize, DoubleCondition condition, size_t (JIT_OPERATION *operation)(JSGlobalObject*, EncodedJSValue, EncodedJSValue), bool invert, Vector<SlowCaseEntry>::iterator& iter)
     294{
    275295
    276296    // We generate inline code for the following cases in the slow path:
     
    303323            emitJumpSlowToHot(branchDouble(condition, fpRegT0, fpRegT1), target);
    304324
    305             emitJumpSlowToHot(jump(), instruction->size());
     325            emitJumpSlowToHot(jump(), instructionSize);
    306326
    307327            fail1.link(this);
     
    329349            emitJumpSlowToHot(branchDouble(condition, fpRegT0, fpRegT1), target);
    330350
    331             emitJumpSlowToHot(jump(), instruction->size());
     351            emitJumpSlowToHot(jump(), instructionSize);
    332352
    333353            fail1.link(this);
     
    353373        emitJumpSlowToHot(branchDouble(condition, fpRegT0, fpRegT1), target);
    354374
    355         emitJumpSlowToHot(jump(), instruction->size());
     375        emitJumpSlowToHot(jump(), instructionSize);
    356376
    357377        fail1.link(this);
Note: See TracChangeset for help on using the changeset viewer.