[Armv7] Linkbuffer: executableOffsetFor() fails for location 2
authorguijemont@igalia.com <guijemont@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jun 2018 17:16:21 +0000 (17:16 +0000)
committerguijemont@igalia.com <guijemont@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Jun 2018 17:16:21 +0000 (17:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186765

Reviewed by Michael Saboff.

This widens the check for 0 so that we handle that case more correctly.

* assembler/LinkBuffer.h:
(JSC::LinkBuffer::executableOffsetFor):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/LinkBuffer.h

index dc72304..e14dc3c 100644 (file)
@@ -1,3 +1,15 @@
+2018-06-20  Guillaume Emont  <guijemont@igalia.com>
+
+        [Armv7] Linkbuffer: executableOffsetFor() fails for location 2
+        https://bugs.webkit.org/show_bug.cgi?id=186765
+
+        Reviewed by Michael Saboff.
+
+        This widens the check for 0 so that we handle that case more correctly.
+
+        * assembler/LinkBuffer.h:
+        (JSC::LinkBuffer::executableOffsetFor):
+
 2018-06-19  Keith Miller  <keith_miller@apple.com>
 
         Fix broken assertion on 32-bit
index 792a8c9..06c2670 100644 (file)
@@ -297,7 +297,11 @@ private:
 #if ENABLE(BRANCH_COMPACTION)
     int executableOffsetFor(int location)
     {
-        if (!location)
+        // Returning 0 in this case works because at location <
+        // sizeof(int32_t), no compaction could have happened before this
+        // point as the assembler could not have placed a branch instruction
+        // within this space that required compaction.
+        if (location < static_cast<int>(sizeof(int32_t)))
             return 0;
         return bitwise_cast<int32_t*>(m_assemblerStorage.buffer())[location / sizeof(int32_t) - 1];
     }