diff --git a/tests/runtime/common/gc/CMakeLists.txt b/tests/runtime/common/gc/CMakeLists.txt index f8b6bb2548e09b540d2321ff8450aa9238284863..608b999b5bb979d98b7c80d5f3666501956671ad 100644 --- a/tests/runtime/common/gc/CMakeLists.txt +++ b/tests/runtime/common/gc/CMakeLists.txt @@ -52,9 +52,10 @@ endfunction() # Use --gc-trigger-type=debug-never to control GC in the test. # In the test we don't need the runtime triggers GC during allocation. -panda_add_ecma_gc_test(FILE startGc.js OPTIONS "--compiler-enable-jit=false" "--gc-trigger-type=debug-never") -panda_add_ecma_gc_test(FILE scheduleGc.js OPTIONS "--compiler-enable-jit=false" "--gc-trigger-type=debug-never" "--gc-use-nth-alloc-trigger=true") -panda_add_ecma_gc_test(FILE spaceTypeTest.js OPTIONS "--compiler-enable-jit=false" "--gc-type=g1-gc" "--run-gc-in-place=true") -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 startGc.js OPTIONS "--gc-trigger-type=debug-never") +panda_add_ecma_gc_test(FILE scheduleGc.js OPTIONS "--gc-trigger-type=debug-never" "--gc-use-nth-alloc-trigger=true") +panda_add_ecma_gc_test(FILE spaceTypeTest.js OPTIONS "--gc-type=g1-gc" "--run-gc-in-place=true") +panda_add_ecma_gc_test(FILE concurrent.js OPTIONS "--gc-type=g1-gc" "--gc-trigger-type=debug-never") +panda_add_ecma_gc_test(FILE hclass_changing_during_concurrent.js OPTIONS "--gc-type=g1-gc" "--gc-trigger-type=debug-never" "--heap-verifier=fail_on_verification:post") +panda_add_ecma_gc_test(FILE pinObject.js OPTIONS "--gc-type=g1-gc" "--gc-trigger-type=debug-never") +panda_add_ecma_gc_test(FILE copylexenvDynTest.js OPTIONS "--gc-type=g1-gc" "--gc-trigger-type=debug-never" "--gc-use-nth-alloc-trigger=true" "--heap-verifier=fail_on_verification:pre:into:post") diff --git a/tests/runtime/common/gc/copylexenvDynTest.js b/tests/runtime/common/gc/copylexenvDynTest.js new file mode 100644 index 0000000000000000000000000000000000000000..4c57fae42dc45fd513c343031d944b1995700523 --- /dev/null +++ b/tests/runtime/common/gc/copylexenvDynTest.js @@ -0,0 +1,31 @@ +/* + * 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 verify that copylexenvDyn function is correctly works when GC occurs + * (objects are wrapped with handles) + */ + +for (let a = 0; a < 1; a++) { + scheduleGcAfterNthAlloc(1, "full"); + // To provoke copylexenvDyn call we need create and use in loop function + // that somehow uses loop variable. + // Thats because of for update loop implementation + // according to 14.7.4.2 Runtime Semantics: ForLoopEvaluating from 262 ecma spec + function aaa() { + var x = a; + } + aaa(); +} \ No newline at end of file