Changeset 260805 in webkit
- Timestamp:
- Apr 27, 2020 6:33:22 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r260784 r260805 1 2020-04-27 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] >>> should call ToNumeric 4 https://bugs.webkit.org/show_bug.cgi?id=211065 5 6 Reviewed by Ross Kirsling. 7 8 * stress/bigint-urshift.js: Added. 9 (shouldBe): 10 (shouldThrow): 11 * test262/expectations.yaml: 12 1 13 2020-04-27 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/JSTests/test262/expectations.yaml
r260733 r260805 3093 3093 default: 'Test262Error: should not be called' 3094 3094 strict mode: 'Test262Error: should not be called' 3095 test/language/expressions/unsigned-right-shift/bigint-toprimitive.js:3096 default: 'Test262Error: 0n >>> {[Symbol.toPrimitive]: function() {throw new MyError();}} throws MyError Expected a MyError but got a TypeError'3097 strict mode: 'Test262Error: 0n >>> {[Symbol.toPrimitive]: function() {throw new MyError();}} throws MyError Expected a MyError but got a TypeError'3098 3095 test/language/expressions/yield/star-iterable.js: 3099 3096 default: 'Test262Error: First result `done` flag Expected SameValue(«false», «undefined») to be true' -
trunk/Source/JavaScriptCore/ChangeLog
r260803 r260805 1 2020-04-27 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] >>> should call ToNumeric 4 https://bugs.webkit.org/show_bug.cgi?id=211065 5 6 Reviewed by Ross Kirsling. 7 8 While BigInt does not support >>> operator, >>> operator should call ToNumeric (in this case, toBigIntOrInt32) for both before throwing an error. 9 We call toBigIntOrInt32 for both operands, and throw an error. And after that, casting int32_t to uint32_t to perform >>> operator. This is correct 10 since the only difference between toUint32 and toInt32 is casting int32_t result to uint32_t. 11 12 * dfg/DFGOperations.cpp: 13 * runtime/CommonSlowPaths.cpp: 14 (JSC::SLOW_PATH_DECL): 15 * runtime/Operations.h: 16 (JSC::shift): 17 (JSC::jsURShift): 18 1 19 2020-04-27 Keith Miller <keith_miller@apple.com> 2 20 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r260744 r260805 507 507 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 508 508 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 509 auto scope = DECLARE_THROW_SCOPE(vm); 510 511 JSValue op1 = JSValue::decode(encodedOp1); 512 JSValue op2 = JSValue::decode(encodedOp2); 513 514 uint32_t a = op1.toUInt32(globalObject); 515 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 516 scope.release(); 517 uint32_t b = op2.toUInt32(globalObject); 518 return JSValue::encode(jsNumber(static_cast<int32_t>(a >> (b & 0x1f)))); 509 510 return JSValue::encode(jsURShift(globalObject, JSValue::decode(encodedOp1), JSValue::decode(encodedOp2))); 519 511 } 520 512 -
trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
r260744 r260805 756 756 BEGIN(); 757 757 auto bytecode = pc->as<OpUrshift>(); 758 uint32_t a = GET_C(bytecode.m_lhs).jsValue().toUInt32(globalObject); 759 if (UNLIKELY(throwScope.exception())) 760 RETURN(JSValue()); 761 uint32_t b = GET_C(bytecode.m_rhs).jsValue().toUInt32(globalObject); 762 RETURN(jsNumber(static_cast<int32_t>(a >> (b & 31)))); 758 JSValue left = GET_C(bytecode.m_lhs).jsValue(); 759 JSValue right = GET_C(bytecode.m_rhs).jsValue(); 760 761 JSValue result = jsURShift(globalObject, left, right); 762 CHECK_EXCEPTION(); 763 RETURN(result); 763 764 } 764 765 -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.h
r260744 r260805 295 295 double toLength(JSGlobalObject*) const; 296 296 297 Optional<uint32_t> toUInt32AfterToNumeric(JSGlobalObject*) const; 298 297 299 // Floating point conversions (this is a convenience function for WebCore; 298 300 // single precision float is not a representation used in JS or JSC). -
trunk/Source/JavaScriptCore/runtime/JSCJSValueInlines.h
r260735 r260805 54 54 inline uint32_t JSValue::toUInt32(JSGlobalObject* globalObject) const 55 55 { 56 // See comment on JSC::toUInt32, in JSCJSValue.h. 56 // The only difference between toInt32 and toUint32 is that toUint32 reinterprets resulted int32_t value as uint32_t. 57 // https://tc39.es/ecma262/#sec-touint32 57 58 return toInt32(globalObject); 58 59 } … … 848 849 849 850 return jsNumber(value); 851 } 852 853 ALWAYS_INLINE Optional<uint32_t> JSValue::toUInt32AfterToNumeric(JSGlobalObject* globalObject) const 854 { 855 VM& vm = getVM(globalObject); 856 auto scope = DECLARE_THROW_SCOPE(vm); 857 JSValue result = toBigIntOrInt32(globalObject); 858 RETURN_IF_EXCEPTION(scope, { }); 859 if (LIKELY(result.isInt32())) 860 return static_cast<uint32_t>(result.asInt32()); 861 return WTF::nullopt; 850 862 } 851 863 -
trunk/Source/JavaScriptCore/runtime/Operations.h
r260720 r260805 793 793 #endif 794 794 795 if ( !(leftNumeric.isBigInt() && rightNumeric.isBigInt())) {795 if (UNLIKELY(!(leftNumeric.isBigInt() && rightNumeric.isBigInt()))) { 796 796 auto errorMessage = isLeft ? "Invalid mix of BigInt and other type in left shift operation." : "Invalid mix of BigInt and other type in signed right shift operation."; 797 797 return throwTypeError(globalObject, scope, errorMessage); … … 824 824 } 825 825 826 ALWAYS_INLINE JSValue jsURShift(JSGlobalObject* globalObject, JSValue left, JSValue right) 827 { 828 VM& vm = globalObject->vm(); 829 auto scope = DECLARE_THROW_SCOPE(vm); 830 831 Optional<uint32_t> leftUint32 = left.toUInt32AfterToNumeric(globalObject); 832 RETURN_IF_EXCEPTION(scope, { }); 833 Optional<uint32_t> rightUint32 = right.toUInt32AfterToNumeric(globalObject); 834 RETURN_IF_EXCEPTION(scope, { }); 835 836 if (UNLIKELY(!leftUint32 || !rightUint32)) { 837 throwTypeError(globalObject, scope, "BigInt does not support >>> operator"_s); 838 return { }; 839 } 840 841 return jsNumber(static_cast<int32_t>(leftUint32.value() >> (rightUint32.value() & 31))); 842 } 843 826 844 template<typename HeapBigIntOperation, typename Int32Operation> 827 845 ALWAYS_INLINE JSValue bitwiseBinaryOp(JSGlobalObject* globalObject, JSValue v1, JSValue v2, HeapBigIntOperation&& bigIntOp, Int32Operation&& int32Op, const char* errorMessage)
Note: See TracChangeset
for help on using the changeset viewer.