!883 Modify the JSHandle of ToNumeric function package

Merge pull request !883 from zhangyouyou/master
This commit is contained in:
openharmony_ci 2022-03-29 06:41:14 +00:00 committed by Gitee
commit 6761eb08d3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 96 additions and 123 deletions

View File

@ -552,16 +552,16 @@ JSTaggedValue BuiltinsMath::Pow(EcmaRuntimeCallInfo *argv)
[[maybe_unused]] EcmaHandleScope handleScope(thread);
JSHandle<JSTaggedValue> msgX = GetCallArg(argv, 0);
JSHandle<JSTaggedValue> msgY = GetCallArg(argv, 1);
JSHandle<JSTaggedValue> baseVale(thread, JSTaggedValue::ToNumeric(thread, msgX));
JSHandle<JSTaggedValue> baseVale = JSTaggedValue::ToNumeric(thread, msgX.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> exponentValue(thread, JSTaggedValue::ToNumeric(thread, msgY));
JSHandle<JSTaggedValue> exponentValue = JSTaggedValue::ToNumeric(thread, msgY.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (baseVale->IsBigInt() && exponentValue->IsBigInt()) {
JSHandle<BigInt> bigBaseVale(baseVale);
JSHandle<BigInt> bigExponentValue(exponentValue);
return BigInt::Exponentiate(thread, bigBaseVale, bigExponentValue).GetTaggedValue();
}
if (baseVale->IsBigInt() || exponentValue->IsBigInt()) {
if (baseVale->IsBigInt() && exponentValue->IsBigInt()) {
JSHandle<BigInt> bigBaseVale(baseVale);
JSHandle<BigInt> 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());
}

View File

@ -44,16 +44,15 @@ JSTaggedValue BuiltinsNumber::NumberConstructor(EcmaRuntimeCallInfo *argv)
if (argv->GetArgsNumber() > 0) {
JSHandle<JSTaggedValue> value = GetCallArg(argv, 0);
// a. Let prim be ? ToNumeric(value).
JSTaggedValue numeric = JSTaggedValue::ToNumeric(thread, value);
JSHandle<JSTaggedValue> numericVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> numericVal(thread, numeric);
// b. If Type(prim) is BigInt, let n be 𝔽((prim)).
if (numericVal->IsBigInt()) {
JSHandle<BigInt> 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.

View File

@ -145,12 +145,11 @@ JSTaggedValue BuiltinsNumberFormat::FormatToParts(EcmaRuntimeCallInfo *argv)
}
// 3. Let x be ? ToNumeric(value).
JSHandle<JSTaggedValue> value = GetCallArg(argv, 0);
JSTaggedNumber x = JSTaggedValue::ToNumber(thread, value);
JSHandle<JSTaggedValue> x = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSArray> result = JSNumberFormat::FormatNumericToParts(thread, JSHandle<JSNumberFormat>::Cast(nf), x);
JSHandle<JSArray> result =
JSNumberFormat::FormatNumericToParts(thread, JSHandle<JSNumberFormat>::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<JSTaggedValue> value = GetCallArg(argv, 0);
// 4 Let x be ? ToNumeric(value).
JSTaggedNumber x = JSTaggedValue::ToNumber(thread, value);
JSHandle<JSTaggedValue> x = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
// 5 Return ? FormatNumeric(nf, x).
JSHandle<JSTaggedValue> result = JSNumberFormat::FormatNumeric(thread, JSHandle<JSNumberFormat>::Cast(nf), x);
JSHandle<JSTaggedValue> result =
JSNumberFormat::FormatNumeric(thread, JSHandle<JSNumberFormat>::Cast(nf), x.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return result.GetTaggedValue();
}

View File

@ -72,8 +72,7 @@ JSTaggedValue SlowRuntimeStub::NegDyn(JSThread *thread, JSTaggedValue value)
INTERPRETER_TRACE(thread, NegDyn);
[[maybe_unused]] EcmaHandleScope handleScope(thread);
JSHandle<JSTaggedValue> input(thread, value);
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, input));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -128,15 +127,15 @@ JSTaggedValue SlowRuntimeStub::ToNumber(JSThread *thread, JSTaggedValue value)
JSHandle<JSTaggedValue> 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<JSTaggedValue> input(thread, value);
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, input));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -151,8 +150,7 @@ JSTaggedValue SlowRuntimeStub::IncDyn(JSThread *thread, JSTaggedValue value)
INTERPRETER_TRACE(thread, IncDyn);
[[maybe_unused]] EcmaHandleScope handleScope(thread);
JSHandle<JSTaggedValue> input(thread, value);
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, input));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -167,8 +165,7 @@ JSTaggedValue SlowRuntimeStub::DecDyn(JSThread *thread, JSTaggedValue value)
INTERPRETER_TRACE(thread, DecDyn);
[[maybe_unused]] EcmaHandleScope handleScope(thread);
JSHandle<JSTaggedValue> input(thread, value);
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, input));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -236,9 +233,9 @@ JSTaggedValue SlowRuntimeStub::Add2Dyn(JSThread *thread, JSTaggedValue left, JST
JSHandle<EcmaString> newString = factory->ConcatFromString(stringA0, stringA1);
return newString.GetTaggedValue();
}
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, primitiveA0));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, primitiveA0.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, primitiveA1));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> leftValue(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> leftValue = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> rightValue(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> leftHandle(thread, left);
JSHandle<JSTaggedValue> rightHandle(thread, right);
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, leftHandle));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, rightHandle));
JSHandle<JSTaggedValue> 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<JSTaggedValue> baseHandle(thread, base);
JSHandle<JSTaggedValue> exponentHandle(thread, exponent);
JSTaggedValue val1 = JSTaggedValue::ToNumeric(thread, baseHandle);
JSHandle<JSTaggedValue> valBase(thread, val1);
JSHandle<JSTaggedValue> valBase = JSTaggedValue::ToNumeric(thread, base);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSTaggedValue val2 = JSTaggedValue::ToNumeric(thread, exponentHandle);
JSHandle<JSTaggedValue> valExponent(thread, val2);
JSHandle<JSTaggedValue> valExponent = JSTaggedValue::ToNumeric(thread, exponent);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (valBase->IsBigInt() || valExponent->IsBigInt()) {
if (valBase->IsBigInt() && valExponent->IsBigInt()) {
JSHandle<BigInt> bigBaseVale(valBase);

View File

@ -953,18 +953,21 @@ bool JSTaggedValue::GetContainerProperty(JSThread *thread, const JSHandle<JSTagg
}
return false;
}
JSTaggedValue JSTaggedValue::ToNumeric(JSThread *thread, const JSHandle<JSTaggedValue> &tagged)
JSHandle<JSTaggedValue> JSTaggedValue::ToNumeric(JSThread *thread, JSTaggedValue tagged)
{
// 1. Let primValue be ? ToPrimitive(value, number)
JSHandle<JSTaggedValue> primValue(thread, ToPrimitive(thread, tagged, PREFER_NUMBER));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> taggedValue(thread, tagged);
JSHandle<JSTaggedValue> 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<JSTaggedValue> value(thread, number);
return value;
}
} // namespace panda::ecmascript

