From 64602e70271750c5420d53f2189bf1286ce13fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 23 Mar 2023 14:10:17 +0100 Subject: refactor(core): move setting up snapshot context to JsRuntime::snapshot (#18383) --- core/runtime.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core') 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 = { -- cgit v1.2.3