From 3efd90806211c6767585a95586bb7176e8ddb89d Mon Sep 17 00:00:00 2001 From: coollixin Date: Tue, 30 Jan 2024 15:21:34 +0800 Subject: [PATCH 1/6] hashset next modify issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8ZXBB Signed-off-by: coollixin --- ecmascript/js_api/js_api_hashset_iterator.cpp | 2 +- ecmascript/js_api/js_api_lightweightset_iterator.cpp | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ecmascript/js_api/js_api_hashset_iterator.cpp b/ecmascript/js_api/js_api_hashset_iterator.cpp index 3e5d261ef3..46f73d44a6 100644 --- a/ecmascript/js_api/js_api_hashset_iterator.cpp +++ b/ecmascript/js_api/js_api_hashset_iterator.cpp @@ -65,7 +65,7 @@ JSTaggedValue JSAPIHashSetIterator::Next(EcmaRuntimeCallInfo *argv) } ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle array = factory->NewTaggedArray(2); // 2 means the length of array - array->Set(thread, 0, JSTaggedValue(--index)); + array->Set(thread, 0, valueHandle); array->Set(thread, 1, valueHandle); JSHandle keyAndValue(JSArray::CreateArrayFromList(thread, array)); return JSIterator::CreateIterResultObject(thread, keyAndValue, false).GetTaggedValue(); diff --git a/ecmascript/js_api/js_api_lightweightset_iterator.cpp b/ecmascript/js_api/js_api_lightweightset_iterator.cpp index 133390f45b..0e589a3396 100644 --- a/ecmascript/js_api/js_api_lightweightset_iterator.cpp +++ b/ecmascript/js_api/js_api_lightweightset_iterator.cpp @@ -65,12 +65,9 @@ JSTaggedValue JSAPILightWeightSetIterator::Next(EcmaRuntimeCallInfo *argv) if (itemKind == IterationKind::VALUE) { return JSIterator::CreateIterResultObject(thread, value, false).GetTaggedValue(); } - TaggedArray *hashArray = - TaggedArray::Cast(JSHandle(lightWeightSet)->GetHashes().GetTaggedObject()); - JSHandle keyHandle(thread, hashArray->Get(index)); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle array = factory->NewTaggedArray(2); // 2 means the length of array - array->Set(thread, 0, keyHandle); + array->Set(thread, 0, value); array->Set(thread, 1, value); JSHandle keyAndValue(JSArray::CreateArrayFromList(thread, array)); return JSIterator::CreateIterResultObject(thread, keyAndValue, false).GetTaggedValue(); -- Gitee From 719b01368d76b4319bdc4fa5a4cf378f7ad19616 Mon Sep 17 00:00:00 2001 From: bi-hu Date: Thu, 1 Feb 2024 17:07:16 +0800 Subject: [PATCH 2/6] Remove redundant code fallback Signed-off-by: bi-hu https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I90IDC --- ecmascript/object_factory.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 0fd940ade2..92089ca2b4 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -2231,11 +2231,14 @@ JSHandle ObjectFactory::NewInternalAccessor(void *setter, void *ge TaggedObject *header = heap_->AllocateNonMovableOrHugeObject( JSHClass::Cast(thread_->GlobalConstants()->GetInternalAccessorClass().GetTaggedObject())); JSHandle obj(thread_, AccessorData::Cast(header)); + obj->SetGetter(thread_, JSTaggedValue::Undefined()); + obj->SetSetter(thread_, JSTaggedValue::Undefined()); if (setter != nullptr) { JSHandle setFunc = NewJSNativePointer(setter, nullptr, nullptr, true); obj->SetSetter(thread_, setFunc.GetTaggedValue()); } else { - obj->SetSetter(thread_, JSTaggedValue::Undefined()); + JSTaggedValue setFunc = JSTaggedValue::Undefined(); + obj->SetSetter(thread_, setFunc); ASSERT(!obj->HasSetter()); } JSHandle getFunc = NewJSNativePointer(getter, nullptr, nullptr, true); -- Gitee From 7e6b8095cff9bb4294e9dfab1a7f88ebb3ab3bd6 Mon Sep 17 00:00:00 2001 From: hwx1163501 Date: Thu, 1 Feb 2024 11:29:40 +0800 Subject: [PATCH 3/6] modify code alarms Signed-off-by: hwx1163501 issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I90E4E --- ecmascript/compiler/bytecodes.cpp | 3 +- ecmascript/date_parse.cpp | 4 +-- ecmascript/js_hclass.cpp | 6 ++-- ecmascript/js_typed_array.cpp | 2 +- ecmascript/object_fast_operator-inl.h | 6 ++-- ecmascript/object_operator.cpp | 13 ++++---- .../tests/pgo_test_case/string_equal.js | 6 ++-- ecmascript/stackmap/llvm_stackmap_parser.cpp | 2 +- test/aottest/string_equal/string_equal.ts | 30 +++++++++---------- 9 files changed, 39 insertions(+), 33 deletions(-) diff --git a/ecmascript/compiler/bytecodes.cpp b/ecmascript/compiler/bytecodes.cpp index ee18b1e48d..fdec70cb7c 100644 --- a/ecmascript/compiler/bytecodes.cpp +++ b/ecmascript/compiler/bytecodes.cpp @@ -1599,8 +1599,7 @@ void BytecodeInfo::InitBytecodeInfo(BytecodeCircuitBuilder *builder, info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); break; } - case EcmaOpcode::STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8: - { + case EcmaOpcode::STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8: { uint32_t slotId = READ_INST_8_0(); uint32_t levelIndex = READ_INST_16_1(); uint32_t slotIndex = READ_INST_16_3(); diff --git a/ecmascript/date_parse.cpp b/ecmascript/date_parse.cpp index 357609dbb5..c6c8e79d2a 100644 --- a/ecmascript/date_parse.cpp +++ b/ecmascript/date_parse.cpp @@ -428,9 +428,9 @@ bool DateParse::DayValue::SetDayValue(int *time) } if (!IsIso()) { if (IsBetween(year, 1, 49)) { // if year is between 1-49 - year += 2000; // it means 2001-2049 + year += 2000; // 2000 : it means 2001-2049 } else if (IsBetween(year, 50, 99)) { // if year is between 50-99 - year += 1900; // it may means 1950-1999 + year += 1900; // 1900 : it may means 1950-1999 } } if (!MonthIsValid(mon) || !DayIsValid(day)) { diff --git a/ecmascript/js_hclass.cpp b/ecmascript/js_hclass.cpp index 333bc8e186..18b7364ecf 100644 --- a/ecmascript/js_hclass.cpp +++ b/ecmascript/js_hclass.cpp @@ -605,7 +605,8 @@ std::tuple JSHClass::ConvertOrTransitionWithRep(const if (oldRep == Representation::DOUBLE) { if (value->IsInt()) { double doubleValue = value->GetInt(); - return std::tuple(false, false, JSTaggedValue(bit_cast(doubleValue))); + return std::tuple(false, false, + JSTaggedValue(bit_cast(doubleValue))); } else if (value->IsObject()) { // Is Object attr.SetRepresentation(Representation::TAGGED); @@ -614,7 +615,8 @@ std::tuple JSHClass::ConvertOrTransitionWithRep(const return std::tuple(true, true, value.GetTaggedValue()); } else { // Is TaggedDouble - return std::tuple(false, false, JSTaggedValue(bit_cast(value->GetDouble()))); + return std::tuple(false, false, + JSTaggedValue(bit_cast(value->GetDouble()))); } } else if (oldRep == Representation::INT) { if (value->IsInt()) { diff --git a/ecmascript/js_typed_array.cpp b/ecmascript/js_typed_array.cpp index 6f7ab7d15c..904166120d 100644 --- a/ecmascript/js_typed_array.cpp +++ b/ecmascript/js_typed_array.cpp @@ -736,7 +736,7 @@ JSTaggedValue JSTypedArray::GetOffHeapBuffer(JSThread *thread, JSHandle typeName(thread, typedArray->GetTypedArrayName()); DataViewType arrayType = JSTypedArray::GetTypeFromName(thread, typeName); JSHandle notOnHeapHclass = TypedArrayHelper::GetNotOnHeapHclassFromType( - thread, typedArray, arrayType); + thread, typedArray, arrayType); TaggedObject::Cast(*typedArray)->SynchronizedSetClass(thread, *notOnHeapHclass); // onHeap->notOnHeap return arrayBuffer.GetTaggedValue(); diff --git a/ecmascript/object_fast_operator-inl.h b/ecmascript/object_fast_operator-inl.h index d2818f3309..7bf9b00be4 100644 --- a/ecmascript/object_fast_operator-inl.h +++ b/ecmascript/object_fast_operator-inl.h @@ -616,9 +616,11 @@ PropertyAttributes ObjectFastOperator::AddPropertyByName(JSThread *thread, JSHan JSHClass::AddProperty(thread, objHandle, keyHandle, attr); auto actualValue = JSHClass::ConvertOrTransitionWithRep(thread, objHandle, keyHandle, valueHandle, attr); if (std::get<0>(actualValue)) { - objHandle->SetPropertyInlinedProps(thread, nextInlinedPropsIndex, std::get<2>(actualValue)); + objHandle->SetPropertyInlinedProps(thread, nextInlinedPropsIndex, + std::get<2>(actualValue)); // 2 : Gets the third value } else { - objHandle->SetPropertyInlinedProps(thread, nextInlinedPropsIndex, std::get<2>(actualValue)); + objHandle->SetPropertyInlinedProps(thread, nextInlinedPropsIndex, + std::get<2>(actualValue)); // 2 : Gets the third value } return attr; } diff --git a/ecmascript/object_operator.cpp b/ecmascript/object_operator.cpp index e327c31f95..6686ffda05 100644 --- a/ecmascript/object_operator.cpp +++ b/ecmascript/object_operator.cpp @@ -718,16 +718,17 @@ bool ObjectOperator::UpdateDataValue(const JSHandle &receiver, const J attributes_.SetRepresentation(attr.GetRepresentation()); if (attr.IsInlinedProps()) { - receiver->SetPropertyInlinedPropsWithRep(thread_, GetIndex(), std::get<2>(actualValue)); + receiver->SetPropertyInlinedPropsWithRep(thread_, GetIndex(), + std::get<2>(actualValue)); // 2 : Gets the third value } else { if (receiver.GetTaggedValue().IsJSCOWArray()) { JSArray::CheckAndCopyArray(thread_, JSHandle(receiver)); properties.Update(JSHandle(receiver)->GetProperties()); } if (std::get<0>(actualValue)) { - properties->Set(thread_, GetIndex(), std::get<2>(actualValue)); + properties->Set(thread_, GetIndex(), std::get<2>(actualValue)); // 2 : Gets the third value } else { - properties->Set(thread_, GetIndex(), std::get<2>(actualValue)); + properties->Set(thread_, GetIndex(), std::get<2>(actualValue)); // 2 : Gets the third value } } } else { @@ -1009,9 +1010,11 @@ void ObjectOperator::AddPropertyInternal(const JSHandle &value) attributes_.SetRepresentation(attr.GetRepresentation()); auto *hclass = receiver_->GetTaggedObject()->GetClass(); if (std::get<0>(actualValue)) { - JSObject::Cast(receiver_.GetTaggedValue())->SetProperty(thread_, hclass, attr, std::get<2>(actualValue)); + JSObject::Cast(receiver_.GetTaggedValue())->SetProperty(thread_, + hclass, attr, std::get<2>(actualValue)); // 2 : Gets the third value } else { - JSObject::Cast(receiver_.GetTaggedValue())->SetProperty(thread_, hclass, attr, std::get<2>(actualValue)); + JSObject::Cast(receiver_.GetTaggedValue())->SetProperty(thread_, + hclass, attr, std::get<2>(actualValue)); // 2 : Gets the third value } uint32_t index = attr.IsInlinedProps() ? attr.GetOffset() : attr.GetOffset() - obj->GetJSHClass()->GetInlinedProperties(); diff --git a/ecmascript/pgo_profiler/tests/pgo_test_case/string_equal.js b/ecmascript/pgo_profiler/tests/pgo_test_case/string_equal.js index 94056e7397..4f7c998ba1 100644 --- a/ecmascript/pgo_profiler/tests/pgo_test_case/string_equal.js +++ b/ecmascript/pgo_profiler/tests/pgo_test_case/string_equal.js @@ -14,14 +14,14 @@ * limitations under the License. */ -let a = "abcString"; +let a = 'abcString'; function foo1(a) { - typeof a == "string"; + typeof a == 'string'; } function foo2(a) { - a[0] == "a"; + a[0] == "a"; } foo1(a); diff --git a/ecmascript/stackmap/llvm_stackmap_parser.cpp b/ecmascript/stackmap/llvm_stackmap_parser.cpp index 5ac91108a2..2aeb2410a7 100644 --- a/ecmascript/stackmap/llvm_stackmap_parser.cpp +++ b/ecmascript/stackmap/llvm_stackmap_parser.cpp @@ -43,7 +43,7 @@ std::string LocationTy::TypeToString(Kind loc) const void LLVMStackMapParser::FilterCallSiteInfo(LLVMStackMapType::CallSiteInfo &info) { - ASSERT(GC_PAIR_SIZE == 2); + ASSERT(GC_PAIR_SIZE == 2); // 2 : The expected value of GC_PAIR_SIZE is 2 ASSERT(info.size() % GC_PAIR_SIZE == 0); for (auto it = info.begin(); it != info.end();) { auto base = it; diff --git a/test/aottest/string_equal/string_equal.ts b/test/aottest/string_equal/string_equal.ts index ee0c055c1b..3b5db937a6 100644 --- a/test/aottest/string_equal/string_equal.ts +++ b/test/aottest/string_equal/string_equal.ts @@ -14,32 +14,32 @@ */ declare function print(arg:any, arg1?:any):string; -let str:string = "1234567890上下左右中"; +let str:string = '1234567890上下左右中'; // two const -print("123" == "123"); -print(str == "1234567890上下左右中"); -print("1" == "1") -print(str[0] == "12") +print('123' == '123'); +print(str == '1234567890上下左右中'); +print('1' == '1') +print(str[0] == '12') // one const let ans = 0; for (let i = 0; i<15; ++i) { - let m:string = str[i]; - if (m == "1" || m == "上" || m == "国") { - ans += 1; - } + let m:string = str[i]; + if (m == '1' || m == '上' || m == '国') { + ans += 1; + } } print(ans); // no const function foo(flag) { - let str = "12"; - if (flag) { - return str[0]; - } else { - return str[1]; - } + let str = '12'; + if (flag) { + return str[0]; + } else { + return str[1]; + } } let left:string = foo(true); let right1:string = foo(true); -- Gitee From 7e095b10eeacbd172f0662d2648969a43357f914 Mon Sep 17 00:00:00 2001 From: chenhantao Date: Wed, 31 Jan 2024 21:26:00 +0800 Subject: [PATCH 4/6] fix regress Signed-off-by: chenhantao Change-Id: I57cd674fbd5394d9d009e0ea5a3131118c088826 --- ecmascript/base/typed_array_helper.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ecmascript/base/typed_array_helper.cpp b/ecmascript/base/typed_array_helper.cpp index ef7279a802..eee3b8d784 100644 --- a/ecmascript/base/typed_array_helper.cpp +++ b/ecmascript/base/typed_array_helper.cpp @@ -507,8 +507,13 @@ JSHandle TypedArrayHelper::TypedArraySpeciesCreate(JSThread *thread, c JSObject::GetProperty(thread, JSHandle(obj), key, JSHandle(obj)).GetValue(); JSHandle result; JSHandle proto(thread, obj->GetJSHClass()->GetPrototype()); - if (proto->IsJSTypedArray() && PropertyDetector::IsTypedArraySpeciesProtectDetectorValid(env) && - buffHandle->IsInt() && objConstructor->IsECMAObject()) { + bool ctrVali = objConstructor->IsUndefined(); + bool isJSTypedArr = proto->IsJSTypedArray(); + bool isCtrUnchanged = PropertyDetector::IsTypedArraySpeciesProtectDetectorValid(env) && + !objConstructor->IsClassConstructor(); + bool isCtrBylen = buffHandle->IsInt(); + bool isCtrObj = objConstructor->IsECMAObject(); + if (ctrVali || (isJSTypedArr && isCtrUnchanged && isCtrBylen && isCtrObj)) { JSType type = obj->GetJSHClass()->GetObjectType(); DataViewType arrayType = GetType(type); uint32_t length = buffHandle->GetInt(); -- Gitee From 994049c1ab461812452e9f3876de67e6a28b4311 Mon Sep 17 00:00:00 2001 From: coollixin Date: Wed, 31 Jan 2024 10:06:28 +0800 Subject: [PATCH 5/6] Add Compare function issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I902NW Signed-off-by: coollixin --- ecmascript/js_api/js_api_hashset_iterator.cpp | 2 +- .../js_api/js_api_lightweightset_iterator.cpp | 5 ++++- ecmascript/tagged_tree.h | 15 +++++++++++++-- test/moduletest/container/container_treemap.js | 13 +++++++++++++ test/moduletest/container/container_treeset.js | 13 +++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/ecmascript/js_api/js_api_hashset_iterator.cpp b/ecmascript/js_api/js_api_hashset_iterator.cpp index 46f73d44a6..3e5d261ef3 100644 --- a/ecmascript/js_api/js_api_hashset_iterator.cpp +++ b/ecmascript/js_api/js_api_hashset_iterator.cpp @@ -65,7 +65,7 @@ JSTaggedValue JSAPIHashSetIterator::Next(EcmaRuntimeCallInfo *argv) } ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle array = factory->NewTaggedArray(2); // 2 means the length of array - array->Set(thread, 0, valueHandle); + array->Set(thread, 0, JSTaggedValue(--index)); array->Set(thread, 1, valueHandle); JSHandle keyAndValue(JSArray::CreateArrayFromList(thread, array)); return JSIterator::CreateIterResultObject(thread, keyAndValue, false).GetTaggedValue(); diff --git a/ecmascript/js_api/js_api_lightweightset_iterator.cpp b/ecmascript/js_api/js_api_lightweightset_iterator.cpp index 0e589a3396..133390f45b 100644 --- a/ecmascript/js_api/js_api_lightweightset_iterator.cpp +++ b/ecmascript/js_api/js_api_lightweightset_iterator.cpp @@ -65,9 +65,12 @@ JSTaggedValue JSAPILightWeightSetIterator::Next(EcmaRuntimeCallInfo *argv) if (itemKind == IterationKind::VALUE) { return JSIterator::CreateIterResultObject(thread, value, false).GetTaggedValue(); } + TaggedArray *hashArray = + TaggedArray::Cast(JSHandle(lightWeightSet)->GetHashes().GetTaggedObject()); + JSHandle keyHandle(thread, hashArray->Get(index)); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle array = factory->NewTaggedArray(2); // 2 means the length of array - array->Set(thread, 0, value); + array->Set(thread, 0, keyHandle); array->Set(thread, 1, value); JSHandle keyAndValue(JSArray::CreateArrayFromList(thread, array)); return JSIterator::CreateIterResultObject(thread, keyAndValue, false).GetTaggedValue(); diff --git a/ecmascript/tagged_tree.h b/ecmascript/tagged_tree.h index 4b4bb51236..8b7632f0f5 100644 --- a/ecmascript/tagged_tree.h +++ b/ecmascript/tagged_tree.h @@ -150,7 +150,17 @@ public: JSTaggedValue callResult = JSFunction::Call(info); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); int compareResult = 0; - if (callResult.IsInt()) { + if (callResult.IsBoolean()) { + if (callResult.IsTrue()) { + compareResult = -1; + } else { + info = EcmaInterpreter::NewRuntimeCallInfo(thread, compareFn, thisArgHandle, undefined, argsLength); + info->SetCallArg(valueY.GetTaggedValue(), valueX.GetTaggedValue()); + callResult = JSFunction::Call(info); + RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); + compareResult = callResult.IsTrue() ? 1 : 0; + } + } else if (callResult.IsInt()) { compareResult = callResult.GetInt(); } else { JSHandle resultHandle(thread, callResult); @@ -158,7 +168,8 @@ public: RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ComparisonResult::UNDEFINED); double value = v.GetNumber(); if (std::isnan(value)) { - THROW_TYPE_ERROR_AND_RETURN(thread, "CompareFn has illegal return value", ComparisonResult::UNDEFINED); + THROW_TYPE_ERROR_AND_RETURN(thread, "CompareFn has illegal return value", + ComparisonResult::UNDEFINED); } compareResult = static_cast(value); } diff --git a/test/moduletest/container/container_treemap.js b/test/moduletest/container/container_treemap.js index e195ede054..4c83561ea8 100644 --- a/test/moduletest/container/container_treemap.js +++ b/test/moduletest/container/container_treemap.js @@ -165,6 +165,19 @@ if (globalThis["ArkPrivate"] != undefined) { dProxy.clear(); res.set("test clear:", dProxy.length == 0); + let commap = new fastmap((firstValue, secondValue) => {return firstValue > secondValue}); + commap.set("c","1"); + commap.set("a","8"); + commap.set("b","2"); + commap.set("d","4"); + if (commap.length == 4) { + commap.remove("a"); + commap.remove("b"); + commap.remove("c"); + commap.remove("d"); + } + res.set("test commpare", commap.length == 0); + flag = false; try { proxy["aa"] = 3; diff --git a/test/moduletest/container/container_treeset.js b/test/moduletest/container/container_treeset.js index d38e7441d9..ccb457292f 100644 --- a/test/moduletest/container/container_treeset.js +++ b/test/moduletest/container/container_treeset.js @@ -93,6 +93,19 @@ if (globalThis["ArkPrivate"] != undefined) { } map.set("test set throw error", flag); + let comset = new fastset((firstValue, secondValue) => {return firstValue < secondValue}); + comset.add("c"); + comset.add("a"); + comset.add("b"); + comset.add("d"); + if (comset.length == 4) { + comset.remove("a"); + comset.remove("b"); + comset.remove("c"); + comset.remove("d"); + } + map.set("test commpare", comset.length == 0); + let set1 = new fastset(); let proxy = new Proxy(set1, {}); proxy.add("aa"); -- Gitee From b81e62c491a9b24e6d63aa0dbc56d19a9e2e7d5f Mon Sep 17 00:00:00 2001 From: coollixin Date: Tue, 30 Jan 2024 15:21:34 +0800 Subject: [PATCH 6/6] hashset next modify issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8ZXBB Signed-off-by: coollixin --- .../tests/containers_hashset_test.cpp | 1 - ecmascript/js_api/js_api_hashset_iterator.cpp | 2 +- .../js_api/js_api_lightweightset_iterator.cpp | 5 +---- test/moduletest/container/container_hashset.js | 16 ++++++++++++++++ .../container/container_lightweightset.js | 17 +++++++++++++++++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/ecmascript/containers/tests/containers_hashset_test.cpp b/ecmascript/containers/tests/containers_hashset_test.cpp index c8bc55a2a2..7a2b7f27cd 100644 --- a/ecmascript/containers/tests/containers_hashset_test.cpp +++ b/ecmascript/containers/tests/containers_hashset_test.cpp @@ -403,7 +403,6 @@ HWTEST_F_L0(ContainersHashSetTest, KeysAndValuesAndEntries) result2.Update(JSAPIHashSetIterator::Next(callInfo6)); TestHelper::TearDownFrame(thread, prev4); entries.Update(JSIterator::IteratorValue(thread, result2).GetTaggedValue()); - EXPECT_EQ(JSTaggedValue(i), JSObject::GetProperty(thread, entries, first).GetValue().GetTaggedValue()); JSHandle iterValue = JSObject::GetProperty(thread, entries, second).GetValue(); JSTaggedValue valueFlag = tSet->Has(thread, iterValue.GetTaggedValue()); EXPECT_EQ(JSTaggedValue::True(), valueFlag); diff --git a/ecmascript/js_api/js_api_hashset_iterator.cpp b/ecmascript/js_api/js_api_hashset_iterator.cpp index 3e5d261ef3..46f73d44a6 100644 --- a/ecmascript/js_api/js_api_hashset_iterator.cpp +++ b/ecmascript/js_api/js_api_hashset_iterator.cpp @@ -65,7 +65,7 @@ JSTaggedValue JSAPIHashSetIterator::Next(EcmaRuntimeCallInfo *argv) } ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle array = factory->NewTaggedArray(2); // 2 means the length of array - array->Set(thread, 0, JSTaggedValue(--index)); + array->Set(thread, 0, valueHandle); array->Set(thread, 1, valueHandle); JSHandle keyAndValue(JSArray::CreateArrayFromList(thread, array)); return JSIterator::CreateIterResultObject(thread, keyAndValue, false).GetTaggedValue(); diff --git a/ecmascript/js_api/js_api_lightweightset_iterator.cpp b/ecmascript/js_api/js_api_lightweightset_iterator.cpp index 133390f45b..0e589a3396 100644 --- a/ecmascript/js_api/js_api_lightweightset_iterator.cpp +++ b/ecmascript/js_api/js_api_lightweightset_iterator.cpp @@ -65,12 +65,9 @@ JSTaggedValue JSAPILightWeightSetIterator::Next(EcmaRuntimeCallInfo *argv) if (itemKind == IterationKind::VALUE) { return JSIterator::CreateIterResultObject(thread, value, false).GetTaggedValue(); } - TaggedArray *hashArray = - TaggedArray::Cast(JSHandle(lightWeightSet)->GetHashes().GetTaggedObject()); - JSHandle keyHandle(thread, hashArray->Get(index)); ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); JSHandle array = factory->NewTaggedArray(2); // 2 means the length of array - array->Set(thread, 0, keyHandle); + array->Set(thread, 0, value); array->Set(thread, 1, value); JSHandle keyAndValue(JSArray::CreateArrayFromList(thread, array)); return JSIterator::CreateIterResultObject(thread, keyAndValue, false).GetTaggedValue(); diff --git a/test/moduletest/container/container_hashset.js b/test/moduletest/container/container_hashset.js index 152aba9dba..50b8e6ff51 100644 --- a/test/moduletest/container/container_hashset.js +++ b/test/moduletest/container/container_hashset.js @@ -130,6 +130,22 @@ if (globalThis["ArkPrivate"] != undefined) { proxy.clear(); map.set("test clear:", proxy.length == 0 && !proxy.has("cc") && proxy.isEmpty()); + flag = false; + let seten = new fastset(); + seten.add(1); + seten.add(2); + seten.add(3); + seten.add(4); + seten.add(5); + let iter = seten.entries(); + let temp = iter.next(); + while(!temp.done) { + if ((temp.value[0]) == (temp.value[1])) { + flag = true; + } + temp = iter.next(); + } + map.set("test entries return type", flag); flag = false; try { proxy["aa"] = 3; diff --git a/test/moduletest/container/container_lightweightset.js b/test/moduletest/container/container_lightweightset.js index bb82472bd3..2541fc0d2e 100644 --- a/test/moduletest/container/container_lightweightset.js +++ b/test/moduletest/container/container_lightweightset.js @@ -111,6 +111,23 @@ if (globalThis["ArkPrivate"] != undefined) { let b = myTest.toArray(); res.set("test COW - check b.length :", b.length == (LOOP_COUNT + 1)); + flag = false; + let seten = new fastset(); + seten.add(1); + seten.add(2); + seten.add(3); + seten.add(4); + seten.add(5); + let iter = seten.entries(); + let temp = iter.next(); + while(!temp.done) { + if ((temp.value[0]) == (temp.value[1])) { + flag = true; + } + temp = iter.next(); + } + res.set("test entries return type", flag); + flag = false; try { proxy["aa"] = 3; -- Gitee