Changeset 192599 in webkit


Ignore:
Timestamp:
Nov 18, 2015 4:30:37 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

Remove some unnecessary jumps in snippet code.
https://bugs.webkit.org/show_bug.cgi?id=151415

Reviewed by Geoffrey Garen.

Previously, the snippet generators always emit a jump at the end of the fast
path. In the baseline JIT and FTL, this results in a jump to the very next
instruction. I've change it to assume that the fast path will just fall thru,
and let the client decide instead if it wants/needs a jump or not after the fast
path.

I also changed the generators to provide a didEmitFastPath() query explicitly
declare if they actually generated the fast path, instead of having the client
infer it from an empty endJumpList.

Benchmarks show that perf is neutral with this change (tested on x86_64).

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileValueAdd):
(JSC::DFG::SpeculativeJIT::compileArithSub):

  • ftl/FTLCompile.cpp:

(JSC::FTL::mmAllocateDataSection):

  • jit/JITAddGenerator.cpp:

(JSC::JITAddGenerator::generateFastPath):

  • jit/JITAddGenerator.h:

(JSC::JITAddGenerator::didEmitFastPath):
(JSC::JITAddGenerator::endJumpList):
(JSC::JITAddGenerator::slowPathJumpList):

  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_sub):

  • jit/JITSubGenerator.cpp:

(JSC::JITSubGenerator::generateFastPath):

  • jit/JITSubGenerator.h:

