Changeset 271217 in webkit
- Timestamp:
- Jan 6, 2021, 3:39:18 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/runtime/JSBigInt.cpp (modified) (1 diff)
-
JavaScriptCore/runtime/JSBigInt.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/IPCTestingAPI.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r271186 r271217 1 2021-01-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Replace JSBigInt::toUint64 with JSBigInt::toBigUInt64 4 https://bugs.webkit.org/show_bug.cgi?id=220378 5 6 Reviewed by Darin Adler. 7 8 This patch replaces JSBigInt::toUint64 with JSBigInt::toBigUInt64. 9 Rough purposes of these functions are the same, and JSBigInt::toBigUInt64 10 has the semantics defined in the ECMA262 spec. While the behavior is 11 slightly different[1], this difference does not matter for the clients of 12 JSBigInt::toUint64. 13 14 [1]: JSBigInt::toUint64 fails conversion if JSBigInt is out of range of uint64_t, 15 while JSBigInt::toBigUInt64 always generates uint64_t by computing mod UINT64_MAX. 16 17 * runtime/JSBigInt.cpp: 18 (JSC::JSBigInt::toUint64Heap): Deleted. 19 * runtime/JSBigInt.h: 20 1 21 2021-01-05 Yusuke Suzuki <ysuzuki@apple.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp
r271168 r271217 3063 3063 } 3064 3064 3065 Optional<uint64_t> JSBigInt::toUint64Heap(JSBigInt* bigInt)3066 {3067 auto length = bigInt->length();3068 if (!length)3069 return 0;3070 if (bigInt->sign())3071 return WTF::nullopt;3072 3073 static_assert(sizeof(uint64_t) == sizeof(Digit) || sizeof(uint64_t) == sizeof(Digit) * 2, "Digit must be either 32-bit or 64-bit");3074 if (sizeof(uint64_t) == sizeof(Digit)) {3075 if (length > 1)3076 return WTF::nullopt;3077 return bigInt->digit(0);3078 }3079 3080 if (length > 2)3081 return WTF::nullopt;3082 uint64_t result = bigInt->digit(0);3083 if (length == 1)3084 result += static_cast<uint64_t>(bigInt->digit(0)) << 32;3085 return result;3086 }3087 3088 3065 static ALWAYS_INLINE unsigned computeHash(JSBigInt::Digit* digits, unsigned length, bool sign) 3089 3066 { -
trunk/Source/JavaScriptCore/runtime/JSBigInt.h
r271168 r271217 441 441 } 442 442 443 static Optional<uint64_t> toUint64(JSValue bigInt)444 {445 ASSERT(bigInt.isBigInt());446 #if USE(BIGINT32)447 if (bigInt.isBigInt32()) {448 auto value = bigInt.bigInt32AsInt32();449 if (value < 0)450 return WTF::nullopt;451 return value;452 }453 #endif454 return toUint64Heap(jsCast<JSBigInt*>(bigInt));455 }456 457 443 Digit digit(unsigned); 458 444 void setDigit(unsigned, Digit); // Use only when initializing. -
trunk/Source/WebKit/ChangeLog
r271214 r271217 1 2021-01-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Replace JSBigInt::toUint64 with JSBigInt::toBigUInt64 4 https://bugs.webkit.org/show_bug.cgi?id=220378 5 6 Reviewed by Darin Adler. 7 8 * WebProcess/WebPage/IPCTestingAPI.cpp: 9 (WebKit::IPCTestingAPI::convertToUint64): 10 (WebKit::IPCTestingAPI::encodeNumericType): 11 1 12 2021-01-06 Andy Estes <aestes@apple.com> 2 13 -
trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp
r269348 r271217 194 194 } 195 195 if (jsValue.isBigInt()) 196 return JSC::JSBigInt::to Uint64(jsValue);196 return JSC::JSBigInt::toBigUInt64(jsValue); 197 197 return WTF::nullopt; 198 198 } … … 353 353 if (jsValue.isBigInt()) { 354 354 // FIXME: Support negative BigInt. 355 auto result = JSC::JSBigInt::toUint64(jsValue); 356 if (!result) 357 return false; 358 encoder << static_cast<IntegralType>(*result); 355 uint64_t result = JSC::JSBigInt::toBigUInt64(jsValue); 356 encoder << static_cast<IntegralType>(result); 359 357 return true; 360 358 }
Note:
See TracChangeset
for help on using the changeset viewer.