Title: [283236] trunk/Source/_javascript_Core
Revision
283236
Author
[email protected]
Date
2021-09-29 11:12:55 -0700 (Wed, 29 Sep 2021)

Log Message

[JSC] Remove CodeBlock::m_llintExecuteCounter
https://bugs.webkit.org/show_bug.cgi?id=230938

Reviewed by Keith Miller.

CodeBlock::m_llintExecuteCounter is a pointer pointing the middle of UnlinkedCodeBlock.
So this is not necessary to have this pointer separately to access to that from LLInt,
since loading UnlinkedCodeBlock and accessing to the middle of that do the same number
of loads.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::finalizeUnconditionally):
(JSC::CodeBlock::jitSoon):
(JSC::CodeBlock::jitNextInvocation):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::checkIfJITThresholdReached):
(JSC::CodeBlock::dontJITAnytimeSoon):
(JSC::CodeBlock::llintExecuteCounter const):
(JSC::CodeBlock::addressOfJITExecuteCounter): Deleted.
* llint/LowLevelInterpreter.asm:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (283235 => 283236)


--- trunk/Source/_javascript_Core/ChangeLog	2021-09-29 18:05:07 UTC (rev 283235)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-09-29 18:12:55 UTC (rev 283236)
@@ -1,3 +1,27 @@
+2021-09-29  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Remove CodeBlock::m_llintExecuteCounter
+        https://bugs.webkit.org/show_bug.cgi?id=230938
+
+        Reviewed by Keith Miller.
+
+        CodeBlock::m_llintExecuteCounter is a pointer pointing the middle of UnlinkedCodeBlock.
+        So this is not necessary to have this pointer separately to access to that from LLInt,
+        since loading UnlinkedCodeBlock and accessing to the middle of that do the same number
+        of loads.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::CodeBlock):
+        (JSC::CodeBlock::finalizeUnconditionally):
+        (JSC::CodeBlock::jitSoon):
+        (JSC::CodeBlock::jitNextInvocation):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::checkIfJITThresholdReached):
+        (JSC::CodeBlock::dontJITAnytimeSoon):
+        (JSC::CodeBlock::llintExecuteCounter const):
+        (JSC::CodeBlock::addressOfJITExecuteCounter): Deleted.
+        * llint/LowLevelInterpreter.asm:
+
 2021-09-29  Saam Barati  <[email protected]>
 
         Code inside strength reduction can incorrectly prove that we know what lastIndex is

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (283235 => 283236)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-09-29 18:05:07 UTC (rev 283235)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp	2021-09-29 18:12:55 UTC (rev 283236)
@@ -307,8 +307,6 @@
     ASSERT(source().provider());
     setNumParameters(other.numParameters());
 
-    m_llintExecuteCounter = &m_unlinkedCode->llintExecuteCounter();
-    
     vm.heap.codeBlockSet().add(this);
 }
 
@@ -357,8 +355,6 @@
     ASSERT(source().provider());
     setNumParameters(unlinkedCodeBlock->numParameters());
 
-    m_llintExecuteCounter = &m_unlinkedCode->llintExecuteCounter();
-
     vm.heap.codeBlockSet().add(this);
 }
 
@@ -1658,7 +1654,7 @@
         case JITType::HostCallThunk:
             return;
         case JITType::InterpreterThunk:
-            count = m_llintExecuteCounter->count();
+            count = m_unlinkedCode->llintExecuteCounter().count();
             break;
         case JITType::BaselineJIT:
             count = m_jitExecuteCounter.count();
@@ -3557,12 +3553,12 @@
 
 void CodeBlock::jitSoon()
 {
-    m_llintExecuteCounter->setNewThreshold(unlinkedCodeBlock()->thresholdForJIT(Options::thresholdForJITSoon()), this);
+    m_unlinkedCode->llintExecuteCounter().setNewThreshold(unlinkedCodeBlock()->thresholdForJIT(Options::thresholdForJITSoon()), this);
 }
 
 void CodeBlock::jitNextInvocation()
 {
-    m_llintExecuteCounter->setNewThreshold(0, this);
+    m_unlinkedCode->llintExecuteCounter().setNewThreshold(0, this);
 }
 
 bool CodeBlock::hasInstalledVMTrapBreakpoints() const

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (283235 => 283236)


