Changeset 205283 in webkit


Ignore:
Timestamp:
Sep 1, 2016 1:22:21 AM (8 years ago)
Author:
sbarati@apple.com
Message:

JITMathIC was misusing maxJumpReplacementSize
https://bugs.webkit.org/show_bug.cgi?id=161356
<rdar://problem/28065560>

Reviewed by Benjamin Poulain.

JITMathIC was assuming that maxJumpReplacementSize is the size
you'd get if you emitted a patchableJump() using the macro assembler.
This is not true, however. It happens to be true on arm64, x86 and x86-64,
however, it is not true on armv7. This patch introduces an alternative to
maxJumpReplacementSize called patchableJumpSize, and switches JITMathIC
to use that number instead.

  • assembler/ARM64Assembler.h:

(JSC::ARM64Assembler::patchableJumpSize):
(JSC::ARM64Assembler::maxJumpReplacementSize): Deleted.

  • assembler/ARMv7Assembler.h:

(JSC::ARMv7Assembler::patchableJumpSize):
(JSC::ARMv7Assembler::maxJumpReplacementSize): Deleted.

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::patchableJumpSize):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::patchableJumpSize):

  • assembler/MacroAssemblerX86Common.h:

(JSC::MacroAssemblerX86Common::patchableJumpSize):

  • assembler/X86Assembler.h:

(JSC::X86Assembler::patchableJumpSize):
(JSC::X86Assembler::maxJumpReplacementSize): Deleted.

  • jit/JITMathIC.h:

(JSC::JITMathIC::generateInline):

Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r205278 r205283  
     12016-09-01  Saam Barati  <sbarati@apple.com>
     2
     3        JITMathIC was misusing maxJumpReplacementSize
     4        https://bugs.webkit.org/show_bug.cgi?id=161356
     5        <rdar://problem/28065560>
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        JITMathIC was assuming that maxJumpReplacementSize is the size
     10        you'd get if you emitted a patchableJump() using the macro assembler.
     11        This is not true, however. It happens to be true on arm64, x86 and x86-64,
     12        however, it is not true on armv7. This patch introduces an alternative to
     13        maxJumpReplacementSize called patchableJumpSize, and switches JITMathIC
     14        to use that number instead.
     15
     16        * assembler/ARM64Assembler.h:
     17        (JSC::ARM64Assembler::patchableJumpSize):
     18        (JSC::ARM64Assembler::maxJumpReplacementSize): Deleted.
     19        * assembler/ARMv7Assembler.h:
     20        (JSC::ARMv7Assembler::patchableJumpSize):
     21        (JSC::ARMv7Assembler::maxJumpReplacementSize): Deleted.
     22        * assembler/MacroAssemblerARM64.h:
     23        (JSC::MacroAssemblerARM64::patchableJumpSize):
     24        * assembler/MacroAssemblerARMv7.h:
     25        (JSC::MacroAssemblerARMv7::patchableJumpSize):
     26        * assembler/MacroAssemblerX86Common.h:
     27        (JSC::MacroAssemblerX86Common::patchableJumpSize):
     28        * assembler/X86Assembler.h:
     29        (JSC::X86Assembler::patchableJumpSize):
     30        (JSC::X86Assembler::maxJumpReplacementSize): Deleted.
     31        * jit/JITMathIC.h:
     32        (JSC::JITMathIC::generateInline):
     33
    1342016-08-31  Yusuke Suzuki  <utatane.tea@gmail.com>
    235
  • trunk/Source/JavaScriptCore/assembler/ARM64Assembler.h

    r202214 r205283  
    25132513        return 4;
    25142514    }
     2515
     2516    static constexpr ptrdiff_t patchableJumpSize()
     2517    {
     2518        return 4;
     2519    }
    25152520   
    25162521    static void replaceWithLoad(void* where)
  • trunk/Source/JavaScriptCore/assembler/ARMv7Assembler.h

    r202214 r205283  
    23412341#endif
    23422342    }
     2343
     2344    static constexpr ptrdiff_t patchableJumpSize()
     2345    {
     2346        return 10;
     2347    }
    23432348   
    23442349    static void replaceWithLoad(void* instructionStart)
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h

    r204912 r205283  
    32503250    }
    32513251
     3252    static ptrdiff_t patchableJumpSize()
     3253    {
     3254        return ARM64Assembler::patchableJumpSize();
     3255    }
     3256
    32523257    RegisterID scratchRegisterForBlinding()
    32533258    {
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r203365 r205283  
    13511351    }
    13521352
     1353    static ptrdiff_t patchableJumpSize()
     1354    {
     1355        return ARMv7Assembler::patchableJumpSize();
     1356    }
     1357
    13531358    // Forwards / external control flow operations:
    13541359    //
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h

    r203390 r205283  
    26322632    {
    26332633        return X86Assembler::maxJumpReplacementSize();
     2634    }
     2635
     2636    static ptrdiff_t patchableJumpSize()
     2637    {
     2638        return X86Assembler::patchableJumpSize();
    26342639    }
    26352640
  • trunk/Source/JavaScriptCore/assembler/X86Assembler.h

    r203390 r205283  
    28142814        return 5;
    28152815    }
     2816
     2817    static constexpr ptrdiff_t patchableJumpSize()
     2818    {
     2819        return 5;
     2820    }
    28162821   
    28172822#if CPU(X86_64)
  • trunk/Source/JavaScriptCore/jit/JITMathIC.h

    r204025 r205283  
    8282                // once we have an idea about the types of lhs and rhs.
    8383                state.slowPathJumps.append(jit.patchableJump());
     84                size_t inlineSize = jit.m_assembler.buffer().codeSize() - startSize;
     85                ASSERT_UNUSED(inlineSize, static_cast<ptrdiff_t>(inlineSize) <= MacroAssembler::patchableJumpSize());
    8486                state.shouldSlowPathRepatch = true;
    8587                state.fastPathEnd = jit.label();
    8688                ASSERT(!m_generateFastPathOnRepatch); // We should have gathered some observed type info for lhs and rhs before trying to regenerate again.
    8789                m_generateFastPathOnRepatch = true;
    88                 size_t inlineSize = jit.m_assembler.buffer().codeSize() - startSize;
    89                 ASSERT_UNUSED(inlineSize, static_cast<ptrdiff_t>(inlineSize) <= MacroAssembler::maxJumpReplacementSize());
    9090                return true;
    9191            }
     
    9797        case JITMathICInlineResult::GeneratedFastPath: {
    9898            size_t inlineSize = jit.m_assembler.buffer().codeSize() - startSize;
    99             if (static_cast<ptrdiff_t>(inlineSize) < MacroAssembler::maxJumpReplacementSize()) {
    100                 size_t nopsToEmitInBytes = MacroAssembler::maxJumpReplacementSize() - inlineSize;
     99            if (static_cast<ptrdiff_t>(inlineSize) < MacroAssembler::patchableJumpSize()) {
     100                size_t nopsToEmitInBytes = MacroAssembler::patchableJumpSize() - inlineSize;
    101101                jit.emitNops(nopsToEmitInBytes);
    102102            }
Note: See TracChangeset for help on using the changeset viewer.