Changeset 280984 in webkit
- Timestamp:
- Aug 12, 2021, 1:45:02 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
assembler/AssemblerBuffer.h (modified) (3 diffs)
-
assembler/LinkBuffer.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r280886 r280984 1 2021-08-12 Saam Barati <sbarati@apple.com> 2 3 Update ARM64EHash 4 https://bugs.webkit.org/show_bug.cgi?id=228962 5 <rdar://79883337> 6 7 Reviewed by Mark Lam. 8 9 * assembler/AssemblerBuffer.h: 10 (JSC::ARM64EHash::makeDiversifier): 11 (JSC::ARM64EHash::nextValue): 12 (JSC::ARM64EHash::bitsForDiversifier): 13 (JSC::ARM64EHash::currentHash): 14 (JSC::ARM64EHash::setUpdatedHash): 15 (JSC::ARM64EHash::ARM64EHash): 16 (JSC::ARM64EHash::update): 17 (JSC::ARM64EHash::finalize): 18 (JSC::AssemblerBuffer::AssemblerBuffer): 19 (JSC::AssemblerBuffer::putIntegralUnchecked): 20 (JSC::AssemblerBuffer::hash const): 21 * assembler/LinkBuffer.cpp: 22 (JSC::LinkBuffer::copyCompactAndLinkCode): 23 1 24 2021-08-11 Yusuke Suzuki <ysuzuki@apple.com> 2 25 -
trunk/Source/JavaScriptCore/assembler/AssemblerBuffer.h
r272191 r280984 206 206 class ARM64EHash { 207 207 public: 208 ARM64EHash(uint32_t initialHash) 209 : m_hash(initialHash) 210 { 211 } 212 213 ALWAYS_INLINE uint32_t update(uint32_t value) 214 { 215 uint64_t input = value ^ m_hash; 216 uint64_t a = static_cast<uint32_t>(tagInt(input, static_cast<PtrTag>(0)) >> 39); 217 uint64_t b = tagInt(input, static_cast<PtrTag>(0xb7e151628aed2a6a)) >> 23; 218 m_hash = a ^ b; 219 return m_hash; 208 static constexpr uint8_t initializationNamespace = 0x11; 209 210 static ALWAYS_INLINE PtrTag makeDiversifier(uint8_t namespaceTag, uint64_t index, uint32_t value) 211 { 212 // <namespaceTag:8><index:24><value:32> 213 return static_cast<PtrTag>((static_cast<uint64_t>(namespaceTag) << 56) + ((index & 0xFFFFFF) << 32) + static_cast<uint64_t>(value)); 214 } 215 216 static ALWAYS_INLINE uint32_t nextValue(uint64_t instruction, uint64_t index, uint32_t currentValue) 217 { 218 uint64_t a = tagInt(instruction, makeDiversifier(0x12, index, currentValue)); 219 uint64_t b = tagInt(instruction, makeDiversifier(0x13, index, currentValue)); 220 return static_cast<uint32_t>((a >> 39) ^ (b >> 23)); 221 } 222 223 static ALWAYS_INLINE uint32_t bitsForDiversifier(void* diversifier) 224 { 225 return static_cast<uint32_t>(bitwise_cast<uintptr_t>(diversifier)); 226 } 227 228 ALWAYS_INLINE uint32_t currentHash(uint32_t index, void* diversifier) 229 { 230 uint64_t result; 231 bool hashFieldIsTagged = index == 0; 232 if (hashFieldIsTagged) 233 result = untagInt(m_hash, makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier))); 234 else 235 result = m_hash; 236 return static_cast<uint32_t>(result); 237 } 238 239 ALWAYS_INLINE void setUpdatedHash(uint32_t value, uint32_t index, void* diversifier) 240 { 241 bool shouldTagHashField = index == 0; 242 if (shouldTagHashField) 243 m_hash = tagInt(static_cast<uint64_t>(value), makeDiversifier(initializationNamespace, index, bitsForDiversifier(diversifier))); 244 else 245 m_hash = value; 246 } 247 248 ARM64EHash(void* diversifier) 249 { 250 setUpdatedHash(0, 0, diversifier); 251 } 252 253 ALWAYS_INLINE uint32_t update(uint32_t instruction, uint32_t index, void* diversifier) 254 { 255 uint32_t currentHash = this->currentHash(index, diversifier); 256 uint64_t nextIndex = index + 1; 257 uint32_t output = nextValue(instruction, nextIndex, currentHash); 258 setUpdatedHash(output, nextIndex, diversifier); 259 return output; 220 260 } 221 261 222 262 private: 223 uint 32_t m_hash;263 uint64_t m_hash; 224 264 }; 225 265 #endif … … 231 271 , m_index(0) 232 272 #if CPU(ARM64E) 233 , m_hash( static_cast<uint32_t>(bitwise_cast<uint64_t>(this)))273 , m_hash(this) 234 274 , m_hashes() 235 275 #endif … … 389 429 static_assert(sizeof(value) == 4, ""); 390 430 #if CPU(ARM64E) 391 uint32_t hash = m_hash.update(value );431 uint32_t hash = m_hash.update(value, m_index / sizeof(IntegralType), this); 392 432 WTF::unalignedStore<uint32_t>(m_hashes.buffer() + m_index, hash); 393 433 #endif -
trunk/Source/JavaScriptCore/assembler/LinkBuffer.cpp
r278253 r280984 246 246 uint8_t* inData = bitwise_cast<uint8_t*>(m_assemblerStorage.buffer()); 247 247 #if CPU(ARM64E) 248 ARM64EHash verifyUncompactedHash { static_cast<uint32_t>(bitwise_cast<uint64_t>(¯oAssembler.m_assembler.buffer())) }; 248 void* bufferPtr = ¯oAssembler.m_assembler.buffer(); 249 ARM64EHash verifyUncompactedHash { bufferPtr }; 249 250 m_assemblerHashesStorage = macroAssembler.m_assembler.buffer().releaseAssemblerHashes(); 250 251 uint32_t* inHashes = bitwise_cast<uint32_t*>(m_assemblerHashesStorage.buffer()); … … 268 269 InstructionType value = *ptr; 269 270 #if CPU(ARM64E) 270 uint32_t hash = verifyUncompactedHash.update(value);271 271 unsigned index = (bitwise_cast<uint8_t*>(ptr) - inData) / 4; 272 uint32_t hash = verifyUncompactedHash.update(value, index, bufferPtr); 272 273 RELEASE_ASSERT(inHashes[index] == hash); 273 274 #endif
Note:
See TracChangeset
for help on using the changeset viewer.