View File

@ -157,7 +157,7 @@ public:
static JSTaggedValue ToBigInt64(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);
static JSTaggedValue ToBigUint64(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);
static JSTaggedNumber ToInteger(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);
static JSTaggedValue ToNumeric(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);
static JSHandle<JSTaggedValue> ToNumeric(JSThread *thread, JSTaggedValue tagged);
static int32_t ToInt32(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);
static uint32_t ToUint32(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);
static int16_t ToInt16(JSThread *thread, const JSHandle<JSTaggedValue> &tagged);

View File

@ -36,7 +36,7 @@
namespace panda::ecmascript {
JSTaggedValue RuntimeStubs::RuntimeIncDyn(JSThread *thread, const JSHandle<JSTaggedValue> &value)
{
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, value));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -48,7 +48,7 @@ JSTaggedValue RuntimeStubs::RuntimeIncDyn(JSThread *thread, const JSHandle<JSTag
JSTaggedValue RuntimeStubs::RuntimeDecDyn(JSThread *thread, const JSHandle<JSTaggedValue> &value)
{
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, value));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -527,7 +527,7 @@ JSTaggedValue RuntimeStubs::RuntimeStGlobalRecord(JSThread *thread, const JSHand
JSTaggedValue RuntimeStubs::RuntimeNegDyn(JSThread *thread, const JSHandle<JSTaggedValue> &value)
{
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, value));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -549,7 +549,7 @@ JSTaggedValue RuntimeStubs::RuntimeNegDyn(JSThread *thread, const JSHandle<JSTag
JSTaggedValue RuntimeStubs::RuntimeNotDyn(JSThread *thread, const JSHandle<JSTaggedValue> &value)
{
JSHandle<JSTaggedValue> inputVal(thread, JSTaggedValue::ToNumeric(thread, value));
JSHandle<JSTaggedValue> inputVal = JSTaggedValue::ToNumeric(thread, value.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (inputVal->IsBigInt()) {
JSHandle<BigInt> bigValue(inputVal);
@ -973,7 +973,7 @@ JSTaggedValue RuntimeStubs::RuntimeStGlobalVar(JSThread *thread, const JSHandle<
JSTaggedValue RuntimeStubs::RuntimeToNumber(JSThread *thread, const JSHandle<JSTaggedValue> &value)
{
return JSTaggedValue::ToNumeric(thread, value);
return JSTaggedValue::ToNumeric(thread, value.GetTaggedValue()).GetTaggedValue();
}
JSTaggedValue RuntimeStubs::RuntimeEqDyn(JSThread *thread, const JSHandle<JSTaggedValue> &left,
@ -1048,16 +1048,16 @@ JSTaggedValue RuntimeStubs::RuntimeAdd2Dyn(JSThread *thread, const JSHandle<JSTa
JSHandle<EcmaString> newString = factory->ConcatFromString(stringA0, stringA1);
return newString.GetTaggedValue();
}
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, primitiveA0));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, primitiveA0.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, primitiveA1));
JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, primitiveA1.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> bigRight(valRight);
return BigInt::Add(thread, bigLeft, bigRight).GetTaggedValue();
}
if (valLeft->IsBigInt() || valRight->IsBigInt()) {
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> 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<JSTa
JSTaggedValue RuntimeStubs::RuntimeSub2Dyn(JSThread *thread, const JSHandle<JSTaggedValue> &left,
const JSHandle<JSTaggedValue> &right)
{
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, left));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, right));
JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> bigRight(valRight);
return BigInt::Subtract(thread, bigLeft, bigRight).GetTaggedValue();
}
if (valLeft->IsBigInt() || valRight->IsBigInt()) {
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> 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<JSTa
JSTaggedValue RuntimeStubs::RuntimeMul2Dyn(JSThread *thread, const JSHandle<JSTaggedValue> &left,
const JSHandle<JSTaggedValue> &right)
{
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, left));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, right));
JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
// 9. ReturnIfAbrupt(rnum).
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> bigRight(valRight);
return BigInt::Multiply(thread, bigLeft, bigRight).GetTaggedValue();
}
if (valLeft->IsBigInt() || valRight->IsBigInt()) {
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> 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<JSTa
JSTaggedValue RuntimeStubs::RuntimeDiv2Dyn(JSThread *thread, const JSHandle<JSTaggedValue> &left,
const JSHandle<JSTaggedValue> &right)
{
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, left));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, right));
JSHandle<JSTaggedValue> valRight = JSTaggedValue::ToNumeric(thread, right.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> bigRight(valRight);
return BigInt::Divide(thread, bigLeft, bigRight).GetTaggedValue();
}
if (valLeft->IsBigInt() || valRight->IsBigInt()) {
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> bigLeft(valLeft);
JSHandle<BigInt> 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<JSTa
JSTaggedValue RuntimeStubs::RuntimeMod2Dyn(JSThread *thread, const JSHandle<JSTaggedValue> &left,
const JSHandle<JSTaggedValue> &right)
{
JSHandle<JSTaggedValue> valLeft(thread, JSTaggedValue::ToNumeric(thread, left));
JSHandle<JSTaggedValue> valLeft = JSTaggedValue::ToNumeric(thread, left.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> valRight(thread, JSTaggedValue::ToNumeric(thread, right));
JSHandle<JSTaggedValue> 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<BigInt> leftBigint(valLeft);
JSHandle<BigInt> rightBigint(valRight);
return BigInt::Remainder(thread, leftBigint, rightBigint).GetTaggedValue();
}
if (valLeft->IsBigInt() || valRight->IsBigInt()) {
if (valLeft->IsBigInt() && valRight->IsBigInt()) {
JSHandle<BigInt> leftBigint(valLeft);
JSHandle<BigInt> 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();