diff --git a/es2panda/BUILD.gn b/es2panda/BUILD.gn index 8bb89f39ee73860e825fc81bb4d63aeaca0ecf58..38776e09e483ccf8bf88d808e338188343a661fb 100644 --- a/es2panda/BUILD.gn +++ b/es2panda/BUILD.gn @@ -539,6 +539,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); }