Repository: denoland/deno_core
Pull request #601 (2024-02-24 01:07:45)

refactor: Remove SnapshotSerializer and Snapshot::JustCreated
This commit removes:
- `deno_core::SnapshotSerializer`
- `deno_core::SnapshotBulkCompressingSerializer`
- `deno_core::SnapshotFileSerializer`
- `deno_core::SnapshotInMemorySerializer`
- `deno_core::Snapshot::JustCreated`

It is caller's responsibility to process snapshot as needed.
`Snapshot::JustCreated` and `Snapshot::Boxed` are effectively
the same thing, the later is the preferred solution from now on.

This change is meant to limit complexity of deno_core in
preparation for more efficient storage of extension source
code.


Patch:
diff --git a/core/benches/snapshot/snapshot.rs b/core/benches/snapshot/snapshot.rs
index ed45b2a..e2b01cc 100644
--- a/core/benches/snapshot/snapshot.rs
+++ b/core/benches/snapshot/snapshot.rs
@@ -128,7 +128,8 @@ fn bench_load_snapshot(c: &mut Criterion) {
       startup_snapshot: None,
       ..Default::default()
     });
-    let snapshot = runtime.snapshot().leak();
+    let snapshot = runtime.snapshot();
+    let snapshot = Box::leak(snapshot);
 
     b.iter_custom(|iters| {
       let mut total = 0;
diff --git a/core/lib.rs b/core/lib.rs
index f39cf0d..e19e55d 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -181,11 +181,6 @@ pub mod snapshot {
   pub use crate::runtime::CreateSnapshotOutput;
   pub use crate::runtime::FilterFn;
   pub use crate::runtime::Snapshot;
-  pub use crate::runtime::SnapshotBulkCompressingSerializer;
-  pub use crate::runtime::SnapshotData;
-  pub use crate::runtime::SnapshotFileSerializer;
-  pub use crate::runtime::SnapshotInMemorySerializer;
-  pub use crate::runtime::SnapshotSerializer;
 }
 
 /// A helper macro that will return a call site in Rust code. Should be
diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs
index c976ad7..0001436 100644
--- a/core/runtime/jsruntime.rs
+++ b/core/runtime/jsruntime.rs
@@ -9,7 +9,6 @@ use super::op_driver::OpDriver;
 use super::setup;
 use super::snapshot;
 use super::stats::RuntimeActivityStatsFactory;
-use super::SnapshotData;
 use super::SnapshotStoreDataStore;
 use super::SnapshottedData;
 use crate::error::exception_to_err_result;
@@ -1875,7 +1874,7 @@ impl JsRuntimeForSnapshot {
   /// Takes a snapshot and consumes the runtime.
   ///
   /// `Error` can usually be downcast to `JsError`.
-  pub fn snapshot(mut self) -> SnapshotData {
+  pub fn snapshot(mut self) -> Box<[u8]> {
     // Ensure there are no live inspectors to prevent crashes.
     self.inner.prepare_for_cleanup();
 
@@ -1931,13 +1930,14 @@ impl JsRuntimeForSnapshot {
     };
     drop(realm);
 
-    let v8 = self
+    let v8_data = self
       .0
       .inner
       .prepare_for_snapshot()
       .create_blob(v8::FunctionCodeHandling::Keep)
       .unwrap();
-    SnapshotData { v8, sidecar_data }
+
+    snapshot::serialize(v8_data, sidecar_data)
   }
 }
 
diff --git a/core/runtime/mod.rs b/core/runtime/mod.rs
index 278c090..a4deb01 100644
--- a/core/runtime/mod.rs
+++ b/core/runtime/mod.rs
@@ -38,13 +38,8 @@ pub use snapshot::CreateSnapshotOptions;
 pub use snapshot::CreateSnapshotOutput;
 pub use snapshot::FilterFn;
 pub use snapshot::Snapshot;
-pub use snapshot::SnapshotBulkCompressingSerializer;
-pub use snapshot::SnapshotData;
 pub(crate) use snapshot::SnapshotDataId;
-pub use snapshot::SnapshotFileSerializer;
-pub use snapshot::SnapshotInMemorySerializer;
 pub(crate) use snapshot::SnapshotLoadDataStore;
-pub use snapshot::SnapshotSerializer;
 pub(crate) use snapshot::SnapshotStoreDataStore;
 pub(crate) use snapshot::SnapshottedData;
 
diff --git a/core/runtime/setup.rs b/core/runtime/setup.rs
index 1f0c3dc..76076bc 100644
--- a/core/runtime/setup.rs
+++ b/core/runtime/setup.rs
@@ -127,7 +127,6 @@ pub fn create_isolate(
     if let Some(snapshot) = maybe_startup_snapshot {
       params = match snapshot {
         V8StartupData::Static(data) => params.snapshot_blob(data),
-        V8StartupData::JustCreated(data) => params.snapshot_blob(data),
         V8StartupData::Boxed(data) => params.snapshot_blob(data),
       };
     }
diff --git a/core/runtime/snapshot.rs b/core/runtime/snapshot.rs
index 7799c55..3343b34 100644
--- a/core/runtime/snapshot.rs
+++ b/core/runtime/snapshot.rs
@@ -4,8 +4,6 @@ use anyhow::Error;
 use serde::Deserialize;
 use serde::Serialize;
 use std::collections::HashMap;
-use std::fmt::Debug;
-use std::io::Write;
 use std::path::Path;
 use std::path::PathBuf;
 use std::time::Instant;
@@ -26,8 +24,6 @@ const ULEN: usize = std::mem::size_of::<usize>();
 pub enum Snapshot {
   /// Embedded in static data.
   Static(&'static [u8]),
-  /// Freshly created, unserialized.
-  JustCreated(SnapshotData),
   /// Freshly created, serialized as a boxed slice.
   Boxed(Box<[u8]>),
 }
@@ -37,8 +33,6 @@ pub enum Snapshot {
 pub(crate) enum V8StartupData {
   /// Embedded in static data.
   Static(&'static [u8]),
-  /// Freshly created, unserialized.
-  JustCreated(v8::StartupData),
   /// Freshly created, serialized as a boxed slice.
   Boxed(Box<[u8]>),
 }
@@ -47,82 +41,44 @@ impl Snapshot {
   pub(crate) fn deconstruct(
     self,
   ) -> (V8StartupData, SerializableSnapshotSidecarData) {
-    if let Snapshot::JustCreated(snapshot) = self {
-      (
-        V8StartupData::JustCreated(snapshot.v8),
-        snapshot.sidecar_data,
-      )
-    } else {
-      match self {
-        Snapshot::Static(slice) => {
-          let len = usize::from_le_bytes(
-            slice[slice.len() - ULEN..].try_into().unwrap(),
-          );
-          let data = SerializableSnapshotSidecarData::from_slice(
-            &slice[len..slice.len() - ULEN],
-          );
-          (V8StartupData::Static(&slice[0..len]), data)
-        }
-        Snapshot::Boxed(slice) => {
-          let len = usize::from_le_bytes(
-            slice[slice.len() - ULEN..].try_into().unwrap(),
-          );
-          let data = SerializableSnapshotSidecarData::from_slice(
-            &slice[len..slice.len() - ULEN],
-          );
-          let mut v8 = Vec::from(slice);
-          v8.truncate(len);
-          let v8 = v8.into_boxed_slice();
-          (V8StartupData::Boxed(v8), data)
-        }
-        Snapshot::JustCreated(..) => unreachable!(),
+    match self {
+      Snapshot::Static(slice) => {
+        let len =
+          usize::from_le_bytes(slice[slice.len() - ULEN..].try_into().unwrap());
+        let data = SerializableSnapshotSidecarData::from_slice(
+          &slice[len..slice.len() - ULEN],
+        );
+        (V8StartupData::Static(&slice[0..len]), data)
+      }
+      Snapshot::Boxed(slice) => {
+        let len =
+          usize::from_le_bytes(slice[slice.len() - ULEN..].try_into().unwrap());
+        let data = SerializableSnapshotSidecarData::from_slice(
+          &slice[len..slice.len() - ULEN],
+        );
+        let mut v8 = Vec::from(slice);
+        v8.truncate(len);
+        let v8 = v8.into_boxed_slice();
+        (V8StartupData::Boxed(v8), data)
       }
     }
   }
 }
 
-/// An opaque blob of snapshot data that can be serialized to a [`SnapshotSerializer`].
-pub struct SnapshotData {
-  pub(crate) v8: v8::StartupData,
-  pub(crate) sidecar_data: SerializableSnapshotSidecarData,
-}
-
-impl SnapshotData {
-  /// Serialize this data into a [`SnapshotSerializer`].
-  pub fn serialize<T>(
-    self,
-    mut serializer: impl SnapshotSerializer<Output = T>,
-  ) -> std::io::Result<T> {
-    let sidecar_data = self.sidecar_data.into_bytes();
-    let len = ULEN + self.v8.len() + sidecar_data.len();
-    serializer.initialize(len)?;
-    let v8_size: usize = self.v8.len();
-    serializer.process_chunk(&self.v8)?;
-    serializer.process_chunk(&sidecar_data)?;
-    serializer.process_chunk(&v8_size.to_le_bytes())?;
-    serializer.finalize()
-  }
-
-  /// Create a static slice for a snapshot by leaking data.
-  pub fn leak(self) -> &'static [u8] {
-    let slice = Box::leak(
-      self
-        .serialize(SnapshotInMemorySerializer::default())
-        .unwrap(),
-    );
-    slice
-  }
+pub(crate) fn serialize(
+  v8_data: v8::StartupData,
+  sidecar_data: SerializableSnapshotSidecarData,
+) -> Box<[u8]> {
+  let v8_data_len = v8_data.len();
+  let sidecar_data = sidecar_data.into_bytes();
+  let mut data = Vec::with_capacity(v8_data_len + sidecar_data.len() + ULEN);
 
-  /// Create a boxed slice for a snapshot.
-  pub fn boxed(self) -> Box<[u8]> {
-    self
-      .serialize(SnapshotInMemorySerializer::default())
-      .unwrap()
-  }
+  // add ulen
+  data.extend_from_slice(&v8_data);
+  data.extend_from_slice(&sidecar_data);
+  data.extend_from_slice(&v8_data_len.to_le_bytes());
 
-  pub fn v8_len(&self) -> usize {
-    self.v8.len()
-  }
+  data.into_boxed_slice()
 }
 
 #[derive(Default)]
@@ -179,200 +135,28 @@ impl SnapshotStoreDataStore {
   }
 }
 
-/// Handles the serialization of the snapshot.
-pub trait SnapshotSerializer: Debug {
-  type Output;
-  fn initialize(&mut self, approximate_length: usize) -> std::io::Result<()>;
-  fn process_chunk(&mut self, chunk: &[u8]) -> std::io::Result<()>;
-  fn finalize(self) -> std::io::Result<Self::Output>;
-}
-
-mod sealed {
-  use super::SnapshotSerializer;
-  use std::any::Any;
-
-  /// Allows us to consume `self` in a boxed trait. This is required to allow
-  /// [`SnapshotSerializer`] to be boxed.
-  pub trait SnapshotSerializerSized: SnapshotSerializer + Unpin {
-    #[allow(clippy::type_complexity)]
-    fn get_finalizer(
-      &mut self,
-    ) -> fn(
-      Box<dyn SnapshotSerializerSized<Output = Self::Output> + 'static>,
-    ) -> std::io::Result<Self::Output>;
-  }
-
-  impl<T, S: SnapshotSerializer<Output = T> + Unpin + Any + 'static>
-    SnapshotSerializerSized for S
-  {
-    fn get_finalizer(
-      &mut self,
-    ) -> fn(
-      Box<dyn SnapshotSerializerSized<Output = Self::Output> + 'static>,
-    ) -> std::io::Result<Self::Output> {
-      |b| {
-        // SAFETY: We know that get_finalizer was called on a type of S through dynamic dispatch, so we can
-        // safely transmute this pointer from fat to thin and then finalize it.
-        let our_type = unsafe { Box::<S>::from_raw(Box::into_raw(b) as _) };
-        our_type.finalize()
-      }
-    }
-  }
-}
-
-impl<T> SnapshotSerializer
-  for Box<dyn sealed::SnapshotSerializerSized<Output = T> + 'static>
-{
-  type Output = T;
-  fn finalize(mut self) -> std::io::Result<Self::Output> {
-    (self.get_finalizer())(self)
-  }
-  fn initialize(&mut self, approximate_length: usize) -> std::io::Result<()> {
-    (**self).initialize(approximate_length)
-  }
-  fn process_chunk(&mut self, chunk: &[u8]) -> std::io::Result<()> {
-    (**self).process_chunk(chunk)
-  }
-}
-
-/// Serializes the snapshot to a file.
-#[derive(Debug)]
-pub struct SnapshotFileSerializer {
-  file: std::fs::File,
-}
-
-impl SnapshotFileSerializer {
-  pub fn new(file: std::fs::File) -> Self {
-    Self { file }
-  }
-}
-
-impl SnapshotSerializer for SnapshotFileSerializer {
-  type Output = std::fs::File;
-  fn initialize(&mut self, _approximate_length: usize) -> std::io::Result<()> {
-    Ok(())
-  }
-
-  fn process_chunk(&mut self, chunk: &[u8]) -> std::io::Result<()> {
-    self.file.write_all(chunk)
-  }
-
-  fn finalize(self) -> std::io::Result<Self::Output> {
-    Ok(self.file)
-  }
-}
-
-/// Serializes the snapshot to another serializer, with a bulk compression operation performed on top.
-pub struct SnapshotBulkCompressingSerializer<S: SnapshotSerializer> {
-  serializer: S,
-  compression: Box<dyn FnOnce(Vec<u8>) -> std::io::Result<Vec<u8>>>,
-  accumulator: Vec<u8>,
-}
-
-impl<S: SnapshotSerializer> Debug for SnapshotBulkCompressingSerializer<S> {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-    f.write_fmt(format_args!(
-      "SnapshotBulkCompressingSerializer {{ {:?} }}",
-      self.serializer
-    ))
-  }
-}
-
-impl<S: SnapshotSerializer> SnapshotBulkCompressingSerializer<S> {
-  /// Create a new bulk-compressing serializer with a function that accepts
-  /// the uncompressed snapshot data and returns a new [`Vec<u8>`] containing
-  /// the compressed data. The compression function may choose to compress in-place.
-  pub fn new(
-    serializer: S,
-    compression: impl FnOnce(Vec<u8>) -> std::io::Result<Vec<u8>> + 'static,
-  ) -> Self {
-    Self {
-      serializer,
-      compression: Box::new(compression),
-      accumulator: Default::default(),
-    }
-  }
-}
-
-impl<S: SnapshotSerializer> SnapshotSerializer
-  for SnapshotBulkCompressingSerializer<S>
-{
-  type Output = S::Output;
-
-  fn initialize(&mut self, approximate_length: usize) -> std::io::Result<()> {
-    // Approximate 25% compression for a snapshot
-    self.accumulator.reserve_exact(approximate_length);
-    self.serializer.initialize(approximate_length * 3 / 4)
-  }
-
-  fn process_chunk(&mut self, chunk: &[u8]) -> std::io::Result<()> {
-    self.accumulator.extend(chunk);
-    Ok(())
-  }
-
-  fn finalize(mut self) -> std::io::Result<Self::Output> {
-    let output = (self.compression)(self.accumulator)?;
-    self.serializer.process_chunk(&output)?;
-    self.serializer.finalize()
-  }
-}
-
-/// Serialize a snapshot to memory.
-#[derive(Default)]
-pub struct SnapshotInMemorySerializer {
-  memory: Vec<u8>,
-}
-
-impl Debug for SnapshotInMemorySerializer {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-    f.write_str("SnapshotInMemorySerializer")
-  }
-}
-
-impl SnapshotSerializer for SnapshotInMemorySerializer {
-  type Output = Box<[u8]>;
-
-  fn initialize(&mut self, length: usize) -> std::io::Result<()> {
-    self.memory.reserve_exact(length);
-    Ok(())
-  }
-
-  fn process_chunk(&mut self, chunk: &[u8]) -> std::io::Result<()> {
-    self.memory.extend(chunk);
-    Ok(())
-  }
-
-  fn finalize(self) -> std::io::Result<Self::Output> {
-    Ok(self.memory.into_boxed_slice())
-  }
-}
-
-pub struct CreateSnapshotOptions<T> {
+pub struct CreateSnapshotOptions {
   pub cargo_manifest_dir: &'static str,
   pub startup_snapshot: Option<Snapshot>,
   pub skip_op_registration: bool,
   pub extensions: Vec<Extension>,
-  pub serializer: Box<dyn sealed::SnapshotSerializerSized<Output = T>>,
   pub with_runtime_cb: Option<Box<WithRuntimeCb>>,
 }
 
-pub struct CreateSnapshotOutput<T> {
+pub struct CreateSnapshotOutput {
   /// Any files marked as LoadedFromFsDuringSnapshot are collected here and should be
   /// printed as 'cargo:rerun-if-changed' lines from your build script.
   pub files_loaded_during_snapshot: Vec<PathBuf>,
-  pub output: T,
+  pub output: Box<[u8]>,
 }
 
 #[must_use = "The files listed by create_snapshot should be printed as 'cargo:rerun-if-changed' lines"]
-pub fn create_snapshot<T>(
-  create_snapshot_options: CreateSnapshotOptions<T>,
+pub fn create_snapshot(
+  create_snapshot_options: CreateSnapshotOptions,
   warmup_script: Option<&'static str>,
-) -> Result<CreateSnapshotOutput<T>, Error> {
+) -> Result<CreateSnapshotOutput, Error> {
   let mut mark = Instant::now();
-  println!(
-    "Serializing snapshot to {:?}",
-    create_snapshot_options.serializer
-  );
+  println!("Creating a snapshot...",);
 
   // Get the extensions for a second pass if we want to warm up the snapshot.
   let warmup_exts = warmup_script.map(|_| {
@@ -413,7 +197,7 @@ pub fn create_snapshot<T>(
     // - Run warmup script in new context.
     // - Serialize the new context into a new snapshot blob.
     let mut js_runtime = JsRuntimeForSnapshot::new(RuntimeOptions {
-      startup_snapshot: Some(Snapshot::JustCreated(snapshot)),
+      startup_snapshot: Some(Snapshot::Boxed(snapshot)),
       extensions: warmup_exts,
       skip_op_registration: true,
       ..Default::default()
@@ -430,13 +214,11 @@ pub fn create_snapshot<T>(
 
   println!(
     "Snapshot size: {}, took {:#?}",
-    snapshot.v8_len(),
+    snapshot.len(),
     mark.elapsed(),
   );
   mark = Instant::now();
 
-  let output = snapshot.serialize(create_snapshot_options.serializer)?;
-
   println!(
     "Snapshot written, took: {:#?}",
     Instant::now().saturating_duration_since(mark),
@@ -444,7 +226,7 @@ pub fn create_snapshot<T>(
 
   Ok(CreateSnapshotOutput {
     files_loaded_during_snapshot,
-    output,
+    output: snapshot,
   })
 }
 
@@ -585,12 +367,6 @@ pub(crate) fn create_snapshot_creator(
           Some(external_refs),
         )
       }
-      V8StartupData::JustCreated(snapshot) => {
-        v8::Isolate::snapshot_creator_from_existing_snapshot(
-          snapshot,
-          Some(external_refs),
-        )
-      }
       V8StartupData::Static(snapshot) => {
         v8::Isolate::snapshot_creator_from_existing_snapshot(
           snapshot,


Test patch:
diff --git a/core/modules/tests.rs b/core/modules/tests.rs
index 9429afc..8a38491 100644
--- a/core/modules/tests.rs
+++ b/core/modules/tests.rs
@@ -1428,7 +1428,7 @@ fn dynamic_imports_snapshot() {
     runtime.snapshot()
   };
 
-  let snapshot = Snapshot::JustCreated(snapshot);
+  let snapshot = Snapshot::Boxed(snapshot);
   let mut runtime2 = JsRuntime::new(RuntimeOptions {
     startup_snapshot: Some(snapshot),
     ..Default::default()
@@ -1471,7 +1471,7 @@ fn import_meta_snapshot() {
     runtime.snapshot()
   };
 
-  let snapshot = Snapshot::JustCreated(snapshot);
+  let snapshot = Snapshot::Boxed(snapshot);
   let mut runtime2 = JsRuntime::new(RuntimeOptions {
     startup_snapshot: Some(snapshot),
     ..Default::default()
diff --git a/core/runtime/tests/jsrealm.rs b/core/runtime/tests/jsrealm.rs
index 7abefd2..37b094f 100644
--- a/core/runtime/tests/jsrealm.rs
+++ b/core/runtime/tests/jsrealm.rs
@@ -144,7 +144,7 @@ fn es_snapshot() {
   };
   let mut runtime = JsRuntime::new(RuntimeOptions {
     module_loader: None,
-    startup_snapshot: Some(Snapshot::JustCreated(startup_data)),
+    startup_snapshot: Some(Snapshot::Boxed(startup_data)),
     ..Default::default()
   });
 
diff --git a/core/runtime/tests/snapshot.rs b/core/runtime/tests/snapshot.rs
index ef3a56f..033d64d 100644
--- a/core/runtime/tests/snapshot.rs
+++ b/core/runtime/tests/snapshot.rs
@@ -11,7 +11,6 @@ use std::rc::Rc;
 
 use self::runtime::create_snapshot;
 use self::runtime::CreateSnapshotOptions;
-use self::runtime::SnapshotInMemorySerializer;
 
 #[test]
 fn will_snapshot() {
@@ -21,7 +20,7 @@ fn will_snapshot() {
     runtime.snapshot()
   };
 
-  let snapshot = Snapshot::JustCreated(snapshot);
+  let snapshot = Snapshot::Boxed(snapshot);
   let mut runtime2 = JsRuntime::new(RuntimeOptions {
     startup_snapshot: Some(snapshot),
     ..Default::default()
@@ -41,7 +40,7 @@ fn will_snapshot2() {
     runtime.snapshot()
   };
 
-  let snapshot = Snapshot::JustCreated(startup_data);
+  let snapshot = Snapshot::Boxed(startup_data);
   let mut runtime = JsRuntimeForSnapshot::new(RuntimeOptions {
     startup_snapshot: Some(snapshot),
     ..Default::default()
@@ -55,7 +54,7 @@ fn will_snapshot2() {
     runtime.snapshot()
   };
 
-  let snapshot = Snapshot::JustCreated(startup_data);
+  let snapshot = Snapshot::Boxed(startup_data);
   {
     let mut runtime = JsRuntime::new(RuntimeOptions {
       startup_snapshot: Some(snapshot),
@@ -94,7 +93,7 @@ fn test_snapshot_callbacks() {
     runtime.snapshot()
   };
 
-  let snapshot = Snapshot::JustCreated(snapshot);
+  let snapshot = Snapshot::Boxed(snapshot);
   let mut runtime2 = JsRuntime::new(RuntimeOptions {
     startup_snapshot: Some(snapshot),
     ..Default::default()
@@ -109,7 +108,7 @@ fn test_from_snapshot_boxed() {
   let snapshot = {
     let mut runtime = JsRuntimeForSnapshot::new(Default::default());
     runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
-    runtime.snapshot().boxed()
+    runtime.snapshot()
   };
 
   let snapshot = Snapshot::Boxed(snapshot);
@@ -127,7 +126,8 @@ fn test_from_snapshot_static() {
   let snapshot = {
     let mut runtime = JsRuntimeForSnapshot::new(Default::default());
     runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
-    runtime.snapshot().leak()
+    let data = runtime.snapshot();
+    Box::leak(data)
   };
 
   let snapshot = Snapshot::Static(snapshot);
@@ -152,7 +152,6 @@ fn test_snapshot_creator() {
       with_runtime_cb: Some(Box::new(|runtime| {
         runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
       })),
-      serializer: Box::<SnapshotInMemorySerializer>::default(),
     },
     None,
   )
@@ -185,7 +184,6 @@ fn test_snapshot_creator_warmup() {
 
         runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
       })),
-      serializer: Box::<SnapshotInMemorySerializer>::default(),
     },
     Some("const b = 'Hello'"),
   )
@@ -297,7 +295,7 @@ fn es_snapshot() {
   let snapshot = runtime.snapshot();
 
   let mut runtime2 = JsRuntimeForSnapshot::new(RuntimeOptions {
-    startup_snapshot: Some(Snapshot::JustCreated(snapshot)),
+    startup_snapshot: Some(Snapshot::Boxed(snapshot)),
     extensions: vec![Extension {
       name: "test_ext",
       ops: Cow::Borrowed(&[op_test::DECL]),
@@ -316,7 +314,7 @@ fn es_snapshot() {
   let snapshot2 = runtime2.snapshot();
 
   let mut runtime3 = JsRuntime::new(RuntimeOptions {
-    startup_snapshot: Some(Snapshot::JustCreated(snapshot2)),
+    startup_snapshot: Some(Snapshot::Boxed(snapshot2)),
     extensions: vec![Extension {
       name: "test_ext",
       ops: Cow::Borrowed(&[op_test::DECL]),
@@ -362,7 +360,7 @@ pub(crate) fn es_snapshot_without_runtime_module_loader() {
 
   let mut runtime = JsRuntime::new(RuntimeOptions {
     module_loader: None,
-    startup_snapshot: Some(Snapshot::JustCreated(startup_data)),
+    startup_snapshot: Some(Snapshot::Boxed(startup_data)),
     ..Default::default()
   });
   let realm = runtime.main_realm();
diff --git a/testing/checkin/runner/mod.rs b/testing/checkin/runner/mod.rs
index c8ebe21..e2da2bc 100644
--- a/testing/checkin/runner/mod.rs
+++ b/testing/checkin/runner/mod.rs
@@ -107,7 +107,7 @@ fn create_runtime(
     ..Default::default()
   });
 
-  let snapshot = runtime_for_snapshot.snapshot().boxed();
+  let snapshot = runtime_for_snapshot.snapshot();
 
   let extensions = vec![checkin_runtime::init_ops()];
   let mut runtime = JsRuntime::new(RuntimeOptions {