diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-23 14:10:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-23 18:40:17 +0530 |
commit | 64602e70271750c5420d53f2189bf1286ce13fba (patch) | |
tree | 6563bfcd09eaaa1c7dab35a3a587c4d76fce0574 /core/runtime.rs | |
parent | 2117d9c1a702f735ece3dff1e33c5e4151a4b534 (diff) |
refactor(core): move setting up snapshot context to JsRuntime::snapshot (#18383)
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 8e1529569..19fe44a3a 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -411,7 +411,6 @@ impl JsRuntime { } global_context = v8::Global::new(scope, context); - scope.set_default_context(context); } (isolate, snapshot_options) } else { @@ -931,6 +930,14 @@ impl JsRuntime { pub fn snapshot(mut self) -> v8::StartupData { self.state.borrow_mut().inspector.take(); + // Set the context to be snapshot's default context + { + let context = self.global_context(); + let mut scope = self.handle_scope(); + let local_context = v8::Local::new(&mut scope, context); + scope.set_default_context(local_context); + } + // Serialize the module map and store its data in the snapshot. { let snapshotted_data = { |