diff --git a/es2panda/BUILD.gn b/es2panda/BUILD.gn index be827ef5e573f047c187edc6f9fd5aed2fc67786..cf68f3245015b0c5b028338f1b9d0d094d81b50b 100644 --- a/es2panda/BUILD.gn +++ b/es2panda/BUILD.gn @@ -560,6 +560,10 @@ ohos_executable("es2panda") { ] } + if (is_build_sdk && is_ohos) { + defines = [ "OHOS_PLATFORM" ] + } + if (ark_standalone_build) { external_deps += [ "protobuf:protobuf_lite_static", diff --git a/es2panda/aot/main.cpp b/es2panda/aot/main.cpp index ae547863dc1ef07b3a5b2d5a6972e5f67c6a5c14..c84b9af5efb6f3e304aa9c5eef32a07386c33e75 100644 --- a/es2panda/aot/main.cpp +++ b/es2panda/aot/main.cpp @@ -23,6 +23,9 @@ #include #include #include +#ifdef OHOS_PLATFORM +#include +#endif namespace panda::es2panda::aot { using mem::MemConfig; @@ -353,6 +356,13 @@ int Run(int argc, const char **argv) int main(int argc, const char **argv) { +// Enable tcache for malloc, resolve the global lock competition caused by multi-threaded scenarios. +#ifdef OHOS_PLATFORM + mallopt(M_OHOS_CONFIG, M_TCACHE_PERFORMANCE_MODE); + mallopt(M_OHOS_CONFIG, M_ENABLE_OPT_TCACHE); + mallopt(M_SET_THREAD_CACHE, M_THREAD_CACHE_ENABLE); + mallopt(M_DELAYED_FREE, M_DELAYED_FREE_ENABLE); +#endif panda::es2panda::aot::MemManager mm; return panda::es2panda::aot::Run(argc, argv); }