Changeset 96563 in webkit


Ignore:
Timestamp:
Oct 3, 2011 6:16:46 PM (13 years ago)
Author:
barraclough@apple.com
Message:

On X86, switch bucketCount into a register, timeoutCheck into memory
https://bugs.webkit.org/show_bug.cgi?id=69299

Reviewed by Geoff Garen.

We don't have sufficient registers to keep both in registers, and DFG JIT will trample esi;
it doesn't matter if the bucketCount gets stomped on (in fact it may add to randomness!),
but it if the timeoutCheck gets trashed we may make calls out to the timout_check stub
function too frequently (regressing performance). This patch has no perf impact on sunspider.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • assembler/MacroAssemblerX86.h:

(JSC::MacroAssemblerX86::branchAdd32):
(JSC::MacroAssemblerX86::branchSub32):

  • Added branchSub32 with AbsoluteAddress.
  • jit/JIT.cpp:

(JSC::JIT::emitTimeoutCheck):

  • Keep timeout count in memory on X86.
  • jit/JITInlineMethods.h:

(JSC::JIT::emitValueProfilingSite):

  • remove X86 specific code, switch bucket count back into a register.
  • jit/JITStubs.cpp:
    • Stop initializing esi (it is no longer the timeoutCheck!)
  • jit/JSInterfaceJIT.h:
    • change definition of esi to be the bucketCountRegister.
  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):

  • runtime/JSGlobalData.h:
    • Add timeoutCount as a property to global data (the counter should be per-thread).
