Changeset 267373 in webkit for trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp
- Timestamp:
- Sep 21, 2020, 3:10:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp
r266250 r267373 55 55 #include "StructureInlines.h" 56 56 #include <algorithm> 57 #include <wtf/Hasher.h> 57 58 #include <wtf/MathExtras.h> 58 59 … … 430 431 : payload(value) 431 432 { } 432 433 static ALWAYS_INLINE JSValue tryConvertToBigInt32(JSBigInt* bigInt)434 {435 #if USE(BIGINT32)436 if (UNLIKELY(!bigInt))437 return JSValue();438 439 if (bigInt->length() <= 1) {440 if (!bigInt->length())441 return jsBigInt32(0);442 JSBigInt::Digit digit = bigInt->digit(0);443 if (bigInt->sign()) {444 static constexpr uint64_t maxValue = -static_cast<int64_t>(std::numeric_limits<int32_t>::min());445 if (digit <= maxValue)446 return jsBigInt32(static_cast<int32_t>(-static_cast<int64_t>(digit)));447 } else {448 static constexpr uint64_t maxValue = static_cast<uint64_t>(std::numeric_limits<int32_t>::max());449 if (digit <= maxValue)450 return jsBigInt32(static_cast<int32_t>(digit));451 }452 }453 #endif454 455 return bigInt;456 }457 433 458 434 static ALWAYS_INLINE JSValue tryConvertToBigInt32(JSBigInt::ImplResult implResult) … … 3074 3050 #endif 3075 3051 3052 static ALWAYS_INLINE unsigned computeHash(JSBigInt::Digit* digits, unsigned length, bool sign) 3053 { 3054 Hasher hasher; 3055 WTF::add(hasher, sign); 3056 for (unsigned index = 0; index < length; ++index) 3057 WTF::add(hasher, digits[index]); 3058 return hasher.hash(); 3059 } 3060 3061 Optional<unsigned> JSBigInt::concurrentHash() 3062 { 3063 // FIXME: Implement JSBigInt::concurrentHash by inserting right store barriers. 3064 // https://bugs.webkit.org/show_bug.cgi?id=216801 3065 return WTF::nullopt; 3066 } 3067 3068 unsigned JSBigInt::hashSlow() 3069 { 3070 ASSERT(!m_hash); 3071 m_hash = computeHash(dataStorage(), length(), m_sign); 3072 return m_hash; 3073 } 3074 3076 3075 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.