Title: [242103] trunk/Source/_javascript_Core
Revision
242103
Author
mark....@apple.com
Date
2019-02-26 13:40:48 -0800 (Tue, 26 Feb 2019)

Log Message

Misc cleanup in StructureIDTable after r242096.
https://bugs.webkit.org/show_bug.cgi?id=195063

Reviewed by Saam Barati.

* runtime/StructureIDTable.cpp:
(JSC::StructureIDTable::allocateID):
- RELEASE_ASSERT that the StructureID allocation will succeed.

* runtime/StructureIDTable.h:
(JSC::StructureIDTable::decode):
(JSC::StructureIDTable::encode):
- Add back a comment that Yusuke requested but was lost when the patch was rolled
  out and relanded.
- Applied bitwise_casts that Saam requested.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (242102 => 242103)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-26 21:01:28 UTC (rev 242102)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-26 21:40:48 UTC (rev 242103)
@@ -1,5 +1,23 @@
 2019-02-26  Mark Lam  <mark....@apple.com>
 
+        Misc cleanup in StructureIDTable after r242096.
+        https://bugs.webkit.org/show_bug.cgi?id=195063
+
+        Reviewed by Saam Barati.
+
+        * runtime/StructureIDTable.cpp:
+        (JSC::StructureIDTable::allocateID):
+        - RELEASE_ASSERT that the StructureID allocation will succeed.
+
+        * runtime/StructureIDTable.h:
+        (JSC::StructureIDTable::decode):
+        (JSC::StructureIDTable::encode):
+        - Add back a comment that Yusuke requested but was lost when the patch was rolled
+          out and relanded.
+        - Applied bitwise_casts that Saam requested.
+
+2019-02-26  Mark Lam  <mark....@apple.com>
+
         Gardening: 32-bit build fix after r242096.
         https://bugs.webkit.org/show_bug.cgi?id=194989
 

Modified: trunk/Source/_javascript_Core/runtime/StructureIDTable.cpp (242102 => 242103)


--- trunk/Source/_javascript_Core/runtime/StructureIDTable.cpp	2019-02-26 21:01:28 UTC (rev 242102)
+++ trunk/Source/_javascript_Core/runtime/StructureIDTable.cpp	2019-02-26 21:40:48 UTC (rev 242103)
@@ -135,11 +135,9 @@
         ASSERT(m_size == m_capacity);
         resize(m_capacity * 2);
         ASSERT(m_size < m_capacity);
-        ASSERT(m_firstFreeOffset);
+        RELEASE_ASSERT(m_firstFreeOffset);
     }
 
-    ASSERT(m_firstFreeOffset != s_unusedID);
-
     // entropyBits must not be zero. This ensures that if a corrupted
     // structureID is encountered (with incorrect entropyBits), the decoded
     // structure pointer for that ID will be always be a bad pointer with

Modified: trunk/Source/_javascript_Core/runtime/StructureIDTable.h (242102 => 242103)


--- trunk/Source/_javascript_Core/runtime/StructureIDTable.h	2019-02-26 21:01:28 UTC (rev 242102)
+++ trunk/Source/_javascript_Core/runtime/StructureIDTable.h	2019-02-26 21:40:48 UTC (rev 242103)
@@ -131,6 +131,25 @@
     static constexpr StructureID s_unusedID = 0;
 
 public:
+    // 1. StructureID is encoded as:
+    //
+    //    ----------------------------------------------------------------
+    //    | 1 Nuke Bit | 24 StructureIDTable index bits | 7 entropy bits |
+    //    ----------------------------------------------------------------
+    //
+    //    The entropy bits are chosen at random and assigned when a StructureID
+    //    is allocated.
+    //
+    // 2. For each StructureID, the StructureIDTable stores encodedStructureBits
+    //    which are encoded from the structure pointer as such:
+    //
+    //    ----------------------------------------------------------------
+    //    | 7 entropy bits |                   57 structure pointer bits |
+    //    ----------------------------------------------------------------
+    //
+    //    The entropy bits here are the same 7 bits used in the encoding of the
+    //    StructureID for this structure entry in the StructureIDTable.
+
     static constexpr uint32_t s_numberOfNukeBits = 1;
     static constexpr uint32_t s_numberOfEntropyBits = 7;
     static constexpr uint32_t s_entropyBitsShiftForStructurePointer = (sizeof(intptr_t) * 8) - s_numberOfEntropyBits;
@@ -140,12 +159,12 @@
 
 ALWAYS_INLINE Structure* StructureIDTable::decode(EncodedStructureBits bits, StructureID structureID)
 {
-    return reinterpret_cast<Structure*>(bits ^ (static_cast<uintptr_t>(structureID) << s_entropyBitsShiftForStructurePointer));
+    return bitwise_cast<Structure*>(bits ^ (static_cast<uintptr_t>(structureID) << s_entropyBitsShiftForStructurePointer));
 }
 
 ALWAYS_INLINE EncodedStructureBits StructureIDTable::encode(Structure* structure, StructureID structureID)
 {
-    return reinterpret_cast<EncodedStructureBits>(structure) ^ (static_cast<EncodedStructureBits>(structureID) << s_entropyBitsShiftForStructurePointer);
+    return bitwise_cast<EncodedStructureBits>(structure) ^ (static_cast<EncodedStructureBits>(structureID) << s_entropyBitsShiftForStructurePointer);
 }
 
 inline Structure* StructureIDTable::get(StructureID structureID)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to