Revert PR7195 Because Incompatible change

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAP6II

Signed-off-by: hecunmao <hecunmao@huawei.com>
Change-Id: I2a6adbe1fbcf5fbf04b21c841d49461f29cd063a
This commit is contained in:
hecunmao 2024-09-05 18:41:45 +08:00
parent a6a9af4ebb
commit 18cedf23dc
5 changed files with 41 additions and 53 deletions

View File

@ -82,15 +82,19 @@ static std::pair<TaggedArray*, size_t> BuildArgumentsListFast(JSThread *thread,
} else if (arrayObj->IsStableJSArray(thread)) {
JSHandle<JSArray> argList = JSHandle<JSArray>::Cast(arrayObj);
TaggedArray *elements = nullptr;
JSHandle<JSObject> obj(arrayObj);
int elementsLength = static_cast<int>(ElementAccessor::GetElementsLength(obj));
JSHandle<TaggedArray> newElements = thread->GetEcmaVM()->GetFactory()->
NewTaggedArray(elementsLength, JSTaggedValue::Undefined());
for (int i = 0; i < elementsLength; ++i) {
JSTaggedValue value = ElementAccessor::Get(obj, i);
newElements->Set(thread, i, value);
if (argList->GetElements().IsMutantTaggedArray()) {
JSHandle<JSObject> obj(arrayObj);
int elementsLength = static_cast<int>(ElementAccessor::GetElementsLength(obj));
JSHandle<TaggedArray> newElements = thread->GetEcmaVM()->GetFactory()->
NewTaggedArray(elementsLength, JSTaggedValue::Undefined());
for (int i = 0; i < elementsLength; ++i) {
JSTaggedValue value = ElementAccessor::Get(obj, i);
newElements->Set(thread, i, value);
}
elements = *newElements;
} else {
elements = TaggedArray::Cast(argList->GetElements().GetTaggedObject());
}
elements = *newElements;
size_t length = argList->GetArrayLength();
if (elements->GetLength() == 0 && length != 0) {
JSHandle<TaggedArray> array =

View File

@ -324,32 +324,37 @@ GateRef BuiltinsFunctionStubBuilder::BuildArgumentsListFastElements(GateRef glue
Bind(&targetIsStableJSArray);
{
res = GetElementsArray(arrayObj);
NewObjectStubBuilder newBuilder(this);
GateRef elementsLength = GetLengthOfTaggedArray(*res);
GateRef newTaggedArgList = newBuilder.NewTaggedArray(glue, elementsLength);
DEFVARIABLE(index, VariableType::INT32(), Int32(0));
Label loopHead(env);
Label loopEnd(env);
Label afterLoop(env);
Label storeValue(env);
Jump(&loopHead);
LoopBegin(&loopHead);
Label isMutantTaggedArray(env);
BRANCH(IsMutantTaggedArray(*res), &isMutantTaggedArray, &exit);
Bind(&isMutantTaggedArray);
{
BRANCH(Int32UnsignedLessThan(*index, elementsLength), &storeValue, &afterLoop);
Bind(&storeValue);
NewObjectStubBuilder newBuilder(this);
GateRef elementsLength = GetLengthOfTaggedArray(*res);
GateRef newTaggedArgList = newBuilder.NewTaggedArray(glue, elementsLength);
DEFVARIABLE(index, VariableType::INT32(), Int32(0));
Label loopHead(env);
Label loopEnd(env);
Label afterLoop(env);
Label storeValue(env);
Jump(&loopHead);
LoopBegin(&loopHead);
{
GateRef value = GetTaggedValueWithElementsKind(arrayObj, *index);
SetValueToTaggedArray(VariableType::JS_ANY(), glue, newTaggedArgList, *index, value);
index = Int32Add(*index, Int32(1));
Jump(&loopEnd);
BRANCH(Int32UnsignedLessThan(*index, elementsLength), &storeValue, &afterLoop);
Bind(&storeValue);
{
GateRef value = GetTaggedValueWithElementsKind(arrayObj, *index);
SetValueToTaggedArray(VariableType::JS_ANY(), glue, newTaggedArgList, *index, value);
index = Int32Add(*index, Int32(1));
Jump(&loopEnd);
}
}
Bind(&loopEnd);
LoopEnd(&loopHead);
Bind(&afterLoop);
{
res = newTaggedArgList;
Jump(&exit);
}
}
Bind(&loopEnd);
LoopEnd(&loopHead);
Bind(&afterLoop);
{
res = newTaggedArgList;
Jump(&exit);
}
}
Bind(&targetNotStableJSArray);

View File

@ -30,12 +30,6 @@ TypeError: Cannot assign to read only property
TypeError: Under strict mode, 'caller' and 'arguments' properties must not be accessed.
TypeError: Under strict mode, 'caller' and 'arguments' properties must not be accessed.
TypeError: Cannot assign to read only property
true
true
true
true
true
true
3
1
2

View File

@ -168,22 +168,6 @@ try{
}
Function.prototype.apply = backup_apply;
var next_expected = 0;
var large_array3 = new Array(100);
large_array3[0] = 0;
large_array3[1] = 1;
large_array3[2] = 2;
large_array3[3] = 3;
large_array3[4] = 4;
large_array3[95] = 95;
function called_by_apply() {};
called_by_apply.apply({}, large_array3);
for (var x in large_array3) {
print(next_expected++ == x);
if (next_expected == 5) {
next_expected = 95;
}
}
let a3 = [1, 2, 3];
function func1(a, b, c, d) {

View File

@ -1862,6 +1862,7 @@
"mjsunit/object-literal-gc.js",
"mjsunit/array-bounds-check-removal.js",
"mjsunit/whitespaces8.js",
"mjsunit/unbox-double-arrays.js",
"mjsunit/whitespaces2.js",
"mjsunit/function-var.js",
"mjsunit/icu-date-to-string.js",