Title: [96563] trunk/Source/_javascript_Core
Revision
96563
Author
[email protected]
Date
2011-10-03 18:16:46 -0700 (Mon, 03 Oct 2011)

Log 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.

* _javascript_Core.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).

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (96562 => 96563)


--- trunk/Source/_javascript_Core/ChangeLog	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-10-04 01:16:46 UTC (rev 96563)
@@ -1,3 +1,35 @@
+2011-10-03  Gavin Barraclough  <[email protected]>
+
+        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.
+
+        * _javascript_Core.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).
+
 2011-10-03  Filip Pizlo  <[email protected]>
 
         DFG backends don't have access to per-node predictions from the propagator

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (96562 => 96563)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2011-10-04 01:16:46 UTC (rev 96563)
@@ -1052,6 +1052,7 @@
 		860161E00F3A83C100F84710 /* MacroAssemblerX86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86.h; sourceTree = "<group>"; };
 		860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86_64.h; sourceTree = "<group>"; };
 		860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86Common.h; sourceTree = "<group>"; };
+		8604F4F2143A6C4400B295F5 /* ChangeLog */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; };
 		8626BECE11928E3900782FAB /* StringStatics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringStatics.cpp; path = text/StringStatics.cpp; sourceTree = "<group>"; };
 		8627E5EA11F1281900A313B5 /* PageAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocation.h; sourceTree = "<group>"; };
 		863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerCodeRef.h; sourceTree = "<group>"; };
@@ -1549,6 +1550,7 @@
 		0867D691FE84028FC02AAC07 /* _javascript_Core */ = {
 			isa = PBXGroup;
 			children = (
+				8604F4F2143A6C4400B295F5 /* ChangeLog */,
 				651122E5140469BA002B101D /* testRegExp.cpp */,
 				A718F8211178EB4B002465A7 /* create_regex_tables */,
 				937B63CC09E766D200A671DD /* DerivedSources.make */,

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86.h (96562 => 96563)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86.h	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86.h	2011-10-04 01:16:46 UTC (rev 96563)
@@ -44,6 +44,7 @@
     using MacroAssemblerX86Common::add32;
     using MacroAssemblerX86Common::and32;
     using MacroAssemblerX86Common::branchAdd32;
+    using MacroAssemblerX86Common::branchSub32;
     using MacroAssemblerX86Common::sub32;
     using MacroAssemblerX86Common::or32;
     using MacroAssemblerX86Common::load32;
@@ -122,12 +123,18 @@
         m_assembler.movl_rm(src, address);
     }
 
-    Jump branchAdd32(ResultCondition cond, TrustedImm32 src, AbsoluteAddress dest)
+    Jump branchAdd32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest)
     {
-        m_assembler.addl_im(src.m_value, dest.m_ptr);
+        m_assembler.addl_im(imm.m_value, dest.m_ptr);
         return Jump(m_assembler.jCC(x86Condition(cond)));
     }
 
+    Jump branchSub32(ResultCondition cond, TrustedImm32 imm, AbsoluteAddress dest)
+    {
+        m_assembler.subl_im(imm.m_value, dest.m_ptr);
+        return Jump(m_assembler.jCC(x86Condition(cond)));
+    }
+
     Jump branch32(RelationalCondition cond, AbsoluteAddress left, RegisterID right)
     {
         m_assembler.cmpl_rm(right, left.m_ptr);

Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (96562 => 96563)


--- trunk/Source/_javascript_Core/jit/JIT.cpp	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp	2011-10-04 01:16:46 UTC (rev 96563)
@@ -108,9 +108,20 @@
 }
 #endif
 
-#if USE(JSVALUE32_64)
+#if CPU(X86)
 void JIT::emitTimeoutCheck()
 {
+    Jump skipTimeout = branchSub32(NonZero, TrustedImm32(1), AbsoluteAddress(&m_globalData->m_timeoutCount));
+    JITStubCall stubCall(this, cti_timeout_check);
+    stubCall.addArgument(regT1, regT0); // save last result registers.
+    stubCall.call(regT0);
+    store32(regT0, &m_globalData->m_timeoutCount);
+    stubCall.getArgument(0, regT1, regT0); // reload last result registers.
+    skipTimeout.link(this);
+}
+#elif USE(JSVALUE32_64)
+void JIT::emitTimeoutCheck()
+{
     Jump skipTimeout = branchSub32(NonZero, TrustedImm32(1), timeoutCheckRegister);
     JITStubCall stubCall(this, cti_timeout_check);
     stubCall.addArgument(regT1, regT0); // save last result registers.
@@ -722,10 +733,6 @@
     repatchBuffer.relink(CodeLocationNearCall(callLinkInfo->callReturnLocation), globalData->jitStubs->ctiVirtualConstruct());
 }
 