(JSC::JITSubGenerator::didEmitFastPath):
(JSC::JITSubGenerator::endJumpList):
(JSC::JITSubGenerator::slowPathJumpList):

Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r192597 r192599  
     12015-11-18  Mark Lam  <mark.lam@apple.com>
     2
     3        Remove some unnecessary jumps in snippet code.
     4        https://bugs.webkit.org/show_bug.cgi?id=151415
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Previously, the snippet generators always emit a jump at the end of the fast
     9        path.  In the baseline JIT and FTL, this results in a jump to the very next
     10        instruction.  I've change it to assume that the fast path will just fall thru,
     11        and let the client decide instead if it wants/needs a jump or not after the fast
     12        path.
     13
     14        I also changed the generators to provide a didEmitFastPath() query explicitly
     15        declare if they actually generated the fast path, instead of having the client
     16        infer it from an empty endJumpList.
     17
     18        Benchmarks show that perf is neutral with this change (tested on x86_64).
     19
     20        * dfg/DFGSpeculativeJIT.cpp:
     21        (JSC::DFG::SpeculativeJIT::compileValueAdd):
     22        (JSC::DFG::SpeculativeJIT::compileArithSub):
     23        * ftl/FTLCompile.cpp:
     24        (JSC::FTL::mmAllocateDataSection):
     25        * jit/JITAddGenerator.cpp:
     26        (JSC::JITAddGenerator::generateFastPath):
     27        * jit/JITAddGenerator.h:
     28        (JSC::JITAddGenerator::didEmitFastPath):
     29        (JSC::JITAddGenerator::endJumpList):
     30        (JSC::JITAddGenerator::slowPathJumpList):
     31        * jit/JITArithmetic.cpp:
     32        (JSC::JIT::emit_op_add):
     33        (JSC::JIT::emit_op_sub):
     34        * jit/JITSubGenerator.cpp:
     35        (JSC::JITSubGenerator::generateFastPath):
     36        * jit/JITSubGenerator.h:
     37        (JSC::JITSubGenerator::didEmitFastPath):
     38        (JSC::JITSubGenerator::endJumpList):
     39        (JSC::JITSubGenerator::slowPathJumpList):
     40
    1412015-11-18  Commit Queue  <commit-queue@webkit.org>
    242
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r192531 r192599  
    28812881    gen.generateFastPath(m_jit);
    28822882
     2883    ASSERT(gen.didEmitFastPath());
     2884    gen.endJumpList().append(m_jit.jump());
     2885
    28832886    gen.slowPathJumpList().link(&m_jit);
    28842887
     
    32403243            leftFPR, rightFPR, scratchGPR, scratchFPR);
    32413244        gen.generateFastPath(m_jit);
     3245
     3246        ASSERT(gen.didEmitFastPath());
     3247        gen.endJumpList().append(m_jit.jump());
    32423248
    32433249        gen.slowPathJumpList().link(&m_jit);
  • trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp

    r192590 r192599  
    463463        gen.generateFastPath(fastPathJIT);
    464464
     465        ASSERT(gen.didEmitFastPath());
    465466        gen.endJumpList().link(&fastPathJIT);
    466467        context.restoreRegisters(fastPathJIT);
  • trunk/Source/JavaScriptCore/jit/JITAddGenerator.cpp

    r192531 r192599  
    4545   
    4646    if (!m_leftType.mightBeNumber() || !m_rightType.mightBeNumber()) {
    47         m_slowPathJumpList.append(jit.jump());
     47        ASSERT(!m_didEmitFastPath);
    4848        return;
    4949    }
     50
     51    m_didEmitFastPath = true;
    5052
    5153    if (m_leftIsConstInt32 || m_rightIsConstInt32) {
     
    138140    jit.addDouble(m_rightFPR, m_leftFPR);
    139141    jit.boxDouble(m_leftFPR, m_result);
    140 
    141     m_endJumpList.append(jit.jump());
    142142}
    143143
  • trunk/Source/JavaScriptCore/jit/JITAddGenerator.h

    r192531 r192599  
    5959    void generateFastPath(CCallHelpers&);
    6060
     61    bool didEmitFastPath() const { return m_didEmitFastPath; }
    6162    CCallHelpers::JumpList endJumpList() { return m_endJumpList; }
    6263    CCallHelpers::JumpList slowPathJumpList() { return m_slowPathJumpList; }
     
    7677    GPRReg m_scratchGPR;
    7778    FPRReg m_scratchFPR;
     79    bool m_didEmitFastPath { false };
    7880
    7981    CCallHelpers::JumpList m_endJumpList;
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r192535 r192599  
    959959    gen.generateFastPath(*this);
    960960
    961     if (!gen.endJumpList().empty()) {
     961    if (gen.didEmitFastPath()) {
    962962        gen.endJumpList().link(this);
    963963        emitPutVirtualRegister(result, resultRegs);
     
    965965        addSlowCase(gen.slowPathJumpList());
    966966    } else {
    967         gen.slowPathJumpList().link(this);
     967        ASSERT(gen.endJumpList().empty());
     968        ASSERT(gen.slowPathJumpList().empty());
    968969        JITSlowPathCall slowPathCall(this, currentInstruction, slow_path_add);
    969970        slowPathCall.call();
     
    10071008
    10081009    gen.generateFastPath(*this);
     1010
     1011    ASSERT(gen.didEmitFastPath());
    10091012    gen.endJumpList().link(this);
    10101013    emitPutVirtualRegister(result, resultRegs);
  • trunk/Source/JavaScriptCore/jit/JITSubGenerator.cpp

    r191713 r192599  
    4141    ASSERT(m_scratchFPR != InvalidFPRReg);
    4242#endif
     43
     44    m_didEmitFastPath = true;
     45
    4346    CCallHelpers::Jump leftNotInt = jit.branchIfNotInt32(m_left);
    4447    CCallHelpers::Jump rightNotInt = jit.branchIfNotInt32(m_right);
     
    8285    jit.subDouble(m_rightFPR, m_leftFPR);
    8386    jit.boxDouble(m_leftFPR, m_result);
    84 
    85     m_endJumpList.append(jit.jump());
    8687}
    8788
  • trunk/Source/JavaScriptCore/jit/JITSubGenerator.h

    r191713 r192599  
    5252    void generateFastPath(CCallHelpers&);
    5353
     54    bool didEmitFastPath() const { return m_didEmitFastPath; }
    5455    CCallHelpers::JumpList endJumpList() { return m_endJumpList; }
    5556    CCallHelpers::JumpList slowPathJumpList() { return m_slowPathJumpList; }
     
    6566    GPRReg m_scratchGPR;
    6667    FPRReg m_scratchFPR;
     68    bool m_didEmitFastPath { false };
    6769
    6870    CCallHelpers::JumpList m_endJumpList;
Note: See TracChangeset for help on using the changeset viewer.