From 574d9c98d8c8baf206060158b1e0c9125f6127fb Mon Sep 17 00:00:00 2001 From: Evgeniy Nikeytsev Date: Thu, 22 Dec 2022 13:46:22 +0300 Subject: [PATCH] Add test to check prewrite barrier work in case of object's propery type change during GC Signed-off-by: Evgeniy Nikeytsev --- tests/runtime/common/gc/CMakeLists.txt | 1 + ...object_header_check_in_prewrite_barrier.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/runtime/common/gc/object_header_check_in_prewrite_barrier.js diff --git a/tests/runtime/common/gc/CMakeLists.txt b/tests/runtime/common/gc/CMakeLists.txt index f8b6bb254..1233ac13f 100644 --- a/tests/runtime/common/gc/CMakeLists.txt +++ b/tests/runtime/common/gc/CMakeLists.txt @@ -58,3 +58,4 @@ panda_add_ecma_gc_test(FILE spaceTypeTest.js OPTIONS "--compiler-enable-jit=fals panda_add_ecma_gc_test(FILE concurrent.js OPTIONS "--compiler-enable-jit=false" "--gc-type=g1-gc" "--gc-trigger-type=debug-never") panda_add_ecma_gc_test(FILE hclass_changing_during_concurrent.js OPTIONS "--compiler-enable-jit=false" "--gc-type=g1-gc" "--gc-trigger-type=debug-never" "--heap-verifier=fail_on_verification:post") panda_add_ecma_gc_test(FILE pinObject.js OPTIONS "--compiler-enable-jit=false" "--gc-type=g1-gc" "--gc-trigger-type=debug-never") +panda_add_ecma_gc_test(FILE object_header_check_in_prewrite_barrier.js OPTIONS "--compiler-enable-jit=false" "--gc-type=g1-gc" "--gc-trigger-type=debug-never") diff --git a/tests/runtime/common/gc/object_header_check_in_prewrite_barrier.js b/tests/runtime/common/gc/object_header_check_in_prewrite_barrier.js new file mode 100644 index 000000000..0bf57e5d8 --- /dev/null +++ b/tests/runtime/common/gc/object_header_check_in_prewrite_barrier.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Test object's property change from primitive type to object ref + * during GC in order to check pre-write barrier behavior in this case + */ + +let holder = new Object(); +let obj2 = new Array(5).fill('aabbcc'); +holder.prop = 42; +let gc = startGC("threshold", function(marker) { + holder.prop = obj2; +}); +waitForFinishGC(gc); -- Gitee