-#if CPU(X86) && ENABLE(VALUE_PROFILER)
-int bucketCounter = 0;
-#endif
-
 } // namespace JSC
 
 #endif // ENABLE(JIT)

Modified: trunk/Source/_javascript_Core/jit/JITInlineMethods.h (96562 => 96563)


--- trunk/Source/_javascript_Core/jit/JITInlineMethods.h	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/jit/JITInlineMethods.h	2011-10-04 01:16:46 UTC (rev 96563)
@@ -446,10 +446,6 @@
 #endif
 }
 
-#if CPU(X86) && ENABLE(VALUE_PROFILER)
-extern int bucketCounter;
-#endif
-
 #if ENABLE(VALUE_PROFILER)
 inline void JIT::emitValueProfilingSite(ValueProfilingSiteKind siteKind)
 {
@@ -469,25 +465,13 @@
     
     ASSERT(valueProfile);
     
-#if CPU(X86)
     if (m_randomGenerator.getUint32() & 1)
-        add32(Imm32(1), AbsoluteAddress(&bucketCounter));
-    else
-        add32(Imm32(3), AbsoluteAddress(&bucketCounter));
-    and32(Imm32(ValueProfile::bucketIndexMask), AbsoluteAddress(&bucketCounter));
-    load32(&bucketCounter, scratch);
-    lshift32(TrustedImm32(3), scratch);
-    addPtr(ImmPtr(valueProfile->m_buckets), scratch);
-    storePtr(value, scratch);
-#else
-    if (m_randomGenerator.getUint32() & 1)
         add32(Imm32(1), bucketCounterRegister);
     else
         add32(Imm32(3), bucketCounterRegister);
     and32(Imm32(ValueProfile::bucketIndexMask), bucketCounterRegister);
     move(ImmPtr(valueProfile->m_buckets), scratch);
     storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight));
-#endif
 }
 #endif
 

Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (96562 => 96563)


--- trunk/Source/_javascript_Core/jit/JITStubs.cpp	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp	2011-10-04 01:16:46 UTC (rev 96563)
@@ -131,7 +131,6 @@
     "pushl %edi" "\n"
     "pushl %ebx" "\n"
     "subl $0x3c, %esp" "\n"
-    "movl $512, %esi" "\n"
     "movl 0x58(%esp), %edi" "\n"
     "call *0x50(%esp)" "\n"
     "addl $0x3c, %esp" "\n"
@@ -261,7 +260,6 @@
             push edi;
             push ebx;
             sub esp, 0x3c;
-            mov esi, 512;
             mov ecx, esp;
             mov edi, [esp + 0x58];
             call [esp + 0x50];

Modified: trunk/Source/_javascript_Core/jit/JSInterfaceJIT.h (96562 => 96563)


--- trunk/Source/_javascript_Core/jit/JSInterfaceJIT.h	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/jit/JSInterfaceJIT.h	2011-10-04 01:16:46 UTC (rev 96563)
@@ -80,7 +80,7 @@
         // OS X if might make more sense to just use regparm.
         static const RegisterID firstArgumentRegister = X86Registers::ecx;
         
-        static const RegisterID timeoutCheckRegister = X86Registers::esi;
+        static const RegisterID bucketCounterRegister = X86Registers::esi;
         static const RegisterID callFrameRegister = X86Registers::edi;
         
         static const RegisterID regT0 = X86Registers::eax;

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp (96562 => 96563)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.cpp	2011-10-04 01:16:46 UTC (rev 96563)
@@ -199,6 +199,9 @@
 #ifndef NDEBUG
     , exclusiveThread(0)
 #endif
+#if CPU(X86) && ENABLE(JIT)
+    , m_timeoutCount(512)
+#endif
 #if ENABLE(GC_VALIDATION)
     , m_isInitializingObject(false)
 #endif

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalData.h (96562 => 96563)


--- trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2011-10-04 01:05:38 UTC (rev 96562)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalData.h	2011-10-04 01:16:46 UTC (rev 96563)
@@ -305,6 +305,10 @@
         void setInitializingObject(bool);
 #endif
 
+#if CPU(X86) && ENABLE(JIT)
+        unsigned m_timeoutCount;
+#endif
+
     private:
         JSGlobalData(GlobalDataType, ThreadStackType, HeapSize);
         static JSGlobalData*& sharedInstanceInternal();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to