mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
[Bug]: Bugfix on Array.slice call ArrayCreate to create dictionary mode array
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7M4TV Signed-off-by: quiet-thought <chenjingxiang1@huawei.com> Change-Id: I01d729837f59ea9197686f3144a688ec1429ae54
This commit is contained in:
parent
2bafcd9845
commit
3fe4f36d1c
@ -115,7 +115,7 @@ JSTaggedValue JSArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObj
|
||||
// Let C be Get(originalArray, "constructor").
|
||||
auto *hclass = originalArray->GetJSHClass();
|
||||
if (hclass->IsJSArray() && !hclass->HasConstructor()) {
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
}
|
||||
JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString();
|
||||
constructor = JSTaggedValue::GetProperty(thread, originalValue, constructorKey).GetValue();
|
||||
@ -133,7 +133,7 @@ JSTaggedValue JSArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObj
|
||||
JSTaggedValue realmArrayConstructor = realmC->GetArrayFunction().GetTaggedValue();
|
||||
// If SameValue(C, realmC.[[intrinsics]].[[%Array%]]) is true, let C be undefined.
|
||||
if (JSTaggedValue::SameValue(constructor.GetTaggedValue(), realmArrayConstructor)) {
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,14 +147,14 @@ JSTaggedValue JSArray::ArraySpeciesCreate(JSThread *thread, const JSHandle<JSObj
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
// If C is null, let C be undefined.
|
||||
if (constructor->IsNull()) {
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If C is undefined, return ArrayCreate(length).
|
||||
if (constructor->IsUndefined()) {
|
||||
return JSArray::ArrayCreate(thread, length).GetTaggedValue();
|
||||
return JSArray::ArrayCreate(thread, length, ArrayMode::LITERAL).GetTaggedValue();
|
||||
}
|
||||
// If IsConstructor(C) is false, throw a TypeError exception.
|
||||
if (!constructor->IsConstructor()) {
|
||||
|
@ -13,3 +13,4 @@
|
||||
|
||||
33333
|
||||
18001
|
||||
0
|
||||
|
@ -39,3 +39,10 @@ do {
|
||||
}
|
||||
} while (t++ < 18000)
|
||||
print(t);
|
||||
|
||||
let bytes = new Uint8Array(new ArrayBuffer(43584));
|
||||
let arr2 = [].slice.call(bytes);
|
||||
while (arr2.length) {
|
||||
arr2.pop();
|
||||
}
|
||||
print(arr2.length);
|
||||
|
Loading…
Reference in New Issue
Block a user