diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-16 09:27:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-16 14:27:16 +0100 |
commit | b25876355888158167ebdefe50c0a88a2d33a38f (patch) | |
tree | 6eabc0b5005c39ecdf79d98f75e68a6f0f2e0a93 /core/modules.rs | |
parent | b9d9cd17c96e19e80932caaed017745e74b44f8b (diff) |
refactor(core): op initialization and snapshot creator (#18221)
This PR cleans up APIs related to snapshot creation and how ops are
initialized.
Prerequisite for #18080
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'core/modules.rs')
-rw-r--r-- | core/modules.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/core/modules.rs b/core/modules.rs index ee5f72d9d..e03f86c01 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -6,6 +6,7 @@ use crate::extensions::ExtensionFileSource; use crate::module_specifier::ModuleSpecifier; use crate::resolve_import; use crate::resolve_url; +use crate::snapshot_util::SnapshottedData; use crate::JsRuntime; use crate::OpState; use anyhow::Error; @@ -1030,7 +1031,7 @@ impl ModuleMap { pub fn serialize_for_snapshotting( &self, scope: &mut v8::HandleScope, - ) -> (v8::Global<v8::Array>, Vec<v8::Global<v8::Module>>) { + ) -> SnapshottedData { let array = v8::Array::new(scope, 3); let next_load_id = v8::Integer::new(scope, self.next_load_id); @@ -1105,16 +1106,19 @@ impl ModuleMap { let array_global = v8::Global::new(scope, array); let handles = self.handles.clone(); - (array_global, handles) + SnapshottedData { + module_map_data: array_global, + module_handles: handles, + } } - pub fn update_with_snapshot_data( + pub fn update_with_snapshotted_data( &mut self, scope: &mut v8::HandleScope, - data: v8::Global<v8::Array>, - module_handles: Vec<v8::Global<v8::Module>>, + snapshotted_data: SnapshottedData, ) { - let local_data: v8::Local<v8::Array> = v8::Local::new(scope, data); + let local_data: v8::Local<v8::Array> = + v8::Local::new(scope, snapshotted_data.module_map_data); { let next_load_id = local_data.get_index(scope, 0).unwrap(); @@ -1258,7 +1262,7 @@ impl ModuleMap { self.by_name = by_name; } - self.handles = module_handles; + self.handles = snapshotted_data.module_handles; } pub(crate) fn new( |