1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

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

Fixes https://github.com/denoland/deno/issues/18120
https://github.com/denoland/deno/issues/18137
https://github.com/denoland/fresh/issues/1073

This reverts commit 0cce9c2bcc.
This commit is contained in:
Ryan Dahl 2023-03-13 08:58:17 -04:00 committed by GitHub
parent e712fbfe4a
commit 224cff7a2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 33 deletions

View file

@ -301,7 +301,6 @@ pub async fn run(
shared_array_buffer_store: None, shared_array_buffer_store: None,
compiled_wasm_module_store: None, compiled_wasm_module_store: None,
stdio: Default::default(), stdio: Default::default(),
leak_isolate: true,
}; };
let mut worker = MainWorker::bootstrap_from_options( let mut worker = MainWorker::bootstrap_from_options(
main_module.clone(), main_module.clone(),

View file

@ -548,7 +548,6 @@ async fn create_main_worker_internal(
shared_array_buffer_store: Some(ps.shared_array_buffer_store.clone()), shared_array_buffer_store: Some(ps.shared_array_buffer_store.clone()),
compiled_wasm_module_store: Some(ps.compiled_wasm_module_store.clone()), compiled_wasm_module_store: Some(ps.compiled_wasm_module_store.clone()),
stdio, stdio,
leak_isolate: !bench_or_test && ps.options.coverage_dir().is_none(),
}; };
let mut worker = MainWorker::bootstrap_from_options( let mut worker = MainWorker::bootstrap_from_options(
@ -778,7 +777,6 @@ mod tests {
shared_array_buffer_store: None, shared_array_buffer_store: None,
compiled_wasm_module_store: None, compiled_wasm_module_store: None,
stdio: Default::default(), stdio: Default::default(),
leak_isolate: false,
}; };
MainWorker::bootstrap_from_options(main_module, permissions, options) MainWorker::bootstrap_from_options(main_module, permissions, options)

View file

@ -76,10 +76,6 @@ impl GothamState {
pub fn take<T: 'static>(&mut self) -> T { pub fn take<T: 'static>(&mut self) -> T {
self.try_take().unwrap_or_else(|| missing::<T>()) self.try_take().unwrap_or_else(|| missing::<T>())
} }
pub fn clear(&mut self) {
self.data.clear();
}
} }
fn missing<T: 'static>() -> ! { fn missing<T: 'static>() -> ! {

View file

@ -179,10 +179,6 @@ impl OpState {
tracker: OpsTracker::new(ops_count), tracker: OpsTracker::new(ops_count),
} }
} }
pub fn clear_state(&mut self) {
self.gotham_state.clear();
}
} }
impl Deref for OpState { impl Deref for OpState {

View file

@ -92,9 +92,6 @@ pub struct JsRuntime {
event_loop_middlewares: Vec<Box<OpEventLoopFn>>, event_loop_middlewares: Vec<Box<OpEventLoopFn>>,
// Marks if this is considered the top-level runtime. Used only be inspector. // Marks if this is considered the top-level runtime. Used only be inspector.
is_main: bool, is_main: bool,
// Marks if it's OK to leak the current isolate. Use only by the
// CLI main worker.
leak_isolate: bool,
} }
pub(crate) struct DynImportModEvaluate { pub(crate) struct DynImportModEvaluate {
@ -299,10 +296,6 @@ pub struct RuntimeOptions {
/// Describe if this is the main runtime instance, used by debuggers in some /// Describe if this is the main runtime instance, used by debuggers in some
/// situation - like disconnecting when program finishes running. /// situation - like disconnecting when program finishes running.
pub is_main: bool, pub is_main: bool,
/// Whether it is OK to leak the V8 isolate. Only to be used by CLI
/// top-level runtime.
pub leak_isolate: bool,
} }
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
@ -336,16 +329,6 @@ impl Drop for JsRuntime {
if let Some(v8_isolate) = self.v8_isolate.as_mut() { if let Some(v8_isolate) = self.v8_isolate.as_mut() {
Self::drop_state_and_module_map(v8_isolate); Self::drop_state_and_module_map(v8_isolate);
} }
if self.leak_isolate {
if let Some(v8_isolate) = self.v8_isolate.take() {
// Clear the GothamState. This allows final env cleanup hooks to run.
// Note: that OpState is cloned for every OpCtx, so we can't just drop
// one reference to it.
let rc_state = self.op_state();
rc_state.borrow_mut().clear_state();
std::mem::forget(v8_isolate);
}
}
} }
} }
@ -683,7 +666,6 @@ impl JsRuntime {
state: state_rc, state: state_rc,
module_map: Some(module_map_rc), module_map: Some(module_map_rc),
is_main: options.is_main, is_main: options.is_main,
leak_isolate: options.leak_isolate,
}; };
// Init resources and ops before extensions to make sure they are // Init resources and ops before extensions to make sure they are

View file

@ -65,7 +65,6 @@ async fn main() -> Result<(), AnyError> {
shared_array_buffer_store: None, shared_array_buffer_store: None,
compiled_wasm_module_store: None, compiled_wasm_module_store: None,
stdio: Default::default(), stdio: Default::default(),
leak_isolate: true,
}; };
let js_path = let js_path =

View file

@ -131,7 +131,6 @@ pub struct WorkerOptions {
/// `WebAssembly.Module` objects cannot be serialized. /// `WebAssembly.Module` objects cannot be serialized.
pub compiled_wasm_module_store: Option<CompiledWasmModuleStore>, pub compiled_wasm_module_store: Option<CompiledWasmModuleStore>,
pub stdio: Stdio, pub stdio: Stdio,
pub leak_isolate: bool,
} }
impl Default for WorkerOptions { impl Default for WorkerOptions {
@ -167,7 +166,6 @@ impl Default for WorkerOptions {
startup_snapshot: Default::default(), startup_snapshot: Default::default(),
bootstrap: Default::default(), bootstrap: Default::default(),
stdio: Default::default(), stdio: Default::default(),
leak_isolate: false,
} }
} }
} }
@ -290,7 +288,6 @@ impl MainWorker {
extensions, extensions,
inspector: options.maybe_inspector_server.is_some(), inspector: options.maybe_inspector_server.is_some(),
is_main: true, is_main: true,
leak_isolate: options.leak_isolate,
..Default::default() ..Default::default()
}); });