挑单6359 6012 6021 5929到4.0release

Signed-off-by: hwx1163501 <hanjing35@huawei.com>
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I98MLQ
This commit is contained in:
hwx1163501 2024-03-14 18:32:38 +08:00
parent 35c73270a0
commit 48a5d7f9d4
8 changed files with 45 additions and 16 deletions

View File

@ -831,6 +831,9 @@ bool JsonStringifier::SerializeKeys(const JSHandle<JSObject> &obj, const JSHandl
JSTaggedValue entryKey = entry.first.GetTaggedValue();
handleKey_.Update(entryKey);
int index = globalDic->FindEntry(entryKey);
if (index == -1) {
continue;
}
JSTaggedValue value = globalDic->GetValue(index);
if (UNLIKELY(value.IsAccessor())) {
value = JSObject::CallGetter(thread_, AccessorData::Cast(value.GetTaggedObject()),

View File

@ -732,10 +732,9 @@ JSTaggedValue JSStableArray::With(JSThread *thread, JSHandle<JSArray> receiver,
int64_t insertCount, int64_t index, JSHandle<JSTaggedValue> value)
{
JSHandle<JSObject> thisObjHandle(receiver);
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
JSTaggedNumber(static_cast<uint32_t>(insertCount)));
JSHandle<JSTaggedValue> newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(0));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
JSHandle<JSObject> newArrayHandle(newArray);
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
@ -745,7 +744,7 @@ JSTaggedValue JSStableArray::With(JSThread *thread, JSHandle<JSArray> receiver,
if (insertCount > destElements->GetLength()) {
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, insertCount);
}
ASSERT(!newArrayHandle->GetJSHClass()->IsDictionaryMode());
for (uint32_t idx = 0; idx < insertCount; idx++) {
if (idx == index) {
destElements->Set(thread, idx, value.GetTaggedValue());
@ -769,10 +768,9 @@ JSTaggedValue JSStableArray::ToSpliced(JSHandle<JSArray> receiver, EcmaRuntimeCa
JSThread *thread = argv->GetThread();
JSHandle<JSObject> thisObjHandle(receiver);
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
JSTaggedNumber(static_cast<uint32_t>(insertCount)));
JSHandle<JSTaggedValue> newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(0));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
JSHandle<JSObject> newArrayHandle(newArray);
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
@ -782,7 +780,7 @@ JSTaggedValue JSStableArray::ToSpliced(JSHandle<JSArray> receiver, EcmaRuntimeCa
if (insertCount > destElements->GetLength()) {
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, insertCount);
}
ASSERT(!newArrayHandle->GetJSHClass()->IsDictionaryMode());
uint32_t i = 0;
uint32_t r = actualStart + actualSkipCount;
@ -821,10 +819,9 @@ JSTaggedValue JSStableArray::ToReversed(JSThread *thread, JSHandle<JSArray> rece
int64_t insertCount)
{
JSHandle<JSObject> thisObjHandle(receiver);
JSTaggedValue newArray = JSArray::ArraySpeciesCreate(thread, thisObjHandle,
JSTaggedNumber(static_cast<uint32_t>(insertCount)));
JSHandle<JSTaggedValue> newArray = JSArray::ArrayCreate(thread, JSTaggedNumber(0));
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSObject> newArrayHandle(thread, newArray);
JSHandle<JSObject> newArrayHandle(newArray);
JSHandle<JSTaggedValue> thisObjVal(thisObjHandle);
TaggedArray *srcElements = TaggedArray::Cast(thisObjHandle->GetElements().GetTaggedObject());
@ -834,7 +831,7 @@ JSTaggedValue JSStableArray::ToReversed(JSThread *thread, JSHandle<JSArray> rece
if (insertCount > destElements->GetLength()) {
destElements = *JSObject::GrowElementsCapacity(thread, newArrayHandle, insertCount);
}
ASSERT(!newArrayHandle->GetJSHClass()->IsDictionaryMode());
for (uint32_t idx = 0; idx < insertCount; idx++) {
auto kValue = srcElementsHandle->Get(idx);
if (kValue.IsHole()) {

View File

@ -847,6 +847,7 @@ JSHandle<JSObject> ObjectFactory::NewJSError(const ErrorType &errorType, const J
JSHandle<JSTaggedValue> nativePrototype(thread_, nativeFunc->GetFunctionPrototype());
JSHandle<JSTaggedValue> ctorKey = globalConst->GetHandledConstructorString();
JSHandle<JSTaggedValue> ctor(JSTaggedValue::GetProperty(thread_, nativePrototype, ctorKey).GetValue());
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSObject, thread_);
JSHandle<JSTaggedValue> undefined = thread_->GlobalConstants()->GetHandledUndefined();
EcmaRuntimeCallInfo *info =
EcmaInterpreter::NewRuntimeCallInfo(thread_, ctor, nativePrototype, undefined, 1, needCheckStack);

View File

@ -431,7 +431,12 @@ JSTaggedValue RuntimeStubs::RuntimeStArraySpread(JSThread *thread, const JSHandl
JSTaggedValue::SetProperty(thread, dst, dstLen + i, strValue, true);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
}
return JSTaggedValue(dstLen + strLen);
JSHandle<JSTaggedValue> length(thread, JSTaggedValue(dstLen + strLen));
if (strLen == 0U) {
JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
JSTaggedValue::SetProperty(thread, dst, lengthKey, length);
}
return length.GetTaggedValue();
}
if (index.GetInt() == 0 && src->IsStableJSArray(thread)) {
@ -465,6 +470,7 @@ JSTaggedValue RuntimeStubs::RuntimeStArraySpread(JSThread *thread, const JSHandl
JSHandle<JSTaggedValue> valueStr = globalConst->GetHandledValueString();
PropertyDescriptor desc(thread);
JSHandle<JSTaggedValue> iterResult;
uint32_t srcLen = 0U;
do {
iterResult = JSIterator::IteratorStep(thread, iter);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
@ -477,9 +483,13 @@ JSTaggedValue RuntimeStubs::RuntimeStArraySpread(JSThread *thread, const JSHandl
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
int tmp = indexHandle->GetInt();
indexHandle.Update(JSTaggedValue(tmp + 1));
++srcLen;
}
} while (true);
if (srcLen == 0U) {
JSHandle<JSTaggedValue> lengthKey = thread->GlobalConstants()->GetHandledLengthString();
JSTaggedValue::SetProperty(thread, dst, lengthKey, indexHandle);
}
return indexHandle.GetTaggedValue();
}

View File

@ -18,3 +18,4 @@ test successful
{"g":8,"f2":1}
{"a":{}}
{"3":3}
end JSON.stringify(globalThis)

View File

@ -83,4 +83,15 @@ var obj={
2:2,
3:3,
}
print(JSON.stringify(obj))
print(JSON.stringify(obj))
Reflect.defineProperty(globalThis,"c",{
get:()=>{
delete this["d"];
return "c";
},
enumerable:true,
});
Reflect.set(globalThis,"d","d");
JSON.stringify(globalThis);
print("end JSON.stringify(globalThis)")

View File

@ -40,3 +40,5 @@ Apple Banana
3
4
true
1
1

View File

@ -136,4 +136,8 @@ try {
} catch (err) {
result.push(err.name == "TypeError");
}
print(result)
print(result)
let arr=[];
print([,...arr].length)
print([,...''].length)