Skip to content

Commit f3f9969

Browse files
authored
chore: Update V8 flag initialization to use V8 API (#458)
* Set flags via the v8 API, instead of directly modifying them --------- Signed-off-by: Rachel Green <rachgreen@google.com>
1 parent 3025566 commit f3f9969

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/v8/v8.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828

2929
#include "include/proxy-wasm/limits.h"
3030

31+
#include "absl/strings/str_format.h"
32+
#include "include/v8-initialization.h"
3133
#include "include/v8-version.h"
3234
#include "include/v8.h"
33-
#include "src/flags/flags.h"
3435
#include "src/wasm/c-api.h"
3536
#include "wasm-api/wasm.hh"
3637

@@ -42,10 +43,13 @@ wasm::Engine *engine() {
4243
static wasm::own<wasm::Engine> engine;
4344

4445
std::call_once(init, []() {
45-
::v8::internal::v8_flags.liftoff = false;
46-
::v8::internal::v8_flags.wasm_max_mem_pages =
47-
PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES / PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES;
46+
// Disable the Liftoff compiler to force optimized JIT up-front.
47+
std::string args = absl::StrFormat("--wasm_max_mem_pages=%u --no-liftoff",
48+
PROXY_WASM_HOST_MAX_WASM_MEMORY_SIZE_BYTES /
49+
PROXY_WASM_HOST_WASM_MEMORY_PAGE_SIZE_BYTES);
50+
::v8::V8::SetFlagsFromString(args.c_str(), args.size());
4851
::v8::V8::EnableWebAssemblyTrapHandler(true);
52+
4953
engine = wasm::Engine::make();
5054
});
5155

0 commit comments

Comments
 (0)