--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2021-09-29 18:05:07 UTC (rev 283235)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h	2021-09-29 18:12:55 UTC (rev 283236)
@@ -599,12 +599,12 @@
 
     bool checkIfJITThresholdReached()
     {
-        return m_llintExecuteCounter->checkIfThresholdCrossedAndSet(this);
+        return m_unlinkedCode->llintExecuteCounter().checkIfThresholdCrossedAndSet(this);
     }
 
     void dontJITAnytimeSoon()
     {
-        m_llintExecuteCounter->deferIndefinitely();
+        m_unlinkedCode->llintExecuteCounter().deferIndefinitely();
     }
 
     void jitSoon();
@@ -612,7 +612,7 @@
 
     const BaselineExecutionCounter& llintExecuteCounter() const
     {
-        return *m_llintExecuteCounter;
+        return m_unlinkedCode->llintExecuteCounter();
     }
 
     typedef HashMap<std::tuple<StructureID, unsigned>, FixedVector<LLIntPrototypeLoadAdaptiveStructureWatchpoint>> StructureWatchpointMap;
@@ -661,11 +661,6 @@
 
     int32_t adjustedCounterValue(int32_t desiredThreshold);
 
-    int32_t* addressOfJITExecuteCounter()
-    {
-        return &m_jitExecuteCounter.m_counter;
-    }
-
     static ptrdiff_t offsetOfJITExecuteCounter() { return OBJECT_OFFSETOF(CodeBlock, m_jitExecuteCounter) + OBJECT_OFFSETOF(BaselineExecutionCounter, m_counter); }
     static ptrdiff_t offsetOfJITExecutionActiveThreshold() { return OBJECT_OFFSETOF(CodeBlock, m_jitExecuteCounter) + OBJECT_OFFSETOF(BaselineExecutionCounter, m_activeThreshold); }
     static ptrdiff_t offsetOfJITExecutionTotalCount() { return OBJECT_OFFSETOF(CodeBlock, m_jitExecuteCounter) + OBJECT_OFFSETOF(BaselineExecutionCounter, m_totalCount); }
@@ -984,7 +979,7 @@
     FixedVector<ValueProfile> m_argumentValueProfiles;
 
     // Constant Pool
-    COMPILE_ASSERT(sizeof(Register) == sizeof(WriteBarrier<Unknown>), Register_must_be_same_size_as_WriteBarrier_Unknown);
+    static_assert(sizeof(Register) == sizeof(WriteBarrier<Unknown>), "Register must be same size as WriteBarrier Unknown");
     // TODO: This could just be a pointer to m_unlinkedCodeBlock's data, but the DFG mutates
     // it, so we're stuck with it for now.
     Vector<WriteBarrier<Unknown>> m_constantRegisters;
@@ -992,8 +987,6 @@
     FixedVector<WriteBarrier<FunctionExecutable>> m_functionExprs;
 
     WriteBarrier<CodeBlock> m_alternative;
-    
-    BaselineExecutionCounter* m_llintExecuteCounter { nullptr };
 
     BaselineExecutionCounter m_jitExecuteCounter;
     uint32_t m_osrExitCounter;
@@ -1013,6 +1006,9 @@
     HashSet<UniquedStringImpl*> m_cachedIdentifierUids;
 #endif
 };
+#if !ASSERT_ENABLED && COMPILER(GCC_COMPATIBLE)
+static_assert(sizeof(CodeBlock) <= 256, "Keep it small for memory saving");
+#endif
 
 template <typename ExecutableType>
 void ScriptExecutable::prepareForExecution(VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock)

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (283235 => 283236)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2021-09-29 18:05:07 UTC (rev 283235)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2021-09-29 18:12:55 UTC (rev 283236)
@@ -1420,8 +1420,8 @@
 
 macro checkSwitchToJIT(increment, action)
     loadp CodeBlock[cfr], t0
-    loadp CodeBlock::m_llintExecuteCounter[t0], t0
-    baddis increment, BaselineExecutionCounter::m_counter[t0], .continue
+    loadp CodeBlock::m_unlinkedCode[t0], t0
+    baddis increment, (UnlinkedCodeBlock::m_llintExecuteCounter + BaselineExecutionCounter::m_counter)[t0], .continue
     action()
     .continue:
 end
@@ -1504,8 +1504,8 @@
     codeBlockGetter(t1)
     codeBlockSetter(t1)
     if not (C_LOOP or C_LOOP_WIN)
-        loadp CodeBlock::m_llintExecuteCounter[t1], t0
-        baddis 5, BaselineExecutionCounter::m_counter[t0], .continue
+        loadp CodeBlock::m_unlinkedCode[t1], t0
+        baddis 5, (UnlinkedCodeBlock::m_llintExecuteCounter + BaselineExecutionCounter::m_counter)[t0], .continue
         if JSVALUE64
             move cfr, a0
             move PC, a1
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to