From a9843a605ec5214f9838425baff76138dacd17c5 Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Tue, 16 Sep 2025 20:09:47 +0000 Subject: [PATCH 1/5] Set flags via the v8 API, instead of directly modifying them Signed-off-by: Rachel Green --- src/v8/v8.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 9e184f29..17760ad6 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -26,11 +26,11 @@ #include #include -#include "include/proxy-wasm/limits.h" - #include "include/v8-version.h" #include "include/v8.h" -#include "src/flags/flags.h" +#include "third_party/absl/strings/str_format.h" +#include "third_party/proxy_wasm_cpp_host/include/proxy-wasm/limits.h" +#include "third_party/v8/include/v8-initialization.h" #include "src/wasm/c-api.h" #include "wasm-api/wasm.hh" @@ -42,10 +42,12 @@ 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; + std::string args = + absl::StrFormat("--wasm_max_mem_pages=%u", 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(); }); From fbec45d9f457b77e6229df040ed9a2bb3444243d Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Tue, 16 Sep 2025 21:31:15 +0000 Subject: [PATCH 2/5] Continue using the liftoff disable flag, but this time via the v8 API Signed-off-by: Rachel Green --- src/v8/v8.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 17760ad6..6c684253 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -42,9 +42,9 @@ wasm::Engine *engine() { static wasm::own engine; std::call_once(init, []() { - std::string args = - absl::StrFormat("--wasm_max_mem_pages=%u", PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES / - PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES); + 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); From 965ccd72fd78f4ed80e750ea30bd683652d74428 Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Tue, 16 Sep 2025 22:05:07 +0000 Subject: [PATCH 3/5] Fixed the includes statements. Signed-off-by: Rachel Green --- src/v8/v8.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 6c684253..e3ebf095 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -28,9 +28,9 @@ #include "include/v8-version.h" #include "include/v8.h" -#include "third_party/absl/strings/str_format.h" -#include "third_party/proxy_wasm_cpp_host/include/proxy-wasm/limits.h" -#include "third_party/v8/include/v8-initialization.h" +#include "absl/strings/str_format.h" +#include "include/proxy-wasm/limits.h" +#include "include/v8-initialization.h" #include "src/wasm/c-api.h" #include "wasm-api/wasm.hh" From d1c7aa28a979046a35b1a97319d6f97eaf87afd2 Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Wed, 17 Sep 2025 14:24:53 +0000 Subject: [PATCH 4/5] Fixed includes ordering. Signed-off-by: Rachel Green --- src/v8/v8.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/v8/v8.cc b/src/v8/v8.cc index e3ebf095..4a506436 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -26,11 +26,12 @@ #include #include -#include "include/v8-version.h" -#include "include/v8.h" -#include "absl/strings/str_format.h" #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/wasm/c-api.h" #include "wasm-api/wasm.hh" From e061828036b69a010e22a9a970058cf6b5acdf44 Mon Sep 17 00:00:00 2001 From: Rachel Green Date: Wed, 17 Sep 2025 21:00:09 +0000 Subject: [PATCH 5/5] Added a comment explaining why we are disabling liftoff. Signed-off-by: Rachel Green --- src/v8/v8.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/v8/v8.cc b/src/v8/v8.cc index 4a506436..932a6004 100644 --- a/src/v8/v8.cc +++ b/src/v8/v8.cc @@ -43,6 +43,7 @@ wasm::Engine *engine() { static wasm::own engine; std::call_once(init, []() { + // 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);