Title: [285331] branches/safari-612-branch/Source/_javascript_Core
Revision
285331
Author
[email protected]
Date
2021-11-04 20:40:02 -0700 (Thu, 04 Nov 2021)

Log Message

Cherry-pick r283954. rdar://problem/85045208

    Share more code that uses ScratchRegisterAllocator in the ICs
    https://bugs.webkit.org/show_bug.cgi?id=231125
    <rdar://problem/84066374>

    Reviewed by Sam Weinig.

    We had the same code to allocate a scratch register allocator copy pasted
    all over the IC code. This patch refactors that to use a shared helper.

    Also, Delete was using a ScratchRegisterAllocator for no reason (it never
    allocated a scratch register), so I deleted that code.

    * bytecode/AccessCase.cpp:
    (JSC::AccessCase::generateWithGuard):
    (JSC::AccessCase::generateImpl):
    * bytecode/GetterSetterAccessCase.cpp:
    (JSC::GetterSetterAccessCase::emitDOMJITGetter):
    * bytecode/PolymorphicAccess.cpp:
    (JSC::AccessGenerationState::makeDefaultScratchAllocator):
    (JSC::PolymorphicAccess::regenerate):
    * bytecode/PolymorphicAccess.h:
    * jit/IntrinsicEmitter.cpp:
    (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283954 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/_javascript_Core/ChangeLog (285330 => 285331)


--- branches/safari-612-branch/Source/_javascript_Core/ChangeLog	2021-11-05 03:27:54 UTC (rev 285330)
+++ branches/safari-612-branch/Source/_javascript_Core/ChangeLog	2021-11-05 03:40:02 UTC (rev 285331)
@@ -1,5 +1,62 @@
 2021-11-04  Russell Epstein  <[email protected]>
 
+        Cherry-pick r283954. rdar://problem/85045208
+
+    Share more code that uses ScratchRegisterAllocator in the ICs
+    https://bugs.webkit.org/show_bug.cgi?id=231125
+    <rdar://problem/84066374>
+    
+    Reviewed by Sam Weinig.
+    
+    We had the same code to allocate a scratch register allocator copy pasted
+    all over the IC code. This patch refactors that to use a shared helper.
+    
+    Also, Delete was using a ScratchRegisterAllocator for no reason (it never
+    allocated a scratch register), so I deleted that code.
+    
+    * bytecode/AccessCase.cpp:
+    (JSC::AccessCase::generateWithGuard):
+    (JSC::AccessCase::generateImpl):
+    * bytecode/GetterSetterAccessCase.cpp:
+    (JSC::GetterSetterAccessCase::emitDOMJITGetter):
+    * bytecode/PolymorphicAccess.cpp:
+    (JSC::AccessGenerationState::makeDefaultScratchAllocator):
+    (JSC::PolymorphicAccess::regenerate):
+    * bytecode/PolymorphicAccess.h:
+    * jit/IntrinsicEmitter.cpp:
+    (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283954 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-11  Saam Barati  <[email protected]>
+
+            Share more code that uses ScratchRegisterAllocator in the ICs
+            https://bugs.webkit.org/show_bug.cgi?id=231125
+            <rdar://problem/84066374>
+
+            Reviewed by Sam Weinig.
+
+            We had the same code to allocate a scratch register allocator copy pasted
+            all over the IC code. This patch refactors that to use a shared helper.
+
+            Also, Delete was using a ScratchRegisterAllocator for no reason (it never
+            allocated a scratch register), so I deleted that code.
+
+            * bytecode/AccessCase.cpp:
+            (JSC::AccessCase::generateWithGuard):
+            (JSC::AccessCase::generateImpl):
+            * bytecode/GetterSetterAccessCase.cpp:
+            (JSC::GetterSetterAccessCase::emitDOMJITGetter):
+            * bytecode/PolymorphicAccess.cpp:
+            (JSC::AccessGenerationState::makeDefaultScratchAllocator):
+            (JSC::PolymorphicAccess::regenerate):
+            * bytecode/PolymorphicAccess.h:
+            * jit/IntrinsicEmitter.cpp:
+            (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter):
+
+2021-11-04  Russell Epstein  <[email protected]>
+
         Cherry-pick r283512. rdar://problem/85034084
 
     IntrinsicGetterAccessCase implementation of __proto__ needs to handle get_by_id_with_this

Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/AccessCase.cpp (285330 => 285331)


--- branches/safari-612-branch/Source/_javascript_Core/bytecode/AccessCase.cpp	2021-11-05 03:27:54 UTC (rev 285330)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/AccessCase.cpp	2021-11-05 03:40:02 UTC (rev 285331)
@@ -1060,14 +1060,7 @@
         jit.load8(CCallHelpers::Address(baseGPR, JSCell::typeInfoTypeOffset()), scratchGPR);
         fallThrough.append(jit.branch32(CCallHelpers::NotEqual, scratchGPR, CCallHelpers::TrustedImm32(ScopedArgumentsType)));
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
         
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
         GPRReg scratch3GPR = allocator.allocateScratchGPR();
@@ -1165,14 +1158,7 @@
         state.failAndRepatch.append(jit.branch32(CCallHelpers::AboveOrEqual, propertyGPR, addressOfLength));
 #endif
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
 
         ScratchRegisterAllocator::PreservedState preservedState = allocator.preserveReusedRegistersByPushing(
@@ -1255,14 +1241,7 @@
 
         fallThrough.append(jit.branchIfNotString(baseGPR));
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
 
         CCallHelpers::JumpList failAndIgnore;
@@ -1316,14 +1295,8 @@
         jit.load8(CCallHelpers::Address(baseGPR, JSCell::indexingTypeAndMiscOffset()), scratchGPR);
         jit.and32(CCallHelpers::TrustedImm32(IndexingShapeMask), scratchGPR);
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
+
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
 #if USE(JSVALUE32_64)
         GPRReg scratch3GPR = allocator.allocateScratchGPR();
@@ -1424,15 +1397,7 @@
 
         CCallHelpers::JumpList isOutOfBounds;
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        if (stubInfo.m_arrayProfileGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_arrayProfileGPR);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
         ScratchRegisterAllocator::PreservedState preservedState;
 
@@ -1611,15 +1576,7 @@
         state.failAndRepatch.append(jit.branch32(CCallHelpers::AboveOrEqual, propertyGPR, addressOfLength));
 #endif
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        if (stubInfo.m_arrayProfileGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_arrayProfileGPR);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
 
         ScratchRegisterAllocator::PreservedState preservedState = allocator.preserveReusedRegistersByPushing(
@@ -1702,14 +1659,7 @@
         
         GPRReg valueGPR = valueRegs.payloadGPR();
         
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
         
         GPRReg scratch2GPR = allocator.allocateScratchGPR();
         
@@ -2278,16 +2228,7 @@
         bool reallocating = allocating && structure()->outOfLineCapacity();
         bool allocatingInline = allocating && !structure()->couldHaveIndexingHeader();
 
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        if (stubInfo.propertyRegs())
-            allocator.lock(stubInfo.propertyRegs());
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        if (stubInfo.m_arrayProfileGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_arrayProfileGPR);
-        allocator.lock(scratchGPR);
+        auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
 
         GPRReg scratchGPR2 = InvalidGPRReg;
         GPRReg scratchGPR3 = InvalidGPRReg;
@@ -2443,14 +2384,6 @@
     }
 
     case Delete: {
-        ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-        allocator.lock(stubInfo.baseRegs());
-        allocator.lock(valueRegs);
-        allocator.lock(baseGPR);
-        if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-            allocator.lock(stubInfo.m_stubInfoGPR);
-        ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-        allocator.lock(scratchGPR);
         ASSERT(structure()->transitionWatchpointSetHasBeenInvalidated());
         ASSERT(newStructure()->transitionKind() == TransitionKind::PropertyDeletion);
         ASSERT(baseGPR != scratchGPR);
@@ -2457,9 +2390,6 @@
         ASSERT(!valueRegs.uses(baseGPR));
         ASSERT(!valueRegs.uses(scratchGPR));
 
-        ScratchRegisterAllocator::PreservedState preservedState =
-            allocator.preserveReusedRegistersByPushing(jit, ScratchRegisterAllocator::ExtraStackSpace::NoExtraSpace);
-
         jit.moveValue(JSValue(), valueRegs);
 
         if (isInlineOffset(m_offset)) {
@@ -2483,7 +2413,6 @@
 
         jit.move(MacroAssembler::TrustedImm32(true), valueRegs.payloadGPR());
 
-        allocator.restoreReusedRegistersByPopping(jit, preservedState);
         state.succeed();
         return;
     }

Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/GetterSetterAccessCase.cpp (285330 => 285331)


--- branches/safari-612-branch/Source/_javascript_Core/bytecode/GetterSetterAccessCase.cpp	2021-11-05 03:27:54 UTC (rev 285330)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/GetterSetterAccessCase.cpp	2021-11-05 03:40:02 UTC (rev 285331)
@@ -136,13 +136,7 @@
     Vector<FPRReg> fpScratch;
     Vector<SnippetParams::Value> regs;
 
-    ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-    allocator.lock(stubInfo.baseRegs());
-    allocator.lock(valueRegs);
-    if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-        allocator.lock(stubInfo.m_stubInfoGPR);
-    ASSERT(stubInfo.m_arrayProfileGPR == InvalidGPRReg);
-    allocator.lock(scratchGPR);
+    auto allocator = state.makeDefaultScratchAllocator(scratchGPR);
 
     GPRReg paramBaseGPR = InvalidGPRReg;
     GPRReg paramGlobalObjectGPR = InvalidGPRReg;

Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp (285330 => 285331)


--- branches/safari-612-branch/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp	2021-11-05 03:27:54 UTC (rev 285330)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp	2021-11-05 03:40:02 UTC (rev 285331)
@@ -250,6 +250,22 @@
     }
 }
 
+ScratchRegisterAllocator AccessGenerationState::makeDefaultScratchAllocator(GPRReg extraToLock)
+{
+    ScratchRegisterAllocator allocator(stubInfo->usedRegisters);
+    allocator.lock(stubInfo->baseRegs());
+    allocator.lock(valueRegs);
+    allocator.lock(u.thisGPR);
+#if USE(JSVALUE32_64)
+    allocator.lock(stubInfo->v.thisTagGPR);
+#endif
+    allocator.lock(stubInfo->m_stubInfoGPR);
+    allocator.lock(stubInfo->m_arrayProfileGPR);
+    allocator.lock(extraToLock);
+
+    return allocator;
+}
+
 PolymorphicAccess::PolymorphicAccess() { }
 PolymorphicAccess::~PolymorphicAccess() { }
 
@@ -480,23 +496,8 @@
     }
     m_list.resize(dstIndex);
 
-    ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
+    auto allocator = state.makeDefaultScratchAllocator();
     state.allocator = &allocator;
-    allocator.lock(state.baseGPR);
-    if (state.u.thisGPR != InvalidGPRReg)
-        allocator.lock(state.u.thisGPR);
-    if (state.valueRegs)
-        allocator.lock(state.valueRegs);
-#if USE(JSVALUE32_64)
-    allocator.lock(stubInfo.baseTagGPR);
-    if (stubInfo.v.thisTagGPR != InvalidGPRReg)
-        allocator.lock(stubInfo.v.thisTagGPR);
-#endif
-    if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-        allocator.lock(stubInfo.m_stubInfoGPR);
-    if (stubInfo.m_arrayProfileGPR != InvalidGPRReg)
-        allocator.lock(stubInfo.m_arrayProfileGPR);
-
     state.scratchGPR = allocator.allocateScratchGPR();
 
     for (auto& accessCase : cases) {

Modified: branches/safari-612-branch/Source/_javascript_Core/bytecode/PolymorphicAccess.h (285330 => 285331)


--- branches/safari-612-branch/Source/_javascript_Core/bytecode/PolymorphicAccess.h	2021-11-05 03:27:54 UTC (rev 285330)
+++ branches/safari-612-branch/Source/_javascript_Core/bytecode/PolymorphicAccess.h	2021-11-05 03:40:02 UTC (rev 285331)
@@ -45,7 +45,6 @@
 class PolymorphicAccess;
 class StructureStubInfo;
 class WatchpointsOnStructureStubInfo;
-class ScratchRegisterAllocator;
 
 DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(PolymorphicAccess);
 
@@ -277,6 +276,8 @@
         m_spillStateForJSGetterSetter = spillState;
     }
     SpillState spillStateForJSGetterSetter() const { return m_spillStateForJSGetterSetter; }
+
+    ScratchRegisterAllocator makeDefaultScratchAllocator(GPRReg extraToLock = InvalidGPRReg);
     
 private:
     const RegisterSet& liveRegistersToPreserveAtExceptionHandlingCallSite();

Modified: branches/safari-612-branch/Source/_javascript_Core/jit/IntrinsicEmitter.cpp (285330 => 285331)


--- branches/safari-612-branch/Source/_javascript_Core/jit/IntrinsicEmitter.cpp	2021-11-05 03:27:54 UTC (rev 285330)
+++ branches/safari-612-branch/Source/_javascript_Core/jit/IntrinsicEmitter.cpp	2021-11-05 03:40:02 UTC (rev 285331)
@@ -152,20 +152,7 @@
     case UnderscoreProtoIntrinsic: {
         StructureStubInfo& stubInfo = *state.stubInfo;
         if (stubInfo.thisValueIsInThisGPR()) {
-            ScratchRegisterAllocator allocator(stubInfo.usedRegisters);
-            allocator.lock(state.scratchGPR);
-            allocator.lock(state.baseGPR);
-            allocator.lock(state.u.thisGPR);
-            allocator.lock(valueRegs);
-#if USE(JSVALUE32_64)
-            allocator.lock(stubInfo.baseTagGPR);
-            allocator.lock(stubInfo.v.thisTagGPR);
-#endif
-            if (stubInfo.m_stubInfoGPR != InvalidGPRReg)
-                allocator.lock(stubInfo.m_stubInfoGPR);
-            if (stubInfo.m_arrayProfileGPR != InvalidGPRReg)
-                allocator.lock(stubInfo.m_arrayProfileGPR);
-
+            auto allocator = state.makeDefaultScratchAllocator(state.scratchGPR);
             GPRReg scratch2GPR = allocator.allocateScratchGPR();
             auto preservedState = allocator.preserveReusedRegistersByPushing(jit, ScratchRegisterAllocator::ExtraStackSpace::NoExtraSpace);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to