mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
Add fastElementkind ut case & Fix fixeddtoa
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9TDU1 Signed-off-by: dov1s <maojunwei1@huawei.com> Change-Id: Ib6b9d70c71a10d234ba8030f7f7fd4dda3328b2b
This commit is contained in:
parent
ede1af4385
commit
e57387ce90
@ -313,7 +313,7 @@ void DtoaHelper::FillFractionals(uint64_t fractionals, int exponent, int fractio
|
||||
fractionals -= static_cast<uint64_t>(digit) << point;
|
||||
}
|
||||
// If the first bit after the point is set we have to round up.
|
||||
if (((fractionals >> (point - 1)) & 1) == 1) {
|
||||
if (point > 0 && ((fractionals >> (point - 1)) & 1) == 1) {
|
||||
RoundUp(buffer, length, decimal_point);
|
||||
}
|
||||
} else { // We need 128 bits.
|
||||
|
@ -1867,11 +1867,19 @@ void BuiltinsArrayStubBuilder::FastReverse(GateRef glue, GateRef thisValue, Gate
|
||||
BRANCH(Int64LessThan(*i, *j), &next, &loopExit);
|
||||
Bind(&next);
|
||||
{
|
||||
GateRef lower = FastGetValueWithElementsKind(elements, *i, kind);
|
||||
GateRef upper = FastGetValueWithElementsKind(elements, *j, kind);
|
||||
FastSetValueWithElementsKind(glue, elements, upper, *i, kind);
|
||||
FastSetValueWithElementsKind(glue, elements, lower, *j, kind);
|
||||
Jump(&loopEnd);
|
||||
if (kind == ElementsKind::INT || kind == ElementsKind::NUMBER) {
|
||||
GateRef lower = GetValueFromMutantTaggedArray(elements, *i);
|
||||
GateRef upper = GetValueFromMutantTaggedArray(elements, *j);
|
||||
FastSetValueWithElementsKind(glue, elements, upper, *i, kind);
|
||||
FastSetValueWithElementsKind(glue, elements, lower, *j, kind);
|
||||
Jump(&loopEnd);
|
||||
} else {
|
||||
GateRef lower = GetValueFromTaggedArray(elements, *i);
|
||||
GateRef upper = GetValueFromTaggedArray(elements, *j);
|
||||
FastSetValueWithElementsKind(glue, elements, upper, *i, kind);
|
||||
FastSetValueWithElementsKind(glue, elements, lower, *j, kind);
|
||||
Jump(&loopEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
Bind(&loopEnd);
|
||||
|
@ -9953,26 +9953,6 @@ GateRef StubBuilder::SetValueWithElementsKind(GateRef glue, GateRef receiver, Ga
|
||||
return ret;
|
||||
}
|
||||
|
||||
GateRef StubBuilder::FastGetValueWithElementsKind(GateRef elements, GateRef index, ElementsKind kind)
|
||||
{
|
||||
auto env = GetEnvironment();
|
||||
Label entryPass(env);
|
||||
env->SubCfgEntry(&entryPass);
|
||||
DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
|
||||
Label exit(env);
|
||||
if (kind == ElementsKind::INT || kind == ElementsKind::NUMBER) {
|
||||
result = GetValueFromTaggedArray(elements, index);
|
||||
Jump(&exit);
|
||||
} else {
|
||||
result = GetValueFromTaggedArray(elements, index);
|
||||
Jump(&exit);
|
||||
}
|
||||
Bind(&exit);
|
||||
auto ret = *result;
|
||||
env->SubCfgExit();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void StubBuilder::FastSetValueWithElementsKind(GateRef glue, GateRef elements, GateRef rawValue,
|
||||
GateRef index, ElementsKind kind)
|
||||
{
|
||||
|
@ -518,7 +518,6 @@ public:
|
||||
GateRef ClearSharedStoreKind(GateRef handlerInfo);
|
||||
GateRef UpdateSOutOfBoundsForHandler(GateRef handlerInfo);
|
||||
GateRef GetTaggedValueWithElementsKind(GateRef receiver, GateRef index);
|
||||
GateRef FastGetValueWithElementsKind(GateRef elements, GateRef index, ElementsKind kind);
|
||||
void FastSetValueWithElementsKind(GateRef glue, GateRef elements, GateRef rawValue,
|
||||
GateRef index, ElementsKind kind);
|
||||
GateRef SetValueWithElementsKind(GateRef glue, GateRef receiver, GateRef rawValue, GateRef index,
|
||||
|
@ -1981,6 +1981,40 @@ function test147() {
|
||||
}
|
||||
}
|
||||
|
||||
//fast Array.reverse
|
||||
function test148() {
|
||||
let a = [];
|
||||
let b = a.reverse();
|
||||
let c = [8, 6, 4, 2];
|
||||
let d = [2, 4, 6, 8].reverse();
|
||||
let e = [1,2,,4];
|
||||
let f = e.reverse();
|
||||
if (a == b && c[1] == d[1] && f[0] == 4 &&
|
||||
f[1] == undefined) {
|
||||
print("test148 - success");
|
||||
} else {
|
||||
print("test148 - failed");
|
||||
}
|
||||
}
|
||||
|
||||
//fast Array.reverse
|
||||
function test149() {
|
||||
let a = [0.4, 0.6, 0.8];
|
||||
let b = a.reverse();
|
||||
let c = ["str2", "str3", "str4"];
|
||||
let d = c.reverse();
|
||||
let proto = { 0: "foo", 19: "bar" };
|
||||
let obj = { length: 20, 5: "foobar", __proto__: proto };
|
||||
Array.prototype.reverse.call(obj);
|
||||
|
||||
if (b[0] == 0.8 && c[0] == "str4" && obj[0] == "bar" &&
|
||||
obj[19] == "foo") {
|
||||
print("test149 - success");
|
||||
} else {
|
||||
print("test149 - failed");
|
||||
}
|
||||
}
|
||||
|
||||
// Int
|
||||
test1();
|
||||
test2();
|
||||
@ -2213,6 +2247,9 @@ test145();
|
||||
test146();
|
||||
test147();
|
||||
|
||||
test148();
|
||||
test149();
|
||||
|
||||
// Test COW ElementsKind
|
||||
class Index {
|
||||
currentArrays = [
|
||||
@ -2269,3 +2306,4 @@ function testLength() {
|
||||
}
|
||||
|
||||
testLength();
|
||||
|
||||
|
@ -178,6 +178,8 @@ test144 - success
|
||||
test145 - success
|
||||
test146 - success
|
||||
test147 - success
|
||||
test148 - success
|
||||
test149 - success
|
||||
16
|
||||
0
|
||||
32
|
||||
|
Loading…
Reference in New Issue
Block a user