Don't use int offsets in StructureStubInfo
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Sep 2018 04:27:10 +0000 (04:27 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Sep 2018 04:27:10 +0000 (04:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190064
<rdar://problem/44784719>

Reviewed by Mark Lam.

* bytecode/InlineAccess.cpp:
(JSC::linkCodeInline):
* bytecode/StructureStubInfo.h:
(JSC::StructureStubInfo::slowPathCallLocation):
(JSC::StructureStubInfo::doneLocation):
(JSC::StructureStubInfo::slowPathStartLocation):
* jit/JITInlineCacheGenerator.cpp:
(JSC::JITInlineCacheGenerator::finalize):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/InlineAccess.cpp
Source/JavaScriptCore/bytecode/StructureStubInfo.h
Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp

index f090e9a..56e3e4f 100644 (file)
@@ -1,3 +1,20 @@
+2018-09-27  Saam barati  <sbarati@apple.com>
+
+        Don't use int offsets in StructureStubInfo
+        https://bugs.webkit.org/show_bug.cgi?id=190064
+        <rdar://problem/44784719>
+
+        Reviewed by Mark Lam.
+
+        * bytecode/InlineAccess.cpp:
+        (JSC::linkCodeInline):
+        * bytecode/StructureStubInfo.h:
+        (JSC::StructureStubInfo::slowPathCallLocation):
+        (JSC::StructureStubInfo::doneLocation):
+        (JSC::StructureStubInfo::slowPathStartLocation):
+        * jit/JITInlineCacheGenerator.cpp:
+        (JSC::JITInlineCacheGenerator::finalize):
+
 2018-09-27  Mark Lam  <mark.lam@apple.com>
 
         DFG::OSREntry::m_machineCodeOffset should be a CodeLocation.
index 4592a18..b7efc37 100644 (file)
@@ -142,9 +142,9 @@ void InlineAccess::dumpCacheSizesAndCrash()
 template <typename Function>
 ALWAYS_INLINE static bool linkCodeInline(const char* name, CCallHelpers& jit, StructureStubInfo& stubInfo, const Function& function)
 {
-    if (jit.m_assembler.buffer().codeSize() <= stubInfo.patch.inlineSize) {
+    if (jit.m_assembler.buffer().codeSize() <= stubInfo.patch.inlineSize()) {
         bool needsBranchCompaction = false;
-        LinkBuffer linkBuffer(jit, stubInfo.patch.start, stubInfo.patch.inlineSize, JITCompilationMustSucceed, needsBranchCompaction);
+        LinkBuffer linkBuffer(jit, stubInfo.patch.start, stubInfo.patch.inlineSize(), JITCompilationMustSucceed, needsBranchCompaction);
         ASSERT(linkBuffer.isValid());
         function(linkBuffer);
         FINALIZE_CODE(linkBuffer, NoPtrTag, "InlineAccessType: '%s'", name);
@@ -159,7 +159,7 @@ ALWAYS_INLINE static bool linkCodeInline(const char* name, CCallHelpers& jit, St
     const bool failIfCantInline = false;
     if (failIfCantInline) {
         dataLog("Failure for: ", name, "\n");
-        dataLog("real size: ", jit.m_assembler.buffer().codeSize(), " inline size:", stubInfo.patch.inlineSize, "\n");
+        dataLog("real size: ", jit.m_assembler.buffer().codeSize(), " inline size:", stubInfo.patch.inlineSize(), "\n");
         CRASH();
     }
 
index 914991e..d3a35ac 100644 (file)
@@ -186,10 +186,18 @@ public:
     
     struct {
         CodeLocationLabel<JITStubRoutinePtrTag> start; // This is either the start of the inline IC for *byId caches. or the location of patchable jump for 'instanceof' caches.
+        CodeLocationLabel<JSInternalPtrTag> doneLocation;
+        CodeLocationCall<JSInternalPtrTag> slowPathCallLocation;
+        CodeLocationLabel<JITStubRoutinePtrTag> slowPathStartLocation;
+
         RegisterSet usedRegisters;
-        uint32_t inlineSize;
-        int32_t deltaFromStartToSlowPathCallLocation;
-        int32_t deltaFromStartToSlowPathStart;
+
+        uint32_t inlineSize() const
+        {
+            int32_t inlineSize = MacroAssembler::differenceBetweenCodePtr(start, doneLocation);
+            ASSERT(inlineSize >= 0);
+            return inlineSize;
+        }
 
         GPRReg baseGPR;
         GPRReg valueGPR;
@@ -206,9 +214,10 @@ public:
         return patch.baseGPR;
     }
 
-    CodeLocationCall<JSInternalPtrTag> slowPathCallLocation() { return patch.start.callAtOffset<JSInternalPtrTag>(patch.deltaFromStartToSlowPathCallLocation); }
-    CodeLocationLabel<JSInternalPtrTag> doneLocation() { return patch.start.labelAtOffset<JSInternalPtrTag>(patch.inlineSize); }
-    CodeLocationLabel<JITStubRoutinePtrTag> slowPathStartLocation() { return patch.start.labelAtOffset(patch.deltaFromStartToSlowPathStart); }
+    CodeLocationCall<JSInternalPtrTag> slowPathCallLocation() { return patch.slowPathCallLocation; }
+    CodeLocationLabel<JSInternalPtrTag> doneLocation() { return patch.doneLocation; }
+    CodeLocationLabel<JITStubRoutinePtrTag> slowPathStartLocation() { return patch.slowPathStartLocation; }
+
     CodeLocationJump<JSInternalPtrTag> patchableJump()
     { 
         ASSERT(accessType == AccessType::InstanceOf);
index baf2799..064f618 100644 (file)
@@ -59,14 +59,10 @@ void JITInlineCacheGenerator::finalize(
 {
     m_stubInfo->patch.start = start;
 
-    int32_t inlineSize = MacroAssembler::differenceBetweenCodePtr(
-        start, fastPath.locationOf<NoPtrTag>(m_done));
-    m_stubInfo->patch.inlineSize = inlineSize;
-
-    m_stubInfo->patch.deltaFromStartToSlowPathCallLocation = MacroAssembler::differenceBetweenCodePtr(
-        start, slowPath.locationOf<NoPtrTag>(m_slowPathCall));
-    m_stubInfo->patch.deltaFromStartToSlowPathStart = MacroAssembler::differenceBetweenCodePtr(
-        start, slowPath.locationOf<NoPtrTag>(m_slowPathBegin));
+    m_stubInfo->patch.doneLocation = fastPath.locationOf<JSInternalPtrTag>(m_done);
+
+    m_stubInfo->patch.slowPathCallLocation = slowPath.locationOf<JSInternalPtrTag>(m_slowPathCall);
+    m_stubInfo->patch.slowPathStartLocation = slowPath.locationOf<JITStubRoutinePtrTag>(m_slowPathBegin);
 }
 
 JITByIdGenerator::JITByIdGenerator(