feat(core): prevent isolate drop for CLI main worker (#18059)

```
Benchmark 1: deno run -A ../empty.js
  Time (mean ± σ):      20.5 ms ±   0.5 ms    [User: 13.4 ms, System: 5.1 ms]
  Range (min … max):    19.8 ms …  24.0 ms    119 runs

Benchmark 2: target/release/deno run -A ../empty.js
  Time (mean ± σ):      18.8 ms ±   0.3 ms    [User: 13.0 ms, System: 4.9 ms]
  Range (min … max):    18.3 ms …  19.9 ms    129 runs
  ```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Divy Srivastava 2023-03-08 22:21:14 +05:30 committed by GitHub
parent 06a12341c6
commit 0cce9c2bcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 0 deletions

View file

@ -141,6 +141,7 @@ pub struct WorkerOptions {
/// `WebAssembly.Module` objects cannot be serialized.
pub compiled_wasm_module_store: Option<CompiledWasmModuleStore>,
pub stdio: Stdio,
pub leak_isolate: bool,
}
impl Default for WorkerOptions {
@ -177,6 +178,7 @@ impl Default for WorkerOptions {
startup_snapshot: Default::default(),
bootstrap: Default::default(),
stdio: Default::default(),
leak_isolate: false,
}
}
}
@ -304,6 +306,7 @@ impl MainWorker {
extensions_with_js: options.extensions_with_js,
inspector: options.maybe_inspector_server.is_some(),
is_main: true,
leak_isolate: options.leak_isolate,
..Default::default()
});