Skip to content

Commit 63dff57

Browse files
authored
Add v8 crate + initialize v8 (#2939)
1 parent 742303c commit 63dff57

File tree

4 files changed

+142
-5
lines changed

4 files changed

+142
-5
lines changed

Cargo.lock

Lines changed: 131 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ unicode-normalization = "0.1.23"
285285
url = "2.3.1"
286286
urlencoding = "2.1.2"
287287
uuid = { version = "1.2.1", features = ["v4"] }
288+
v8 = "137.2"
288289
walkdir = "2.2.5"
289290
wasmbin = "0.6"
290291
webbrowser = "1.0.2"

crates/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ tracing.workspace = true
112112
url.workspace = true
113113
urlencoding.workspace = true
114114
uuid.workspace = true
115+
v8.workspace = true
115116
wasmtime.workspace = true
116117
jwks.workspace = true
117118
async_cache = "0.3.1"

crates/core/src/host/v8/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,22 @@ impl ModuleRuntime for V8Runtime {
2424
}
2525
}
2626

27-
static V8_RUNTIME_GLOBAL: LazyLock<V8RuntimeInner> = LazyLock::new(V8RuntimeInner::new);
27+
static V8_RUNTIME_GLOBAL: LazyLock<V8RuntimeInner> = LazyLock::new(V8RuntimeInner::init);
2828

2929
/// The actual V8 runtime, with initialization of V8.
3030
struct V8RuntimeInner {
3131
_priv: (),
3232
}
3333

3434
impl V8RuntimeInner {
35-
#[allow(clippy::new_without_default)]
36-
const fn new() -> Self {
37-
// TODO: actually setup V8.
35+
fn init() -> Self {
36+
// Our current configuration:
37+
// - will pick a number of worker threads for background jobs based on the num CPUs.
38+
// - does not allow idle tasks
39+
let platform = v8::new_default_platform(0, false).make_shared();
40+
// Initialize V8. Internally, this uses a global lock so it's safe that we don't.
41+
v8::V8::initialize_platform(platform);
42+
v8::V8::initialize();
3843

3944
Self { _priv: () }
4045
}

0 commit comments

Comments
 (0)