diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 9e184f29..932a6004 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -28,9 +28,10 @@ #include "include/proxy-wasm/limits.h" +#include "absl/strings/str_format.h" +#include "include/v8-initialization.h" #include "include/v8-version.h" #include "include/v8.h" -#include "src/flags/flags.h" #include "src/wasm/c-api.h" #include "wasm-api/wasm.hh" @@ -42,10 +43,13 @@ wasm::Engine *engine() { static wasm::own engine; std::call_once(init, []() { - ::v8::internal::v8_flags.liftoff = false; - ::v8::internal::v8_flags.wasm_max_mem_pages = - PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES / PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES; + // Disable the Liftoff compiler to force optimized JIT up-front. + std::string args = absl::StrFormat("--wasm_max_mem_pages=%u --no-liftoff", + PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES / + PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES); + ::v8::V8::SetFlagsFromString(args.c_str(), args.size()); ::v8::V8::EnableWebAssemblyTrapHandler(true); + engine = wasm::Engine::make(); });