Location:
trunk/Source/JavaScriptCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r96562 r96563  
     12011-10-03  Gavin Barraclough  <barraclough@apple.com>
     2
     3        On X86, switch bucketCount into a register, timeoutCheck into memory
     4        https://bugs.webkit.org/show_bug.cgi?id=69299
     5
     6        Reviewed by Geoff Garen.
     7
     8        We don't have sufficient registers to keep both in registers, and DFG JIT will trample esi;
     9        it doesn't matter if the bucketCount gets stomped on (in fact it may add to randomness!),
     10        but it if the timeoutCheck gets trashed we may make calls out to the timout_check stub
     11        function too frequently (regressing performance). This patch has no perf impact on sunspider.
     12
     13        * JavaScriptCore.xcodeproj/project.pbxproj:
     14        * assembler/MacroAssemblerX86.h:
     15        (JSC::MacroAssemblerX86::branchAdd32):
     16        (JSC::MacroAssemblerX86::branchSub32):
     17            - Added branchSub32 with AbsoluteAddress.
     18        * jit/JIT.cpp:
     19        (JSC::JIT::emitTimeoutCheck):
     20            - Keep timeout count in memory on X86.
     21        * jit/JITInlineMethods.h:
     22        (JSC::JIT::emitValueProfilingSite):
     23            - remove X86 specific code, switch bucket count back into a register.
     24        * jit/JITStubs.cpp:
     25            - Stop initializing esi (it is no longer the timeoutCheck!)
     26        * jit/JSInterfaceJIT.h:
     27            - change definition of esi to be the bucketCountRegister.
     28        * runtime/JSGlobalData.cpp:
     29        (JSC::JSGlobalData::JSGlobalData):
     30        * runtime/JSGlobalData.h:
     31            - Add timeoutCount as a property to global data (the counter should be per-thread).
     32
    1332011-10-03  Filip Pizlo  <fpizlo@apple.com>
    234
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r96527 r96563  
    10531053                860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86_64.h; sourceTree = "<group>"; };
    10541054                860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86Common.h; sourceTree = "<group>"; };
     1055                8604F4F2143A6C4400B295F5 /* ChangeLog */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; };
    10551056                8626BECE11928E3900782FAB /* StringStatics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringStatics.cpp; path = text/StringStatics.cpp; sourceTree = "<group>"; };
    10561057                8627E5EA11F1281900A313B5 /* PageAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocation.h; sourceTree = "<group>"; };
     
    15501551                        isa = PBXGroup;
    15511552                        children = (
     1553                                8604F4F2143A6C4400B295F5 /* ChangeLog */,
    15521554                                651122E5140469BA002B101D /* testRegExp.cpp */,
    15531555                                A718F8211178EB4B002465A7 /* create_regex_tables */,
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h

    r95902 r96563  
    4545    using MacroAssemblerX86Common::and32;
    4646    using MacroAssemblerX86Common::branchAdd32;
     47    using MacroAssemblerX86Common::branchSub32;
    4748    using MacroAssemblerX86Common::sub32;
    4849    using MacroAssemblerX86Common::or32;
     
    123124    }
    124125
    125     Jump branchAdd32(ResultCondition cond, TrustedImm32 src, AbsoluteAddress dest)
    126     {
    127         m_assembler.addl_im(src.m_value, dest.m_ptr);
     126    Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest)
     127    {
     128        m_assembler.addl_im(imm.m_value, dest.m_ptr);
     129        return Jump(m_assembler.jCC(x86Condition(cond)));
     130    }
     131
     132    Jump branchSub32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest)
     133    {
     134        m_assembler.subl_im(imm.m_value, dest.m_ptr);
    128135        return Jump(m_assembler.jCC(x86Condition(cond)));
    129136    }
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r96463 r96563  
    109109#endif
    110110
    111 #if USE(JSVALUE32_64)
     111#if CPU(X86)
     112void JIT::emitTimeoutCheck()
     113{
     114    Jump skipTimeout = branchSub32(NonZero, TrustedImm32(1), AbsoluteAddress(&m_globalData->m_timeoutCount));
     115    JITStubCall stubCall(this, cti_timeout_check);
     116    stubCall.addArgument(regT1, regT0); // save last result registers.
     117    stubCall.call(regT0);
     118    store32(regT0, &m_globalData->m_timeoutCount);
     119    stubCall.getArgument(0, regT1, regT0); // reload last result registers.
     120    skipTimeout.link(this);
     121}
     122#elif USE(JSVALUE32_64)
    112123void JIT::emitTimeoutCheck()
    113124{
     
    723734}
    724735
    725 #if CPU(X86) && ENABLE(VALUE_PROFILER)
    726 int bucketCounter = 0;
    727 #endif
    728 
    729736} // namespace JSC
    730737
  • trunk/Source/JavaScriptCore/jit/JITInlineMethods.h

    r95901 r96563  
    447447}
    448448
    449 #if CPU(X86) && ENABLE(VALUE_PROFILER)
    450 extern int bucketCounter;
    451 #endif
    452 
    453449#if ENABLE(VALUE_PROFILER)
    454450inline void JIT::emitValueProfilingSite(ValueProfilingSiteKind siteKind)
     
    470466    ASSERT(valueProfile);
    471467   
    472 #if CPU(X86)
    473     if (m_randomGenerator.getUint32() & 1)
    474         add32(Imm32(1), AbsoluteAddress(&bucketCounter));
    475     else
    476         add32(Imm32(3), AbsoluteAddress(&bucketCounter));
    477     and32(Imm32(ValueProfile::bucketIndexMask), AbsoluteAddress(&bucketCounter));
    478     load32(&bucketCounter, scratch);
    479     lshift32(TrustedImm32(3), scratch);
    480     addPtr(ImmPtr(valueProfile->m_buckets), scratch);
    481     storePtr(value, scratch);
    482 #else
    483468    if (m_randomGenerator.getUint32() & 1)
    484469        add32(Imm32(1), bucketCounterRegister);
     
    488473    move(ImmPtr(valueProfile->m_buckets), scratch);
    489474    storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight));
    490 #endif
    491475}
    492476#endif
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r96527 r96563  
    132132    "pushl %ebx" "\n"
    133133    "subl $0x3c, %esp" "\n"
    134     "movl $512, %esi" "\n"
    135134    "movl 0x58(%esp), %edi" "\n"
    136135    "call *0x50(%esp)" "\n"
     
    262261            push ebx;
    263262            sub esp, 0x3c;
    264             mov esi, 512;
    265263            mov ecx, esp;
    266264            mov edi, [esp + 0x58];
  • trunk/Source/JavaScriptCore/jit/JSInterfaceJIT.h

    r95901 r96563  
    8181        static const RegisterID firstArgumentRegister = X86Registers::ecx;
    8282       
    83         static const RegisterID timeoutCheckRegister = X86Registers::esi;
     83        static const RegisterID bucketCounterRegister = X86Registers::esi;
    8484        static const RegisterID callFrameRegister = X86Registers::edi;
    8585       
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r96465 r96563  
    200200    , exclusiveThread(0)
    201201#endif
     202#if CPU(X86) && ENABLE(JIT)
     203    , m_timeoutCount(512)
     204#endif
    202205#if ENABLE(GC_VALIDATION)
    203206    , m_isInitializingObject(false)
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r96465 r96563  
    306306#endif
    307307
     308#if CPU(X86) && ENABLE(JIT)
     309        unsigned m_timeoutCount;
     310#endif
     311
    308312    private:
    309313        JSGlobalData(GlobalDataType, ThreadStackType, HeapSize);
Note: See TracChangeset for help on using the changeset viewer.