mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-07-20 23:00:29 -04:00
fix expdyn stub handle error in bigint
desc: fix expdyn stub handle error in bigint solution: 1. Slowruntime expdyn need adaption to bigint, but stub's slowruntime doesn't modify. So fill up modification. issue: https://gitee.com/openharmony/ark_js_runtime/issues/I50ZRS Signed-off-by: wanghuan <wanghuan80@huawei.com> Change-Id: I46e4b11f3ed54239becdb3f80b5cea94d93f505b
This commit is contained in:
@@ -41,7 +41,7 @@ void name##Stub::GenerateCircuit(const CompilationConfig *cfg)
|
||||
GateRef profileTypeInfo = TaggedPointerArgument(4); /* 4 : 5th parameter is value */ \
|
||||
GateRef acc = TaggedArgument(5); /* 5: 6th parameter is value */ \
|
||||
GateRef hotnessCounter = Int32Argument(6); /* 6 : 7th parameter is value */ \
|
||||
DebugPrint(glue, { Int32(GET_MESSAGE_STRING_ID(name)) }); \
|
||||
DebugPrint(glue, { Int32(GET_MESSAGE_STRING_ID(name)) }); \
|
||||
GenerateCircuitImpl(glue, pc, sp, constpool, profileTypeInfo, acc, hotnessCounter); \
|
||||
} \
|
||||
void name##Stub::GenerateCircuitImpl(GateRef glue, GateRef pc, GateRef sp, \
|
||||
|
||||
@@ -58,19 +58,26 @@ JSTaggedValue RuntimeStubs::RuntimeDecDyn(JSThread *thread, const JSHandle<JSTag
|
||||
return JSTaggedValue(--number);
|
||||
}
|
||||
|
||||
JSTaggedValue RuntimeStubs::RuntimeExpDyn(JSThread *thread, const JSHandle<JSTaggedValue> &base,
|
||||
const JSHandle<JSTaggedValue> &exponent)
|
||||
JSTaggedValue RuntimeStubs::RuntimeExpDyn(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent)
|
||||
{
|
||||
JSTaggedNumber baseNumber = JSTaggedValue::ToNumber(thread, base);
|
||||
JSHandle<JSTaggedValue> valBase = JSTaggedValue::ToNumeric(thread, base);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
double doubleBase = baseNumber.GetNumber();
|
||||
JSTaggedNumber exponentNumber = JSTaggedValue::ToNumber(thread, exponent);
|
||||
JSHandle<JSTaggedValue> valExponent = JSTaggedValue::ToNumeric(thread, exponent);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
double doubleExponent = exponentNumber.GetNumber();
|
||||
if (valBase->IsBigInt() || valExponent->IsBigInt()) {
|
||||
if (valBase->IsBigInt() && valExponent->IsBigInt()) {
|
||||
JSHandle<BigInt> bigBaseVale(valBase);
|
||||
JSHandle<BigInt> bigExponentValue(valExponent);
|
||||
return BigInt::Exponentiate(thread, bigBaseVale, bigExponentValue).GetTaggedValue();
|
||||
}
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot mix BigInt and other types, use explicit conversions",
|
||||
JSTaggedValue::Exception());
|
||||
}
|
||||
double doubleBase = valBase->GetNumber();
|
||||
double doubleExponent = valExponent->GetNumber();
|
||||
if (std::abs(doubleBase) == 1 && std::isinf(doubleExponent)) {
|
||||
return JSTaggedValue(base::NAN_VALUE);
|
||||
}
|
||||
|
||||
if (((doubleBase == 0) && ((bit_cast<uint64_t>(doubleBase)) & base::DOUBLE_SIGN_MASK) == base::DOUBLE_SIGN_MASK) &&
|
||||
std::isfinite(doubleExponent) && base::NumberHelper::TruncateDouble(doubleExponent) == doubleExponent &&
|
||||
base::NumberHelper::TruncateDouble(doubleExponent / 2) + base::HALF == (doubleExponent / 2)) { // 2: half
|
||||
|
||||
@@ -468,8 +468,7 @@ DEF_RUNTIME_STUBS(ExpDyn)
|
||||
return JSTaggedValue(std::pow(doubleBase, doubleExponent)).GetRawData();
|
||||
}
|
||||
// Slow path
|
||||
JSTaggedValue res = RuntimeExpDyn(thread, JSHandle<JSTaggedValue>(thread, baseValue),
|
||||
JSHandle<JSTaggedValue>(thread, exponentValue));
|
||||
JSTaggedValue res = RuntimeExpDyn(thread, baseValue, exponentValue);
|
||||
return res.GetRawData();
|
||||
}
|
||||
|
||||
|
||||
@@ -222,8 +222,7 @@ private:
|
||||
|
||||
static inline JSTaggedValue RuntimeIncDyn(JSThread *thread, const JSHandle<JSTaggedValue> &value);
|
||||
static inline JSTaggedValue RuntimeDecDyn(JSThread *thread, const JSHandle<JSTaggedValue> &value);
|
||||
static inline JSTaggedValue RuntimeExpDyn(JSThread *thread, const JSHandle<JSTaggedValue> &base,
|
||||
const JSHandle<JSTaggedValue> &exponent);
|
||||
static inline JSTaggedValue RuntimeExpDyn(JSThread *thread, JSTaggedValue base, JSTaggedValue exponent);
|
||||
static inline JSTaggedValue RuntimeIsInDyn(JSThread *thread, const JSHandle<JSTaggedValue> &prop,
|
||||
const JSHandle<JSTaggedValue> &obj);
|
||||
static inline JSTaggedValue RuntimeInstanceofDyn(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
|
||||
|
||||
Reference in New Issue
Block a user