From 5d2bed4b940e8b235575c044a125e9343e70f4aa Mon Sep 17 00:00:00 2001 From: Sannikov Roman Date: Thu, 14 Jul 2022 09:10:33 +0300 Subject: [PATCH] Add new explicit-concurrent-gc-enabled option Signed-off-by: Sannikov Roman --- runtime/napi/include/jsnapi.h | 11 +++++++++++ runtime/napi/jsnapi.cpp | 1 + tests/runtime/common/test_helper.h | 1 + tests/runtime/mem/g1gc_barrier_test.cpp | 1 + tests/runtime/mem/weak_containers_test.cpp | 1 + 5 files changed, 15 insertions(+) diff --git a/runtime/napi/include/jsnapi.h b/runtime/napi/include/jsnapi.h index 8c20ba29d..165025eee 100644 --- a/runtime/napi/include/jsnapi.h +++ b/runtime/napi/include/jsnapi.h @@ -723,6 +723,11 @@ public: FATAL = 7, }; + void SetExplicitConcurrentGcEnabled(bool value) + { + is_explicit_concurrent_gc_enabled_ = value; + } + void SetGcType(GC_TYPE type) { gcType_ = type; @@ -804,6 +809,11 @@ private: return logLevel; } + bool GetExplicitConcurrentGcEnabled() const + { + return is_explicit_concurrent_gc_enabled_; + } + uint32_t GetGcPoolSize() const { return gcPoolSize_; @@ -831,6 +841,7 @@ private: GC_TYPE gcType_ = GC_TYPE::EPSILON; LOG_LEVEL logLevel_ = LOG_LEVEL::DEBUG; + bool is_explicit_concurrent_gc_enabled_ {false}; uint32_t gcPoolSize_ = DEFAULT_GC_POOL_SIZE; LOG_PRINT logBufPrint_ {nullptr}; std::string debuggerLibraryPath_ {}; diff --git a/runtime/napi/jsnapi.cpp b/runtime/napi/jsnapi.cpp index 2a1a49af1..203a8bf04 100644 --- a/runtime/napi/jsnapi.cpp +++ b/runtime/napi/jsnapi.cpp @@ -120,6 +120,7 @@ bool JSNApi::CreateRuntime(const RuntimeOption &option) runtimeOptions.SetGcType(option.GetGcType()); runtimeOptions.SetRunGcInPlace(true); runtimeOptions.SetArkProperties(option.GetArkProperties()); + runtimeOptions.SetExplicitConcurrentGcEnabled(option.GetExplicitConcurrentGcEnabled()); // Mem runtimeOptions.SetHeapSizeLimit(option.GetGcPoolSize()); runtimeOptions.SetInternalMemorySizeLimit(INTERNAL_POOL_SIZE); diff --git a/tests/runtime/common/test_helper.h b/tests/runtime/common/test_helper.h index eb039f0c7..8d865e140 100644 --- a/tests/runtime/common/test_helper.h +++ b/tests/runtime/common/test_helper.h @@ -49,6 +49,7 @@ public: options.SetShouldInitializeIntrinsics(false); options.SetLoadRuntimes({"ecmascript"}); options.SetRunGcInPlace(true); + options.SetExplicitConcurrentGcEnabled(false); static EcmaLanguageContext lcEcma; [[maybe_unused]] bool success = Runtime::Create(options, {&lcEcma}); ASSERT_TRUE(success) << "Cannot create Runtime"; diff --git a/tests/runtime/mem/g1gc_barrier_test.cpp b/tests/runtime/mem/g1gc_barrier_test.cpp index 27cb4481e..744149846 100644 --- a/tests/runtime/mem/g1gc_barrier_test.cpp +++ b/tests/runtime/mem/g1gc_barrier_test.cpp @@ -31,6 +31,7 @@ public: options.SetGcTriggerType("debug-never"); options.SetShouldLoadBootPandaFiles(false); options.SetShouldInitializeIntrinsics(false); + options.SetExplicitConcurrentGcEnabled(false); Runtime::Create(options); diff --git a/tests/runtime/mem/weak_containers_test.cpp b/tests/runtime/mem/weak_containers_test.cpp index cbc3e26e0..9ac61efcd 100644 --- a/tests/runtime/mem/weak_containers_test.cpp +++ b/tests/runtime/mem/weak_containers_test.cpp @@ -38,6 +38,7 @@ public: RuntimeOption option; option.SetGcType(RuntimeOption::GC_TYPE::G1_GC); option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR); + option.SetExplicitConcurrentGcEnabled(false); vm_ = JSNApi::CreateJSVM(option); ASSERT_TRUE(vm_ != nullptr) << "Cannot create Runtime"; thread_ = vm_->GetAssociatedJSThread(); -- Gitee