From a8e6c79472399db0b6cbca7e9fb22722eb583580 Mon Sep 17 00:00:00 2001 From: MothBuzzing Date: Thu, 22 Aug 2024 16:13:06 +0800 Subject: [PATCH] Fix bug of creating collection objects Modified newobjectstubbuilder:createjscollectioniterator (Changed memory attribute of variable linked in createjscollectioniterator to non-share); Added one more method to memoryattribute; Add test case (Modified aottest/setobjwithproto). Issue: IALSOA Signed-off-by: mothbuzzing --- ecmascript/compiler/mcr_gate_meta_data.h | 5 +++++ ecmascript/compiler/new_object_stub_builder.cpp | 2 +- test/aottest/setobjectwithproto/expect_output.txt | 1 + .../setobjectwithproto/setobjectwithproto.ts | 14 +++++++++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ecmascript/compiler/mcr_gate_meta_data.h b/ecmascript/compiler/mcr_gate_meta_data.h index 156ad83ef2..508199c150 100644 --- a/ecmascript/compiler/mcr_gate_meta_data.h +++ b/ecmascript/compiler/mcr_gate_meta_data.h @@ -375,6 +375,11 @@ public: return Create(NOT_ATOMIC, NEED_BARRIER); } + static MemoryAttribute UnknownBarrier() + { + return Create(NOT_ATOMIC, UNKNOWN_BARRIER); + } + static MemoryAttribute DefaultWithShareBarrier() { return Create(NOT_ATOMIC, UNKNOWN_BARRIER, SHARED); diff --git a/ecmascript/compiler/new_object_stub_builder.cpp b/ecmascript/compiler/new_object_stub_builder.cpp index 37f16629f1..3abcce4cc6 100644 --- a/ecmascript/compiler/new_object_stub_builder.cpp +++ b/ecmascript/compiler/new_object_stub_builder.cpp @@ -2075,7 +2075,7 @@ void NewObjectStubBuilder::CreateJSCollectionIterator( // SetIterated GateRef iteratorOffset = IntPtr(iterOffset); Store(VariableType::JS_POINTER(), glue_, result->ReadVariable(), iteratorOffset, linked, - MemoryAttribute::NeedBarrier()); + MemoryAttribute::UnknownBarrier()); // SetIteratorNextIndex GateRef nextIndexOffset = IntPtr(IteratorType::NEXT_INDEX_OFFSET); diff --git a/test/aottest/setobjectwithproto/expect_output.txt b/test/aottest/setobjectwithproto/expect_output.txt index 1455f704a2..bb7e145004 100644 --- a/test/aottest/setobjectwithproto/expect_output.txt +++ b/test/aottest/setobjectwithproto/expect_output.txt @@ -13,3 +13,4 @@ true false +true \ No newline at end of file diff --git a/test/aottest/setobjectwithproto/setobjectwithproto.ts b/test/aottest/setobjectwithproto/setobjectwithproto.ts index 69ece1ab1f..3fe2427f9d 100644 --- a/test/aottest/setobjectwithproto/setobjectwithproto.ts +++ b/test/aottest/setobjectwithproto/setobjectwithproto.ts @@ -20,4 +20,16 @@ var obj ={ __proto__: proto } print(obj.__proto__ == proto) -print(obj.__proto__ == proto2); \ No newline at end of file +print(obj.__proto__ == proto2); + +class C12 extends Set { +} +const v13 = new C12(); +const o59 = { + __proto__: v13, +}; +try { + o59.values(); +} catch (error) { + print(o59.__proto__ == v13); +}