Title: [280996] trunk/Source/_javascript_Core
Revision
280996
Author
[email protected]
Date
2021-08-12 16:49:42 -0700 (Thu, 12 Aug 2021)

Log Message

Refactor some ARM64EHash code.
https://bugs.webkit.org/show_bug.cgi?id=229054

Reviewed by Keith Miller and Robin Morisset.

This patch only refactors ARM64EHash code by moving some methods into the private
section, and removing some unneeded static_casts.

Verified with a diff of `otool -tv` dumps of the built _javascript_Core binaries,
that there are no diffs in the generated code from this change.

* assembler/AssemblerBuffer.h:
(JSC::ARM64EHash::ARM64EHash):
(JSC::ARM64EHash::update):
(JSC::ARM64EHash::makeDiversifier):
(JSC::ARM64EHash::nextValue):
(JSC::ARM64EHash::bitsForDiversifier):
(JSC::ARM64EHash::currentHash):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (280995 => 280996)


--- trunk/Source/_javascript_Core/ChangeLog	2021-08-12 23:34:07 UTC (rev 280995)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-08-12 23:49:42 UTC (rev 280996)
@@ -1,3 +1,24 @@
+2021-08-12  Mark Lam  <[email protected]>
+
+        Refactor some ARM64EHash code.
+        https://bugs.webkit.org/show_bug.cgi?id=229054
+
+        Reviewed by Keith Miller and Robin Morisset.
+
+        This patch only refactors ARM64EHash code by moving some methods into the private
+        section, and removing some unneeded static_casts.
+
+        Verified with a diff of `otool -tv` dumps of the built _javascript_Core binaries,
+        that there are no diffs in the generated code from this change.
+
+        * assembler/AssemblerBuffer.h:
+        (JSC::ARM64EHash::ARM64EHash):
+        (JSC::ARM64EHash::update):
+        (JSC::ARM64EHash::makeDiversifier):
+        (JSC::ARM64EHash::nextValue):
+        (JSC::ARM64EHash::bitsForDiversifier):
+        (JSC::ARM64EHash::currentHash):
+
 2021-08-12  Saam Barati  <[email protected]>
 
         Update ARM64EHash

Modified: trunk/Source/_javascript_Core/assembler/AssemblerBuffer.h (280995 => 280996)


--- trunk/Source/_javascript_Core/assembler/AssemblerBuffer.h	2021-08-12 23:34:07 UTC (rev 280995)
+++ trunk/Source/_javascript_Core/assembler/AssemblerBuffer.h	2021-08-12 23:49:42 UTC (rev 280996)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -205,12 +205,27 @@
 #if CPU(ARM64E)
     class ARM64EHash {
     public:
+        ARM64EHash(void* diversifier)
+        {
+            setUpdatedHash(0, 0, diversifier);
+        }
+
+        ALWAYS_INLINE uint32_t update(uint32_t instruction, uint32_t index, void* diversifier)
+        {
+            uint32_t currentHash = this->currentHash(index, diversifier);
+            uint64_t nextIndex = index + 1;
+            uint32_t output = nextValue(instruction, nextIndex, currentHash);
+            setUpdatedHash(output, nextIndex, diversifier);
+            return output;
+        }
+
+    private:
         static constexpr uint8_t initializationNamespace = 0x11;
 
         static ALWAYS_INLINE PtrTag makeDiversifier(uint8_t namespaceTag, uint64_t index, uint32_t value)
         {
             // <namespaceTag:8><index:24><value:32>
-            return static_cast<PtrTag>((static_cast<uint64_t>(namespaceTag) << 56) + ((index & 0xFFFFFF) << 32) + static_cast<uint64_t>(value));
+            return static_cast<PtrTag>((static_cast<uint64_t>(namespaceTag) << 56) + ((index & 0xFFFFFF) << 32) + value);
         }
 
         static ALWAYS_INLINE uint32_t nextValue(uint64_t instruction, uint64_t index, uint32_t currentValue)
@@ -217,23 +232,20 @@
         {
             uint64_t a = tagInt(instruction, makeDiversifier(0x12, index, currentValue));
             uint64_t b = tagInt(instruction, makeDiversifier(0x13, index, currentValue));
-            return static_cast<uint32_t>((a >> 39) ^ (b >> 23));
+            return (a >> 39) ^ (b >> 23);
         }
 
         static ALWAYS_INLINE uint32_t bitsForDiversifier(void* diversifier)
         {
-            return static_cast<uint32_t>(bitwise_cast<uintptr_t>(diversifier));
+            return bitwise_cast<uintptr_t>(diversifier);
         }
 
         ALWAYS_INLINE uint32_t currentHash(uint32_t index, void* diversifier)
         {
-            uint64_t result;
             bool hashFieldIsTagged = index == 0;
             if (hashFieldIsTagged)
-                result = untagInt(m_hash, makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier)));
-            else
-                result = m_hash;
-            return static_cast<uint32_t>(result);
+                return untagInt(m_hash, makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier)));
+            return m_hash;
         }
 
         ALWAYS_INLINE void setUpdatedHash(uint32_t value, uint32_t index, void* diversifier)
@@ -245,21 +257,6 @@
                 m_hash = value;
         }
 
-        ARM64EHash(void* diversifier)
-        {
-            setUpdatedHash(0, 0, diversifier);
-        }
- 
-        ALWAYS_INLINE uint32_t update(uint32_t instruction, uint32_t index, void* diversifier)
-        {
-            uint32_t currentHash = this->currentHash(index, diversifier);
-            uint64_t nextIndex = index + 1;
-            uint32_t output = nextValue(instruction, nextIndex, currentHash);
-            setUpdatedHash(output, nextIndex, diversifier);
-            return output;
-        }
-
-    private:
         uint64_t m_hash;
     };
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to