Changeset 260810 in webkit
- Timestamp:
- Apr 27, 2020 11:41:54 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r260806 r260810 1 2020-04-27 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Throw OutOfMemoryError instead of RangeError if BigInt is too big 4 https://bugs.webkit.org/show_bug.cgi?id=211111 5 6 Reviewed by Saam Barati. 7 8 * stress/big-int-constructor-oom.js: 9 (catch): 10 * stress/big-int-left-shift-range-error.js: 11 (assertThrowRangeError): 12 * stress/big-int-out-of-memory-tests.js: 13 (catch): 14 * stress/bigint-exponential-oom.js: Added. 15 (shouldThrow): 16 * stress/bigint-int32-min-shift.js: 17 (shouldThrow): 18 1 19 2020-04-27 Keith Miller <keith_miller@apple.com> 2 20 -
trunk/JSTests/stress/big-int-constructor-oom.js
r226377 r260810 17 17 assert(false); 18 18 } catch(e) { 19 assert(e.message == "Out of memory ")19 assert(e.message == "Out of memory: BigInt generated from this operation is too big") 20 20 } 21 21 -
trunk/JSTests/stress/big-int-left-shift-range-error.js
r238790 r260810 11 11 assert(false, message + ": Should throw RangeError, but executed without exception"); 12 12 } catch (e) { 13 assert(e instanceof RangeError, message + ": expected RangeError, got: " + e);13 assert(e instanceof Error, message + ": expected Error , got: " + e); 14 14 } 15 15 } -
trunk/JSTests/stress/big-int-out-of-memory-tests.js
r238790 r260810 13 13 assert(false, "Should throw OutOfMemoryError, but executed without exception"); 14 14 } catch(e) { 15 assert(e.message == "Out of memory ", "Expected OutOfMemoryError, but got: " + e);15 assert(e.message == "Out of memory: BigInt generated from this operation is too big", "Expected OutOfMemoryError, but got: " + e); 16 16 } 17 17 … … 20 20 assert(false, "Should throw OutOfMemoryError, but executed without exception"); 21 21 } catch(e) { 22 assert(e.message == "Out of memory ", "Expected OutOfMemoryError, but got: " + e);22 assert(e.message == "Out of memory: BigInt generated from this operation is too big", "Expected OutOfMemoryError, but got: " + e); 23 23 } 24 24 … … 27 27 assert(false, "Should throw OutOfMemoryError, but executed without exception"); 28 28 } catch(e) { 29 assert(e.message == "Out of memory ", "Expected OutOfMemoryError, but got: " + e);29 assert(e.message == "Out of memory: BigInt generated from this operation is too big", "Expected OutOfMemoryError, but got: " + e); 30 30 } 31 31 … … 34 34 assert(false, "Should throw OutOfMemoryError, but executed without exception"); 35 35 } catch(e) { 36 assert(e.message == "Out of memory ", "Expected OutOfMemoryError, but got: " + e);36 assert(e.message == "Out of memory: BigInt generated from this operation is too big", "Expected OutOfMemoryError, but got: " + e); 37 37 } 38 38 … … 41 41 assert(false, "Should throw OutOfMemoryError, but executed without exception"); 42 42 } catch(e) { 43 assert(e.message == "Out of memory ", "Expected OutOfMemoryError, but got: " + e);43 assert(e.message == "Out of memory: BigInt generated from this operation is too big", "Expected OutOfMemoryError, but got: " + e); 44 44 } 45 45 … … 48 48 assert(false, "Should throw OutOfMemoryError, but executed without exception"); 49 49 } catch(e) { 50 assert(e.message == "Out of memory ", "Expected OutOfMemoryError, but got: " + e);50 assert(e.message == "Out of memory: BigInt generated from this operation is too big", "Expected OutOfMemoryError, but got: " + e); 51 51 } 52 52 -
trunk/JSTests/stress/bigint-int32-min-shift.js
r260720 r260810 38 38 shouldThrow(() => { 39 39 1n >> int32min; 40 }, ` RangeError: BigInt generated from this operation is too big`);40 }, `Error: Out of memory: BigInt generated from this operation is too big`); 41 41 shouldThrow(() => { 42 42 -1n >> int32min; 43 }, ` RangeError: BigInt generated from this operation is too big`);43 }, `Error: Out of memory: BigInt generated from this operation is too big`); 44 44 shouldThrow(() => { 45 45 0x7fffffffn >> int32min; 46 }, ` RangeError: BigInt generated from this operation is too big`);46 }, `Error: Out of memory: BigInt generated from this operation is too big`); 47 47 shouldThrow(() => { 48 48 (-0x7fffffffn - 1n) >> int32min; 49 }, ` RangeError: BigInt generated from this operation is too big`);49 }, `Error: Out of memory: BigInt generated from this operation is too big`); -
trunk/Source/JavaScriptCore/ChangeLog
r260809 r260810 1 2020-04-27 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Throw OutOfMemoryError instead of RangeError if BigInt is too big 4 https://bugs.webkit.org/show_bug.cgi?id=211111 5 6 Reviewed by Saam Barati. 7 8 Currently, we are throwing a RangeError if we detect that JSBigInt becomes too large. But this is not consistent with our JSString's policy. 9 We should throw OutOfMemoryError in this case. This also makes DFG simple since DFG allows throwing OutOfMemoryError in any places which node 10 is even removed. 11 12 * dfg/DFGFixupPhase.cpp: 13 (JSC::DFG::FixupPhase::fixupNode): 14 * runtime/ExceptionHelpers.cpp: 15 (JSC::throwOutOfMemoryError): 16 * runtime/ExceptionHelpers.h: 17 * runtime/JSBigInt.cpp: 18 (JSC::JSBigInt::tryCreateWithLength): 19 (JSC::JSBigInt::exponentiateHeap): 20 (JSC::JSBigInt::leftShiftByAbsolute): 21 (JSC::JSBigInt::allocateFor): 22 1 23 2020-04-27 Saam Barati <sbarati@apple.com> 2 24 -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r260730 r260810 326 326 fixEdge<HeapBigIntUse>(node->child2()); 327 327 #endif 328 // Shift can throw RangeError. 329 switch (node->op()) { 330 case ValueBitXor: 331 case ValueBitOr: 332 case ValueBitAnd: 333 node->clearFlags(NodeMustGenerate); 334 break; 335 default: 336 break; 337 } 328 node->clearFlags(NodeMustGenerate); 338 329 break; 339 330 } -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r260722 r260810 334 334 } 335 335 336 Exception* throwOutOfMemoryError(JSGlobalObject* globalObject, ThrowScope& scope, const String& message) 337 { 338 return throwException(globalObject, scope, createOutOfMemoryError(globalObject, message)); 339 } 340 336 341 Exception* throwStackOverflowError(JSGlobalObject* globalObject, ThrowScope& scope) 337 342 { -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.h
r258059 r260810 57 57 58 58 JS_EXPORT_PRIVATE Exception* throwOutOfMemoryError(JSGlobalObject*, ThrowScope&); 59 JS_EXPORT_PRIVATE Exception* throwOutOfMemoryError(JSGlobalObject*, ThrowScope&, const String&); 59 60 JS_EXPORT_PRIVATE Exception* throwStackOverflowError(JSGlobalObject*, ThrowScope&); 60 61 JS_EXPORT_PRIVATE Exception* throwTerminatedExecutionException(JSGlobalObject*, ThrowScope&); -
trunk/Source/JavaScriptCore/runtime/JSBigInt.cpp
r260809 r260810 96 96 97 97 if (UNLIKELY(length > maxLength)) { 98 throwOutOfMemoryError(globalObject, scope );98 throwOutOfMemoryError(globalObject, scope, "BigInt generated from this operation is too big"_s); 99 99 return nullptr; 100 100 } … … 365 365 static_assert(maxLengthBits < std::numeric_limits<Digit>::max(), "maxLengthBits needs to be less than digit::max()"); 366 366 if (exponent.length() > 1) { 367 throw RangeError(globalObject, scope, "BigInt generated from this operation is too big"_s);367 throwOutOfMemoryError(globalObject, scope, "BigInt generated from this operation is too big"_s); 368 368 return nullptr; 369 369 } … … 373 373 return base; 374 374 if (expValue >= maxLengthBits) { 375 throw RangeError(globalObject, scope, "BigInt generated from this operation is too big"_s);375 throwOutOfMemoryError(globalObject, scope, "BigInt generated from this operation is too big"_s); 376 376 return nullptr; 377 377 } … … 1792 1792 auto optionalShift = toShiftAmount(y); 1793 1793 if (!optionalShift) { 1794 throw RangeError(globalObject, scope, "BigInt generated from this operation is too big"_s);1794 throwOutOfMemoryError(globalObject, scope, "BigInt generated from this operation is too big"_s); 1795 1795 return nullptr; 1796 1796 } … … 1803 1803 int resultLength = length + digitShift + grow; 1804 1804 if (static_cast<unsigned>(resultLength) > maxLength) { 1805 throw RangeError(globalObject, scope, "BigInt generated from this operation is too big"_s);1805 throwOutOfMemoryError(globalObject, scope, "BigInt generated from this operation is too big"_s); 1806 1806 return nullptr; 1807 1807 } … … 2159 2159 if (globalObject) { 2160 2160 auto scope = DECLARE_THROW_SCOPE(vm); 2161 throwOutOfMemoryError(globalObject, scope );2161 throwOutOfMemoryError(globalObject, scope, "BigInt generated from this operation is too big"_s); 2162 2162 } 2163 2163 return nullptr;
Note: See TracChangeset
for help on using the changeset viewer.