mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-12-02 16:07:20 +00:00
!7327 修复String endsWith输入越界值结果错误问题
Merge pull request !7327 from liujia178/mjsunit_string_endwith
This commit is contained in:
commit
bc8109c947
@ -404,7 +404,7 @@ JSTaggedValue BuiltinsString::EndsWith(EcmaRuntimeCallInfo *argv)
|
||||
if (posVal.GetNumber() == BuiltinsNumber::POSITIVE_INFINITY) {
|
||||
pos = static_cast<int32_t>(thisLen);
|
||||
} else {
|
||||
pos = posVal.ToInt32();
|
||||
pos = base::NumberHelper::DoubleInRangeInt32(posVal.GetNumber());
|
||||
}
|
||||
}
|
||||
pos = std::min(std::max(pos, 0), static_cast<int32_t>(thisLen));
|
||||
|
@ -2732,7 +2732,6 @@ void BuiltinsStringStubBuilder::EndsWith(GateRef glue, GateRef thisValue, GateRe
|
||||
Label posTagNotExists(env);
|
||||
Label posTagIsNumber(env);
|
||||
Label posTagIsInt(env);
|
||||
Label posTagIsDouble(env);
|
||||
Label afterCallArg(env);
|
||||
Label endPosLessThanZero(env);
|
||||
Label endPosNotLessThanZero(env);
|
||||
@ -2768,30 +2767,12 @@ void BuiltinsStringStubBuilder::EndsWith(GateRef glue, GateRef thisValue, GateRe
|
||||
GateRef posTag = GetCallArg1(numArgs);
|
||||
BRANCH(TaggedIsNumber(posTag), &posTagIsNumber, slowPath);
|
||||
Bind(&posTagIsNumber);
|
||||
BRANCH(TaggedIsInt(posTag), &posTagIsInt, &posTagIsDouble);
|
||||
BRANCH(TaggedIsInt(posTag), &posTagIsInt, slowPath);
|
||||
Bind(&posTagIsInt);
|
||||
{
|
||||
searchPos = GetInt32OfTInt(posTag);
|
||||
Jump(&afterCallArg);
|
||||
}
|
||||
Bind(&posTagIsDouble);
|
||||
{
|
||||
Label posTagIsPositiveInfinity(env);
|
||||
Label posTagNotPositiveInfinity(env);
|
||||
GateRef doubleVal = GetDoubleOfTDouble(posTag);
|
||||
BRANCH(DoubleEqual(doubleVal, Double(builtins::BuiltinsNumber::POSITIVE_INFINITY)),
|
||||
&posTagIsPositiveInfinity, &posTagNotPositiveInfinity);
|
||||
Bind(&posTagIsPositiveInfinity);
|
||||
{
|
||||
searchPos = thisLen;
|
||||
Jump(&afterCallArg);
|
||||
}
|
||||
Bind(&posTagNotPositiveInfinity);
|
||||
{
|
||||
searchPos = DoubleToInt(glue, doubleVal);
|
||||
Jump(&afterCallArg);
|
||||
}
|
||||
}
|
||||
}
|
||||
Bind(&posTagNotExists);
|
||||
{
|
||||
|
@ -142,3 +142,5 @@ abc
|
||||
abc
|
||||
bc
|
||||
c
|
||||
true
|
||||
true
|
||||
|
@ -387,3 +387,8 @@ print(abc_str.substr(0, positiveHeapNumber));
|
||||
print(abc_str.substr(-2, positiveHeapNumber));
|
||||
print(abc_str.substr(-1, positiveHeapNumber));
|
||||
|
||||
{
|
||||
function f(n) { return "cba".endsWith("a", n); }
|
||||
print(f());
|
||||
print(f(4294967296));
|
||||
}
|
||||
|
@ -2494,7 +2494,6 @@
|
||||
"mjsunit/compiler/fast-api-calls-pointer.js",
|
||||
"mjsunit/compiler/number-constructor-deopt.js",
|
||||
"mjsunit/compiler/fast-api-clamp-annotations.js",
|
||||
"mjsunit/compiler/string-endswith.js",
|
||||
"mjsunit/compiler/osr-forin.js",
|
||||
"mjsunit/compiler/bigint-multiply-truncate.js",
|
||||
"mjsunit/compiler/construct-receiver.js",
|
||||
|
Loading…
Reference in New Issue
Block a user