diff --git a/ecmascript/builtins/builtins_math.cpp b/ecmascript/builtins/builtins_math.cpp index 755c394c89..6121227e56 100644 --- a/ecmascript/builtins/builtins_math.cpp +++ b/ecmascript/builtins/builtins_math.cpp @@ -552,16 +552,16 @@ JSTaggedValue BuiltinsMath::Pow(EcmaRuntimeCallInfo *argv) [[maybe_unused]] EcmaHandleScope handleScope(thread); JSHandle msgX = GetCallArg(argv, 0); JSHandle msgY = GetCallArg(argv, 1); - JSHandle baseVale(thread, JSTaggedValue::ToNumeric(thread, msgX)); + JSHandle baseVale = JSTaggedValue::ToNumeric(thread, msgX.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle exponentValue(thread, JSTaggedValue::ToNumeric(thread, msgY)); + JSHandle exponentValue = JSTaggedValue::ToNumeric(thread, msgY.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - if (baseVale->IsBigInt() && exponentValue->IsBigInt()) { - JSHandle bigBaseVale(baseVale); - JSHandle bigExponentValue(exponentValue); - return BigInt::Exponentiate(thread, bigBaseVale, bigExponentValue).GetTaggedValue(); - } if (baseVale->IsBigInt() || exponentValue->IsBigInt()) { + if (baseVale->IsBigInt() && exponentValue->IsBigInt()) { + JSHandle bigBaseVale(baseVale); + JSHandle bigExponentValue(exponentValue); + return BigInt::Exponentiate(thread, bigBaseVale, bigExponentValue).GetTaggedValue(); + } THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot mix BigInt and other types, use explicit conversions", JSTaggedValue::Exception()); } diff --git a/ecmascript/builtins/builtins_number.cpp b/ecmascript/builtins/builtins_number.cpp index 9dbe6b49b5..343c10c580 100644 --- a/ecmascript/builtins/builtins_number.cpp +++ b/ecmascript/builtins/builtins_number.cpp @@ -44,16 +44,15 @@ JSTaggedValue BuiltinsNumber::NumberConstructor(EcmaRuntimeCallInfo *argv) if (argv->GetArgsNumber() > 0) { JSHandle value = GetCallArg(argv, 0); // a. Let prim be ? ToNumeric(value). - JSTaggedValue numeric = JSTaggedValue::ToNumeric(thread, value); + JSHandle numericVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle numericVal(thread, numeric); // b. If Type(prim) is BigInt, let n be 𝔽(ℝ(prim)). if (numericVal->IsBigInt()) { JSHandle bigNumericVal(numericVal); numberValue = BigInt::BigIntToNumber(bigNumericVal); } else { // c. Otherwise, let n be prim. - numberValue = JSTaggedNumber(numeric); + numberValue = JSTaggedNumber(numericVal.GetTaggedValue()); } } // 3. If NewTarget is undefined, return n. diff --git a/ecmascript/builtins/builtins_number_format.cpp b/ecmascript/builtins/builtins_number_format.cpp index 657eb5fa97..fac2ce913c 100644 --- a/ecmascript/builtins/builtins_number_format.cpp +++ b/ecmascript/builtins/builtins_number_format.cpp @@ -145,12 +145,11 @@ JSTaggedValue BuiltinsNumberFormat::FormatToParts(EcmaRuntimeCallInfo *argv) } // 3. Let x be ? ToNumeric(value). JSHandle value = GetCallArg(argv, 0); - JSTaggedNumber x = JSTaggedValue::ToNumber(thread, value); + JSHandle x = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - - JSHandle result = JSNumberFormat::FormatNumericToParts(thread, JSHandle::Cast(nf), x); + JSHandle result = + JSNumberFormat::FormatNumericToParts(thread, JSHandle::Cast(nf), x.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - return result.GetTaggedValue(); } // 13.4.5 Intl.NumberFormat.prototype.resolvedOptions () @@ -196,10 +195,11 @@ JSTaggedValue BuiltinsNumberFormat::NumberFormatInternalFormatNumber(EcmaRuntime // 3. If value is not provided, let value be undefined. JSHandle value = GetCallArg(argv, 0); // 4 Let x be ? ToNumeric(value). - JSTaggedNumber x = JSTaggedValue::ToNumber(thread, value); + JSHandle x = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 5 Return ? FormatNumeric(nf, x). - JSHandle result = JSNumberFormat::FormatNumeric(thread, JSHandle::Cast(nf), x); + JSHandle result = + JSNumberFormat::FormatNumeric(thread, JSHandle::Cast(nf), x.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); return result.GetTaggedValue(); } diff --git a/ecmascript/interpreter/slow_runtime_stub.cpp b/ecmascript/interpreter/slow_runtime_stub.cpp index c4b1828ed1..7ddb7f6d8b 100644 --- a/ecmascript/interpreter/slow_runtime_stub.cpp +++ b/ecmascript/interpreter/slow_runtime_stub.cpp @@ -72,8 +72,7 @@ JSTaggedValue SlowRuntimeStub::NegDyn(JSThread *thread, JSTaggedValue value) INTERPRETER_TRACE(thread, NegDyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle input(thread, value); - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, input)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -128,15 +127,15 @@ JSTaggedValue SlowRuntimeStub::ToNumber(JSThread *thread, JSTaggedValue value) JSHandle number(thread, value); // may return exception - return JSTaggedValue::ToNumeric(thread, number); + return JSTaggedValue::ToNumeric(thread, number.GetTaggedValue()).GetTaggedValue(); } JSTaggedValue SlowRuntimeStub::NotDyn(JSThread *thread, JSTaggedValue value) { INTERPRETER_TRACE(thread, NotDyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle input(thread, value); - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, input)); + + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -151,8 +150,7 @@ JSTaggedValue SlowRuntimeStub::IncDyn(JSThread *thread, JSTaggedValue value) INTERPRETER_TRACE(thread, IncDyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle input(thread, value); - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, input)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -167,8 +165,7 @@ JSTaggedValue SlowRuntimeStub::DecDyn(JSThread *thread, JSTaggedValue value) INTERPRETER_TRACE(thread, DecDyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle input(thread, value); - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, input)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -236,9 +233,9 @@ JSTaggedValue SlowRuntimeStub::Add2Dyn(JSThread *thread, JSTaggedValue left, JST JSHandle newString = factory->ConcatFromString(stringA0, stringA1); return newString.GetTaggedValue(); } - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, primitiveA0)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, primitiveA0.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, primitiveA1)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, primitiveA1.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -258,11 +255,9 @@ JSTaggedValue SlowRuntimeStub::Sub2Dyn(JSThread *thread, JSTaggedValue left, JST INTERPRETER_TRACE(thread, Sub2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -282,11 +277,9 @@ JSTaggedValue SlowRuntimeStub::Mul2Dyn(JSThread *thread, JSTaggedValue left, JST INTERPRETER_TRACE(thread, Mul2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 9. ReturnIfAbrupt(rnum). if (valLeft->IsBigInt() || valRight->IsBigInt()) { @@ -308,11 +301,9 @@ JSTaggedValue SlowRuntimeStub::Div2Dyn(JSThread *thread, JSTaggedValue left, JST INTERPRETER_TRACE(thread, Div2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -340,11 +331,9 @@ JSTaggedValue SlowRuntimeStub::Mod2Dyn(JSThread *thread, JSTaggedValue left, JST INTERPRETER_TRACE(thread, Mod2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 12.6.3.3 Applying the % Operator @@ -445,11 +434,10 @@ JSTaggedValue SlowRuntimeStub::Shl2Dyn(JSThread *thread, JSTaggedValue left, JST { INTERPRETER_TRACE(thread, Shl2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle leftValue(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + + JSHandle leftValue = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle rightValue(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle rightValue = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (leftValue->IsBigInt() || rightValue->IsBigInt()) { if (leftValue->IsBigInt() && rightValue->IsBigInt()) { @@ -478,11 +466,9 @@ JSTaggedValue SlowRuntimeStub::Shr2Dyn(JSThread *thread, JSTaggedValue left, JST INTERPRETER_TRACE(thread, Shr2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -509,11 +495,9 @@ JSTaggedValue SlowRuntimeStub::Ashr2Dyn(JSThread *thread, JSTaggedValue left, JS INTERPRETER_TRACE(thread, Ashr2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -539,12 +523,9 @@ JSTaggedValue SlowRuntimeStub::And2Dyn(JSThread *thread, JSTaggedValue left, JST { INTERPRETER_TRACE(thread, And2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -570,11 +551,9 @@ JSTaggedValue SlowRuntimeStub::Or2Dyn(JSThread *thread, JSTaggedValue left, JSTa INTERPRETER_TRACE(thread, Or2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -600,11 +579,9 @@ JSTaggedValue SlowRuntimeStub::Xor2Dyn(JSThread *thread, JSTaggedValue left, JST INTERPRETER_TRACE(thread, Xor2Dyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle leftHandle(thread, left); - JSHandle rightHandle(thread, right); - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (valLeft->IsBigInt() || valRight->IsBigInt()) { if (valLeft->IsBigInt() && valRight->IsBigInt()) { @@ -734,16 +711,10 @@ JSTaggedValue SlowRuntimeStub::ExpDyn(JSThread *thread, JSTaggedValue base, JSTa INTERPRETER_TRACE(thread, ExpDyn); [[maybe_unused]] EcmaHandleScope handleScope(thread); - JSHandle baseHandle(thread, base); - JSHandle exponentHandle(thread, exponent); - - JSTaggedValue val1 = JSTaggedValue::ToNumeric(thread, baseHandle); - JSHandle valBase(thread, val1); + JSHandle valBase = JSTaggedValue::ToNumeric(thread, base); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSTaggedValue val2 = JSTaggedValue::ToNumeric(thread, exponentHandle); - JSHandle valExponent(thread, val2); + JSHandle valExponent = JSTaggedValue::ToNumeric(thread, exponent); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - if (valBase->IsBigInt() || valExponent->IsBigInt()) { if (valBase->IsBigInt() && valExponent->IsBigInt()) { JSHandle bigBaseVale(valBase); diff --git a/ecmascript/js_tagged_value.cpp b/ecmascript/js_tagged_value.cpp index d40148e271..573ac574dc 100644 --- a/ecmascript/js_tagged_value.cpp +++ b/ecmascript/js_tagged_value.cpp @@ -953,18 +953,21 @@ bool JSTaggedValue::GetContainerProperty(JSThread *thread, const JSHandle &tagged) +JSHandle JSTaggedValue::ToNumeric(JSThread *thread, JSTaggedValue tagged) { // 1. Let primValue be ? ToPrimitive(value, number) - JSHandle primValue(thread, ToPrimitive(thread, tagged, PREFER_NUMBER)); - RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + JSHandle taggedValue(thread, tagged); + + JSHandle primValue(thread, ToPrimitive(thread, taggedValue, PREFER_NUMBER)); + RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread); // 2. If Type(primValue) is BigInt, return primValue. if (primValue->IsBigInt()) { - return primValue.GetTaggedValue(); + return primValue; } // 3. Return ? ToNumber(primValue). JSTaggedNumber number = ToNumber(thread, primValue); - RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - return number; + RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread); + JSHandle value(thread, number); + return value; } } // namespace panda::ecmascript diff --git a/ecmascript/js_tagged_value.h b/ecmascript/js_tagged_value.h index 5eadce46d8..6c327c140a 100644 --- a/ecmascript/js_tagged_value.h +++ b/ecmascript/js_tagged_value.h @@ -157,7 +157,7 @@ public: static JSTaggedValue ToBigInt64(JSThread *thread, const JSHandle &tagged); static JSTaggedValue ToBigUint64(JSThread *thread, const JSHandle &tagged); static JSTaggedNumber ToInteger(JSThread *thread, const JSHandle &tagged); - static JSTaggedValue ToNumeric(JSThread *thread, const JSHandle &tagged); + static JSHandle ToNumeric(JSThread *thread, JSTaggedValue tagged); static int32_t ToInt32(JSThread *thread, const JSHandle &tagged); static uint32_t ToUint32(JSThread *thread, const JSHandle &tagged); static int16_t ToInt16(JSThread *thread, const JSHandle &tagged); diff --git a/ecmascript/stubs/runtime_stubs-inl.h b/ecmascript/stubs/runtime_stubs-inl.h index 1002a90db2..520e83071f 100644 --- a/ecmascript/stubs/runtime_stubs-inl.h +++ b/ecmascript/stubs/runtime_stubs-inl.h @@ -36,7 +36,7 @@ namespace panda::ecmascript { JSTaggedValue RuntimeStubs::RuntimeIncDyn(JSThread *thread, const JSHandle &value) { - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, value)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -48,7 +48,7 @@ JSTaggedValue RuntimeStubs::RuntimeIncDyn(JSThread *thread, const JSHandle &value) { - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, value)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -527,7 +527,7 @@ JSTaggedValue RuntimeStubs::RuntimeStGlobalRecord(JSThread *thread, const JSHand JSTaggedValue RuntimeStubs::RuntimeNegDyn(JSThread *thread, const JSHandle &value) { - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, value)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -549,7 +549,7 @@ JSTaggedValue RuntimeStubs::RuntimeNegDyn(JSThread *thread, const JSHandle &value) { - JSHandle inputVal(thread, JSTaggedValue::ToNumeric(thread, value)); + JSHandle inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (inputVal->IsBigInt()) { JSHandle bigValue(inputVal); @@ -973,7 +973,7 @@ JSTaggedValue RuntimeStubs::RuntimeStGlobalVar(JSThread *thread, const JSHandle< JSTaggedValue RuntimeStubs::RuntimeToNumber(JSThread *thread, const JSHandle &value) { - return JSTaggedValue::ToNumeric(thread, value); + return JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()).GetTaggedValue(); } JSTaggedValue RuntimeStubs::RuntimeEqDyn(JSThread *thread, const JSHandle &left, @@ -1048,16 +1048,16 @@ JSTaggedValue RuntimeStubs::RuntimeAdd2Dyn(JSThread *thread, const JSHandle newString = factory->ConcatFromString(stringA0, stringA1); return newString.GetTaggedValue(); } - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, primitiveA0)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, primitiveA0.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, primitiveA1)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, primitiveA1.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - if (valLeft->IsBigInt() && valRight->IsBigInt()) { - JSHandle bigLeft(valLeft); - JSHandle bigRight(valRight); - return BigInt::Add(thread, bigLeft, bigRight).GetTaggedValue(); - } if (valLeft->IsBigInt() || valRight->IsBigInt()) { + if (valLeft->IsBigInt() && valRight->IsBigInt()) { + JSHandle bigLeft(valLeft); + JSHandle bigRight(valRight); + return BigInt::Add(thread, bigLeft, bigRight).GetTaggedValue(); + } return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions"); } double a0Double = valLeft->GetNumber(); @@ -1068,16 +1068,16 @@ JSTaggedValue RuntimeStubs::RuntimeAdd2Dyn(JSThread *thread, const JSHandle &left, const JSHandle &right) { - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, left)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, right)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - if (valLeft->IsBigInt() && valRight->IsBigInt()) { - JSHandle bigLeft(valLeft); - JSHandle bigRight(valRight); - return BigInt::Subtract(thread, bigLeft, bigRight).GetTaggedValue(); - } if (valLeft->IsBigInt() || valRight->IsBigInt()) { + if (valLeft->IsBigInt() && valRight->IsBigInt()) { + JSHandle bigLeft(valLeft); + JSHandle bigRight(valRight); + return BigInt::Subtract(thread, bigLeft, bigRight).GetTaggedValue(); + } return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions"); } JSTaggedNumber number0(valLeft.GetTaggedValue()); @@ -1088,17 +1088,17 @@ JSTaggedValue RuntimeStubs::RuntimeSub2Dyn(JSThread *thread, const JSHandle &left, const JSHandle &right) { - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, left)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, right)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 9. ReturnIfAbrupt(rnum). - if (valLeft->IsBigInt() && valRight->IsBigInt()) { - JSHandle bigLeft(valLeft); - JSHandle bigRight(valRight); - return BigInt::Multiply(thread, bigLeft, bigRight).GetTaggedValue(); - } if (valLeft->IsBigInt() || valRight->IsBigInt()) { + if (valLeft->IsBigInt() && valRight->IsBigInt()) { + JSHandle bigLeft(valLeft); + JSHandle bigRight(valRight); + return BigInt::Multiply(thread, bigLeft, bigRight).GetTaggedValue(); + } return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions"); } // 12.6.3.1 Applying the * Operator @@ -1110,16 +1110,16 @@ JSTaggedValue RuntimeStubs::RuntimeMul2Dyn(JSThread *thread, const JSHandle &left, const JSHandle &right) { - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, left)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, right)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - if (valLeft->IsBigInt() && valRight->IsBigInt()) { - JSHandle bigLeft(valLeft); - JSHandle bigRight(valRight); - return BigInt::Divide(thread, bigLeft, bigRight).GetTaggedValue(); - } if (valLeft->IsBigInt() || valRight->IsBigInt()) { + if (valLeft->IsBigInt() && valRight->IsBigInt()) { + JSHandle bigLeft(valLeft); + JSHandle bigRight(valRight); + return BigInt::Divide(thread, bigLeft, bigRight).GetTaggedValue(); + } return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions"); } double dLeft = valLeft->GetNumber(); @@ -1138,18 +1138,18 @@ JSTaggedValue RuntimeStubs::RuntimeDiv2Dyn(JSThread *thread, const JSHandle &left, const JSHandle &right) { - JSHandle valLeft(thread, JSTaggedValue::ToNumeric(thread, left)); + JSHandle valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); - JSHandle valRight(thread, JSTaggedValue::ToNumeric(thread, right)); + JSHandle valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue()); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); // 12.6.3.3 Applying the % Operator - if (valLeft->IsBigInt() && valRight->IsBigInt()) { - JSHandle leftBigint(valLeft); - JSHandle rightBigint(valRight); - return BigInt::Remainder(thread, leftBigint, rightBigint).GetTaggedValue(); - } if (valLeft->IsBigInt() || valRight->IsBigInt()) { + if (valLeft->IsBigInt() && valRight->IsBigInt()) { + JSHandle leftBigint(valLeft); + JSHandle rightBigint(valRight); + return BigInt::Remainder(thread, leftBigint, rightBigint).GetTaggedValue(); + } return RuntimeThrowTypeError(thread, "Cannot mix BigInt and other types, use explicit conversions"); } double dLeft = valLeft->GetNumber();