Changeset 267373 in webkit for trunk/Source/JavaScriptCore/runtime/JSBigInt.h
- Timestamp:
- Sep 21, 2020, 3:10:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSBigInt.h
r266795 r267373 428 428 JS_EXPORT_PRIVATE JSBigInt* tryRightTrim(VM&); 429 429 430 JS_EXPORT_PRIVATE Optional<unsigned> concurrentHash(); 431 unsigned hash() 432 { 433 if (m_hash) 434 return m_hash; 435 return hashSlow(); 436 } 437 430 438 private: 431 439 JSBigInt(VM&, Structure*, Digit*, unsigned length); 432 440 433 441 JSBigInt* rightTrim(JSGlobalObject*, VM&); 442 443 JS_EXPORT_PRIVATE unsigned hashSlow(); 434 444 435 445 static JSBigInt* createFromImpl(JSGlobalObject*, uint64_t value, bool sign); … … 573 583 574 584 inline Digit* dataStorage() { return m_data.get(m_length); } 585 inline Digit* dataStorageUnsafe() { return m_data.getUnsafe(); } 575 586 576 587 const unsigned m_length; 588 unsigned m_hash { 0 }; 577 589 bool m_sign { false }; 578 590 CagedBarrierPtr<Gigacage::Primitive, Digit, tagCagedPtr> m_data; … … 609 621 } 610 622 623 ALWAYS_INLINE JSValue tryConvertToBigInt32(JSBigInt* bigInt) 624 { 625 #if USE(BIGINT32) 626 if (UNLIKELY(!bigInt)) 627 return JSValue(); 628 629 if (bigInt->length() <= 1) { 630 if (!bigInt->length()) 631 return jsBigInt32(0); 632 JSBigInt::Digit digit = bigInt->digit(0); 633 if (bigInt->sign()) { 634 static constexpr uint64_t maxValue = -static_cast<int64_t>(std::numeric_limits<int32_t>::min()); 635 if (digit <= maxValue) 636 return jsBigInt32(static_cast<int32_t>(-static_cast<int64_t>(digit))); 637 } else { 638 static constexpr uint64_t maxValue = static_cast<uint64_t>(std::numeric_limits<int32_t>::max()); 639 if (digit <= maxValue) 640 return jsBigInt32(static_cast<int32_t>(digit)); 641 } 642 } 643 #endif 644 645 return bigInt; 646 } 647 611 648 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.