Title: [199710] trunk/Source/_javascript_Core
Revision
199710
Author
commit-qu...@webkit.org
Date
2016-04-18 23:54:25 -0700 (Mon, 18 Apr 2016)

Log Message

[JSC] Fix some overhead affecting small codegen
https://bugs.webkit.org/show_bug.cgi?id=156728

Patch by Benjamin Poulain <bpoul...@apple.com> on 2016-04-18
Reviewed by Filip Pizlo.

* assembler/AbstractMacroAssembler.h:
(JSC::AbstractMacroAssembler::AbstractMacroAssembler):
(JSC::AbstractMacroAssembler::random):
cryptographicallyRandomNumber() is very costly.
We only need it in lowering some very particular cases
of non-trusted immediates. No inline cache needs that.

* assembler/LinkBuffer.h:
(JSC::LinkBuffer::link):
* jit/JIT.h:
* jit/JITInlines.h:
(JSC::JIT::addSlowCase):
Do not copy the JumpList to access its elements.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (199709 => 199710)


--- trunk/Source/_javascript_Core/ChangeLog	2016-04-19 06:33:05 UTC (rev 199709)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-04-19 06:54:25 UTC (rev 199710)
@@ -1,3 +1,24 @@
+2016-04-18  Benjamin Poulain  <bpoul...@apple.com>
+
+        [JSC] Fix some overhead affecting small codegen
+        https://bugs.webkit.org/show_bug.cgi?id=156728
+
+        Reviewed by Filip Pizlo.
+
+        * assembler/AbstractMacroAssembler.h:
+        (JSC::AbstractMacroAssembler::AbstractMacroAssembler):
+        (JSC::AbstractMacroAssembler::random):
+        cryptographicallyRandomNumber() is very costly.
+        We only need it in lowering some very particular cases
+        of non-trusted immediates. No inline cache needs that.
+
+        * assembler/LinkBuffer.h:
+        (JSC::LinkBuffer::link):
+        * jit/JIT.h:
+        * jit/JITInlines.h:
+        (JSC::JIT::addSlowCase):
+        Do not copy the JumpList to access its elements.
+
 2016-04-18  Saam barati  <sbar...@apple.com>
 
         implement dynamic scope accesses in the DFG/FTL

Modified: trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (199709 => 199710)


--- trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2016-04-19 06:33:05 UTC (rev 199709)
+++ trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2016-04-19 06:54:25 UTC (rev 199710)
@@ -711,8 +711,6 @@
     // A JumpList is a set of Jump objects.
     // All jumps in the set will be linked to the same destination.
     class JumpList {
-        friend class LinkBuffer;
-
     public:
         typedef Vector<Jump, 2> JumpVector;
         
@@ -1040,16 +1038,21 @@
 
 protected:
     AbstractMacroAssembler()
-        : m_randomSource(cryptographicallyRandomNumber())
+        : m_randomSource(0)
     {
         invalidateAllTempRegisters();
     }
 
     uint32_t random()
     {
+        if (!m_randomSourceIsInitialized) {
+            m_randomSourceIsInitialized = true;
+            m_randomSource.setSeed(cryptographicallyRandomNumber());
+        }
         return m_randomSource.getUint32();
     }
 
+    bool m_randomSourceIsInitialized { false };
     WeakRandom m_randomSource;
 
 #if ENABLE(DFG_REGISTER_ALLOCATION_VALIDATION)

Modified: trunk/Source/_javascript_Core/assembler/LinkBuffer.h (199709 => 199710)


--- trunk/Source/_javascript_Core/assembler/LinkBuffer.h	2016-04-19 06:33:05 UTC (rev 199709)
+++ trunk/Source/_javascript_Core/assembler/LinkBuffer.h	2016-04-19 06:54:25 UTC (rev 199710)
@@ -144,10 +144,10 @@
         MacroAssembler::linkJump(code(), jump, label);
     }
 
-    void link(JumpList list, CodeLocationLabel label)
+    void link(const JumpList& list, CodeLocationLabel label)
     {
-        for (unsigned i = 0; i < list.m_jumps.size(); ++i)
-            link(list.m_jumps[i], label);
+        for (const Jump& jump : list.jumps())
+            link(jump, label);
     }
 
     void patch(DataLabelPtr label, void* value)

Modified: trunk/Source/_javascript_Core/jit/JIT.h (199709 => 199710)


--- trunk/Source/_javascript_Core/jit/JIT.h	2016-04-19 06:33:05 UTC (rev 199709)
+++ trunk/Source/_javascript_Core/jit/JIT.h	2016-04-19 06:54:25 UTC (rev 199710)
@@ -307,7 +307,7 @@
         void privateCompileExceptionHandlers();
 
         void addSlowCase(Jump);
-        void addSlowCase(JumpList);
+        void addSlowCase(const JumpList&);
         void addSlowCase();
         void addJump(Jump, int);
         void emitJumpSlowToHot(Jump, int);

Modified: trunk/Source/_javascript_Core/jit/JITInlines.h (199709 => 199710)


--- trunk/Source/_javascript_Core/jit/JITInlines.h	2016-04-19 06:33:05 UTC (rev 199709)
+++ trunk/Source/_javascript_Core/jit/JITInlines.h	2016-04-19 06:54:25 UTC (rev 199710)
@@ -831,14 +831,12 @@
     m_slowCases.append(SlowCaseEntry(jump, m_bytecodeOffset));
 }
 
-ALWAYS_INLINE void JIT::addSlowCase(JumpList jumpList)
+ALWAYS_INLINE void JIT::addSlowCase(const JumpList& jumpList)
 {
     ASSERT(m_bytecodeOffset != std::numeric_limits<unsigned>::max()); // This method should only be called during hot/cold path generation, so that m_bytecodeOffset is set.
 
-    const JumpList::JumpVector& jumpVector = jumpList.jumps();
-    size_t size = jumpVector.size();
-    for (size_t i = 0; i < size; ++i)
-        m_slowCases.append(SlowCaseEntry(jumpVector[i], m_bytecodeOffset));
+    for (const Jump& jump : jumpList.jumps())
+        m_slowCases.append(SlowCaseEntry(jump, m_bytecodeOffset));
 }
 
 ALWAYS_INLINE void JIT::addSlowCase()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to