Repository: denoland/deno_core
Pull request #390 (2023-12-20 21:41:34)

 refactor(core): add arenas and op driver infrastructure
Building blocks for a new `OpSet`.

This commit introduces three distinct types of arenas:

1. Raw Arena: Provides basic functionality for memory allocation and deallocation within an arena structure. It manages raw memory blocks and allows recycling of allocated data.

2. Shared Atomic Arena: Offers thread-safe allocation and deallocation capabilities within the arena. It incorporates a mutex for exclusive access to the internal data, enabling multiple threads to safely allocate, share, and deallocate objects within the arena.

3. Unique Arena: Enables exclusive ownership semantics similar to a Box, maintaining the sole ownership of allocated data within the arena. It manages the cleanup of allocated data when the ArenaUnique instance is dropped, ensuring exclusive access and efficient memory management.

In addition, this updates our old JoinSet-based op system with the new arenas. Futures that resolve immediately are about 25% faster, and deferred ops are ~10% faster.

Before:

```
test bench_op_async_void                  ... bench:      79,904 ns/iter (+/- 4,763)
test bench_op_async_void_deferred         ... bench:   1,147,430 ns/iter (+/- 73,283)
test bench_op_async_void_deferred_nofast  ... bench:   1,120,793 ns/iter (+/- 40,374)
test bench_op_async_void_deferred_return  ... bench:   1,111,990 ns/iter (+/- 36,113)
test bench_op_async_void_indirect         ... bench:     139,757 ns/iter (+/- 3,190)
```

After:

```
test bench_op_async_void                  ... bench:      58,617 ns/iter (+/- 1,916)
test bench_op_async_void_deferred         ... bench:   1,049,621 ns/iter (+/- 49,606)
test bench_op_async_void_deferred_nofast  ... bench:   1,048,056 ns/iter (+/- 26,152)
test bench_op_async_void_deferred_return  ... bench:   1,027,673 ns/iter (+/- 41,257)
test bench_op_async_void_indirect         ... bench:     117,257 ns/iter (+/- 2,621)
```







Patch:
diff --git a/Cargo.lock b/Cargo.lock
index c173732..aee940c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -106,6 +106,21 @@ dependencies = [
  "scoped-tls",
 ]
 
+[[package]]
+name = "bit-set"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
+dependencies = [
+ "bit-vec",
+]
+
+[[package]]
+name = "bit-vec"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
+
 [[package]]
 name = "bitflags"
 version = "1.3.2"
@@ -258,10 +273,12 @@ dependencies = [
 
 [[package]]
 name = "deno_core"
-version = "0.238.0"
+version = "0.240.0"
 dependencies = [
  "anyhow",
  "bencher",
+ "bit-set",
+ "bit-vec",
  "bytes",
  "cooked-waker",
  "deno_ast",
@@ -271,6 +288,7 @@ dependencies = [
  "futures",
  "libc",
  "log",
+ "memoffset",
  "parking_lot",
  "pin-project",
  "pretty_assertions",
@@ -282,6 +300,7 @@ dependencies = [
  "sourcemap 7.0.1",
  "static_assertions",
  "tokio",
+ "unicycle",
  "url",
  "v8",
 ]
@@ -313,7 +332,7 @@ dependencies = [
 
 [[package]]
 name = "deno_ops"
-version = "0.114.0"
+version = "0.116.0"
 dependencies = [
  "pretty_assertions",
  "prettyplease",
@@ -345,9 +364,9 @@ dependencies = [
 
 [[package]]
 name = "deno_unsync"
-version = "0.3.0"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f8a8f3722afd50e566ecfc783cc8a3a046bc4dd5eb45007431dfb2776aeb8993"
+checksum = "2e902f81b6d372427a99b65372379568e6350735562f3237c3daf61086e1d6e6"
 dependencies = [
  "tokio",
 ]
@@ -714,6 +733,15 @@ version = "2.6.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
 
+[[package]]
+name = "memoffset"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
+dependencies = [
+ "autocfg",
+]
+
 [[package]]
 name = "miniz_oxide"
 version = "0.7.1"
@@ -1212,7 +1240,7 @@ dependencies = [
 
 [[package]]
 name = "serde_v8"
-version = "0.147.0"
+version = "0.149.0"
 dependencies = [
  "bencher",
  "bytes",
@@ -1926,6 +1954,25 @@ version = "0.1.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
 
+[[package]]
+name = "unicycle"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0edfa5ca2452d3fbf68f7078c5e7f42b96f0c0c7def017994147f8acd8c4264d"
+dependencies = [
+ "futures-core",
+ "lock_api",
+ "parking_lot",
+ "pin-project",
+ "uniset",
+]
+
+[[package]]
+name = "uniset"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c9f21fe154ca4d5d06fc2ebb8c58cc80e338eacc372ec794943f69e535c131c"
+
 [[package]]
 name = "url"
 version = "2.5.0"
diff --git a/Cargo.toml b/Cargo.toml
index 7eb311f..38b51b2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,16 +18,18 @@ repository = "https://github.com/denoland/deno_core"
 
 [workspace.dependencies]
 # Local dependencies
-deno_core = { version = "0.238.0", path = "./core" }
-deno_ops = { version = "0.114.0", path = "./ops" }
-serde_v8 = { version = "0.147.0", path = "./serde_v8" }
+deno_core = { version = "0.240.0", path = "./core" }
+deno_ops = { version = "0.116.0", path = "./ops" }
+serde_v8 = { version = "0.149.0", path = "./serde_v8" }
 
 v8 = { version = "0.82.0", default-features = false }
 deno_ast = { version = "0.31.2", features = ["transpiling"] }
-deno_unsync = "0.3.0"
+deno_unsync = "0.3.1"
 
 anyhow = "1"
 bencher = "0.1"
+bit-set = "0"
+bit-vec = "0"
 bytes = "1.4.0"
 cooked-waker = "5"
 derive_more = "0.99.17"
@@ -35,6 +37,7 @@ fastrand = "2"
 futures = "0.3.21"
 libc = "0.2.126"
 log = "0.4.17"
+memoffset = ">=0.9"
 num-bigint = { version = "0.4", features = ["rand"] }
 parking_lot = "0.12.0"
 pin-project = "1"
diff --git a/core/01_core.js b/core/01_core.js
index 6f34b6a..af6052e 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -9,6 +9,7 @@
     ArrayPrototypePush,
     Error,
     ErrorCaptureStackTrace,
+    FunctionPrototypeBind,
     MapPrototypeDelete,
     MapPrototypeGet,
     MapPrototypeHas,
@@ -18,6 +19,7 @@
     ObjectFreeze,
     ObjectFromEntries,
     ObjectKeys,
+    ObjectHasOwn,
     Promise,
     PromiseReject,
     PromiseResolve,
@@ -740,17 +742,25 @@
     setUpAsyncStub(opName);
   }
 
-  function ensureFastOps() {
+  function ensureFastOps(keep) {
     return new Proxy({}, {
       get(_target, opName) {
         if (ops[opName] === undefined) {
-          throw new Error(`Unknown or disabled op '${opName}'`);
+          ops.op_panic(`Unknown or disabled op '${opName}'`);
         }
+        let op;
         if (asyncOps[opName] !== undefined) {
-          return setUpAsyncStub(opName);
+          op = setUpAsyncStub(opName);
+          if (keep !== true) {
+            delete asyncOps[opName];
+          }
         } else {
-          return ops[opName];
+          op = ops[opName];
+          if (keep !== true) {
+            delete ops[opName];
+          }
         }
+        return op;
       },
     });
   }
@@ -766,7 +776,7 @@
     op_read_sync: readSync,
     op_write_sync: writeSync,
     op_shutdown: shutdown,
-  } = ensureFastOps();
+  } = ensureFastOps(true);
 
   const callSiteRetBuf = new Uint32Array(2);
   const callSiteRetBufU8 = new Uint8Array(callSiteRetBuf.buffer);
@@ -780,6 +790,109 @@
 
   const hostObjectBrand = SymbolFor("Deno.core.hostObject");
 
+  // A helper function that will bind our own console implementation
+  // with default implementation of Console from V8. This will cause
+  // console messages to be piped to inspector console.
+  //
+  // We are using `Deno.core.callConsole` binding to preserve proper stack
+  // frames in inspector console. This has to be done because V8 considers
+  // the last JS stack frame as gospel for the inspector. In our case we
+  // specifically want the latest user stack frame to be the one that matters
+  // though.
+  //
+  // Inspired by:
+  // https://github.com/nodejs/node/blob/1317252dfe8824fd9cfee125d2aaa94004db2f3b/lib/internal/util/inspector.js#L39-L61
+  function wrapConsole(customConsole, consoleFromV8) {
+    const callConsole = window.Deno.core.callConsole;
+
+    const keys = ObjectKeys(consoleFromV8);
+    for (let i = 0; i < keys.length; ++i) {
+      const key = keys[i];
+      if (ObjectHasOwn(customConsole, key)) {
+        customConsole[key] = FunctionPrototypeBind(
+          callConsole,
+          customConsole,
+          consoleFromV8[key],
+          customConsole[key],
+        );
+      } else {
+        // Add additional console APIs from the inspector
+        customConsole[key] = consoleFromV8[key];
+      }
+    }
+  }
+
+  // Minimal console implementation, that uses `Deno.core.print` under the hood.
+  // It's not fully fledged and is meant to make debugging slightly easier when working with
+  // only `deno_core` crate.
+  class CoreConsole {
+    #stringify = (arg) => {
+      if (
+        typeof arg === "string" || typeof arg === "boolean" ||
+        typeof arg === "number" || arg === null || arg === undefined
+      ) {
+        return arg;
+      }
+      return JSON.stringify(arg, undefined, 2);
+    };
+
+    log = (...args) => {
+      const stringifiedArgs = args.map(this.#stringify);
+      ops.op_print(`${stringifiedArgs.join(" ")}\n`, false);
+    };
+
+    debug = (...args) => {
+      const stringifiedArgs = args.map(this.#stringify);
+      ops.op_print(`${stringifiedArgs.join(" ")}\n`, false);
+    };
+
+    warn = (...args) => {
+      const stringifiedArgs = args.map(this.#stringify);
+      ops.op_print(`${stringifiedArgs.join(" ")}\n`, false);
+    };
+
+    error = (...args) => {
+      const stringifiedArgs = args.map(this.#stringify);
+      ops.op_print(`${stringifiedArgs.join(" ")}\n`, true);
+    };
+  }
+
+  const v8Console = globalThis.console;
+  const coreConsole = new CoreConsole();
+  globalThis.console = coreConsole;
+  wrapConsole(coreConsole, v8Console);
+
+  const {
+    op_is_any_array_buffer,
+    op_is_arguments_object,
+    op_is_array_buffer,
+    op_is_array_buffer_view,
+    op_is_async_function,
+    op_is_big_int_object,
+    op_is_boolean_object,
+    op_is_boxed_primitive,
+    op_is_data_view,
+    op_is_date,
+    op_is_generator_function,
+    op_is_generator_object,
+    op_is_map,
+    op_is_map_iterator,
+    op_is_module_namespace_object,
+    op_is_native_error,
+    op_is_number_object,
+    op_is_promise,
+    op_is_proxy,
+    op_is_reg_exp,
+    op_is_set,
+    op_is_set_iterator,
+    op_is_shared_array_buffer,
+    op_is_string_object,
+    op_is_symbol_object,
+    op_is_typed_array,
+    op_is_weak_map,
+    op_is_weak_set,
+  } = ensureFastOps();
+
   // Extra Deno.core.* exports
   const core = ObjectAssign(globalThis.Deno.core, {
     asyncStub,
@@ -835,7 +948,34 @@
     deserialize: (buffer, options) => ops.op_deserialize(buffer, options),
     getPromiseDetails: (promise) => ops.op_get_promise_details(promise),
     getProxyDetails: (proxy) => ops.op_get_proxy_details(proxy),
-    isProxy: (value) => ops.op_is_proxy(value),
+    isAnyArrayBuffer: (value) => op_is_any_array_buffer(value),
+    isArgumentsObject: (value) => op_is_arguments_object(value),
+    isArrayBuffer: (value) => op_is_array_buffer(value),
+    isArrayBufferView: (value) => op_is_array_buffer_view(value),
+    isAsyncFunction: (value) => op_is_async_function(value),
+    isBigIntObject: (value) => op_is_big_int_object(value),
+    isBooleanObject: (value) => op_is_boolean_object(value),
+    isBoxedPrimitive: (value) => op_is_boxed_primitive(value),
+    isDataView: (value) => op_is_data_view(value),
+    isDate: (value) => op_is_date(value),
+    isGeneratorFunction: (value) => op_is_generator_function(value),
+    isGeneratorObject: (value) => op_is_generator_object(value),
+    isMap: (value) => op_is_map(value),
+    isMapIterator: (value) => op_is_map_iterator(value),
+    isModuleNamespaceObject: (value) => op_is_module_namespace_object(value),
+    isNativeError: (value) => op_is_native_error(value),
+    isNumberObject: (value) => op_is_number_object(value),
+    isPromise: (value) => op_is_promise(value),
+    isProxy: (value) => op_is_proxy(value),
+    isRegExp: (value) => op_is_reg_exp(value),
+    isSet: (value) => op_is_set(value),
+    isSetIterator: (value) => op_is_set_iterator(value),
+    isSharedArrayBuffer: (value) => op_is_shared_array_buffer(value),
+    isStringObject: (value) => op_is_string_object(value),
+    isSymbolObject: (value) => op_is_symbol_object(value),
+    isTypedArray: (value) => op_is_typed_array(value),
+    isWeakMap: (value) => op_is_weak_map(value),
+    isWeakSet: (value) => op_is_weak_set(value),
     memoryUsage: () => ops.op_memory_usage(),
     setWasmStreamingCallback: (fn) => ops.op_set_wasm_streaming_callback(fn),
     abortWasmStreaming: (
@@ -859,6 +999,8 @@
     build,
     setBuildInfo,
     currentUserCallSite,
+    wrapConsole,
+    v8Console,
   });
 
   const internals = {};
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 03e8f94..4b3aa46 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "deno_core"
-version = "0.238.0"
+version = "0.240.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
@@ -14,20 +14,26 @@ description = "A modern JavaScript/TypeScript runtime built with V8, Rust, and T
 path = "lib.rs"
 
 [features]
-default = ["include_icu_data", "v8_use_custom_libcxx"]
+default = ["include_icu_data", "v8_use_custom_libcxx", "op_driver_joinset"]
 include_icu_data = []
 v8_use_custom_libcxx = ["v8/use_custom_libcxx"]
 include_js_files_for_snapshotting = []
 unsafe_runtime_options = []
 
+op_driver_joinset = []
+
 [dependencies]
 anyhow.workspace = true
+bit-set.workspace = true
+bit-vec.workspace = true
 bytes.workspace = true
+cooked-waker.workspace = true
 deno_ops.workspace = true
 deno_unsync.workspace = true
 futures.workspace = true
 libc.workspace = true
 log.workspace = true
+memoffset.workspace = true
 parking_lot.workspace = true
 pin-project.workspace = true
 serde.workspace = true
@@ -39,7 +45,6 @@ static_assertions.workspace = true
 tokio.workspace = true
 url.workspace = true
 v8.workspace = true
-cooked-waker.workspace = true
 
 [dev-dependencies]
 deno_ast.workspace = true
@@ -47,6 +52,7 @@ bencher.workspace = true
 pretty_assertions.workspace = true
 rstest.workspace = true
 fastrand.workspace = true
+unicycle = "0"
 
 [[bench]]
 name = "ops_sync"
@@ -59,3 +65,13 @@ name = "ops_async"
 path = "benches/ops/async.rs"
 harness = false
 required-features = ["unsafe_runtime_options"]
+
+[[bench]]
+name = "opset"
+path = "benches/ops/opset.rs"
+harness = false
+
+[[bench]]
+name = "arena"
+path = "benches/infra/arena.rs"
+harness = false
diff --git a/core/arena/mod.rs b/core/arena/mod.rs
new file mode 100644
index 0000000..6a370d4
--- /dev/null
+++ b/core/arena/mod.rs
@@ -0,0 +1,51 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+mod raw_arena;
+mod shared_arena;
+mod shared_atomic_arena;
+mod unique_arena;
+
+use std::{
+  alloc::{handle_alloc_error, Layout},
+  ptr::NonNull,
+};
+
+pub use raw_arena::*;
+pub use shared_arena::*;
+pub use shared_atomic_arena::*;
+pub use unique_arena::*;
+
+const unsafe fn ptr_byte_add<T, U>(
+  ptr: NonNull<T>,
+  offset: usize,
+) -> NonNull<U> {
+  NonNull::new_unchecked((ptr.as_ptr() as *mut u8).add(offset) as _)
+}
+
+const unsafe fn ptr_byte_sub<T, U>(
+  ptr: NonNull<T>,
+  offset: usize,
+) -> NonNull<U> {
+  NonNull::new_unchecked((ptr.as_ptr() as *mut u8).sub(offset) as _)
+}
+
+#[inline(always)]
+fn alloc_layout<T>(layout: Layout) -> NonNull<T> {
+  // Layout of size zero is UB
+  assert!(std::mem::size_of::<T>() > 0);
+  let alloc = unsafe { std::alloc::alloc(layout) } as *mut _;
+  let Some(alloc) = NonNull::new(alloc) else {
+    handle_alloc_error(layout);
+  };
+  alloc
+}
+
+#[inline(always)]
+fn alloc<T>() -> NonNull<T> {
+  // Layout of size zero is UB
+  assert!(std::mem::size_of::<T>() > 0);
+  let alloc = unsafe { std::alloc::alloc(Layout::new::<T>()) } as *mut _;
+  let Some(alloc) = NonNull::new(alloc) else {
+    handle_alloc_error(Layout::new::<T>());
+  };
+  alloc
+}
diff --git a/core/arena/raw_arena.rs b/core/arena/raw_arena.rs
new file mode 100644
index 0000000..877107f
--- /dev/null
+++ b/core/arena/raw_arena.rs
@@ -0,0 +1,487 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use std::alloc::Layout;
+use std::cell::Cell;
+use std::mem::ManuallyDrop;
+use std::ptr::NonNull;
+
+use bit_set::BitSet;
+use bit_vec::BitVec;
+
+use super::alloc;
+use super::alloc_layout;
+
+/// In debug mode we use a signature to ensure that raw pointers are pointing to the correct
+/// shape of arena object.
+#[cfg(debug_assertions)]
+const SIGNATURE: usize = 0x1234567812345678;
+
+/// A very-`unsafe`, arena for raw pointers that falls back to raw allocation when full. This
+/// should be used with great care, and ideally you should only be using the higher-level arenas
+/// built on top of this.
+///
+/// # Safety
+///
+/// Items placed into the RawArena are dropped, but there is no check to ensure that an allocated
+/// item is valid before dropping it. Use `recycle_without_drop` to return an item to the arena
+/// without dropping it.
+///
+/// # Example
+///
+/// ```rust
+/// # use deno_core::arena::RawArena;
+/// // Create a RawArena with a capacity of 10 elements
+/// let arena = RawArena::<usize>::with_capacity(10);
+///
+/// // Allocate elements in the arena
+/// unsafe {
+///   let mut elements = Vec::new();
+///   for i in 0..10 {
+///     let mut element_ptr = arena.allocate();
+///     *element_ptr.as_mut() = i * 2;
+///     elements.push(element_ptr);
+///   }
+///
+///   // Recycle elements back into the arena
+///   for &element_ptr in elements.iter() {
+///     arena.recycle(element_ptr);
+///   }
+/// }
+/// ```
+pub struct RawArena<T> {
+  #[cfg(debug_assertions)]
+  signature: usize,
+  alloc: NonNull<RawArenaEntry<T>>,
+  past_alloc_end: NonNull<RawArenaEntry<T>>,
+  max: Cell<NonNull<RawArenaEntry<T>>>,
+  next: Cell<NonNull<RawArenaEntry<T>>>,
+  allocated: Cell<usize>,
+  capacity: usize,
+}
+
+/// The [`RawArena`] is [`Send`], but not [`Sync`].
+unsafe impl<T> Send for RawArena<T> {}
+
+static_assertions::assert_impl_one!(RawArena<()>: Send);
+static_assertions::assert_not_impl_any!(RawArena<()>: Sync);
+
+union RawArenaEntry<T> {
+  /// If this is a vacant entry, points to the next entry.
+  next: NonNull<RawArenaEntry<T>>,
+  /// If this is a valid entry, contains the raw data.
+  value: ManuallyDrop<T>,
+}
+
+impl<T> RawArenaEntry<T> {
+  #[inline(always)]
+  unsafe fn next(
+    entry: NonNull<RawArenaEntry<T>>,
+  ) -> NonNull<RawArenaEntry<T>> {
+    (*(entry.as_ptr())).next
+  }
+
+  #[inline(always)]
+  unsafe fn drop(entry: NonNull<RawArenaEntry<T>>) {
+    std::ptr::drop_in_place(
+      std::ptr::addr_of_mut!((*entry.as_ptr()).value) as *mut T
+    );
+  }
+}
+
+impl<T> RawArena<T> {
+  /// Allocate an arena, completely initialized. This memory is not zeroed, and
+  /// we use the high-water mark to keep track of what we've initialized so far.
+  ///
+  /// This is safe, because dropping the [`RawArena`] without doing anything to
+  /// it is safe.
+  pub fn with_capacity(capacity: usize) -> Self {
+    let alloc = alloc_layout(Self::layout(capacity));
+    Self {
+      #[cfg(debug_assertions)]
+      signature: SIGNATURE,
+      alloc,
+      past_alloc_end: unsafe {
+        NonNull::new_unchecked(alloc.as_ptr().add(capacity))
+      },
+      max: alloc.into(),
+      next: Cell::new(alloc),
+      allocated: Default::default(),
+      capacity,
+    }
+  }
+
+  // TODO(mmastrac): const when https://github.com/rust-lang/rust/issues/67521 is fixed
+  fn layout(capacity: usize) -> Layout {
+    match Layout::array::<RawArenaEntry<T>>(capacity) {
+      Ok(l) => l,
+      _ => panic!("Zero-sized objects are not supported"),
+    }
+  }
+
+  /// Helper method to transmute internal pointers.
+  ///
+  /// # Safety
+  ///
+  /// For internal use.
+  #[inline(always)]
+  unsafe fn entry_to_data(entry: NonNull<RawArenaEntry<T>>) -> NonNull<T> {
+    // Transmute the union
+    entry.cast()
+  }
+
+  /// Helper method to transmute internal pointers.
+  ///
+  /// # Safety
+  ///
+  /// For internal use.
+  #[inline(always)]
+  unsafe fn data_to_entry(data: NonNull<T>) -> NonNull<RawArenaEntry<T>> {
+    // Transmute the union
+    data.cast()
+  }
+
+  /// Gets the next free entry, allocating if necessary. This is `O(1)` if we have free space in
+  /// the arena, `O(?)` if we need to allocate from the allocator (where `?` is defined by the
+  /// system allocator).
+  ///
+  /// # Safety
+  ///
+  /// As the memory area is considered uninitialized and you must be careful to fully and validly
+  /// initialize the underlying data, this method is marked as unsafe.
+  ///
+  /// This pointer will be invalidated when we drop the `RawArena`, so the allocator API is `unsafe`
+  /// as there are no lifetimes here.
+  ///
+  /// **IMPORTANT:** Ensure all allocated entries are fully initialized before dropping `RawArena`,
+  /// or use `recycle_without_drop` to manually handle recycling, as dropping the arena does not
+  /// perform any validation or cleanup on the allocated items. Dropping `RawArena` will automatically
+  /// trigger the drop of all items allocated within.
+  pub unsafe fn allocate(&self) -> NonNull<T> {
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(self.signature, SIGNATURE);
+    let next = self.next.get();
+    let max = self.max.get();
+
+    // Check to see if we have gone past our high-water mark, and we need to extend it. The high-water
+    // mark allows us to leave the allocation uninitialized, and assume that the remaining part of the
+    // next-free list is a trivial linked-list where each node points to the next one.
+    if max == next {
+      // Are we out of room?
+      if max == self.past_alloc_end {
+        // We filled the RawArena, so start allocating
+        return Self::entry_to_data(alloc());
+      }
+
+      // Nope, we can extend by one
+      let next = NonNull::new_unchecked(self.max.get().as_ptr().add(1));
+      self.next.set(next);
+      self.max.set(next);
+    } else {
+      // We haven't passed the high-water mark, so walk the internal next-free list
+      // for our next allocation
+      self.next.set(RawArenaEntry::next(next));
+    }
+
+    // Update accounting
+    self.allocated.set(self.allocated.get() + 1);
+    Self::entry_to_data(next)
+  }
+
+  /// Gets the next free entry, returning null if full. This is `O(1)`.
+  ///
+  /// # Safety
+  ///
+  /// As the memory area is considered uninitialized and you must be careful to fully and validly
+  /// initialize the underlying data, this method is marked as unsafe.
+  ///
+  /// This pointer will be invalidated when we drop the `RawArena`, so the allocator API is `unsafe`
+  /// as there are no lifetimes here.
+  ///
+  /// **IMPORTANT:** Ensure all allocated entries are fully initialized before dropping `RawArena`,
+  /// or use `recycle_without_drop` to manually handle recycling, as dropping the arena does not
+  /// perform any validation or cleanup on the allocated items. Dropping `RawArena` will automatically
+  /// trigger the drop of all items allocated within.
+  pub unsafe fn allocate_if_space(&self) -> Option<NonNull<T>> {
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(self.signature, SIGNATURE);
+    let next = self.next.get();
+    let max = self.max.get();
+
+    // Check to see if we have gone past our high-water mark, and we need to extend it. The high-water
+    // mark allows us to leave the allocation uninitialized, and assume that the remaining part of the
+    // next-free list is a trivial linked-list where each node points to the next one.
+    if max == next {
+      // Are we out of room?
+      if max == self.past_alloc_end {
+        // We filled the RawArena, so return None
+        return None;
+      }
+
+      // Nope, we can extend by one
+      let next = NonNull::new_unchecked(self.max.get().as_ptr().add(1));
+      self.next.set(next);
+      self.max.set(next);
+    } else {
+      // We haven't passed the high-water mark, so walk the internal next-free list
+      // for our next allocation
+      self.next.set((*(next.as_ptr())).next);
+    }
+
+    // Update accounting
+    self.allocated.set(self.allocated.get() + 1);
+    Some(Self::entry_to_data(next))
+  }
+
+  /// Returns the remaining capacity of this [`RawArena`] that can be provided without allocation.
+  pub fn remaining(&self) -> usize {
+    self.capacity - self.allocated.get()
+  }
+
+  /// Returns the remaining capacity of this [`RawArena`] that can be provided without allocation.
+  pub fn allocated(&self) -> usize {
+    self.allocated.get()
+  }
+
+  /// Clear all internally-allocated entries, resetting the arena state to its original state. Any
+  /// non-vacant entries are dropped.
+  ///
+  /// This operation must walk the vacant list and is worst-case `O(n)`, where `n` is the largest
+  /// size of this arena since the last clear operation.
+  ///
+  /// # Safety
+  ///
+  /// Does not clear system-allocator entries. Pointers previously [`allocate`](Self::allocate)d may still be in use.
+  pub unsafe fn clear_allocated(&self) {
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(self.signature, SIGNATURE);
+
+    // We need to drop the allocated pointers, but we don't know which ones they are. We only
+    // know the vacant slots.
+    if self.allocated.get() > 0 {
+      unsafe {
+        // How many entries are we possibly using?
+        let max = self.max.get();
+
+        // Compute the vacant set by walking the `next` pointers
+        let count = max.as_ptr().offset_from(self.alloc.as_ptr()) as usize;
+        let mut vacant = BitVec::with_capacity(count);
+        vacant.grow(count, false);
+
+        let mut next = self.next.get();
+        while next != max {
+          let i = next.as_ptr().offset_from(self.alloc.as_ptr()) as usize;
+          vacant.set(i, true);
+          next = RawArenaEntry::next(next);
+        }
+
+        vacant.negate();
+
+        // Iterate over the inverse of the vacant set and free those items
+        for alloc in BitSet::from_bit_vec(vacant).into_iter() {
+          let entry = self.alloc.as_ptr().add(alloc);
+          std::ptr::drop_in_place(
+            std::ptr::addr_of_mut!((*entry).value) as *mut T
+          );
+        }
+      }
+    }
+
+    self.max.set(self.alloc);
+    self.next.set(self.alloc);
+    self.allocated.set(0);
+  }
+
+  /// Recycle a used item, returning it to the next-free list. Drops the associated item
+  /// in place before recycling.
+  ///
+  /// # Safety
+  ///
+  /// We assume this pointer is either internal to the arena (in which case we return it
+  /// to the arena), or allocated via [`std::alloc::alloc`] in [`allocate`](Self::allocate).
+  pub unsafe fn recycle(&self, data: NonNull<T>) -> bool {
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(self.signature, SIGNATURE);
+    let mut entry = Self::data_to_entry(data);
+    let mut emptied = false;
+    RawArenaEntry::drop(entry);
+    if entry >= self.alloc && entry < self.past_alloc_end {
+      let next = self.next.get();
+      let count = self.allocated.get() - 1;
+      emptied = count == 0;
+      self.allocated.set(count);
+      entry.as_mut().next = next;
+      self.next.set(entry);
+    } else {
+      std::alloc::dealloc(
+        entry.as_ptr() as _,
+        Layout::new::<RawArenaEntry<T>>(),
+      );
+    }
+    emptied
+  }
+
+  /// Recycle a used item, returning it to the next-free list.
+  ///
+  /// # Safety
+  ///
+  /// We assume this pointer is either internal to the arena (in which case we return it
+  /// to the arena), or allocated via [`std::alloc::alloc`] in [`allocate`](Self::allocate).
+  pub unsafe fn recycle_without_drop(&self, data: NonNull<T>) -> bool {
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(self.signature, SIGNATURE);
+    let mut entry = Self::data_to_entry(data);
+    let mut emptied = false;
+    if entry >= self.alloc && entry < self.past_alloc_end {
+      let next = self.next.get();
+      let count = self.allocated.get() - 1;
+      emptied = count == 0;
+      self.allocated.set(count);
+      entry.as_mut().next = next;
+      self.next.set(entry);
+    } else {
+      std::alloc::dealloc(
+        entry.as_ptr() as _,
+        Layout::new::<RawArenaEntry<T>>(),
+      );
+    }
+    emptied
+  }
+}
+
+impl<T> Drop for RawArena<T> {
+  /// Drop the arena. All pointers are invalidated at this point, except for those
+  /// allocated outside outside of the arena.
+  ///
+  /// The allocation APIs are unsafe because we don't track lifetimes here.
+  fn drop(&mut self) {
+    unsafe { self.clear_allocated() };
+
+    #[cfg(debug_assertions)]
+    {
+      debug_assert_eq!(self.signature, SIGNATURE);
+      self.signature = 0;
+    }
+    unsafe {
+      std::alloc::dealloc(self.alloc.as_ptr() as _, Self::layout(self.capacity))
+    }
+  }
+}
+
+#[cfg(test)]
+mod tests {
+  use super::*;
+
+  #[must_use = "If you don't use this, it'll leak!"]
+  unsafe fn allocate(arena: &RawArena<usize>, i: usize) -> NonNull<usize> {
+    let mut new = arena.allocate();
+    *new.as_mut() = i;
+    new
+  }
+
+  #[test]
+  fn test_add_remove_many() {
+    let arena = RawArena::<usize>::with_capacity(1024);
+    unsafe {
+      for i in 0..2000 {
+        let v = allocate(&arena, i);
+        assert_eq!(arena.remaining(), 1023);
+        assert_eq!(*v.as_ref(), i);
+        arena.recycle(v);
+        assert_eq!(arena.remaining(), 1024);
+      }
+    }
+  }
+
+  #[test]
+  fn test_add_clear_many() {
+    let arena = RawArena::<usize>::with_capacity(1024);
+    unsafe {
+      for i in 0..2000 {
+        _ = allocate(&arena, i);
+        assert_eq!(arena.remaining(), 1023);
+        arena.clear_allocated();
+        assert_eq!(arena.remaining(), 1024);
+      }
+    }
+  }
+
+  #[test]
+  fn test_add_remove_many_separate() {
+    let arena = RawArena::<usize>::with_capacity(1024);
+    unsafe {
+      let mut nodes = vec![];
+      // This will spill over into memory allocations
+      for i in 0..2000 {
+        nodes.push(allocate(&arena, i));
+      }
+      assert_eq!(arena.remaining(), 0);
+      for i in (0..2000).rev() {
+        let node = nodes.pop().unwrap();
+        assert_eq!(*node.as_ref(), i);
+        arena.recycle(node);
+      }
+      assert_eq!(arena.remaining(), 1024);
+    }
+  }
+
+  #[test]
+  fn test_droppable() {
+    // Make sure we correctly drop all the items in this arena if they are droppable
+    let arena = RawArena::<_>::with_capacity(16);
+    unsafe {
+      let mut nodes = vec![];
+      // This will spill over into memory allocations
+      for i in 0..20 {
+        let node = arena.allocate();
+        std::ptr::write(
+          node.as_ptr(),
+          Box::new(std::future::ready(format!("iteration {i}"))),
+        );
+        nodes.push(node);
+      }
+      assert_eq!(arena.remaining(), 0);
+      for node in nodes {
+        arena.recycle(node);
+      }
+      assert_eq!(arena.remaining(), 16);
+    }
+  }
+
+  #[test]
+  fn test_no_drop() {
+    let arena = RawArena::<String>::with_capacity(16);
+    unsafe {
+      arena.recycle_without_drop(arena.allocate());
+      arena.clear_allocated();
+    }
+  }
+
+  #[test]
+  fn test_drops() {
+    let arena = RawArena::<_>::with_capacity(16);
+    unsafe {
+      for i in 0..2 {
+        let ptr = arena.allocate();
+        std::ptr::write(ptr.as_ptr(), format!("iteration {i}"));
+      }
+      // Leave a space in the internal allocations
+      let ptr = arena.allocate();
+      std::ptr::write(ptr.as_ptr(), "deleted".to_owned());
+      arena.recycle(ptr);
+      arena.clear_allocated();
+    }
+  }
+
+  #[test]
+  fn test_drops_full() {
+    struct Droppable(String);
+
+    let arena = RawArena::<_>::with_capacity(16);
+    unsafe {
+      for i in 0..2 {
+        let ptr = arena.allocate();
+        std::ptr::write(ptr.as_ptr(), Droppable(format!("iteration {i}")));
+      }
+      arena.clear_allocated();
+    }
+  }
+}
diff --git a/core/arena/shared_arena.rs b/core/arena/shared_arena.rs
new file mode 100644
index 0000000..9b3a978
--- /dev/null
+++ b/core/arena/shared_arena.rs
@@ -0,0 +1,465 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use std::alloc::Layout;
+use std::cell::Cell;
+use std::ptr::NonNull;
+
+use crate::arena::raw_arena::RawArena;
+
+use super::alloc;
+use super::ptr_byte_add;
+use super::ptr_byte_sub;
+
+/// In debug mode we use a signature to ensure that raw pointers are pointing to the correct
+/// shape of arena object.
+#[cfg(debug_assertions)]
+const SIGNATURE: usize = 0x1122334455667788;
+
+pub struct ArenaSharedReservation<T>(NonNull<ArenaRcData<T>>);
+
+impl<T> Drop for ArenaSharedReservation<T> {
+  fn drop(&mut self) {
+    panic!("A reservation must be completed or forgotten")
+  }
+}
+
+/// Represents an atomic reference-counted pointer into an arena-allocated object.
+pub struct ArenaRc<T> {
+  ptr: NonNull<ArenaRcData<T>>,
+}
+
+static_assertions::assert_not_impl_any!(ArenaRc<()>: Send, Sync);
+
+impl<T> ArenaRc<T> {
+  /// Offset of the `ptr` field within the `ArenaRc` struct.
+  const PTR_OFFSET: usize = memoffset::offset_of!(ArenaRc<T>, ptr);
+
+  /// Converts a raw pointer to the data into a `NonNull` pointer to `ArenaRcData`.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the input `ptr` points to the data within an `ArenaRc` object.
+  /// Improper usage may result in undefined behavior.
+  #[inline(always)]
+  unsafe fn data_from_ptr(ptr: NonNull<T>) -> NonNull<ArenaRcData<T>> {
+    ptr_byte_sub(ptr, Self::PTR_OFFSET)
+  }
+
+  /// Converts a `NonNull` pointer to `ArenaRcData` into a raw pointer to the data.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the input `ptr` is a valid `NonNull` pointer to `ArenaRcData`.
+  /// Improper usage may result in undefined behavior.
+  #[inline(always)]
+  unsafe fn ptr_from_data(ptr: NonNull<ArenaRcData<T>>) -> NonNull<T> {
+    ptr_byte_add(ptr, Self::PTR_OFFSET)
+  }
+
+  /// Consumes the `ArenaRc`, forgetting it, and returns a raw pointer to the contained data.
+  ///
+  /// # Safety
+  ///
+  /// This function returns a raw pointer without managing the memory, potentially leading to
+  /// memory leaks if the pointer is not properly handled or deallocated.
+  #[inline(always)]
+  pub fn into_raw(arc: ArenaRc<T>) -> NonNull<T> {
+    let ptr = arc.ptr;
+    std::mem::forget(arc);
+    unsafe { Self::ptr_from_data(ptr) }
+  }
+
+  /// Clones the `ArenaRc` reference, increments its reference count, and returns a raw pointer to the contained data.
+  ///
+  /// This function increments the reference count of the `ArenaRc`.
+  #[inline(always)]
+  pub fn clone_into_raw(arc: &ArenaRc<T>) -> NonNull<T> {
+    unsafe {
+      let ptr = arc.ptr;
+      ptr.as_ref().ref_count.set(ptr.as_ref().ref_count.get() + 1);
+      Self::ptr_from_data(arc.ptr)
+    }
+  }
+
+  /// Constructs an `ArenaRc` from a raw pointer to the contained data.
+  ///
+  /// This function safely constructs an `ArenaRc` from a raw pointer, assuming the pointer is
+  /// valid, properly aligned, and was originally created by `into_raw` or `clone_into_raw`.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes the provided `ptr` is a valid raw pointer to the data within an `ArenaRc`
+  /// object. Misuse may lead to undefined behavior, memory unsafety, or data corruption.
+  #[inline(always)]
+  pub unsafe fn from_raw(ptr: NonNull<T>) -> ArenaRc<T> {
+    let ptr = Self::data_from_ptr(ptr);
+
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(ptr.as_ref().signature, SIGNATURE);
+    ArenaRc { ptr }
+  }
+
+  /// Clones an `ArenaRc` reference from a raw pointer and increments its reference count.
+  ///
+  /// This method increments the reference count of the `ArenaRc` instance
+  /// associated with the provided raw pointer, allowing multiple references
+  /// to the same allocated data.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the provided `ptr` is a valid raw pointer
+  /// to the data within an `ArenaRc` object. Improper usage may lead
+  /// to memory unsafety or data corruption.
+  #[inline(always)]
+  pub unsafe fn clone_from_raw(ptr: NonNull<T>) -> ArenaRc<T> {
+    let ptr = Self::data_from_ptr(ptr);
+    ptr.as_ref().ref_count.set(ptr.as_ref().ref_count.get() + 1);
+    ArenaRc { ptr }
+  }
+
+  /// Increments the reference count associated with the raw pointer to an `ArenaRc`-managed data.
+  ///
+  /// This method manually increases the reference count of the `ArenaRc` instance
+  /// associated with the provided raw pointer. It allows incrementing the reference count
+  /// without constructing a full `ArenaRc` instance, ideal for scenarios where direct
+  /// manipulation of raw pointers is required.
+  ///
+  /// # Safety
+  ///
+  /// This method bypasses some safety checks enforced by the `ArenaRc` type. Incorrect usage
+  /// or mishandling of raw pointers might lead to memory unsafety or data corruption.
+  /// Use with caution and ensure proper handling of associated data.
+  #[inline(always)]
+  pub unsafe fn clone_raw_from_raw(ptr: NonNull<T>) {
+    let ptr = Self::data_from_ptr(ptr);
+    ptr.as_ref().ref_count.set(ptr.as_ref().ref_count.get() + 1);
+  }
+
+  /// Drops the `ArenaRc` reference pointed to by the raw pointer.
+  ///
+  /// If the reference count drops to zero, the associated data is returned to the arena.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the provided `ptr` is a valid raw pointer
+  /// to the data within an `ArenaRc` object. Improper usage may lead
+  /// to memory unsafety or data corruption.
+  #[inline(always)]
+  pub unsafe fn drop_from_raw(ptr: NonNull<T>) {
+    let ptr = Self::data_from_ptr(ptr);
+    let ref_count = ptr.as_ref().ref_count.get();
+    if ref_count == 0 {
+      let this = ptr.as_ref();
+      ArenaShared::delete(this.arena_data, ptr);
+    } else {
+      ptr.as_ref().ref_count.set(ref_count - 1);
+    }
+  }
+}
+
+impl<T> ArenaRc<T> {}
+
+impl<T> Drop for ArenaRc<T> {
+  fn drop(&mut self) {
+    unsafe {
+      let ref_count = self.ptr.as_ref().ref_count.get();
+      if ref_count == 0 {
+        let this = self.ptr.as_ref();
+        ArenaShared::delete(this.arena_data, self.ptr);
+      } else {
+        self.ptr.as_ref().ref_count.set(ref_count - 1);
+      }
+    }
+  }
+}
+
+impl<T> std::ops::Deref for ArenaRc<T> {
+  type Target = T;
+  fn deref(&self) -> &Self::Target {
+    unsafe { &self.ptr.as_ref().data }
+  }
+}
+
+impl<T> std::convert::AsRef<T> for ArenaRc<T> {
+  fn as_ref(&self) -> &T {
+    unsafe { &self.ptr.as_ref().data }
+  }
+}
+
+/// Data structure containing metadata and the actual data within the `ArenaRc`.
+struct ArenaRcData<T> {
+  #[cfg(debug_assertions)]
+  signature: usize,
+  ref_count: Cell<usize>,
+  arena_data: NonNull<ArenaSharedData<T>>,
+  data: T,
+}
+
+/// An atomic reference-counted pointer into an arena-allocated object
+/// with thread-safe allocation and deallocation capabilities.
+///
+/// This structure ensures atomic access and safe sharing of allocated
+/// data across multiple threads while maintaining reference counting
+/// to manage the memory deallocation when no longer needed.
+///
+/// It combines a thread-safe `RawArena` for allocation and deallocation
+/// and provides a mutex to guarantee exclusive access to the internal
+/// data for safe multi-threaded operation.
+///
+/// The `ArenaShared` allows multiple threads to allocate, share,
+/// and deallocate objects within the arena, ensuring safety and atomicity
+/// during these operations.
+pub struct ArenaShared<T> {
+  ptr: NonNull<ArenaSharedData<T>>,
+}
+
+static_assertions::assert_not_impl_any!(ArenaShared<()>: Send, Sync);
+
+/// Data structure containing a mutex and the `RawArena` for atomic access in the `ArenaShared`.
+struct ArenaSharedData<T> {
+  raw_arena: RawArena<ArenaRcData<T>>,
+  ref_count: usize,
+}
+
+impl<T> ArenaShared<T> {
+  pub fn with_capacity(capacity: usize) -> Self {
+    unsafe {
+      let ptr = alloc();
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaSharedData {
+          raw_arena: RawArena::with_capacity(capacity),
+          ref_count: 0,
+        },
+      );
+      Self { ptr }
+    }
+  }
+
+  #[cold]
+  #[inline(never)]
+  unsafe fn drop_data(data: NonNull<ArenaSharedData<T>>) {
+    let data = data.as_ptr();
+    std::ptr::drop_in_place(data);
+    std::alloc::dealloc(data as _, Layout::new::<ArenaSharedData<T>>());
+  }
+
+  #[inline(always)]
+  unsafe fn delete(
+    mut arena_ptr: NonNull<ArenaSharedData<T>>,
+    data: NonNull<ArenaRcData<T>>,
+  ) {
+    let arena = arena_ptr.as_mut();
+    arena.raw_arena.recycle(data as _);
+    if arena.ref_count == 0 {
+      Self::drop_data(arena_ptr);
+    } else {
+      arena.ref_count -= 1;
+    }
+  }
+
+  /// Allocates a new object in the arena and returns an `ArenaRc` pointing to it.
+  ///
+  /// This method creates a new instance of type `T` within the `RawArena`. The provided `data`
+  /// is initialized within the arena, and an `ArenaRc` is returned to manage this allocated data.
+  /// The `ArenaRc` serves as an atomic, reference-counted pointer to the allocated data within
+  /// the arena, ensuring safe concurrent access across multiple threads while maintaining the
+  /// reference count for memory management.
+  ///
+  /// The allocation process employs a mutex to ensure thread-safe access to the arena, allowing
+  /// only one thread at a time to modify the internal state, including allocating and deallocating memory.
+  ///
+  /// # Safety
+  ///
+  /// The provided `data` is allocated within the arena and managed by the `ArenaRc`. Improper handling
+  /// or misuse of the returned `ArenaRc` pointer may lead to memory leaks or memory unsafety.
+  ///
+  /// # Example
+  ///
+  /// ```rust
+  /// # use deno_core::arena::ArenaShared;
+  ///
+  /// // Define a struct that will be allocated within the arena
+  /// struct MyStruct {
+  ///     data: usize,
+  /// }
+  ///
+  /// // Create a new instance of ArenaShared with a specified base capacity
+  /// let arena: ArenaShared<MyStruct> = ArenaShared::with_capacity(16);
+  ///
+  /// // Allocate a new MyStruct instance within the arena
+  /// let data_instance = MyStruct { data: 42 };
+  /// let allocated_arc = arena.allocate(data_instance);
+  ///
+  /// // Now, allocated_arc can be used as a managed reference to the allocated data
+  /// assert_eq!(allocated_arc.data, 42); // Validate the data stored in the allocated arc
+  /// ```
+  pub fn allocate(&self, data: T) -> ArenaRc<T> {
+    let ptr = unsafe {
+      let this = self.ptr.as_ptr();
+      let ptr = (*this).raw_arena.allocate();
+      (*this).ref_count += 1;
+
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaRcData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          ref_count: Default::default(),
+          data,
+        },
+      );
+      ptr
+    };
+
+    ArenaRc { ptr }
+  }
+
+  /// Allocates a new object in the arena and returns an `ArenaRc` pointing to it. If no space
+  /// is available, returns the original object.
+  ///
+  /// This method creates a new instance of type `T` within the `RawArena`. The provided `data`
+  /// is initialized within the arena, and an `ArenaRc` is returned to manage this allocated data.
+  /// The `ArenaRc` serves as an atomic, reference-counted pointer to the allocated data within
+  /// the arena, ensuring safe concurrent access across multiple threads while maintaining the
+  /// reference count for memory management.
+  ///
+  /// The allocation process employs a mutex to ensure thread-safe access to the arena, allowing
+  /// only one thread at a time to modify the internal state, including allocating and deallocating memory.
+  pub fn allocate_if_space(&self, data: T) -> Result<ArenaRc<T>, T> {
+    let ptr = unsafe {
+      let this = &mut *self.ptr.as_ptr();
+      let Some(ptr) = this.raw_arena.allocate_if_space() else {
+        return Err(data);
+      };
+      this.ref_count += 1;
+
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaRcData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          ref_count: Default::default(),
+          data,
+        },
+      );
+      ptr
+    };
+
+    Ok(ArenaRc { ptr })
+  }
+
+  /// Attempt to reserve space in this arena.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn reserve_space(&self) -> Option<ArenaSharedReservation<T>> {
+    let this = &mut *self.ptr.as_ptr();
+    let ptr = this.raw_arena.allocate_if_space()?;
+    this.ref_count += 1;
+    Some(ArenaSharedReservation(ptr))
+  }
+
+  /// Forget a reservation.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn forget_reservation(
+    &self,
+    reservation: ArenaSharedReservation<T>,
+  ) {
+    let ptr = reservation.0;
+    std::mem::forget(reservation);
+    let this = self.ptr.as_ptr();
+    (*this).ref_count -= 1;
+    (*this).raw_arena.recycle_without_drop(ptr);
+  }
+
+  /// Complete a reservation.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn complete_reservation(
+    &self,
+    reservation: ArenaSharedReservation<T>,
+    data: T,
+  ) -> ArenaRc<T> {
+    let ptr = reservation.0;
+    std::mem::forget(reservation);
+    let ptr = {
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaRcData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          ref_count: Default::default(),
+          data,
+        },
+      );
+      ptr
+    };
+
+    ArenaRc { ptr }
+  }
+}
+
+impl<T> Drop for ArenaShared<T> {
+  fn drop(&mut self) {
+    unsafe {
+      let this = self.ptr.as_mut();
+      if this.ref_count == 0 {
+        Self::drop_data(self.ptr);
+      } else {
+        this.ref_count -= 1;
+      }
+    }
+  }
+}
+
+#[cfg(test)]
+mod tests {
+  use super::*;
+  use std::cell::RefCell;
+
+  #[test]
+  fn test_raw() {
+    let arena: ArenaShared<RefCell<usize>> = ArenaShared::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    let raw = ArenaRc::into_raw(arc);
+    _ = unsafe { ArenaRc::from_raw(raw) };
+  }
+
+  #[test]
+  fn test_clone_into_raw() {
+    let arena: ArenaShared<RefCell<usize>> = ArenaShared::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    let raw = ArenaRc::clone_into_raw(&arc);
+    _ = unsafe { ArenaRc::from_raw(raw) };
+  }
+
+  #[test]
+  fn test_allocate_drop_arc_first() {
+    let arena: ArenaShared<RefCell<usize>> = ArenaShared::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    *arc.borrow_mut() += 1;
+    drop(arc);
+    drop(arena);
+  }
+
+  #[test]
+  fn test_allocate_drop_arena_first() {
+    let arena: ArenaShared<RefCell<usize>> = ArenaShared::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    *arc.borrow_mut() += 1;
+    drop(arena);
+    drop(arc);
+  }
+}
diff --git a/core/arena/shared_atomic_arena.rs b/core/arena/shared_atomic_arena.rs
new file mode 100644
index 0000000..b21b0c5
--- /dev/null
+++ b/core/arena/shared_atomic_arena.rs
@@ -0,0 +1,544 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use std::alloc::Layout;
+use std::ptr::NonNull;
+use std::sync::atomic::AtomicUsize;
+use std::sync::atomic::Ordering;
+
+use parking_lot::lock_api::RawMutex;
+
+use crate::arena::raw_arena::RawArena;
+
+use super::alloc;
+use super::ptr_byte_add;
+use super::ptr_byte_sub;
+
+/// In debug mode we use a signature to ensure that raw pointers are pointing to the correct
+/// shape of arena object.
+#[cfg(debug_assertions)]
+const SIGNATURE: usize = 0x1133224455667788;
+
+pub struct ArenaSharedAtomicReservation<T>(NonNull<ArenaArcData<T>>);
+
+impl<T> Drop for ArenaSharedAtomicReservation<T> {
+  fn drop(&mut self) {
+    panic!("A reservation must be completed or forgotten")
+  }
+}
+
+/// Represents an atomic reference-counted pointer into an arena-allocated object.
+pub struct ArenaArc<T> {
+  ptr: NonNull<ArenaArcData<T>>,
+}
+
+impl<T> ArenaArc<T> {
+  /// Offset of the `ptr` field within the `ArenaArc` struct.
+  const PTR_OFFSET: usize = memoffset::offset_of!(ArenaArc<T>, ptr);
+
+  /// Converts a raw pointer to the data into a `NonNull` pointer to `ArenaArcData`.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the input `ptr` points to the data within an `ArenaArc` object.
+  /// Improper usage may result in undefined behavior.
+  #[inline(always)]
+  unsafe fn data_from_ptr(ptr: NonNull<T>) -> NonNull<ArenaArcData<T>> {
+    ptr_byte_sub(ptr, Self::PTR_OFFSET)
+  }
+
+  /// Converts a `NonNull` pointer to `ArenaArcData` into a raw pointer to the data.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the input `ptr` is a valid `NonNull` pointer to `ArenaArcData`.
+  /// Improper usage may result in undefined behavior.
+  #[inline(always)]
+  unsafe fn ptr_from_data(ptr: NonNull<ArenaArcData<T>>) -> NonNull<T> {
+    ptr_byte_add(ptr, Self::PTR_OFFSET)
+  }
+
+  /// Consumes the `ArenaArc`, forgetting it, and returns a raw pointer to the contained data.
+  ///
+  /// # Safety
+  ///
+  /// This function returns a raw pointer without managing the memory, potentially leading to
+  /// memory leaks if the pointer is not properly handled or deallocated.
+  #[inline(always)]
+  pub fn into_raw(arc: ArenaArc<T>) -> NonNull<T> {
+    let ptr = arc.ptr;
+    std::mem::forget(arc);
+    unsafe { Self::ptr_from_data(ptr) }
+  }
+
+  /// Clones the `ArenaArc` reference, increments its reference count, and returns a raw pointer to the contained data.
+  ///
+  /// This function increments the reference count of the `ArenaArc`.
+  #[inline(always)]
+  pub fn clone_into_raw(arc: &ArenaArc<T>) -> NonNull<T> {
+    unsafe {
+      arc.ptr.as_ref().ref_count.fetch_add(1, Ordering::Relaxed);
+      Self::ptr_from_data(arc.ptr)
+    }
+  }
+
+  /// Constructs an `ArenaArc` from a raw pointer to the contained data.
+  ///
+  /// This function safely constructs an `ArenaArc` from a raw pointer, assuming the pointer is
+  /// valid, properly aligned, and was originally created by `into_raw` or `clone_into_raw`.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes the provided `ptr` is a valid raw pointer to the data within an `ArenaArc`
+  /// object. Misuse may lead to undefined behavior, memory unsafety, or data corruption.
+  #[inline(always)]
+  pub unsafe fn from_raw(ptr: NonNull<T>) -> ArenaArc<T> {
+    let ptr = Self::data_from_ptr(ptr);
+
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(ptr.as_ref().signature, SIGNATURE);
+    ArenaArc { ptr }
+  }
+
+  /// Clones an `ArenaArc` reference from a raw pointer and increments its reference count.
+  ///
+  /// This method increments the reference count of the `ArenaArc` instance
+  /// associated with the provided raw pointer, allowing multiple references
+  /// to the same allocated data.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the provided `ptr` is a valid raw pointer
+  /// to the data within an `ArenaArc` object. Improper usage may lead
+  /// to memory unsafety or data corruption.
+  #[inline(always)]
+  pub unsafe fn clone_from_raw(ptr: NonNull<T>) -> ArenaArc<T> {
+    let ptr = Self::data_from_ptr(ptr);
+    let this = ptr.as_ref();
+    this.ref_count.fetch_add(1, Ordering::Relaxed);
+    ArenaArc { ptr }
+  }
+
+  /// Increments the reference count associated with the raw pointer to an `ArenaArc`-managed data.
+  ///
+  /// This method manually increases the reference count of the `ArenaArc` instance
+  /// associated with the provided raw pointer. It allows incrementing the reference count
+  /// without constructing a full `ArenaArc` instance, ideal for scenarios where direct
+  /// manipulation of raw pointers is required.
+  ///
+  /// # Safety
+  ///
+  /// This method bypasses some safety checks enforced by the `ArenaArc` type. Incorrect usage
+  /// or mishandling of raw pointers might lead to memory unsafety or data corruption.
+  /// Use with caution and ensure proper handling of associated data.
+  #[inline(always)]
+  pub unsafe fn clone_raw_from_raw(ptr: NonNull<T>) {
+    let this = Self::data_from_ptr(ptr).as_ref();
+    this.ref_count.fetch_add(1, Ordering::Relaxed);
+  }
+
+  /// Drops the `ArenaArc` reference pointed to by the raw pointer.
+  ///
+  /// If the reference count drops to zero, the associated data is returned to the arena.
+  ///
+  /// # Safety
+  ///
+  /// This function assumes that the provided `ptr` is a valid raw pointer
+  /// to the data within an `ArenaArc` object. Improper usage may lead
+  /// to memory unsafety or data corruption.
+  #[inline(always)]
+  pub unsafe fn drop_from_raw(ptr: NonNull<T>) {
+    let ptr = Self::data_from_ptr(ptr);
+    let this = ptr.as_ref();
+    if this.ref_count.fetch_sub(1, Ordering::Relaxed) == 0 {
+      ArenaSharedAtomic::delete(ptr);
+    }
+  }
+}
+
+unsafe impl<T: Send + Sync> Send for ArenaArc<T> {}
+unsafe impl<T: Send + Sync> Sync for ArenaArc<T> {}
+
+// T is Send + Sync, so ArenaArc is too
+static_assertions::assert_impl_all!(ArenaArc<()>: Send, Sync);
+// T is !Send & !Sync, so ArenaArc is too
+static_assertions::assert_not_impl_any!(ArenaArc<*mut ()>: Send, Sync);
+
+impl<T> ArenaArc<T> {}
+
+impl<T> Drop for ArenaArc<T> {
+  fn drop(&mut self) {
+    unsafe {
+      let this = self.ptr.as_ref();
+      if this.ref_count.fetch_sub(1, Ordering::Relaxed) == 0 {
+        ArenaSharedAtomic::delete(self.ptr);
+      }
+    }
+  }
+}
+
+impl<T> std::ops::Deref for ArenaArc<T> {
+  type Target = T;
+  #[inline(always)]
+  fn deref(&self) -> &Self::Target {
+    unsafe { &self.ptr.as_ref().data }
+  }
+}
+
+impl<T> std::convert::AsRef<T> for ArenaArc<T> {
+  #[inline(always)]
+  fn as_ref(&self) -> &T {
+    unsafe { &self.ptr.as_ref().data }
+  }
+}
+
+/// Data structure containing metadata and the actual data within the `ArenaArc`.
+struct ArenaArcData<T> {
+  #[cfg(debug_assertions)]
+  signature: usize,
+  ref_count: AtomicUsize,
+  arena_data: NonNull<ArenaSharedAtomicData<T>>,
+  data: T,
+}
+
+/// An atomic reference-counted pointer into an arena-allocated object
+/// with thread-safe allocation and deallocation capabilities.
+///
+/// This structure ensures atomic access and safe sharing of allocated
+/// data across multiple threads while maintaining reference counting
+/// to manage the memory deallocation when no longer needed.
+///
+/// It combines a thread-safe `RawArena` for allocation and deallocation
+/// and provides a mutex to guarantee exclusive access to the internal
+/// data for safe multi-threaded operation.
+///
+/// The `ArenaSharedAtomic` allows multiple threads to allocate, share,
+/// and deallocate objects within the arena, ensuring safety and atomicity
+/// during these operations.
+pub struct ArenaSharedAtomic<T> {
+  ptr: NonNull<ArenaSharedAtomicData<T>>,
+}
+
+unsafe impl<T> Send for ArenaSharedAtomic<T> {}
+
+// The arena itself may not be shared so that we can guarantee all [`RawArena`]
+// access happens on the owning thread.
+static_assertions::assert_impl_any!(ArenaSharedAtomic<()>: Send);
+static_assertions::assert_not_impl_any!(ArenaSharedAtomic<()>: Sync);
+
+/// Data structure containing a mutex and the `RawArena` for atomic access in the `ArenaSharedAtomic`.
+struct ArenaSharedAtomicData<T> {
+  /// A mutex ensuring thread-safe access to the internal raw arena and refcount.
+  mutex: parking_lot::RawMutex,
+  protected: ArenaSharedAtomicDataProtected<T>,
+}
+
+struct ArenaSharedAtomicDataProtected<T> {
+  raw_arena: RawArena<ArenaArcData<T>>,
+  ref_count: usize,
+}
+
+impl<T> ArenaSharedAtomic<T> {
+  pub fn with_capacity(capacity: usize) -> Self {
+    unsafe {
+      let ptr = alloc();
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaSharedAtomicData {
+          mutex: parking_lot::RawMutex::INIT,
+          protected: ArenaSharedAtomicDataProtected {
+            raw_arena: RawArena::with_capacity(capacity),
+            ref_count: 0,
+          },
+        },
+      );
+      Self { ptr }
+    }
+  }
+
+  #[inline(always)]
+  unsafe fn lock<'s>(
+    arena: NonNull<ArenaSharedAtomicData<T>>,
+  ) -> &'s mut ArenaSharedAtomicDataProtected<T> {
+    let mutex = &*std::ptr::addr_of!((*arena.as_ptr()).mutex);
+    while !mutex.try_lock() {
+      std::thread::yield_now();
+    }
+    &mut *std::ptr::addr_of_mut!((*arena.as_ptr()).protected)
+  }
+
+  #[inline(always)]
+  unsafe fn unlock(arena: NonNull<ArenaSharedAtomicData<T>>) {
+    let mutex = &*std::ptr::addr_of!((*arena.as_ptr()).mutex);
+    mutex.unlock()
+  }
+
+  #[cold]
+  #[inline(never)]
+  unsafe fn drop_data(arena: NonNull<ArenaSharedAtomicData<T>>) {
+    let arena = arena.as_ptr();
+    std::ptr::drop_in_place(arena);
+    std::alloc::dealloc(arena as _, Layout::new::<ArenaSharedAtomicData<T>>());
+  }
+
+  #[inline(always)]
+  unsafe fn delete(data: NonNull<ArenaArcData<T>>) {
+    let ptr = (*data.as_ptr()).arena_data;
+    // We cannot materialize a reference to arena_data until we have the lock
+    let this = Self::lock(ptr);
+    this.raw_arena.recycle(data);
+    if this.ref_count == 0 {
+      Self::drop_data(ptr);
+    } else {
+      this.ref_count -= 1;
+      Self::unlock(ptr);
+    }
+  }
+
+  /// Allocates a new object in the arena and returns an `ArenaArc` pointing to it.
+  ///
+  /// This method creates a new instance of type `T` within the `RawArena`. The provided `data`
+  /// is initialized within the arena, and an `ArenaArc` is returned to manage this allocated data.
+  /// The `ArenaArc` serves as an atomic, reference-counted pointer to the allocated data within
+  /// the arena, ensuring safe concurrent access across multiple threads while maintaining the
+  /// reference count for memory management.
+  ///
+  /// The allocation process employs a mutex to ensure thread-safe access to the arena, allowing
+  /// only one thread at a time to modify the internal state, including allocating and deallocating memory.
+  ///
+  /// # Safety
+  ///
+  /// The provided `data` is allocated within the arena and managed by the `ArenaArc`. Improper handling
+  /// or misuse of the returned `ArenaArc` pointer may lead to memory leaks or memory unsafety.
+  ///
+  /// # Example
+  ///
+  /// ```rust
+  /// # use deno_core::arena::ArenaSharedAtomic;
+  ///
+  /// // Define a struct that will be allocated within the arena
+  /// struct MyStruct {
+  ///     data: usize,
+  /// }
+  ///
+  /// // Create a new instance of ArenaSharedAtomic with a specified base capacity
+  /// let arena: ArenaSharedAtomic<MyStruct> = ArenaSharedAtomic::with_capacity(16);
+  ///
+  /// // Allocate a new MyStruct instance within the arena
+  /// let data_instance = MyStruct { data: 42 };
+  /// let allocated_arc = arena.allocate(data_instance);
+  ///
+  /// // Now, allocated_arc can be used as a managed reference to the allocated data
+  /// assert_eq!(allocated_arc.data, 42); // Validate the data stored in the allocated arc
+  /// ```
+  pub fn allocate(&self, data: T) -> ArenaArc<T> {
+    let ptr = unsafe {
+      let this = Self::lock(self.ptr);
+      let ptr = this.raw_arena.allocate();
+      this.ref_count += 1;
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaArcData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          ref_count: AtomicUsize::default(),
+          data,
+        },
+      );
+      Self::unlock(self.ptr);
+      ptr
+    };
+
+    ArenaArc { ptr }
+  }
+
+  /// Allocates a new object in the arena and returns an `ArenaArc` pointing to it. If no space
+  /// is available, returns the original object.
+  ///
+  /// This method creates a new instance of type `T` within the `RawArena`. The provided `data`
+  /// is initialized within the arena, and an `ArenaArc` is returned to manage this allocated data.
+  /// The `ArenaArc` serves as an atomic, reference-counted pointer to the allocated data within
+  /// the arena, ensuring safe concurrent access across multiple threads while maintaining the
+  /// reference count for memory management.
+  ///
+  /// The allocation process employs a mutex to ensure thread-safe access to the arena, allowing
+  /// only one thread at a time to modify the internal state, including allocating and deallocating memory.
+  pub fn allocate_if_space(&self, data: T) -> Result<ArenaArc<T>, T> {
+    let ptr = unsafe {
+      let this = Self::lock(self.ptr);
+      let Some(ptr) = this.raw_arena.allocate_if_space() else {
+        return Err(data);
+      };
+      this.ref_count += 1;
+      Self::unlock(self.ptr);
+
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaArcData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          ref_count: AtomicUsize::default(),
+          data,
+        },
+      );
+      ptr
+    };
+
+    Ok(ArenaArc { ptr })
+  }
+
+  /// Attempt to reserve space in this arena.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn reserve_space(
+    &self,
+  ) -> Option<ArenaSharedAtomicReservation<T>> {
+    let this = Self::lock(self.ptr);
+    let ptr = this.raw_arena.allocate_if_space()?;
+    this.ref_count += 1;
+    Self::unlock(self.ptr);
+    Some(ArenaSharedAtomicReservation(ptr))
+  }
+
+  /// Forget a reservation.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn forget_reservation(
+    &self,
+    reservation: ArenaSharedAtomicReservation<T>,
+  ) {
+    let ptr = reservation.0;
+    std::mem::forget(reservation);
+    let this = Self::lock(self.ptr);
+    this.ref_count -= 1;
+    this.raw_arena.recycle_without_drop(ptr);
+    Self::unlock(self.ptr);
+  }
+
+  /// Complete a reservation.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn complete_reservation(
+    &self,
+    reservation: ArenaSharedAtomicReservation<T>,
+    data: T,
+  ) -> ArenaArc<T> {
+    let ptr = reservation.0;
+    std::mem::forget(reservation);
+    let ptr = {
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaArcData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          ref_count: AtomicUsize::default(),
+          data,
+        },
+      );
+      ptr
+    };
+    ArenaArc { ptr }
+  }
+}
+
+impl<T> Drop for ArenaSharedAtomic<T> {
+  fn drop(&mut self) {
+    unsafe {
+      let this = Self::lock(self.ptr);
+      if this.ref_count == 0 {
+        Self::drop_data(self.ptr);
+      } else {
+        this.ref_count -= 1;
+        Self::unlock(self.ptr);
+      }
+    }
+  }
+}
+
+#[cfg(test)]
+mod tests {
+  use super::*;
+  use std::cell::RefCell;
+  use std::sync::Arc;
+  use std::sync::Mutex;
+
+  #[test]
+  fn test_raw() {
+    let arena: ArenaSharedAtomic<RefCell<usize>> =
+      ArenaSharedAtomic::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    let raw = ArenaArc::into_raw(arc);
+    _ = unsafe { ArenaArc::from_raw(raw) };
+  }
+
+  #[test]
+  fn test_clone_into_raw() {
+    let arena: ArenaSharedAtomic<RefCell<usize>> =
+      ArenaSharedAtomic::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    let raw = ArenaArc::clone_into_raw(&arc);
+    _ = unsafe { ArenaArc::from_raw(raw) };
+  }
+
+  #[test]
+  fn test_allocate_drop_arc_first() {
+    let arena: ArenaSharedAtomic<RefCell<usize>> =
+      ArenaSharedAtomic::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    *arc.borrow_mut() += 1;
+    drop(arc);
+    drop(arena);
+  }
+
+  #[test]
+  fn test_allocate_drop_arena_first() {
+    let arena: ArenaSharedAtomic<RefCell<usize>> =
+      ArenaSharedAtomic::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    *arc.borrow_mut() += 1;
+    drop(arena);
+    drop(arc);
+  }
+
+  #[test]
+  fn test_threaded() {
+    let arena: Arc<Mutex<ArenaSharedAtomic<RefCell<usize>>>> =
+      Arc::new(Mutex::new(ArenaSharedAtomic::with_capacity(2000)));
+    const THREADS: usize = 20;
+    const ITERATIONS: usize = 100;
+
+    let mut handles = Vec::new();
+    let barrier = Arc::new(std::sync::Barrier::new(THREADS));
+
+    for _ in 0..THREADS {
+      let arena = Arc::clone(&arena);
+      let barrier = Arc::clone(&barrier);
+
+      let handle = std::thread::spawn(move || {
+        barrier.wait();
+
+        for _ in 0..ITERATIONS {
+          let arc = arena.lock().unwrap().allocate(RefCell::new(0));
+          *arc.borrow_mut() += 1;
+          drop(arc); // Ensure the Arc is dropped at the end of the iteration
+        }
+      });
+
+      handles.push(handle);
+    }
+
+    for handle in handles {
+      handle.join().unwrap();
+    }
+  }
+}
diff --git a/core/arena/unique_arena.rs b/core/arena/unique_arena.rs
new file mode 100644
index 0000000..c8c6f71
--- /dev/null
+++ b/core/arena/unique_arena.rs
@@ -0,0 +1,363 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use std::alloc::Layout;
+use std::future::Future;
+use std::pin::Pin;
+use std::ptr::NonNull;
+
+use crate::arena::raw_arena::RawArena;
+
+use super::alloc;
+use super::ptr_byte_add;
+use super::ptr_byte_sub;
+
+/// In debug mode we use a signature to ensure that raw pointers are pointing to the correct
+/// shape of arena object.
+#[cfg(debug_assertions)]
+const SIGNATURE: usize = 0x8877665544332211;
+
+pub struct ArenaUniqueReservation<T>(NonNull<ArenaBoxData<T>>);
+
+impl<T> Drop for ArenaUniqueReservation<T> {
+  fn drop(&mut self) {
+    panic!("A reservation must be completed or forgotten")
+  }
+}
+
+pub struct ArenaBox<T: 'static> {
+  ptr: NonNull<ArenaBoxData<T>>,
+}
+
+impl<T> Unpin for ArenaBox<T> {}
+
+struct ArenaBoxData<T> {
+  #[cfg(debug_assertions)]
+  signature: usize,
+  arena_data: NonNull<ArenaUniqueData<T>>,
+  data: T,
+}
+
+impl<T: 'static> ArenaBox<T> {
+  /// Offset of the `ptr` field within the `ArenaBox` struct.
+  const PTR_OFFSET: usize = memoffset::offset_of!(ArenaBox<T>, ptr);
+
+  /// Constructs a `NonNull` reference to `ArenaBoxData` from a raw pointer to `T`.
+  #[inline(always)]
+  unsafe fn data_from_ptr(ptr: NonNull<T>) -> NonNull<ArenaBoxData<T>> {
+    ptr_byte_sub(ptr, Self::PTR_OFFSET)
+  }
+
+  /// Obtains a raw pointer to `T` from a `NonNull` reference to `ArenaBoxData`.  
+  #[inline(always)]
+  unsafe fn ptr_from_data(ptr: NonNull<ArenaBoxData<T>>) -> NonNull<T> {
+    ptr_byte_add(ptr, Self::PTR_OFFSET)
+  }
+
+  /// Transforms an `ArenaBox` into a raw pointer to `T` and forgets it.
+  ///
+  /// # Safety
+  ///
+  /// This function returns a raw pointer without managing the memory, potentially leading to
+  /// memory leaks if the pointer is not properly handled or deallocated.
+  #[inline(always)]
+  pub fn into_raw(mut alloc: ArenaBox<T>) -> NonNull<T> {
+    let ptr = NonNull::from(alloc.data_mut());
+    std::mem::forget(alloc);
+    unsafe { Self::ptr_from_data(ptr) }
+  }
+
+  /// Constructs an `ArenaBox` from a raw pointer to the contained data.
+  ///
+  /// # Safety
+  ///
+  /// This function safely constructs an `ArenaBox` from a raw pointer, assuming the pointer is
+  /// valid and properly aligned. Misuse may lead to undefined behavior, memory unsafety, or data corruption.
+  #[inline(always)]
+  pub unsafe fn from_raw(ptr: NonNull<T>) -> ArenaBox<T> {
+    let ptr = Self::data_from_ptr(ptr);
+
+    #[cfg(debug_assertions)]
+    debug_assert_eq!(ptr.as_ref().signature, SIGNATURE);
+    ArenaBox { ptr }
+  }
+}
+
+// This Box cannot be sent between threads
+static_assertions::assert_not_impl_any!(ArenaBox<()>: Send, Sync);
+
+impl<T> ArenaBox<T> {
+  #[inline(always)]
+  fn data(&self) -> &ArenaBoxData<T> {
+    unsafe { self.ptr.as_ref() }
+  }
+
+  #[inline(always)]
+  fn data_mut(&mut self) -> &mut ArenaBoxData<T> {
+    unsafe { self.ptr.as_mut() }
+  }
+}
+
+impl<T> Drop for ArenaBox<T> {
+  #[inline(always)]
+  fn drop(&mut self) {
+    unsafe {
+      ArenaUnique::delete(self.ptr);
+    }
+  }
+}
+
+impl<T> std::ops::Deref for ArenaBox<T> {
+  type Target = T;
+  #[inline(always)]
+  fn deref(&self) -> &Self::Target {
+    &self.data().data
+  }
+}
+
+impl<T> std::convert::AsRef<T> for ArenaBox<T> {
+  #[inline(always)]
+  fn as_ref(&self) -> &T {
+    &self.data().data
+  }
+}
+
+impl<T> std::ops::DerefMut for ArenaBox<T> {
+  #[inline(always)]
+  fn deref_mut(&mut self) -> &mut Self::Target {
+    &mut self.data_mut().data
+  }
+}
+
+impl<T> std::convert::AsMut<T> for ArenaBox<T> {
+  #[inline(always)]
+  fn as_mut(&mut self) -> &mut T {
+    &mut self.data_mut().data
+  }
+}
+
+impl<F, R> std::future::Future for ArenaBox<F>
+where
+  F: Future<Output = R>,
+{
+  type Output = R;
+
+  #[inline(always)]
+  fn poll(
+    mut self: Pin<&mut Self>,
+    cx: &mut std::task::Context<'_>,
+  ) -> std::task::Poll<Self::Output> {
+    unsafe { F::poll(Pin::new_unchecked(&mut self.data_mut().data), cx) }
+  }
+}
+
+/// An arena-based unique ownership container allowing allocation
+/// and deallocation of objects with exclusive ownership semantics.
+///
+/// `ArenaUnique` provides exclusive ownership semantics similar to
+/// a `Box`. It utilizes a `RawArena` for allocation and
+/// deallocation of objects, maintaining the sole ownership of the
+/// allocated data and enabling safe cleanup when the `ArenaUnique`
+/// instance is dropped.
+///
+/// This container guarantees exclusive access to the allocated data
+/// within the arena, allowing single-threaded operations while
+/// efficiently managing memory and ensuring cleanup on drop.
+pub struct ArenaUnique<T> {
+  ptr: NonNull<ArenaUniqueData<T>>,
+}
+
+// The arena itself may not be shared so that we can guarantee all [`RawArena`]
+// access happens on the owning thread.
+static_assertions::assert_not_impl_any!(ArenaUnique<()>: Send, Sync);
+
+struct ArenaUniqueData<T> {
+  raw_arena: RawArena<ArenaBoxData<T>>,
+  alive: bool,
+}
+
+impl<T> ArenaUnique<T> {
+  pub fn with_capacity(capacity: usize) -> Self {
+    unsafe {
+      let ptr = alloc();
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaUniqueData {
+          raw_arena: RawArena::with_capacity(capacity),
+          alive: true,
+        },
+      );
+      Self { ptr }
+    }
+  }
+
+  #[cold]
+  #[inline(never)]
+  unsafe fn drop_data(data: NonNull<ArenaUniqueData<T>>) {
+    let data = data.as_ptr();
+    std::ptr::drop_in_place(data);
+    std::alloc::dealloc(data as _, Layout::new::<ArenaUniqueData<T>>());
+  }
+
+  /// Deletes the data associated with an `ArenaBox` from the arena. If this is the last
+  /// allocation for the arena and the arena has been dropped, de-allocate everything.
+  #[inline(always)]
+  unsafe fn delete(data: NonNull<ArenaBoxData<T>>) {
+    let arena_data = data.as_ref().arena_data;
+    let arena = arena_data.as_ref();
+    if arena.raw_arena.recycle(data) && !arena.alive {
+      Self::drop_data(arena_data)
+    }
+  }
+
+  /// Allocates a new data instance of type `T` within the arena, encapsulating it within an `ArenaBox`.
+  ///
+  /// This method creates a new instance of type `T` within the `RawArena`. The provided `data`
+  /// is initialized within the arena, and an `ArenaBox` is returned to manage this allocated data.
+  /// The `ArenaBox` serves as a reference to the allocated data within the arena, providing safe access
+  /// and management of the stored value.
+  ///
+  /// # Safety
+  ///
+  /// The provided `data` is allocated within the arena and managed by the `ArenaBox`. Improper handling
+  /// or misuse of the returned `ArenaBox` pointer may lead to memory leaks or memory unsafety.
+  ///
+  /// # Example
+  ///
+  /// ```rust
+  /// # use deno_core::arena::ArenaUnique;
+  ///
+  /// // Define a struct that will be allocated within the arena
+  /// struct MyStruct {
+  ///   data: usize,
+  /// }
+  ///
+  /// // Create a new instance of ArenaUnique with a specified base capacity
+  /// let arena: ArenaUnique<MyStruct> = ArenaUnique::with_capacity(16);
+  ///
+  /// // Allocate a new MyStruct instance within the arena
+  /// let data_instance = MyStruct { data: 42 };
+  /// let allocated_box = arena.allocate(data_instance);
+  ///
+  /// // Now, allocated_box can be used as a managed reference to the allocated data
+  /// assert_eq!(allocated_box.data, 42); // Validate the data stored in the allocated box
+  /// ```
+  pub fn allocate(&self, data: T) -> ArenaBox<T> {
+    let ptr = unsafe {
+      let this = self.ptr.as_ptr();
+      let ptr = (*this).raw_arena.allocate();
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaBoxData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          data,
+        },
+      );
+      ptr
+    };
+
+    ArenaBox { ptr }
+  }
+
+  /// Attempt to reserve space in this arena.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn reserve_space(&self) -> Option<ArenaUniqueReservation<T>> {
+    let this = &mut *self.ptr.as_ptr();
+    let ptr = this.raw_arena.allocate_if_space()?;
+    Some(ArenaUniqueReservation(ptr))
+  }
+
+  /// Forget a reservation.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn forget_reservation(
+    &self,
+    reservation: ArenaUniqueReservation<T>,
+  ) {
+    let ptr = reservation.0;
+    std::mem::forget(reservation);
+    let this = self.ptr.as_ptr();
+    (*this).raw_arena.recycle_without_drop(ptr);
+  }
+
+  /// Complete a reservation.
+  ///
+  /// # Safety
+  ///
+  /// Reservations must be either completed or forgotten, and must be provided to the same
+  /// arena that created them.
+  pub unsafe fn complete_reservation(
+    &self,
+    reservation: ArenaUniqueReservation<T>,
+    data: T,
+  ) -> ArenaBox<T> {
+    let ptr = reservation.0;
+    std::mem::forget(reservation);
+    let ptr = {
+      std::ptr::write(
+        ptr.as_ptr(),
+        ArenaBoxData {
+          #[cfg(debug_assertions)]
+          signature: SIGNATURE,
+          arena_data: self.ptr,
+          data,
+        },
+      );
+      ptr
+    };
+
+    ArenaBox { ptr }
+  }
+}
+
+impl<T> Drop for ArenaUnique<T> {
+  fn drop(&mut self) {
+    unsafe {
+      let this = self.ptr.as_mut();
+      if this.raw_arena.allocated() == 0 {
+        Self::drop_data(self.ptr);
+      } else {
+        this.alive = false;
+      }
+    }
+  }
+}
+
+#[cfg(test)]
+mod tests {
+  use super::*;
+  use std::cell::RefCell;
+
+  #[test]
+  fn test_raw() {
+    let arena: ArenaUnique<RefCell<usize>> = ArenaUnique::with_capacity(16);
+    let arc = arena.allocate(Default::default());
+    let raw = ArenaBox::into_raw(arc);
+    _ = unsafe { ArenaBox::from_raw(raw) };
+  }
+
+  #[test]
+  fn test_allocate_drop_box_first() {
+    let arena: ArenaUnique<RefCell<usize>> = ArenaUnique::with_capacity(16);
+    let alloc = arena.allocate(Default::default());
+    *alloc.borrow_mut() += 1;
+    drop(alloc);
+    drop(arena);
+  }
+
+  #[test]
+  fn test_allocate_drop_arena_first() {
+    let arena: ArenaUnique<RefCell<usize>> = ArenaUnique::with_capacity(16);
+    let alloc = arena.allocate(Default::default());
+    *alloc.borrow_mut() += 1;
+    drop(arena);
+    drop(alloc);
+  }
+}
diff --git a/core/benches/infra/arena.rs b/core/benches/infra/arena.rs
new file mode 100644
index 0000000..a55755b
--- /dev/null
+++ b/core/benches/infra/arena.rs
@@ -0,0 +1,192 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+#![allow(clippy::needless_range_loop)]
+use bencher::benchmark_group;
+use bencher::benchmark_main;
+use bencher::Bencher;
+use deno_core::arena::ArenaShared;
+use deno_core::arena::ArenaSharedAtomic;
+use deno_core::arena::ArenaUnique;
+use deno_core::arena::RawArena;
+use std::alloc::Layout;
+use std::cell::RefCell;
+use std::hint::black_box;
+use std::ptr::NonNull;
+use std::rc::Rc;
+use std::sync::Arc;
+
+const COUNT: usize = 10_000;
+type TestType = RefCell<usize>;
+
+fn validate_array<T>(v: &[T]) {
+  assert_eq!(v.len(), COUNT);
+  for t in v {
+    let _ = black_box(t);
+  }
+}
+
+fn initialize_data<T: AsRef<TestType>>() -> [Option<T>; COUNT] {
+  unsafe { std::mem::zeroed() }
+}
+
+fn bench_arc_arena(b: &mut Bencher) {
+  let arena = ArenaSharedAtomic::<TestType>::with_capacity(COUNT);
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      data[i] = Some(arena.allocate(Default::default()));
+    }
+    validate_array(&data);
+  });
+}
+
+fn bench_rc_arena(b: &mut Bencher) {
+  let arena = ArenaShared::<TestType>::with_capacity(COUNT);
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      data[i] = Some(arena.allocate(Default::default()));
+    }
+    validate_array(&data);
+  });
+}
+
+fn bench_rc_of_raw_arena(b: &mut Bencher) {
+  struct RcData(NonNull<TestType>, Rc<RawArena<TestType>>);
+  impl AsRef<TestType> for RcData {
+    fn as_ref(&self) -> &TestType {
+      unsafe { self.0.as_ref() }
+    }
+  }
+
+  let arena = Rc::new(RawArena::<TestType>::with_capacity(COUNT));
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      unsafe {
+        let ptr = arena.allocate();
+        std::ptr::write(ptr.as_ptr(), Default::default());
+        data[i] = Some(RcData(ptr, arena.clone()));
+      }
+    }
+    validate_array(&data);
+    for i in 0..COUNT {
+      unsafe {
+        let data = data[i].as_ref().unwrap();
+        data.1.recycle(data.0);
+      }
+    }
+  });
+}
+
+fn bench_box_arena(b: &mut Bencher) {
+  let arena = ArenaUnique::<TestType>::with_capacity(COUNT);
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      data[i] = Some(arena.allocate(Default::default()));
+    }
+    validate_array(&data);
+  });
+}
+
+#[allow(clippy::arc_with_non_send_sync)]
+fn bench_arc(b: &mut Bencher) {
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      data[i] = Some(Arc::<TestType>::new(Default::default()));
+    }
+    validate_array(&data);
+  })
+}
+
+fn bench_rc(b: &mut Bencher) {
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      data[i] = Some(Rc::<TestType>::new(Default::default()));
+    }
+    validate_array(&data);
+  })
+}
+
+fn bench_box(b: &mut Bencher) {
+  b.iter(|| {
+    let mut data = initialize_data();
+    for i in 0..COUNT {
+      data[i] = Some(Box::<TestType>::default());
+    }
+    validate_array(&data);
+  })
+}
+
+fn bench_raw_arena_init(b: &mut Bencher) {
+  let arena = RawArena::<TestType>::with_capacity(COUNT);
+  b.iter(|| {
+    let mut data = [NonNull::dangling(); 10000];
+    for i in 0..COUNT {
+      unsafe {
+        let ptr = arena.allocate();
+        std::ptr::write(ptr.as_ptr(), Default::default());
+        data[i] = ptr;
+      }
+    }
+    validate_array(&data);
+    for i in 0..COUNT {
+      unsafe {
+        arena.recycle(data[i]);
+      }
+    }
+  });
+}
+
+fn bench_raw_arena_uninit(b: &mut Bencher) {
+  let arena = RawArena::<TestType>::with_capacity(COUNT);
+  b.iter(|| {
+    let mut data = [NonNull::dangling(); 10000];
+    for i in 0..COUNT {
+      unsafe {
+        data[i] = arena.allocate();
+      }
+    }
+    validate_array(&data);
+    for i in 0..COUNT {
+      unsafe {
+        arena.recycle_without_drop(data[i]);
+      }
+    }
+  });
+}
+
+fn bench_raw_alloc(b: &mut Bencher) {
+  b.iter(|| {
+    let mut data = [std::ptr::null_mut(); COUNT];
+    for i in 0..COUNT {
+      unsafe {
+        data[i] = std::alloc::alloc(Layout::new::<TestType>());
+      }
+    }
+    validate_array(&data);
+    for i in 0..COUNT {
+      unsafe {
+        std::alloc::dealloc(data[i], Layout::new::<TestType>());
+      }
+    }
+  })
+}
+
+benchmark_main!(benches);
+
+benchmark_group!(
+  benches,
+  bench_arc,
+  bench_arc_arena,
+  bench_rc,
+  bench_rc_arena,
+  bench_rc_of_raw_arena,
+  bench_box,
+  bench_box_arena,
+  bench_raw_alloc,
+  bench_raw_arena_init,
+  bench_raw_arena_uninit,
+);
diff --git a/core/benches/ops/async.rs b/core/benches/ops/async.rs
index 05d5b7e..83e449a 100644
--- a/core/benches/ops/async.rs
+++ b/core/benches/ops/async.rs
@@ -3,6 +3,7 @@ use bencher::*;
 use deno_core::error::generic_error;
 use deno_core::*;
 use std::ffi::c_void;
+use tokio::runtime::Runtime;
 
 deno_core::extension!(
   testing,
@@ -150,16 +151,23 @@ fn bench_op(
   let bench = v8::Global::new(&mut scope, bench);
   drop(scope);
   drop(guard);
-  b.iter(move || {
-    tokio.block_on(async {
-      let guard = tokio.enter();
-      let call = runtime.call(&bench);
-      runtime
-        .with_event_loop_promise(call, PollEventLoopOptions::default())
-        .await
-        .unwrap();
-      drop(guard);
-    });
+  b.iter(move || do_benchmark(&bench, &tokio, &mut runtime));
+}
+
+#[inline(never)]
+fn do_benchmark(
+  bench: &v8::Global<v8::Function>,
+  tokio: &Runtime,
+  runtime: &mut JsRuntime,
+) {
+  tokio.block_on(async {
+    let guard = tokio.enter();
+    let call = runtime.call(bench);
+    runtime
+      .with_event_loop_promise(call, PollEventLoopOptions::default())
+      .await
+      .unwrap();
+    drop(guard);
   });
 }
 
@@ -181,6 +189,17 @@ fn baseline_promise(b: &mut Bencher) {
   );
 }
 
+/// Tests the overhead of execute_script with a promise.
+fn baseline_promise_with_resolver(b: &mut Bencher) {
+  bench_op(
+    b,
+    BENCH_COUNT,
+    "op_async_void",
+    0,
+    "{ let { promise, resolve } = Promise.withResolvers(); resolve(null); await promise; }",
+  );
+}
+
 /// Tests the overhead of execute_script with a promise.
 fn baseline_op_promise_resolver(b: &mut Bencher) {
   bench_op(
@@ -262,6 +281,7 @@ benchmark_group!(
   benches,
   baseline,
   baseline_promise,
+  baseline_promise_with_resolver,
   baseline_op_promise_resolver,
   baseline_op_promise,
   baseline_sync,
diff --git a/core/benches/ops/opset.rs b/core/benches/ops/opset.rs
new file mode 100644
index 0000000..18715eb
--- /dev/null
+++ b/core/benches/ops/opset.rs
@@ -0,0 +1,115 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use bencher::*;
+use futures::stream::FuturesOrdered;
+use futures::stream::FuturesUnordered;
+use futures::StreamExt;
+use std::net::Ipv4Addr;
+use std::net::SocketAddr;
+use std::net::SocketAddrV4;
+use tokio::net::TcpListener;
+use tokio::task::JoinSet;
+
+const LOOPS: usize = 10;
+const COUNT: usize = 10;
+
+async fn task() {
+  tokio::task::yield_now().await;
+  let mut v = vec![];
+  for _ in 0..3 {
+    v.push(TcpListener::bind(SocketAddr::V4(SocketAddrV4::new(
+      Ipv4Addr::LOCALHOST,
+      0,
+    ))));
+  }
+  drop(v);
+}
+
+fn bench_futures_unordered(b: &mut Bencher) {
+  let runtime = tokio::runtime::Builder::new_current_thread()
+    .enable_time()
+    .build()
+    .unwrap();
+  let mut futures = FuturesUnordered::default();
+  b.iter(|| {
+    runtime.block_on(async {
+      for _ in 0..LOOPS {
+        for _ in 0..COUNT {
+          futures.push(task());
+        }
+        for _ in 0..COUNT {
+          futures.next().await;
+        }
+      }
+    });
+  });
+}
+
+fn bench_futures_ordered(b: &mut Bencher) {
+  let runtime = tokio::runtime::Builder::new_current_thread()
+    .enable_time()
+    .build()
+    .unwrap();
+  let mut futures = FuturesOrdered::default();
+  b.iter(|| {
+    runtime.block_on(async {
+      for _ in 0..LOOPS {
+        for _ in 0..COUNT {
+          futures.push_back(task());
+        }
+        for _ in 0..COUNT {
+          futures.next().await;
+        }
+      }
+    });
+  });
+}
+
+fn bench_joinset(b: &mut Bencher) {
+  let runtime = tokio::runtime::Builder::new_current_thread()
+    .enable_time()
+    .build()
+    .unwrap();
+  let mut futures = JoinSet::default();
+  b.iter(|| {
+    runtime.block_on(async {
+      for _ in 0..LOOPS {
+        for _ in 0..COUNT {
+          futures.spawn(task());
+        }
+        for _ in 0..COUNT {
+          futures.join_next().await;
+        }
+      }
+    });
+  });
+}
+
+fn bench_unicycle(b: &mut Bencher) {
+  let runtime = tokio::runtime::Builder::new_current_thread()
+    .enable_time()
+    .build()
+    .unwrap();
+  let mut futures = unicycle::FuturesUnordered::new();
+  b.iter(|| {
+    runtime.block_on(async {
+      for _ in 0..LOOPS {
+        for _ in 0..COUNT {
+          futures.push(task());
+        }
+        for _ in 0..COUNT {
+          futures.next().await;
+        }
+      }
+    });
+  });
+}
+
+benchmark_main!(benches);
+
+benchmark_group!(
+  benches,
+  bench_futures_ordered,
+  bench_futures_unordered,
+  bench_joinset,
+  bench_unicycle,
+);
diff --git a/core/examples/panik.rs b/core/examples/panik.rs
deleted file mode 100644
index 9f5ae9b..0000000
--- a/core/examples/panik.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-//!  This example shows that op-panics currently result in UB (likely "failed to initiate panic")
-//!  without a custom panic hook that aborts the process or -C panic=abort.
-//!
-//!  This happens due to the UB of panicking in an extern "C",
-//!  given how ops are reduced via rusty_v8::MapFnTo
-//!  See:
-//!    - https://github.com/rust-lang/rust/issues/74990
-//!    - https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html
-
-use deno_core::*;
-
-fn main() {
-  #[op2(fast)]
-  fn op_panik() {
-    panic!("panik !!!")
-  }
-
-  let extensions = vec![Extension {
-    name: "my_ext",
-    ops: std::borrow::Cow::Borrowed(&[op_panik::DECL]),
-    ..Default::default()
-  }];
-  let mut rt = JsRuntime::new(RuntimeOptions {
-    extensions,
-    ..Default::default()
-  });
-  rt.execute_script_static("panik", "Deno.core.ops.op_panik()")
-    .unwrap();
-}
diff --git a/core/examples/ts_module_loader.rs b/core/examples/ts_module_loader.rs
index d8fe49b..d78f435 100644
--- a/core/examples/ts_module_loader.rs
+++ b/core/examples/ts_module_loader.rs
@@ -22,6 +22,7 @@ use deno_core::resolve_path;
 use deno_core::JsRuntime;
 use deno_core::ModuleLoader;
 use deno_core::ModuleSource;
+use deno_core::ModuleSourceCode;
 use deno_core::ModuleSourceFuture;
 use deno_core::ModuleSpecifier;
 use deno_core::ModuleType;
@@ -120,7 +121,7 @@ impl ModuleLoader for TypescriptModuleLoader {
       };
       Ok(ModuleSource::new(
         module_type,
-        code.into(),
+        ModuleSourceCode::String(code.into()),
         module_specifier,
       ))
     }
diff --git a/core/feature_checker.rs b/core/feature_checker.rs
index 9dfd7b1..fc2a429 100644
--- a/core/feature_checker.rs
+++ b/core/feature_checker.rs
@@ -4,13 +4,13 @@ use std::collections::BTreeSet;
 use std::fmt::Debug;
 
 pub type ExitCb = Box<dyn Fn(&str, &str) + Send + Sync>;
-pub type WarnCb = Box<dyn Fn(&str) + Send + Sync>;
+pub type WarnCb = Box<dyn Fn(&str, &str) + Send + Sync>;
 
 fn exit(_feature: &str, _api_name: &str) {
   std::process::exit(70);
 }
 
-fn warn_legacy_flag(_feature: &str) {}
+fn warn_legacy_flag(_feature: &str, _api_name: &str) {}
 
 pub struct FeatureChecker {
   features: BTreeSet<&'static str>,
@@ -86,7 +86,7 @@ impl FeatureChecker {
     if !self.features.contains(feature) {
       if self.legacy_unstable {
         if self.warn_on_legacy_unstable {
-          (self.warn_cb)(feature);
+          (self.warn_cb)(feature, api_name);
         }
         return;
       }
@@ -122,7 +122,7 @@ mod tests {
       EXIT_COUNT.fetch_add(1, Ordering::Relaxed);
     }
 
-    fn warn_cb(_feature: &str) {
+    fn warn_cb(_feature: &str, _api_name: &str) {
       WARN_COUNT.fetch_add(1, Ordering::Relaxed);
     }
 
diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts
index 0c64fef..0ad62a5 100644
--- a/core/lib.deno_core.d.ts
+++ b/core/lib.deno_core.d.ts
@@ -1,6 +1,6 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 
-// deno-lint-ignore-file no-explicit-any
+// deno-lint-ignore-file ban-types no-explicit-any
 
 /// <reference no-default-lib="true" />
 /// <reference lib="esnext" />
@@ -252,6 +252,58 @@ declare namespace Deno {
       resolve_hook?: (promise: Promise<unknown>) => void,
     ): void;
 
+    function isAnyArrayBuffer(
+      value: unknown,
+    ): value is ArrayBuffer | SharedArrayBuffer;
+    function isArgumentsObject(value: unknown): value is IArguments;
+    function isArrayBuffer(value: unknown): value is ArrayBuffer;
+    function isArrayBufferView(value: unknown): value is ArrayBufferView;
+    function isAsyncFunction(
+      value: unknown,
+    ): value is (
+      ...args: unknown[]
+    ) => Promise<unknown> | AsyncGeneratorFunction;
+    function isBigIntObject(value: unknown): value is BigInt;
+    function isBooleanObject(value: unknown): value is Boolean;
+    function isBoxedPrimitive(
+      value: unknown,
+    ): value is BigInt | Boolean | Number | String | Symbol;
+    function isDataView(value: unknown): value is DataView;
+    function isDate(value: unknown): value is Date;
+    function isGeneratorFunction(
+      value: unknown,
+    ): value is GeneratorFunction | AsyncGeneratorFunction;
+    function isGeneratorObject(value: unknown): value is Generator;
+    function isMap(value: unknown): value is Map<unknown, unknown>;
+    function isMapIterator(value: unknown): value is IterableIterator<unknown>;
+    function isModuleNamespaceObject(value: unknown): value is object;
+    function isNativeError(value: unknown): value is Error;
+    function isNumberObject(value: unknown): value is Number;
+    function isPromise(value: unknown): value is Promise<unknown>;
+    function isProxy(value: unknown): value is object;
+    function isRegExp(value: unknown): value is RegExp;
+    function isSet(value: unknown): value is Set<unknown>;
+    function isSetIterator(value: unknown): value is IterableIterator<unknown>;
+    function isSharedArrayBuffer(value: unknown): value is SharedArrayBuffer;
+    function isStringObject(value: unknown): value is String;
+    function isSymbolObject(value: unknown): value is Symbol;
+    function isTypedArray(
+      value: unknown,
+    ): value is
+      | Uint8Array
+      | Uint8ClampedArray
+      | Uint16Array
+      | Uint32Array
+      | Int8Array
+      | Int16Array
+      | Int32Array
+      | Float32Array
+      | Float64Array
+      | BigUint64Array
+      | BigInt64Array;
+    function isWeakMap(value: unknown): value is WeakMap<WeakKey, unknown>;
+    function isWeakSet(value: unknown): value is WeakSet<WeakKey>;
+
     const build: {
       target: string;
       arch: string;
diff --git a/core/lib.rs b/core/lib.rs
index b60f78b..cda4f05 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -1,4 +1,5 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+pub mod arena;
 mod async_cancel;
 mod async_cell;
 mod buffer_strategy;
@@ -17,6 +18,7 @@ mod modules;
 mod normalize_path;
 mod ops;
 mod ops_builtin;
+mod ops_builtin_types;
 mod ops_builtin_v8;
 mod ops_metrics;
 mod path;
@@ -94,6 +96,7 @@ pub use crate::modules::ModuleCode;
 pub use crate::modules::ModuleId;
 pub use crate::modules::ModuleLoader;
 pub use crate::modules::ModuleSource;
+pub use crate::modules::ModuleSourceCode;
 pub use crate::modules::ModuleSourceFuture;
 pub use crate::modules::ModuleType;
 pub use crate::modules::NoopModuleLoader;
@@ -101,9 +104,7 @@ pub use crate::modules::ResolutionKind;
 pub use crate::modules::StaticModuleLoader;
 pub use crate::modules::ValidateImportAttributesCb;
 pub use crate::normalize_path::normalize_path;
-pub use crate::ops::OpError;
 pub use crate::ops::OpId;
-pub use crate::ops::OpResult;
 pub use crate::ops::OpState;
 pub use crate::ops::PromiseId;
 pub use crate::ops_builtin::op_close;
@@ -158,7 +159,6 @@ pub mod _ops {
   #[cfg(debug_assertions)]
   pub use super::ops::reentrancy_check;
   pub use super::ops::OpCtx;
-  pub use super::ops::OpResult;
   pub use super::ops_metrics::dispatch_metrics_async;
   pub use super::ops_metrics::dispatch_metrics_fast;
   pub use super::ops_metrics::dispatch_metrics_slow;
diff --git a/core/modules/loaders.rs b/core/modules/loaders.rs
index 09c59f3..916cb45 100644
--- a/core/modules/loaders.rs
+++ b/core/modules/loaders.rs
@@ -10,8 +10,10 @@ use crate::modules::ModuleType;
 use crate::modules::ResolutionKind;
 use crate::resolve_import;
 use crate::Extension;
+use crate::ModuleSourceCode;
 
 use anyhow::anyhow;
+use anyhow::Context;
 use anyhow::Error;
 use futures::future::ready;
 use futures::future::FutureExt;
@@ -155,7 +157,11 @@ impl ModuleLoader for ExtModuleLoader {
     let result = source.load();
     match result {
       Ok(code) => {
-        let res = ModuleSource::new(ModuleType::JavaScript, code, specifier);
+        let res = ModuleSource::new(
+          ModuleType::JavaScript,
+          ModuleSourceCode::String(code),
+          specifier,
+        );
         return futures::future::ok(res).boxed_local();
       }
       Err(err) => return futures::future::err(err).boxed_local(),
@@ -211,7 +217,11 @@ impl ModuleLoader for LazyEsmModuleLoader {
     let result = source.load();
     match result {
       Ok(code) => {
-        let res = ModuleSource::new(ModuleType::JavaScript, code, specifier);
+        let res = ModuleSource::new(
+          ModuleType::JavaScript,
+          ModuleSourceCode::String(code),
+          specifier,
+        );
         return futures::future::ok(res).boxed_local();
       }
       Err(err) => return futures::future::err(err).boxed_local(),
@@ -293,8 +303,14 @@ impl ModuleLoader for FsModuleLoader {
         ModuleType::JavaScript
       };
 
-      let code = std::fs::read_to_string(path)?.into();
-      let module = ModuleSource::new(module_type, code, module_specifier);
+      let code = std::fs::read(path).with_context(|| {
+        format!("Failed to load {}", module_specifier.as_str())
+      })?;
+      let module = ModuleSource::new(
+        module_type,
+        ModuleSourceCode::Bytes(code),
+        module_specifier,
+      );
       Ok(module)
     }
 
@@ -347,7 +363,7 @@ impl ModuleLoader for StaticModuleLoader {
     let res = if let Some(code) = self.map.get(module_specifier) {
       Ok(ModuleSource::new(
         ModuleType::JavaScript,
-        code.try_clone().unwrap(),
+        ModuleSourceCode::String(code.try_clone().unwrap()),
         module_specifier,
       ))
     } else {
diff --git a/core/modules/map.rs b/core/modules/map.rs
index 45f1cf7..ca4e4d2 100644
--- a/core/modules/map.rs
+++ b/core/modules/map.rs
@@ -5,10 +5,10 @@ use crate::error::throw_type_error;
 use crate::error::to_v8_type_error;
 use crate::error::AnyError;
 use crate::error::JsError;
-use crate::modules::get_asserted_module_type_from_assertions;
-use crate::modules::parse_import_assertions;
+use crate::modules::get_requested_module_type_from_attributes;
+use crate::modules::parse_import_attributes;
 use crate::modules::recursive_load::RecursiveModuleLoad;
-use crate::modules::ImportAssertionsKind;
+use crate::modules::ImportAttributesKind;
 use crate::modules::ModuleCode;
 use crate::modules::ModuleError;
 use crate::modules::ModuleId;
@@ -48,8 +48,8 @@ use std::task::Poll;
 use tokio::sync::oneshot;
 
 use super::module_map_data::ModuleMapData;
-use super::AssertedModuleType;
 use super::LazyEsmModuleLoader;
+use super::RequestedModuleType;
 
 type PrepareLoadFuture =
   dyn Future<Output = (ModuleLoadId, Result<RecursiveModuleLoad, Error>)>;
@@ -182,8 +182,8 @@ impl ModuleMap {
     name: impl AsRef<str>,
   ) -> Option<v8::Global<v8::Module>> {
     let id = self
-      .get_id(name.as_ref(), AssertedModuleType::JavaScriptOrWasm)
-      .or_else(|| self.get_id(name.as_ref(), AssertedModuleType::Json))?;
+      .get_id(name.as_ref(), RequestedModuleType::None)
+      .or_else(|| self.get_id(name.as_ref(), RequestedModuleType::Json))?;
     self.get_handle(id)
   }
 
@@ -192,9 +192,9 @@ impl ModuleMap {
   pub(crate) fn get_id(
     &self,
     name: impl AsRef<str>,
-    asserted_module_type: impl AsRef<AssertedModuleType>,
+    requested_module_type: impl AsRef<RequestedModuleType>,
   ) -> Option<ModuleId> {
-    self.data.borrow().get_id(name, asserted_module_type)
+    self.data.borrow().get_id(name, requested_module_type)
   }
 
   pub(crate) fn is_main_module(&self, global: &v8::Global<v8::Module>) -> bool {
@@ -230,9 +230,9 @@ impl ModuleMap {
   pub fn is_alias(
     &self,
     name: &str,
-    asserted_module_type: impl AsRef<AssertedModuleType>,
+    requested_module_type: impl AsRef<RequestedModuleType>,
   ) -> bool {
-    self.data.borrow().is_alias(name, asserted_module_type)
+    self.data.borrow().is_alias(name, requested_module_type)
   }
 
   #[cfg(test)]
@@ -269,24 +269,26 @@ impl ModuleMap {
       module_url_specified
     };
 
-    let asserted_module_type = AssertedModuleType::from(module_type);
-    let maybe_module_id = self.get_id(&module_url_found, asserted_module_type);
-    let module_id = match maybe_module_id {
-      Some(id) => {
-        debug!(
-          "Already-registered module fetched again: {:?}",
-          module_url_found
-        );
-        id
+    let requested_module_type = RequestedModuleType::from(module_type);
+    let maybe_module_id = self.get_id(&module_url_found, requested_module_type);
+
+    if let Some(module_id) = maybe_module_id {
+      debug!(
+        "Already-registered module fetched again: {:?}",
+        module_url_found
+      );
+      return Ok(module_id);
+    }
+
+    let code = ModuleSource::get_string_source(module_url_found.as_str(), code)
+      .map_err(ModuleError::Other)?;
+    let module_id = match module_type {
+      ModuleType::JavaScript => {
+        self.new_es_module(scope, main, module_url_found, code, dynamic)?
+      }
+      ModuleType::Json => {
+        self.new_json_module(scope, module_url_found, code)?
       }
-      None => match module_type {
-        ModuleType::JavaScript => {
-          self.new_es_module(scope, main, module_url_found, code, dynamic)?
-        }
-        ModuleType::Json => {
-          self.new_json_module(scope, module_url_found, code)?
-        }
-      },
     };
     Ok(module_id)
   }
@@ -368,19 +370,19 @@ impl ModuleMap {
         .get_specifier()
         .to_rust_string_lossy(tc_scope);
 
-      let import_assertions = module_request.get_import_assertions();
+      let import_attributes = module_request.get_import_assertions();
 
-      let assertions = parse_import_assertions(
+      let attributes = parse_import_attributes(
         tc_scope,
-        import_assertions,
-        ImportAssertionsKind::StaticImport,
+        import_attributes,
+        ImportAttributesKind::StaticImport,
       );
 
       // FIXME(bartomieju): there are no stack frames if exception
       // is thrown here
       {
         let state = JsRuntime::state_from(tc_scope);
-        (state.validate_import_attributes_cb)(tc_scope, &assertions);
+        (state.validate_import_attributes_cb)(tc_scope, &attributes);
       }
 
       if tc_scope.has_caught() {
@@ -401,11 +403,11 @@ impl ModuleMap {
         Ok(s) => s,
         Err(e) => return Err(ModuleError::Other(e)),
       };
-      let asserted_module_type =
-        get_asserted_module_type_from_assertions(&assertions);
+      let requested_module_type =
+        get_requested_module_type_from_attributes(&attributes);
       let request = ModuleRequest {
         specifier: module_specifier.to_string(),
-        asserted_module_type,
+        requested_module_type,
       };
       requests.push(request);
     }
@@ -493,7 +495,7 @@ impl ModuleMap {
   fn module_resolve_callback<'s>(
     context: v8::Local<'s, v8::Context>,
     specifier: v8::Local<'s, v8::String>,
-    import_assertions: v8::Local<'s, v8::FixedArray>,
+    import_attributes: v8::Local<'s, v8::FixedArray>,
     referrer: v8::Local<'s, v8::Module>,
   ) -> Option<v8::Local<'s, v8::Module>> {
     // SAFETY: `CallbackScope` can be safely constructed from `Local<Context>`
@@ -513,10 +515,10 @@ impl ModuleMap {
 
     let specifier_str = specifier.to_rust_string_lossy(scope);
 
-    let assertions = parse_import_assertions(
+    let assertions = parse_import_attributes(
       scope,
-      import_assertions,
-      ImportAssertionsKind::StaticImport,
+      import_attributes,
+      ImportAttributesKind::StaticImport,
     );
     let maybe_module = module_map.resolve_callback(
       scope,
@@ -568,7 +570,7 @@ impl ModuleMap {
     scope: &mut v8::HandleScope<'s>,
     specifier: &str,
     referrer: &str,
-    import_assertions: HashMap<String, String>,
+    import_attributes: HashMap<String, String>,
   ) -> Option<v8::Local<'s, v8::Module>> {
     let resolved_specifier =
       match self.resolve(specifier, referrer, ResolutionKind::Import) {
@@ -580,7 +582,7 @@ impl ModuleMap {
       };
 
     let module_type =
-      get_asserted_module_type_from_assertions(&import_assertions);
+      get_requested_module_type_from_attributes(&import_attributes);
 
     if let Some(id) = self.get_id(resolved_specifier.as_str(), module_type) {
       if let Some(handle) = self.get_handle(id) {
@@ -639,13 +641,13 @@ impl ModuleMap {
     self: Rc<Self>,
     specifier: &str,
     referrer: &str,
-    asserted_module_type: AssertedModuleType,
+    requested_module_type: RequestedModuleType,
     resolver_handle: v8::Global<v8::PromiseResolver>,
   ) {
     let load = RecursiveModuleLoad::dynamic_import(
       specifier,
       referrer,
-      asserted_module_type.clone(),
+      requested_module_type.clone(),
       self.clone(),
     );
 
@@ -661,7 +663,7 @@ impl ModuleMap {
         if self
           .data
           .borrow()
-          .is_registered(module_specifier, asserted_module_type)
+          .is_registered(module_specifier, requested_module_type)
         {
           async move { (load.id, Ok(load)) }.boxed_local()
         } else {
@@ -1364,8 +1366,8 @@ impl ModuleMap {
     // Check if this module has already been loaded.
     {
       let module_map_data = self.data.borrow();
-      if let Some(id) = module_map_data
-        .get_id(module_specifier, AssertedModuleType::JavaScriptOrWasm)
+      if let Some(id) =
+        module_map_data.get_id(module_specifier, RequestedModuleType::None)
       {
         let handle = module_map_data.get_handle(id).unwrap();
         let handle_local = v8::Local::new(scope, handle);
@@ -1380,7 +1382,11 @@ impl ModuleMap {
       loader.load(&specifier, None, false).await
     })?;
 
-    self.lazy_load_es_module_from_code(scope, module_specifier, source.code)
+    self.lazy_load_es_module_from_code(
+      scope,
+      module_specifier,
+      ModuleSource::get_string_source(specifier.as_str(), source.code)?,
+    )
   }
 }
 
diff --git a/core/modules/mod.rs b/core/modules/mod.rs
index 6271ade..7903af1 100644
--- a/core/modules/mod.rs
+++ b/core/modules/mod.rs
@@ -1,7 +1,9 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use crate::error::AnyError;
 use crate::fast_string::FastString;
 use crate::module_specifier::ModuleSpecifier;
 use anyhow::bail;
+use anyhow::Context;
 use anyhow::Error;
 use serde::Deserialize;
 use serde::Serialize;
@@ -33,6 +35,18 @@ pub(crate) use map::ModuleMap;
 
 pub type ModuleId = usize;
 pub(crate) type ModuleLoadId = i32;
+
+/// The actual source code returned from the loader. Most embedders should
+/// try to return bytes and let deno_core interpret if the module should be
+/// converted to a string or not.
+#[derive(Debug)]
+pub enum ModuleSourceCode {
+  String(ModuleCode),
+  Bytes(Vec<u8>),
+}
+
+// TODO(bartlomieju): maybe remove it? It might be confusing between `ModuleSourceCode`
+// and `ModuleCode`.
 pub type ModuleCode = FastString;
 pub type ModuleName = FastString;
 
@@ -87,34 +101,32 @@ pub(crate) fn validate_import_attributes(
 }
 
 #[derive(Debug)]
-pub(crate) enum ImportAssertionsKind {
+pub(crate) enum ImportAttributesKind {
   StaticImport,
   DynamicImport,
 }
 
-pub(crate) fn parse_import_assertions(
+pub(crate) fn parse_import_attributes(
   scope: &mut v8::HandleScope,
-  import_assertions: v8::Local<v8::FixedArray>,
-  kind: ImportAssertionsKind,
+  attributes: v8::Local<v8::FixedArray>,
+  kind: ImportAttributesKind,
 ) -> HashMap<String, String> {
   let mut assertions: HashMap<String, String> = HashMap::default();
 
   let assertions_per_line = match kind {
     // For static imports, assertions are triples of (keyword, value and source offset)
     // Also used in `module_resolve_callback`.
-    ImportAssertionsKind::StaticImport => 3,
+    ImportAttributesKind::StaticImport => 3,
     // For dynamic imports, assertions are tuples of (keyword, value)
-    ImportAssertionsKind::DynamicImport => 2,
+    ImportAttributesKind::DynamicImport => 2,
   };
-  assert_eq!(import_assertions.length() % assertions_per_line, 0);
-  let no_of_assertions = import_assertions.length() / assertions_per_line;
+  assert_eq!(attributes.length() % assertions_per_line, 0);
+  let no_of_assertions = attributes.length() / assertions_per_line;
 
   for i in 0..no_of_assertions {
-    let assert_key = import_assertions
-      .get(scope, assertions_per_line * i)
-      .unwrap();
+    let assert_key = attributes.get(scope, assertions_per_line * i).unwrap();
     let assert_key_val = v8::Local::<v8::Value>::try_from(assert_key).unwrap();
-    let assert_value = import_assertions
+    let assert_value = attributes
       .get(scope, (assertions_per_line * i) + 1)
       .unwrap();
     let assert_value_val =
@@ -128,19 +140,18 @@ pub(crate) fn parse_import_assertions(
   assertions
 }
 
-pub(crate) fn get_asserted_module_type_from_assertions(
-  assertions: &HashMap<String, String>,
-) -> AssertedModuleType {
-  assertions
-    .get("type")
-    .map(|ty| {
-      if ty == "json" {
-        AssertedModuleType::Json
-      } else {
-        AssertedModuleType::JavaScriptOrWasm
-      }
-    })
-    .unwrap_or(AssertedModuleType::JavaScriptOrWasm)
+pub(crate) fn get_requested_module_type_from_attributes(
+  attributes: &HashMap<String, String>,
+) -> RequestedModuleType {
+  let Some(ty) = attributes.get("type") else {
+    return RequestedModuleType::None;
+  };
+
+  if ty == "json" {
+    RequestedModuleType::Json
+  } else {
+    RequestedModuleType::Other(Cow::Owned(ty.to_string()))
+  }
 }
 
 /// A type of module to be executed.
@@ -183,7 +194,7 @@ impl std::fmt::Display for ModuleType {
 // NOTE: This should _not_ be made #[derive(Clone)] unless we take some precautions to avoid excessive string copying.
 #[derive(Debug)]
 pub struct ModuleSource {
-  pub code: ModuleCode,
+  pub code: ModuleSourceCode,
   pub module_type: ModuleType,
   module_url_specified: ModuleName,
   /// If the module was found somewhere other than the specified address, this will be [`Some`].
@@ -194,7 +205,7 @@ impl ModuleSource {
   /// Create a [`ModuleSource`] without a redirect.
   pub fn new(
     module_type: impl Into<ModuleType>,
-    code: ModuleCode,
+    code: ModuleSourceCode,
     specifier: &ModuleSpecifier,
   ) -> Self {
     let module_url_specified = specifier.as_ref().to_owned().into();
@@ -210,7 +221,7 @@ impl ModuleSource {
   /// specifier, the code behaves the same was as `ModuleSource::new`.
   pub fn new_with_redirect(
     module_type: impl Into<ModuleType>,
-    code: ModuleCode,
+    code: ModuleSourceCode,
     specifier: &ModuleSpecifier,
     specifier_found: &ModuleSpecifier,
   ) -> Self {
@@ -231,7 +242,7 @@ impl ModuleSource {
   #[cfg(test)]
   pub fn for_test(code: &'static str, file: impl AsRef<str>) -> Self {
     Self {
-      code: ModuleCode::from_static(code),
+      code: ModuleSourceCode::String(FastString::from_static(code)),
       module_type: ModuleType::JavaScript,
       module_url_specified: file.as_ref().to_owned().into(),
       module_url_found: None,
@@ -253,12 +264,27 @@ impl ModuleSource {
       Some(found.into())
     };
     Self {
-      code: ModuleCode::from_static(code),
+      code: ModuleSourceCode::String(FastString::from_static(code)),
       module_type: ModuleType::JavaScript,
       module_url_specified: specified.into(),
       module_url_found: found,
     }
   }
+
+  pub fn get_string_source(
+    specifier: &str,
+    code: ModuleSourceCode,
+  ) -> Result<ModuleCode, AnyError> {
+    match code {
+      ModuleSourceCode::String(code) => Ok(code),
+      ModuleSourceCode::Bytes(bytes) => {
+        let str_ = String::from_utf8(bytes).with_context(|| {
+          format!("Can't convert source code to string for {}", specifier)
+        })?;
+        Ok(ModuleCode::from(str_))
+      }
+    }
+  }
 }
 
 pub type ModuleSourceFuture = dyn Future<Output = Result<ModuleSource, Error>>;
@@ -280,10 +306,13 @@ pub enum ResolutionKind {
 
 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
 #[repr(u8)]
-pub(crate) enum AssertedModuleType {
-  /// JavaScript or WASM.
-  JavaScriptOrWasm,
-  /// JSON.
+pub(crate) enum RequestedModuleType {
+  /// There was no attribute specified in the import statement.
+  None,
+
+  /// `type` attribute had value `json`. This is the only known module type
+  /// in `deno_core`. Embedders should use `Other` variant for custom module
+  /// types like `wasm`, `bytes` or `text`.
   Json,
 
   // IMPORTANT: If you add any additional enum values here, you must update `to_v8`` below!
@@ -291,15 +320,15 @@ pub(crate) enum AssertedModuleType {
   Other(Cow<'static, str>),
 }
 
-impl AssertedModuleType {
+impl RequestedModuleType {
   pub fn to_v8<'s>(
     &self,
     scope: &mut v8::HandleScope<'s>,
   ) -> v8::Local<'s, v8::Value> {
     match self {
-      AssertedModuleType::JavaScriptOrWasm => v8::Integer::new(scope, 0).into(),
-      AssertedModuleType::Json => v8::Integer::new(scope, 1).into(),
-      AssertedModuleType::Other(ty) => {
+      RequestedModuleType::None => v8::Integer::new(scope, 0).into(),
+      RequestedModuleType::Json => v8::Integer::new(scope, 1).into(),
+      RequestedModuleType::Other(ty) => {
         v8::String::new(scope, ty).unwrap().into()
       }
     }
@@ -311,46 +340,46 @@ impl AssertedModuleType {
   ) -> Option<Self> {
     Some(if let Some(int) = value.to_integer(scope) {
       match int.int32_value(scope).unwrap_or_default() {
-        0 => AssertedModuleType::JavaScriptOrWasm,
-        1 => AssertedModuleType::Json,
+        0 => RequestedModuleType::None,
+        1 => RequestedModuleType::Json,
         _ => return None,
       }
     } else if let Ok(str) = v8::Local::<v8::String>::try_from(value) {
-      AssertedModuleType::Other(Cow::Owned(str.to_rust_string_lossy(scope)))
+      RequestedModuleType::Other(Cow::Owned(str.to_rust_string_lossy(scope)))
     } else {
       return None;
     })
   }
 }
 
-impl AsRef<AssertedModuleType> for AssertedModuleType {
-  fn as_ref(&self) -> &AssertedModuleType {
+impl AsRef<RequestedModuleType> for RequestedModuleType {
+  fn as_ref(&self) -> &RequestedModuleType {
     self
   }
 }
 
-impl PartialEq<ModuleType> for AssertedModuleType {
+impl PartialEq<ModuleType> for RequestedModuleType {
   fn eq(&self, other: &ModuleType) -> bool {
     match other {
-      ModuleType::JavaScript => self == &AssertedModuleType::JavaScriptOrWasm,
-      ModuleType::Json => self == &AssertedModuleType::Json,
+      ModuleType::JavaScript => self == &RequestedModuleType::None,
+      ModuleType::Json => self == &RequestedModuleType::Json,
     }
   }
 }
 
-impl From<ModuleType> for AssertedModuleType {
-  fn from(module_type: ModuleType) -> AssertedModuleType {
+impl From<ModuleType> for RequestedModuleType {
+  fn from(module_type: ModuleType) -> RequestedModuleType {
     match module_type {
-      ModuleType::JavaScript => AssertedModuleType::JavaScriptOrWasm,
-      ModuleType::Json => AssertedModuleType::Json,
+      ModuleType::JavaScript => RequestedModuleType::None,
+      ModuleType::Json => RequestedModuleType::Json,
     }
   }
 }
 
-impl std::fmt::Display for AssertedModuleType {
+impl std::fmt::Display for RequestedModuleType {
   fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
     match self {
-      Self::JavaScriptOrWasm => write!(f, "JavaScriptOrWasm"),
+      Self::None => write!(f, "None"),
       Self::Json => write!(f, "JSON"),
       Self::Other(ty) => write!(f, "Other({ty})"),
     }
@@ -360,11 +389,11 @@ impl std::fmt::Display for AssertedModuleType {
 /// Describes a request for a module as parsed from the source code.
 /// Usually executable (`JavaScriptOrWasm`) is used, except when an
 /// import assertions explicitly constrains an import to JSON, in
-/// which case this will have a `AssertedModuleType::Json`.
+/// which case this will have a `RequestedModuleType::Json`.
 #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
 pub(crate) struct ModuleRequest {
   pub specifier: String,
-  pub asserted_module_type: AssertedModuleType,
+  pub requested_module_type: RequestedModuleType,
 }
 
 #[derive(Debug, PartialEq)]
@@ -374,7 +403,7 @@ pub(crate) struct ModuleInfo {
   pub main: bool,
   pub name: ModuleName,
   pub requests: Vec<ModuleRequest>,
-  pub module_type: AssertedModuleType,
+  pub module_type: RequestedModuleType,
 }
 
 #[derive(Debug)]
diff --git a/core/modules/module_map_data.rs b/core/modules/module_map_data.rs
index 63a75e6..4482d5c 100644
--- a/core/modules/module_map_data.rs
+++ b/core/modules/module_map_data.rs
@@ -1,5 +1,5 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-use super::AssertedModuleType;
+use super::RequestedModuleType;
 use crate::fast_string::FastString;
 use crate::modules::ModuleId;
 use crate::modules::ModuleInfo;
@@ -24,10 +24,10 @@ pub(crate) enum SymbolicModule {
   Mod(ModuleId),
 }
 
-/// Map of [`ModuleName`] and [`AssertedModuleType`] to a data field.
+/// Map of [`ModuleName`] and [`RequestedModuleType`] to a data field.
 struct ModuleNameTypeMap<T> {
   submaps: Vec<HashMap<ModuleName, T>>,
-  map_index: HashMap<AssertedModuleType, usize>,
+  map_index: HashMap<RequestedModuleType, usize>,
   len: usize,
 }
 
@@ -46,11 +46,11 @@ impl<T> ModuleNameTypeMap<T> {
     self.len
   }
 
-  fn map_index(&self, ty: &AssertedModuleType) -> Option<usize> {
+  fn map_index(&self, ty: &RequestedModuleType) -> Option<usize> {
     self.map_index.get(ty).copied()
   }
 
-  pub fn get<Q>(&self, ty: &AssertedModuleType, name: &Q) -> Option<&T>
+  pub fn get<Q>(&self, ty: &RequestedModuleType, name: &Q) -> Option<&T>
   where
     ModuleName: std::borrow::Borrow<Q>,
     Q: std::cmp::Eq + std::hash::Hash + ?Sized,
@@ -72,7 +72,7 @@ impl<T> ModuleNameTypeMap<T> {
 
   pub fn insert(
     &mut self,
-    module_type: &AssertedModuleType,
+    module_type: &RequestedModuleType,
     name: FastString,
     module: T,
   ) {
@@ -101,7 +101,7 @@ impl<T> ModuleNameTypeMap<T> {
   /// doesn't have generators.
   pub fn walk(
     &self,
-    mut f: impl FnMut(usize, &AssertedModuleType, &ModuleName, &T),
+    mut f: impl FnMut(usize, &RequestedModuleType, &ModuleName, &T),
   ) {
     let mut i = 0;
     for (ty, value) in self.map_index.iter() {
@@ -172,18 +172,18 @@ impl ModuleMapData {
   pub fn get_id(
     &self,
     name: impl AsRef<str>,
-    asserted_module_type: impl AsRef<AssertedModuleType>,
+    requested_module_type: impl AsRef<RequestedModuleType>,
   ) -> Option<ModuleId> {
     let map = &self.by_name;
     let first_symbolic_module =
-      map.get(asserted_module_type.as_ref(), name.as_ref())?;
+      map.get(requested_module_type.as_ref(), name.as_ref())?;
     let mut mod_name = match first_symbolic_module {
       SymbolicModule::Mod(mod_id) => return Some(*mod_id),
       SymbolicModule::Alias(target) => target,
     };
     loop {
       let symbolic_module =
-        map.get(asserted_module_type.as_ref(), mod_name.as_ref())?;
+        map.get(requested_module_type.as_ref(), mod_name.as_ref())?;
       match symbolic_module {
         SymbolicModule::Alias(target) => {
           debug_assert!(mod_name != target);
@@ -197,22 +197,22 @@ impl ModuleMapData {
   pub fn is_registered(
     &self,
     specifier: impl AsRef<str>,
-    asserted_module_type: impl AsRef<AssertedModuleType>,
+    requested_module_type: impl AsRef<RequestedModuleType>,
   ) -> bool {
     self
-      .get_id(specifier.as_ref(), asserted_module_type.as_ref())
+      .get_id(specifier.as_ref(), requested_module_type.as_ref())
       .is_some()
   }
 
   pub(crate) fn alias(
     &mut self,
     name: FastString,
-    asserted_module_type: &AssertedModuleType,
+    requested_module_type: &RequestedModuleType,
     target: FastString,
   ) {
     debug_assert_ne!(name, target);
     self.by_name.insert(
-      asserted_module_type,
+      requested_module_type,
       name,
       SymbolicModule::Alias(target),
     );
@@ -222,10 +222,10 @@ impl ModuleMapData {
   pub(crate) fn is_alias(
     &self,
     name: &str,
-    asserted_module_type: impl AsRef<AssertedModuleType>,
+    requested_module_type: impl AsRef<RequestedModuleType>,
   ) -> bool {
     let map = &self.by_name;
-    let entry = map.get(asserted_module_type.as_ref(), name);
+    let entry = map.get(requested_module_type.as_ref(), name);
     matches!(entry, Some(SymbolicModule::Alias(_)))
   }
 
@@ -294,7 +294,7 @@ impl ModuleMapData {
         )
         .unwrap();
         requests_arr.set_index(scope, 2 * i as u32, specifier.into());
-        let value = request.asserted_module_type.to_v8(scope);
+        let value = request.requested_module_type.to_v8(scope);
         requests_arr.set_index(scope, (2 * i) as u32 + 1, value);
       }
       module_info_arr.set_index(scope, 2, requests_arr.into());
@@ -413,17 +413,17 @@ impl ModuleMapData {
             .to_rust_string_lossy(scope);
           let value =
             requests_arr.get_index(scope, (2 * i + 1) as u32).unwrap();
-          let asserted_module_type =
-            AssertedModuleType::try_from_v8(scope, value).unwrap();
+          let requested_module_type =
+            RequestedModuleType::try_from_v8(scope, value).unwrap();
           requests.push(ModuleRequest {
             specifier,
-            asserted_module_type,
+            requested_module_type,
           });
         }
 
         let value = module_info_arr.get_index(scope, 3).unwrap();
         let module_type =
-          AssertedModuleType::try_from_v8(scope, value).unwrap();
+          RequestedModuleType::try_from_v8(scope, value).unwrap();
 
         let main = self.main_module_id == Some(id);
         let module_info = ModuleInfo {
@@ -455,15 +455,15 @@ impl ModuleMapData {
 
         let specifier =
           arr.get_index(scope, 0).unwrap().to_rust_string_lossy(scope);
-        let asserted_module_type = match arr
+        let requested_module_type = match arr
           .get_index(scope, 1)
           .unwrap()
           .to_integer(scope)
           .unwrap()
           .value()
         {
-          0 => AssertedModuleType::JavaScriptOrWasm,
-          1 => AssertedModuleType::Json,
+          0 => RequestedModuleType::None,
+          1 => RequestedModuleType::Json,
           _ => unreachable!(),
         };
 
@@ -485,7 +485,7 @@ impl ModuleMapData {
 
         self
           .by_name
-          .insert(&asserted_module_type, specifier.into(), val);
+          .insert(&requested_module_type, specifier.into(), val);
       }
     }
 
diff --git a/core/modules/recursive_load.rs b/core/modules/recursive_load.rs
index 685c188..8cb02a3 100644
--- a/core/modules/recursive_load.rs
+++ b/core/modules/recursive_load.rs
@@ -2,11 +2,11 @@
 use crate::error::generic_error;
 use crate::module_specifier::ModuleSpecifier;
 use crate::modules::map::ModuleMap;
-use crate::modules::AssertedModuleType;
 use crate::modules::ModuleError;
 use crate::modules::ModuleId;
 use crate::modules::ModuleLoadId;
 use crate::modules::ModuleRequest;
+use crate::modules::RequestedModuleType;
 use crate::modules::ResolutionKind;
 use crate::resolve_url;
 use crate::ModuleLoader;
@@ -37,7 +37,7 @@ enum LoadInit {
   Side(String),
   /// Dynamic import specifier with referrer and expected
   /// module type (which is determined by import assertion).
-  DynamicImport(String, String, AssertedModuleType),
+  DynamicImport(String, String, RequestedModuleType),
 }
 
 #[derive(Debug, Eq, PartialEq)]
@@ -53,7 +53,7 @@ pub(crate) struct RecursiveModuleLoad {
   pub id: ModuleLoadId,
   pub root_module_id: Option<ModuleId>,
   init: LoadInit,
-  root_asserted_module_type: Option<AssertedModuleType>,
+  root_asserted_module_type: Option<RequestedModuleType>,
   state: LoadState,
   module_map_rc: Rc<ModuleMap>,
   pending: FuturesUnordered<Pin<Box<ModuleLoadFuture>>>,
@@ -83,14 +83,14 @@ impl RecursiveModuleLoad {
   pub(crate) fn dynamic_import(
     specifier: &str,
     referrer: &str,
-    asserted_module_type: AssertedModuleType,
+    requested_module_type: RequestedModuleType,
     module_map_rc: Rc<ModuleMap>,
   ) -> Self {
     Self::new(
       LoadInit::DynamicImport(
         specifier.to_string(),
         referrer.to_string(),
-        asserted_module_type,
+        requested_module_type,
       ),
       module_map_rc,
     )
@@ -99,9 +99,9 @@ impl RecursiveModuleLoad {
   fn new(init: LoadInit, module_map_rc: Rc<ModuleMap>) -> Self {
     let id = module_map_rc.next_load_id();
     let loader = module_map_rc.loader.borrow().clone();
-    let asserted_module_type = match &init {
+    let requested_module_type = match &init {
       LoadInit::DynamicImport(_, _, module_type) => module_type.clone(),
-      _ => AssertedModuleType::JavaScriptOrWasm,
+      _ => RequestedModuleType::None,
     };
     let mut load = Self {
       id,
@@ -119,10 +119,10 @@ impl RecursiveModuleLoad {
     // Ignore the error here, let it be hit in `Stream::poll_next()`.
     if let Ok(root_specifier) = load.resolve_root() {
       if let Some(module_id) =
-        module_map_rc.get_id(root_specifier, &asserted_module_type)
+        module_map_rc.get_id(root_specifier, &requested_module_type)
       {
         load.root_module_id = Some(module_id);
-        load.root_asserted_module_type = Some(asserted_module_type);
+        load.root_asserted_module_type = Some(requested_module_type);
       }
     }
     load
@@ -195,11 +195,11 @@ impl RecursiveModuleLoad {
     module_request: &ModuleRequest,
     module_source: ModuleSource,
   ) -> Result<(), ModuleError> {
-    let asserted_module_type = module_request.asserted_module_type.clone();
-    if asserted_module_type != module_source.module_type {
+    let requested_module_type = module_request.requested_module_type.clone();
+    if requested_module_type != module_source.module_type {
       return Err(ModuleError::Other(generic_error(format!(
         "Expected a \"{}\" module but loaded a \"{}\" module.",
-        asserted_module_type, module_source.module_type,
+        requested_module_type, module_source.module_type,
       ))));
     }
 
@@ -215,7 +215,7 @@ impl RecursiveModuleLoad {
     // Update `self.state` however applicable.
     if self.state == LoadState::LoadingRoot {
       self.root_module_id = Some(module_id);
-      self.root_asserted_module_type = Some(asserted_module_type);
+      self.root_asserted_module_type = Some(requested_module_type);
       self.state = LoadState::LoadingImports;
     }
     if self.pending.is_empty() {
@@ -258,7 +258,7 @@ impl RecursiveModuleLoad {
         {
           if let Some(module_id) = self.module_map_rc.get_id(
             module_request.specifier.as_str(),
-            &module_request.asserted_module_type,
+            &module_request.requested_module_type,
           ) {
             already_registered.push_back((module_id, module_request.clone()));
           } else {
@@ -314,13 +314,13 @@ impl Stream for RecursiveModuleLoad {
           Ok(url) => url,
           Err(error) => return Poll::Ready(Some(Err(error))),
         };
-        let asserted_module_type = match &inner.init {
+        let requested_module_type = match &inner.init {
           LoadInit::DynamicImport(_, _, module_type) => module_type.clone(),
-          _ => AssertedModuleType::JavaScriptOrWasm,
+          _ => RequestedModuleType::None,
         };
         let module_request = ModuleRequest {
           specifier: module_specifier.to_string(),
-          asserted_module_type,
+          requested_module_type,
         };
         let load_fut = if let Some(module_id) = inner.root_module_id {
           // If the inner future is already in the map, we might be done (assuming there are no pending
diff --git a/core/ops.rs b/core/ops.rs
index eb31761..81f5b14 100644
--- a/core/ops.rs
+++ b/core/ops.rs
@@ -9,9 +9,7 @@ use crate::runtime::ContextState;
 use crate::runtime::JsRuntimeState;
 use crate::FeatureChecker;
 use crate::OpDecl;
-use anyhow::Error;
 use futures::task::AtomicWaker;
-use serde::Serialize;
 use std::cell::RefCell;
 use std::cell::UnsafeCell;
 use std::ops::Deref;
@@ -25,7 +23,6 @@ use v8::Isolate;
 
 pub type PromiseId = i32;
 pub type OpId = u16;
-pub struct PendingOp(pub PromiseId, pub OpId, pub OpResult, pub bool);
 
 #[cfg(debug_assertions)]
 thread_local! {
@@ -58,53 +55,6 @@ pub fn reentrancy_check(decl: &'static OpDecl) -> Option<ReentrancyGuard> {
   Some(ReentrancyGuard {})
 }
 
-#[allow(clippy::type_complexity)]
-pub enum OpResult {
-  Ok(serde_v8::SerializablePkg),
-  Err(OpError),
-  /// We temporarily provide a mapping function in a box for op2. This will go away when op goes away.
-  Op2Temp(
-    Box<
-      dyn for<'a> FnOnce(
-        &mut v8::HandleScope<'a>,
-      )
-        -> Result<v8::Local<'a, v8::Value>, serde_v8::Error>,
-    >,
-  ),
-}
-
-impl OpResult {
-  pub fn to_v8<'a>(
-    self,
-    scope: &mut v8::HandleScope<'a>,
-  ) -> Result<v8::Local<'a, v8::Value>, serde_v8::Error> {
-    match self {
-      Self::Ok(mut x) => x.to_v8(scope),
-      Self::Err(err) => serde_v8::to_v8(scope, err),
-      Self::Op2Temp(f) => f(scope),
-    }
-  }
-}
-
-#[derive(Debug, Serialize)]
-#[serde(rename_all = "camelCase")]
-pub struct OpError {
-  #[serde(rename = "$err_class_name")]
-  class_name: &'static str,
-  message: String,
-  code: Option<&'static str>,
-}
-
-impl OpError {
-  pub fn new(get_class: GetErrorClassFn, err: Error) -> Self {
-    Self {
-      class_name: (get_class)(&err),
-      message: format!("{err:#}"),
-      code: crate::error_codes::get_error_code(&err),
-    }
-  }
-}
-
 /// Per-op context.
 ///
 // Note: We don't worry too much about the size of this struct because it's allocated once per realm, and is
@@ -192,6 +142,7 @@ impl OpCtx {
     &self.decl
   }
 
+  #[inline(always)]
   pub fn metrics_enabled(&self) -> bool {
     self.metrics_fn.is_some()
   }
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index 4cca5bb..3141fd6 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -5,6 +5,7 @@ use crate::error::type_error;
 use crate::io::BufMutView;
 use crate::io::BufView;
 use crate::op2;
+use crate::ops_builtin_types;
 use crate::ops_builtin_v8;
 use crate::resources::ResourceId;
 use crate::JsBuffer;
@@ -43,8 +44,36 @@ deno_core::extension!(
     op_write_type_error,
     op_shutdown,
     op_format_file_name,
-    op_is_proxy,
     op_str_byte_length,
+    op_panic,
+    ops_builtin_types::op_is_any_array_buffer,
+    ops_builtin_types::op_is_arguments_object,
+    ops_builtin_types::op_is_array_buffer,
+    ops_builtin_types::op_is_array_buffer_view,
+    ops_builtin_types::op_is_async_function,
+    ops_builtin_types::op_is_big_int_object,
+    ops_builtin_types::op_is_boolean_object,
+    ops_builtin_types::op_is_boxed_primitive,
+    ops_builtin_types::op_is_data_view,
+    ops_builtin_types::op_is_date,
+    ops_builtin_types::op_is_generator_function,
+    ops_builtin_types::op_is_generator_object,
+    ops_builtin_types::op_is_map,
+    ops_builtin_types::op_is_map_iterator,
+    ops_builtin_types::op_is_module_namespace_object,
+    ops_builtin_types::op_is_native_error,
+    ops_builtin_types::op_is_number_object,
+    ops_builtin_types::op_is_promise,
+    ops_builtin_types::op_is_proxy,
+    ops_builtin_types::op_is_reg_exp,
+    ops_builtin_types::op_is_set,
+    ops_builtin_types::op_is_set_iterator,
+    ops_builtin_types::op_is_shared_array_buffer,
+    ops_builtin_types::op_is_string_object,
+    ops_builtin_types::op_is_symbol_object,
+    ops_builtin_types::op_is_typed_array,
+    ops_builtin_types::op_is_weak_map,
+    ops_builtin_types::op_is_weak_set,
     ops_builtin_v8::op_timer_queue,
     ops_builtin_v8::op_timer_cancel,
     ops_builtin_v8::op_timer_ref,
@@ -82,6 +111,12 @@ deno_core::extension!(
   ],
 );
 
+#[op2(fast)]
+pub fn op_panic(#[string] message: String) {
+  eprintln!("JS PANIC: {}", message);
+  panic!("JS PANIC: {}", message);
+}
+
 /// Return map of resources with id as key
 /// and string representation as value.
 #[op2]
@@ -319,11 +354,6 @@ fn op_format_file_name(#[string] file_name: &str) -> String {
   format_file_name(file_name)
 }
 
-#[op2(fast)]
-fn op_is_proxy(value: v8::Local<v8::Value>) -> bool {
-  value.is_proxy()
-}
-
 #[op2]
 fn op_str_byte_length(
   scope: &mut v8::HandleScope,
diff --git a/core/ops_builtin_types.rs b/core/ops_builtin_types.rs
new file mode 100644
index 0000000..608ae88
--- /dev/null
+++ b/core/ops_builtin_types.rs
@@ -0,0 +1,146 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use crate::op2;
+
+#[op2(fast)]
+pub fn op_is_any_array_buffer(value: &v8::Value) -> bool {
+  value.is_array_buffer() || value.is_shared_array_buffer()
+}
+
+#[op2(fast)]
+pub fn op_is_arguments_object(value: &v8::Value) -> bool {
+  value.is_arguments_object()
+}
+
+#[op2(fast)]
+pub fn op_is_array_buffer(value: &v8::Value) -> bool {
+  value.is_array_buffer()
+}
+
+#[op2(fast)]
+pub fn op_is_array_buffer_view(value: &v8::Value) -> bool {
+  value.is_array_buffer_view()
+}
+
+#[op2(fast)]
+pub fn op_is_async_function(value: &v8::Value) -> bool {
+  value.is_async_function()
+}
+
+#[op2(fast)]
+pub fn op_is_big_int_object(value: &v8::Value) -> bool {
+  value.is_big_int_object()
+}
+
+#[op2(fast)]
+pub fn op_is_boolean_object(value: &v8::Value) -> bool {
+  value.is_boolean_object()
+}
+
+#[op2(fast)]
+pub fn op_is_boxed_primitive(value: &v8::Value) -> bool {
+  value.is_boolean_object()
+    || value.is_string_object()
+    || value.is_number_object()
+    || value.is_symbol_object()
+    || value.is_big_int_object()
+}
+
+#[op2(fast)]
+pub fn op_is_data_view(value: &v8::Value) -> bool {
+  value.is_data_view()
+}
+
+#[op2(fast)]
+pub fn op_is_date(value: &v8::Value) -> bool {
+  value.is_date()
+}
+
+#[op2(fast)]
+pub fn op_is_generator_function(value: &v8::Value) -> bool {
+  value.is_generator_function()
+}
+
+#[op2(fast)]
+pub fn op_is_generator_object(value: &v8::Value) -> bool {
+  value.is_generator_object()
+}
+
+#[op2(fast)]
+pub fn op_is_map(value: &v8::Value) -> bool {
+  value.is_map()
+}
+
+#[op2(fast)]
+pub fn op_is_map_iterator(value: &v8::Value) -> bool {
+  value.is_map_iterator()
+}
+
+#[op2(fast)]
+pub fn op_is_module_namespace_object(value: &v8::Value) -> bool {
+  value.is_module_namespace_object()
+}
+
+#[op2(fast)]
+pub fn op_is_native_error(value: &v8::Value) -> bool {
+  value.is_native_error()
+}
+
+#[op2(fast)]
+pub fn op_is_number_object(value: &v8::Value) -> bool {
+  value.is_number_object()
+}
+
+#[op2(fast)]
+pub fn op_is_promise(value: &v8::Value) -> bool {
+  value.is_promise()
+}
+
+#[op2(fast)]
+pub fn op_is_proxy(value: &v8::Value) -> bool {
+  value.is_proxy()
+}
+
+#[op2(fast)]
+pub fn op_is_reg_exp(value: &v8::Value) -> bool {
+  value.is_reg_exp()
+}
+
+#[op2(fast)]
+pub fn op_is_set(value: &v8::Value) -> bool {
+  value.is_set()
+}
+
+#[op2(fast)]
+pub fn op_is_set_iterator(value: &v8::Value) -> bool {
+  value.is_set_iterator()
+}
+
+#[op2(fast)]
+pub fn op_is_shared_array_buffer(value: &v8::Value) -> bool {
+  value.is_shared_array_buffer()
+}
+
+#[op2(fast)]
+pub fn op_is_string_object(value: &v8::Value) -> bool {
+  value.is_string_object()
+}
+
+#[op2(fast)]
+pub fn op_is_symbol_object(value: &v8::Value) -> bool {
+  value.is_symbol_object()
+}
+
+#[op2(fast)]
+pub fn op_is_typed_array(value: &v8::Value) -> bool {
+  value.is_typed_array()
+}
+
+#[op2(fast)]
+pub fn op_is_weak_map(value: &v8::Value) -> bool {
+  value.is_weak_map()
+}
+
+#[op2(fast)]
+pub fn op_is_weak_set(value: &v8::Value) -> bool {
+  value.is_weak_set()
+}
diff --git a/core/runtime/bindings.rs b/core/runtime/bindings.rs
index 47e463d..19bc6fb 100644
--- a/core/runtime/bindings.rs
+++ b/core/runtime/bindings.rs
@@ -9,9 +9,9 @@ use crate::error::has_call_site;
 use crate::error::is_instance_of_error;
 use crate::error::throw_type_error;
 use crate::error::JsStackFrame;
-use crate::modules::get_asserted_module_type_from_assertions;
-use crate::modules::parse_import_assertions;
-use crate::modules::ImportAssertionsKind;
+use crate::modules::get_requested_module_type_from_attributes;
+use crate::modules::parse_import_attributes;
+use crate::modules::ImportAttributesKind;
 use crate::modules::ModuleMap;
 use crate::ops::OpCtx;
 use crate::runtime::InitMode;
@@ -266,7 +266,7 @@ pub fn host_import_module_dynamically_callback<'s>(
   _host_defined_options: v8::Local<'s, v8::Data>,
   resource_name: v8::Local<'s, v8::Value>,
   specifier: v8::Local<'s, v8::String>,
-  import_assertions: v8::Local<'s, v8::FixedArray>,
+  import_attributes: v8::Local<'s, v8::FixedArray>,
 ) -> Option<v8::Local<'s, v8::Promise>> {
   // NOTE(bartlomieju): will crash for non-UTF-8 specifier
   let specifier_str = specifier
@@ -281,10 +281,10 @@ pub fn host_import_module_dynamically_callback<'s>(
   let resolver = v8::PromiseResolver::new(scope).unwrap();
   let promise = resolver.get_promise(scope);
 
-  let assertions = parse_import_assertions(
+  let assertions = parse_import_attributes(
     scope,
-    import_assertions,
-    ImportAssertionsKind::DynamicImport,
+    import_attributes,
+    ImportAttributesKind::DynamicImport,
   );
 
   {
@@ -299,8 +299,8 @@ pub fn host_import_module_dynamically_callback<'s>(
       resolver.reject(tc_scope, e);
     }
   }
-  let asserted_module_type =
-    get_asserted_module_type_from_assertions(&assertions);
+  let requested_module_type =
+    get_requested_module_type_from_attributes(&assertions);
 
   let resolver_handle = v8::Global::new(scope, resolver);
   {
@@ -315,7 +315,7 @@ pub fn host_import_module_dynamically_callback<'s>(
       module_map_rc,
       &specifier_str,
       &referrer_name_str,
-      asserted_module_type,
+      requested_module_type,
       resolver_handle,
     );
     state.notify_new_dynamic_import();
@@ -564,7 +564,7 @@ where
   .data(external.into())
   .build(scope);
 
-  let on_rejected: Option<v8::Local<'_, v8::Function>> = v8::Function::builder(
+  let on_rejected = v8::Function::builder(
     |scope: &mut v8::HandleScope,
      args: v8::FunctionCallbackArguments,
      rv: v8::ReturnValue| {
diff --git a/core/runtime/jsrealm.rs b/core/runtime/jsrealm.rs
index 517d8bb..dcf3f3e 100644
--- a/core/runtime/jsrealm.rs
+++ b/core/runtime/jsrealm.rs
@@ -1,6 +1,7 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 use super::bindings;
 use super::exception_state::ExceptionState;
+use super::op_driver::OpDriver;
 use crate::error::exception_to_err_result;
 use crate::module_specifier::ModuleSpecifier;
 use crate::modules::ModuleCode;
@@ -8,11 +9,9 @@ use crate::modules::ModuleError;
 use crate::modules::ModuleId;
 use crate::modules::ModuleMap;
 use crate::ops::OpCtx;
-use crate::ops::PendingOp;
 use crate::tasks::V8TaskSpawnerFactory;
 use crate::web_timeout::WebTimers;
 use anyhow::Error;
-use deno_unsync::JoinSet;
 use futures::stream::StreamExt;
 use std::cell::Cell;
 use std::cell::RefCell;
@@ -45,8 +44,13 @@ impl Hasher for IdentityHasher {
   }
 }
 
+/// We will be experimenting with different driver types in the future. This allows us to
+/// swap the driver out for experimentation.
+#[cfg(feature = "op_driver_joinset")]
+type DefaultOpDriver = super::op_driver::JoinSetDriver;
+
 #[derive(Default)]
-pub(crate) struct ContextState {
+pub(crate) struct ContextState<OpDriverImpl: OpDriver = DefaultOpDriver> {
   pub(crate) task_spawner_factory: Arc<V8TaskSpawnerFactory>,
   pub(crate) timers: WebTimers<(v8::Global<v8::Function>, u32)>,
   pub(crate) js_event_loop_tick_cb:
@@ -55,7 +59,7 @@ pub(crate) struct ContextState {
     RefCell<Option<Rc<v8::Global<v8::Function>>>>,
   pub(crate) unrefed_ops:
     RefCell<HashSet<i32, BuildHasherDefault<IdentityHasher>>>,
-  pub(crate) pending_ops: RefCell<JoinSet<PendingOp>>,
+  pub(crate) pending_ops: OpDriverImpl,
   // We don't explicitly re-read this prop but need the slice to live alongside
   // the context
   pub(crate) op_ctxs: RefCell<Box<[OpCtx]>>,
@@ -194,7 +198,7 @@ impl JsRealm {
   #[cfg(test)]
   #[inline(always)]
   pub fn num_pending_ops(&self) -> usize {
-    self.0.context_state.pending_ops.borrow().len()
+    self.0.context_state.pending_ops.len()
   }
 
   #[cfg(test)]
diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs
index 4705384..7475eac 100644
--- a/core/runtime/jsruntime.rs
+++ b/core/runtime/jsruntime.rs
@@ -3,6 +3,7 @@ use super::bindings;
 use super::bindings::watch_promise;
 use super::exception_state::ExceptionState;
 use super::jsrealm::JsRealmInner;
+use super::op_driver::OpDriver;
 use super::snapshot_util;
 use crate::error::exception_to_err_result;
 use crate::error::AnyError;
@@ -15,17 +16,16 @@ use crate::include_js_files;
 use crate::inspector::JsRuntimeInspector;
 use crate::module_specifier::ModuleSpecifier;
 use crate::modules::default_import_meta_resolve_cb;
-use crate::modules::AssertedModuleType;
 use crate::modules::ExtModuleLoader;
 use crate::modules::ImportMetaResolveCallback;
 use crate::modules::ModuleCode;
 use crate::modules::ModuleId;
 use crate::modules::ModuleLoader;
 use crate::modules::ModuleMap;
+use crate::modules::RequestedModuleType;
 use crate::modules::ValidateImportAttributesCb;
 use crate::ops::*;
 use crate::ops_metrics::dispatch_metrics_async;
-use crate::ops_metrics::OpMetricsEvent;
 use crate::ops_metrics::OpMetricsFactoryFn;
 use crate::runtime::ContextState;
 use crate::runtime::JsRealm;
@@ -35,8 +35,8 @@ use crate::Extension;
 use crate::ExtensionFileSource;
 use crate::FeatureChecker;
 use crate::NoopModuleLoader;
+use crate::OpMetricsEvent;
 use crate::OpMiddlewareFn;
-use crate::OpResult;
 use crate::OpState;
 use crate::V8_WRAPPER_OBJECT_INDEX;
 use crate::V8_WRAPPER_TYPE_INDEX;
@@ -1015,7 +1015,7 @@ impl JsRuntime {
       for specifier in esm_entrypoints {
         let mod_id = {
           module_map
-            .get_id(specifier, AssertedModuleType::JavaScriptOrWasm)
+            .get_id(specifier, RequestedModuleType::None)
             .unwrap_or_else(|| {
               panic!("{} not present in the module map", specifier)
             })
@@ -1661,6 +1661,7 @@ impl JsRuntime {
     scope: &mut v8::HandleScope,
     poll_options: PollEventLoopOptions,
   ) -> Poll<Result<(), Error>> {
+    eprintln!("looping");
     let has_inspector = self.inner.state.has_inspector.get();
     self.inner.state.waker.register(cx.waker());
 
@@ -1902,7 +1903,7 @@ impl EventLoopPendingState {
     modules: &ModuleMap,
   ) -> Self {
     let num_unrefed_ops = state.unrefed_ops.borrow().len();
-    let num_pending_ops = state.pending_ops.borrow().len();
+    let num_pending_ops = state.pending_ops.len();
     let has_pending_tasks = state.task_spawner_factory.has_pending_tasks();
     let has_pending_timers = state.timers.has_pending_timers();
     let has_pending_dyn_imports = modules.has_pending_dynamic_imports();
@@ -2120,20 +2121,14 @@ impl JsRuntime {
       SmallVec::with_capacity(32);
 
     loop {
-      let Poll::Ready(item) =
-        context_state.pending_ops.borrow_mut().poll_join_next(cx)
+      let Poll::Ready((promise_id, op_id, metrics_event, res)) =
+        context_state.pending_ops.poll_ready(cx, scope)
       else {
         break;
       };
-      // TODO(mmastrac): If this task is really errored, things could be pretty bad
-      let PendingOp(promise_id, op_id, resp, metrics_event) = item.unwrap();
-      context_state.unrefed_ops.borrow_mut().remove(&promise_id);
-      dispatched_ops |= true;
-      args.push(v8::Integer::new(scope, promise_id).into());
-      let was_error = matches!(resp, OpResult::Err(_));
-      let res = resp.to_v8(scope);
+
       if metrics_event {
-        if res.is_ok() && !was_error {
+        if res.is_ok() {
           dispatch_metrics_async(
             &context_state.op_ctxs.borrow()[op_id as usize],
             OpMetricsEvent::CompletedAsync,
@@ -2145,12 +2140,11 @@ impl JsRuntime {
           );
         }
       }
-      args.push(match res {
-        Ok(v) => v,
-        Err(e) => OpResult::Err(OpError::new(&|_| "TypeError", e.into()))
-          .to_v8(scope)
-          .unwrap(),
-      });
+
+      context_state.unrefed_ops.borrow_mut().remove(&promise_id);
+      dispatched_ops |= true;
+      args.push(v8::Integer::new(scope, promise_id).into());
+      args.push(res.unwrap_or_else(std::convert::identity));
     }
 
     let undefined: v8::Local<v8::Value> = v8::undefined(scope).into();
diff --git a/core/runtime/mod.rs b/core/runtime/mod.rs
index fd185d3..9560b5c 100644
--- a/core/runtime/mod.rs
+++ b/core/runtime/mod.rs
@@ -3,6 +3,7 @@ pub(crate) mod bindings;
 pub(crate) mod exception_state;
 mod jsrealm;
 mod jsruntime;
+pub mod op_driver;
 #[doc(hidden)]
 pub mod ops;
 pub mod ops_rust_to_v8;
diff --git a/core/runtime/op_driver/erased_future.rs b/core/runtime/op_driver/erased_future.rs
new file mode 100644
index 0000000..9d1498f
--- /dev/null
+++ b/core/runtime/op_driver/erased_future.rs
@@ -0,0 +1,185 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use std::future::Future;
+use std::marker::PhantomData;
+use std::marker::PhantomPinned;
+use std::mem::MaybeUninit;
+use std::pin::Pin;
+use std::task::Context;
+use std::task::Poll;
+
+#[repr(C, align(16))]
+pub struct TypeErased<const MAX_SIZE: usize> {
+  memory: [MaybeUninit<u8>; MAX_SIZE],
+  drop: fn(this: *mut ()),
+  _unpin: PhantomPinned,
+}
+
+impl<const MAX_SIZE: usize> TypeErased<MAX_SIZE> {
+  pub unsafe fn take<R: 'static>(self) -> R {
+    assert!(
+      std::mem::size_of::<R>() <= std::mem::size_of_val(&self.memory),
+      "Invalid size for {}: {} (max {})",
+      std::any::type_name::<R>(),
+      std::mem::size_of::<R>(),
+      std::mem::size_of_val(&self.memory)
+    );
+    assert!(
+      std::mem::align_of::<R>() <= std::mem::align_of_val(&self),
+      "Invalid alignment for {}: {} (max {})",
+      std::any::type_name::<R>(),
+      std::mem::align_of::<R>(),
+      std::mem::align_of_val(&self)
+    );
+    let r = std::ptr::read(self.memory.as_ptr() as _);
+    std::mem::forget(self);
+    r
+  }
+
+  pub fn raw_ptr(&mut self) -> *mut () {
+    self.memory.as_mut_ptr() as _
+  }
+
+  pub fn new<R>(r: R) -> Self {
+    let mut new = Self {
+      memory: [MaybeUninit::uninit(); MAX_SIZE],
+      drop: |this| unsafe { std::ptr::drop_in_place::<R>(this as _) },
+      _unpin: PhantomPinned,
+    };
+    assert!(
+      std::mem::size_of::<R>() <= std::mem::size_of_val(&new.memory),
+      "Invalid size for {}: {} (max {})",
+      std::any::type_name::<R>(),
+      std::mem::size_of::<R>(),
+      std::mem::size_of_val(&new.memory)
+    );
+    assert!(
+      std::mem::align_of::<R>() <= std::mem::align_of_val(&new),
+      "Invalid alignment for {}: {} (max {})",
+      std::any::type_name::<R>(),
+      std::mem::align_of::<R>(),
+      std::mem::align_of_val(&new),
+    );
+    unsafe { std::ptr::write(new.memory.as_mut_ptr() as *mut R, r) };
+    new
+  }
+}
+
+impl<const MAX_SIZE: usize> Drop for TypeErased<MAX_SIZE> {
+  fn drop(&mut self) {
+    (self.drop)(self.raw_ptr())
+  }
+}
+
+pub struct ErasedFuture<const MAX_SIZE: usize, Output> {
+  erased: TypeErased<MAX_SIZE>,
+  poll: unsafe fn(
+    this: Pin<&mut TypeErased<MAX_SIZE>>,
+    cx: &mut Context,
+  ) -> Poll<Output>,
+  _output: PhantomData<Output>,
+}
+
+impl<const MAX_SIZE: usize, Output> ErasedFuture<MAX_SIZE, Output> {
+  unsafe fn poll<F>(
+    pin: Pin<&mut TypeErased<MAX_SIZE>>,
+    cx: &mut Context<'_>,
+  ) -> Poll<Output>
+  where
+    F: Future<Output = Output>,
+  {
+    F::poll(std::mem::transmute(pin), cx)
+  }
+
+  pub fn new<F>(f: F) -> Self
+  where
+    F: Future<Output = Output>,
+  {
+    Self {
+      erased: TypeErased::new(f),
+      poll: Self::poll::<F>,
+      _output: PhantomData,
+    }
+  }
+}
+
+impl<const MAX_SIZE: usize, Output> Future for ErasedFuture<MAX_SIZE, Output> {
+  type Output = Output;
+  fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+    unsafe {
+      (self.poll)(Pin::new_unchecked(&mut self.get_unchecked_mut().erased), cx)
+    }
+  }
+}
+
+#[cfg(test)]
+mod tests {
+  use super::*;
+  use crate::arena::ArenaUnique;
+
+  struct Countdown(usize);
+
+  impl Future for Countdown {
+    type Output = ();
+    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+      if self.0 == 0 {
+        Poll::Ready(())
+      } else {
+        self.get_mut().0 -= 1;
+        cx.waker().wake_by_ref();
+        Poll::Pending
+      }
+    }
+  }
+
+  #[inline(never)]
+  async fn add_one_to_reference(r: &mut usize) {
+    Countdown(10).await;
+    *r += 1;
+  }
+
+  #[test]
+  fn test_outside_arena() {
+    let future = Box::pin(async {
+      let mut v = 1;
+      add_one_to_reference(&mut v).await;
+      v
+    });
+    assert_eq!(2, futures::executor::block_on(future));
+  }
+
+  #[test]
+  fn test_in_arena_simple() {
+    let arena = ArenaUnique::<ErasedFuture<256, usize>>::with_capacity(16);
+    let future = arena.allocate(ErasedFuture::new(async { 1 }));
+    assert_eq!(1, futures::executor::block_on(future));
+  }
+
+  #[test]
+  fn test_in_arena_selfref_easy() {
+    let arena = ArenaUnique::<ErasedFuture<256, usize>>::with_capacity(16);
+    #[allow(clippy::useless_vec)]
+    let future = arena.allocate(ErasedFuture::new(async {
+      let mut v = vec![1];
+      let v = v.get_mut(0).unwrap();
+      Countdown(10).await;
+      *v = 2;
+      *v
+    }));
+    assert_eq!(2, futures::executor::block_on(future));
+  }
+
+  // This test doesn't pass in Miri because we're waiting on https://github.com/rust-lang/rfcs/pull/3467
+  // Miri believes this is invalid because the internal future has a &mut alive when it suspends, and we need
+  // to re-create the &mut to properly Pin it during the next poll cycle.
+  #[cfg(not(miri))]
+  #[test]
+  fn test_in_arena_selfref_hard() {
+    let arena = ArenaUnique::<ErasedFuture<256, usize>>::with_capacity(16);
+    let future = arena.allocate(ErasedFuture::new(async {
+      let mut v = 1;
+      add_one_to_reference(&mut v).await;
+      v
+    }));
+    assert_eq!(2, futures::executor::block_on(future));
+  }
+}
diff --git a/core/runtime/op_driver/future_arena.rs b/core/runtime/op_driver/future_arena.rs
new file mode 100644
index 0000000..23eb4cc
--- /dev/null
+++ b/core/runtime/op_driver/future_arena.rs
@@ -0,0 +1,113 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use super::erased_future::ErasedFuture;
+use crate::arena::ArenaBox;
+use crate::arena::ArenaUnique;
+use futures::FutureExt;
+use std::future::Future;
+use std::pin::Pin;
+use std::task::Context;
+use std::task::Poll;
+
+const MAX_ARENA_FUTURE_SIZE: usize = 1024;
+const FUTURE_ARENA_COUNT: usize = 256;
+
+pub enum FutureAllocation<R: 'static> {
+  Arena(ArenaBox<ErasedFuture<MAX_ARENA_FUTURE_SIZE, R>>),
+  Box(Pin<Box<dyn Future<Output = R>>>),
+}
+
+impl<R> Unpin for FutureAllocation<R> {}
+
+impl<R> Future for FutureAllocation<R> {
+  type Output = R;
+
+  #[inline(always)]
+  fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+    match self.get_mut() {
+      Self::Arena(f) => f.poll_unpin(cx),
+      Self::Box(f) => f.poll_unpin(cx),
+    }
+  }
+}
+
+/// An arena of erased futures. Futures too large for the arena, or futures allocated when the
+/// arena are full, are automatically moved to the heap instead.
+#[repr(transparent)]
+pub struct FutureArena {
+  arena: ArenaUnique<ErasedFuture<MAX_ARENA_FUTURE_SIZE, ()>>,
+}
+
+impl Default for FutureArena {
+  fn default() -> Self {
+    FutureArena {
+      arena: ArenaUnique::with_capacity(FUTURE_ARENA_COUNT),
+    }
+  }
+}
+
+impl FutureArena {
+  /// Allocate a future to run in this `FuturesUnordered`. If the future is too large, or the arena
+  /// is full, allocated in the heap.
+  pub fn allocate<F, R>(&self, f: F) -> FutureAllocation<R>
+  where
+    F: Future<Output = R> + 'static,
+  {
+    if std::mem::size_of::<F>() > MAX_ARENA_FUTURE_SIZE {
+      FutureAllocation::Box(f.boxed_local())
+    } else {
+      unsafe {
+        match self.arena.reserve_space() {
+          Some(reservation) => {
+            let alloc = self.arena.complete_reservation(
+              reservation,
+              std::mem::transmute(
+                ErasedFuture::<MAX_ARENA_FUTURE_SIZE, _>::new(f),
+              ),
+            );
+            FutureAllocation::Arena(std::mem::transmute(alloc))
+          }
+          None => FutureAllocation::Box(f.boxed_local()),
+        }
+      }
+    }
+  }
+}
+
+#[cfg(test)]
+mod tests {
+  use std::future::ready;
+
+  use super::*;
+
+  #[test]
+  fn test_double_free() {
+    let arena = FutureArena::default();
+    let f = arena.allocate(async { 1 });
+    drop(f);
+    let f = arena.allocate(Box::pin(async { 1 }));
+    drop(f);
+    let f = arena.allocate(ready(Box::new(1)));
+    drop(f);
+  }
+
+  #[test]
+  fn test_exceed_arena() {
+    let arena = FutureArena::default();
+    let mut v = vec![];
+    for _ in 0..1000 {
+      v.push(arena.allocate(ready(Box::new(1))));
+    }
+    drop(v);
+  }
+
+  #[test]
+  fn test_drop_after_joinset() {
+    let arena = FutureArena::default();
+    let mut v = vec![];
+    for _ in 0..1000 {
+      v.push(arena.allocate(ready(Box::new(1))));
+    }
+    drop(arena);
+    drop(v);
+  }
+}
diff --git a/core/runtime/op_driver/joinset_driver.rs b/core/runtime/op_driver/joinset_driver.rs
new file mode 100644
index 0000000..5a63588
--- /dev/null
+++ b/core/runtime/op_driver/joinset_driver.rs
@@ -0,0 +1,216 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use super::future_arena::FutureAllocation;
+use super::future_arena::FutureArena;
+use super::op_results::*;
+use super::OpDriver;
+use super::RetValMapper;
+use crate::ops::OpCtx;
+use crate::GetErrorClassFn;
+use crate::OpId;
+use crate::PromiseId;
+use anyhow::Error;
+use deno_unsync::JoinSet;
+use futures::task::noop_waker_ref;
+use futures::FutureExt;
+use std::cell::RefCell;
+use std::future::ready;
+use std::future::Future;
+use std::task::ready;
+use std::task::Context;
+use std::task::Poll;
+
+/// [`OpDriver`] implementation built on a tokio [`JoinSet`].
+#[derive(Default)]
+pub struct JoinSetDriver {
+  pending_ops: RefCell<JoinSet<PendingOp>>,
+  arena: FutureArena,
+}
+
+impl JoinSetDriver {
+  /// Spawn an unpolled task, along with a function that can map it to a [`PendingOp`].
+  #[inline(always)]
+  fn spawn_unpolled<R>(
+    &self,
+    task: impl Future<Output = R> + 'static,
+    map: impl FnOnce(R) -> PendingOp + 'static,
+  ) {
+    self.pending_ops.borrow_mut().spawn(task.map(map));
+  }
+
+  /// Spawn a ready task that already has a [`PendingOp`].
+  #[inline(always)]
+  fn spawn_ready(&self, ready_op: PendingOp) {
+    self.pending_ops.borrow_mut().spawn(ready(ready_op));
+  }
+
+  /// Spawn a polled task inside a [`FutureAllocation`], along with a function that can map it to a [`PendingOp`].
+  #[inline(always)]
+  fn spawn_polled<R>(
+    &self,
+    task: FutureAllocation<R>,
+    map: impl FnOnce(R) -> PendingOp + 'static,
+  ) {
+    self.pending_ops.borrow_mut().spawn(task.map(map));
+  }
+
+  #[inline(always)]
+  fn pending_op_success<R: 'static>(
+    info: PendingOpInfo,
+    rv_map: RetValMapper<R>,
+    v: R,
+  ) -> PendingOp {
+    PendingOp(info, OpResult::new_value(v, rv_map))
+  }
+
+  #[inline(always)]
+  fn pending_op_failure<E: Into<Error> + 'static>(
+    info: PendingOpInfo,
+    get_class: GetErrorClassFn,
+    err: E,
+  ) -> PendingOp {
+    PendingOp(info, OpResult::Err(OpError::new(get_class, err.into())))
+  }
+
+  #[inline(always)]
+  fn pending_op_result<R: 'static, E: Into<Error> + 'static>(
+    info: PendingOpInfo,
+    rv_map: RetValMapper<R>,
+    get_class: GetErrorClassFn,
+    result: Result<R, E>,
+  ) -> PendingOp {
+    match result {
+      Ok(r) => Self::pending_op_success(info, rv_map, r),
+      Err(err) => Self::pending_op_failure(info, get_class, err),
+    }
+  }
+}
+
+impl OpDriver for JoinSetDriver {
+  fn submit_op_fallible<
+    R: 'static,
+    E: Into<Error> + 'static,
+    const LAZY: bool,
+    const DEFERRED: bool,
+  >(
+    &self,
+    ctx: &OpCtx,
+    promise_id: i32,
+    op: impl Future<Output = Result<R, E>> + 'static,
+    rv_map: RetValMapper<R>,
+  ) -> Option<Result<R, E>> {
+    {
+      let info = PendingOpInfo(promise_id, ctx.id, ctx.metrics_enabled());
+      let get_class = ctx.get_error_class_fn;
+
+      if LAZY {
+        self.spawn_unpolled(op, move |r| {
+          Self::pending_op_result(info, rv_map, get_class, r)
+        });
+        return None;
+      }
+
+      // We poll every future here because it's much faster to return a result than
+      // spin the event loop to get it.
+      let mut pinned = self.arena.allocate(op);
+      match pinned.poll_unpin(&mut Context::from_waker(noop_waker_ref())) {
+        Poll::Pending => self.spawn_polled(pinned, move |r| {
+          Self::pending_op_result(info, rv_map, get_class, r)
+        }),
+        Poll::Ready(res) => {
+          if DEFERRED {
+            self.spawn_ready(Self::pending_op_result(
+              info, rv_map, get_class, res,
+            ))
+          } else {
+            return Some(res);
+          }
+        }
+      };
+      None
+    }
+  }
+
+  fn submit_op_infallible<
+    R: 'static,
+    const LAZY: bool,
+    const DEFERRED: bool,
+  >(
+    &self,
+    ctx: &OpCtx,
+    promise_id: i32,
+    op: impl Future<Output = R> + 'static,
+    rv_map: RetValMapper<R>,
+  ) -> Option<R> {
+    {
+      let info = PendingOpInfo(promise_id, ctx.id, ctx.metrics_enabled());
+      if LAZY {
+        self.spawn_unpolled(op, move |r| {
+          Self::pending_op_success(info, rv_map, r)
+        });
+        return None;
+      }
+
+      // We poll every future here because it's much faster to return a result than
+      // spin the event loop to get it.
+      let mut pinned = self.arena.allocate(op);
+      match pinned.poll_unpin(&mut Context::from_waker(noop_waker_ref())) {
+        Poll::Pending => self.spawn_polled(pinned, move |res| {
+          Self::pending_op_success(info, rv_map, res)
+        }),
+        Poll::Ready(res) => {
+          if DEFERRED {
+            self.spawn_ready(Self::pending_op_success(info, rv_map, res))
+          } else {
+            return Some(res);
+          }
+        }
+      };
+
+      None
+    }
+  }
+
+  #[inline(always)]
+  fn poll_ready<'s>(
+    &self,
+    cx: &mut Context,
+    scope: &mut v8::HandleScope<'s>,
+  ) -> Poll<(
+    PromiseId,
+    OpId,
+    bool,
+    Result<v8::Local<'s, v8::Value>, v8::Local<'s, v8::Value>>,
+  )> {
+    let item = ready!(self.pending_ops.borrow_mut().poll_join_next(cx));
+    let PendingOp(PendingOpInfo(promise_id, op_id, metrics_event), resp) =
+      match item {
+        Ok(x) => x,
+        Err(_) => {
+          // If this task is really errored, things could be pretty bad
+          panic!("Unrecoverable error: op panicked");
+        }
+      };
+
+    let was_error = matches!(resp, OpResult::Err(_));
+    let res = match resp.into_v8(scope) {
+      Ok(v) => {
+        if was_error {
+          Err(v)
+        } else {
+          Ok(v)
+        }
+      }
+      Err(e) => Err(
+        OpResult::Err(OpError::new(&|_| "TypeError", e.into()))
+          .into_v8(scope)
+          .unwrap(),
+      ),
+    };
+    Poll::Ready((promise_id, op_id, metrics_event, res))
+  }
+
+  #[inline(always)]
+  fn len(&self) -> usize {
+    self.pending_ops.borrow().len()
+  }
+}
diff --git a/core/runtime/op_driver/mod.rs b/core/runtime/op_driver/mod.rs
new file mode 100644
index 0000000..4826f38
--- /dev/null
+++ b/core/runtime/op_driver/mod.rs
@@ -0,0 +1,68 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use crate::ops::OpCtx;
+use crate::OpId;
+use crate::PromiseId;
+use anyhow::Error;
+use std::future::Future;
+use std::task::Context;
+use std::task::Poll;
+
+mod erased_future;
+mod future_arena;
+mod joinset_driver;
+mod op_results;
+
+pub use joinset_driver::JoinSetDriver;
+
+pub type RetValMapper<R> =
+  for<'r> fn(
+    &mut v8::HandleScope<'r>,
+    R,
+  ) -> Result<v8::Local<'r, v8::Value>, serde_v8::Error>;
+
+/// `OpDriver` encapsulates the interface for handling operations within Deno's runtime.
+///
+/// This trait defines methods for submitting ops and polling readiness inside of the
+/// event loop.
+pub(crate) trait OpDriver: Default {
+  /// Submits an operation that is expected to complete successfully without errors.
+  fn submit_op_infallible<R: 'static, const LAZY: bool, const DEFERRED: bool>(
+    &self,
+    ctx: &OpCtx,
+    promise_id: i32,
+    op: impl Future<Output = R> + 'static,
+    rv_map: RetValMapper<R>,
+  ) -> Option<R>;
+
+  /// Submits an operation that may produce errors during execution.
+  ///
+  /// This method is similar to `submit_op_infallible` but is used when the op
+  /// might return an error (`Result`).
+  fn submit_op_fallible<
+    R: 'static,
+    E: Into<Error> + 'static,
+    const LAZY: bool,
+    const DEFERRED: bool,
+  >(
+    &self,
+    ctx: &OpCtx,
+    promise_id: i32,
+    op: impl Future<Output = Result<R, E>> + 'static,
+    rv_map: RetValMapper<R>,
+  ) -> Option<Result<R, E>>;
+
+  #[allow(clippy::type_complexity)]
+  /// Polls the readiness of the op driver.
+  fn poll_ready<'s>(
+    &self,
+    cx: &mut Context,
+    scope: &mut v8::HandleScope<'s>,
+  ) -> Poll<(
+    PromiseId,
+    OpId,
+    bool,
+    Result<v8::Local<'s, v8::Value>, v8::Local<'s, v8::Value>>,
+  )>;
+
+  fn len(&self) -> usize;
+}
diff --git a/core/runtime/op_driver/op_results.rs b/core/runtime/op_driver/op_results.rs
new file mode 100644
index 0000000..dc21b5f
--- /dev/null
+++ b/core/runtime/op_driver/op_results.rs
@@ -0,0 +1,94 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use super::erased_future::TypeErased;
+use super::RetValMapper;
+use crate::GetErrorClassFn;
+use crate::OpId;
+use crate::PromiseId;
+use anyhow::Error;
+use serde::Serialize;
+
+const MAX_RESULT_SIZE: usize = 32;
+
+pub struct PendingOp(pub PendingOpInfo, pub OpResult);
+
+pub struct PendingOpInfo(pub PromiseId, pub OpId, pub bool);
+
+#[allow(clippy::type_complexity)]
+pub struct OpValue {
+  value: TypeErased<MAX_RESULT_SIZE>,
+  rv_map: *const fn(),
+  map_fn: for<'a> fn(
+    scope: &mut v8::HandleScope<'a>,
+    rv_map: *const fn(),
+    value: TypeErased<MAX_RESULT_SIZE>,
+  ) -> Result<v8::Local<'a, v8::Value>, serde_v8::Error>,
+}
+
+impl OpValue {
+  pub fn new<R: 'static>(rv_map: RetValMapper<R>, v: R) -> Self {
+    Self {
+      value: TypeErased::new(v),
+      rv_map: rv_map as _,
+      map_fn: |scope, rv_map, erased| unsafe {
+        let r = erased.take();
+        let rv_map: RetValMapper<R> = std::mem::transmute(rv_map);
+        rv_map(scope, r)
+      },
+    }
+  }
+}
+
+pub type ValueLargeFn =
+  dyn for<'a> FnOnce(
+    &mut v8::HandleScope<'a>,
+  ) -> Result<v8::Local<'a, v8::Value>, serde_v8::Error>;
+
+pub enum OpResult {
+  /// Errors.
+  Err(OpError),
+  /// For small ops, we include them in an erased type container.
+  Value(OpValue),
+  /// For ops that return "large" results (> MAX_RESULT_SIZE bytes) we just box a function
+  /// that can turn it into a v8 value.
+  ValueLarge(Box<ValueLargeFn>),
+}
+
+impl OpResult {
+  pub fn new_value<R: 'static>(v: R, rv_map: RetValMapper<R>) -> Self {
+    if std::mem::size_of::<R>() > MAX_RESULT_SIZE {
+      OpResult::ValueLarge(Box::new(move |scope| rv_map(scope, v)))
+    } else {
+      OpResult::Value(OpValue::new(rv_map, v))
+    }
+  }
+
+  pub fn into_v8<'a>(
+    self,
+    scope: &mut v8::HandleScope<'a>,
+  ) -> Result<v8::Local<'a, v8::Value>, serde_v8::Error> {
+    match self {
+      Self::Err(err) => serde_v8::to_v8(scope, err),
+      Self::Value(f) => (f.map_fn)(scope, f.rv_map, f.value),
+      Self::ValueLarge(f) => f(scope),
+    }
+  }
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct OpError {
+  #[serde(rename = "$err_class_name")]
+  class_name: &'static str,
+  message: String,
+  code: Option<&'static str>,
+}
+
+impl OpError {
+  pub fn new(get_class: GetErrorClassFn, err: Error) -> Self {
+    Self {
+      class_name: (get_class)(&err),
+      message: format!("{err:#}"),
+      code: crate::error_codes::get_error_code(&err),
+    }
+  }
+}
diff --git a/core/runtime/ops.rs b/core/runtime/ops.rs
index f4bdc64..36e9ac9 100644
--- a/core/runtime/ops.rs
+++ b/core/runtime/ops.rs
@@ -1,164 +1,67 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 use crate::ops::*;
-use crate::OpResult;
 use anyhow::Error;
 use futures::future::Future;
-use futures::future::FutureExt;
-use futures::task::noop_waker_ref;
 use serde::Deserialize;
 use serde_v8::from_v8;
 use serde_v8::V8Sliceable;
 use std::borrow::Cow;
 use std::ffi::c_void;
-use std::future::ready;
 use std::mem::MaybeUninit;
 use std::option::Option;
 use std::ptr::NonNull;
-use std::task::Context;
-use std::task::Poll;
 use v8::WriteOptions;
 
+use super::op_driver::OpDriver;
+use super::op_driver::RetValMapper;
+
 /// The default string buffer size on the stack that prevents mallocs in some
 /// string functions. Keep in mind that Windows only offers 1MB stacks by default,
 /// so this is a limited resource!
 pub const STRING_STACK_BUFFER_SIZE: usize = 1024 * 8;
 
-#[inline]
+#[inline(always)]
 pub fn map_async_op_infallible<R: 'static>(
   ctx: &OpCtx,
   lazy: bool,
   deferred: bool,
   promise_id: i32,
   op: impl Future<Output = R> + 'static,
-  rv_map: for<'r> fn(
-    &mut v8::HandleScope<'r>,
-    R,
-  ) -> Result<v8::Local<'r, v8::Value>, serde_v8::Error>,
+  rv_map: RetValMapper<R>,
 ) -> Option<R> {
-  let id = ctx.id;
-  let metrics = ctx.metrics_enabled();
+  let pending_ops = &ctx.context_state().pending_ops;
   if lazy {
-    let mapper = move |r| {
-      PendingOp(
-        promise_id,
-        id,
-        OpResult::Op2Temp(Box::new(move |scope| rv_map(scope, r))),
-        metrics,
-      )
-    };
-    ctx
-      .context_state()
-      .pending_ops
-      .borrow_mut()
-      .spawn(op.map(mapper));
-    return None;
-  }
-
-  // TODO(mmastrac): We have to poll every future here because that assumption is baked into a large number
-  // of ops. If we can figure out a way around this, we can remove this call to boxed_local and save a malloc per future.
-  let mut pinned = op.map(move |res| (promise_id, id, res)).boxed_local();
-
-  let pinned =
-    match pinned.poll_unpin(&mut Context::from_waker(noop_waker_ref())) {
-      Poll::Pending => pinned,
-      Poll::Ready(res) => {
-        // TODO(mmastrac): optimize this so we don't double-allocate
-        if deferred {
-          ready(res).boxed_local()
-        } else {
-          return Some(res.2);
-        }
-      }
-    };
-
-  ctx
-    .context_state()
-    .pending_ops
-    .borrow_mut()
-    .spawn(pinned.map(move |r| {
-      PendingOp(
-        r.0,
-        r.1,
-        OpResult::Op2Temp(Box::new(move |scope| rv_map(scope, r.2))),
-        metrics,
-      )
-    }));
-  None
+    pending_ops
+      .submit_op_infallible::<_, true, false>(ctx, promise_id, op, rv_map)
+  } else if deferred {
+    pending_ops
+      .submit_op_infallible::<_, false, true>(ctx, promise_id, op, rv_map)
+  } else {
+    pending_ops
+      .submit_op_infallible::<_, false, false>(ctx, promise_id, op, rv_map)
+  }
 }
 
-#[inline]
+#[inline(always)]
 pub fn map_async_op_fallible<R: 'static, E: Into<Error> + 'static>(
   ctx: &OpCtx,
   lazy: bool,
   deferred: bool,
   promise_id: i32,
   op: impl Future<Output = Result<R, E>> + 'static,
-  rv_map: for<'r> fn(
-    &mut v8::HandleScope<'r>,
-    R,
-  ) -> Result<v8::Local<'r, v8::Value>, serde_v8::Error>,
+  rv_map: RetValMapper<R>,
 ) -> Option<Result<R, E>> {
-  let id = ctx.id;
-  let metrics = ctx.metrics_enabled();
-
+  let pending_ops = &ctx.context_state().pending_ops;
   if lazy {
-    let get_class = ctx.get_error_class_fn;
-    ctx.context_state().pending_ops.borrow_mut().spawn(op.map(
-      move |r| match r {
-        Ok(v) => PendingOp(
-          promise_id,
-          id,
-          OpResult::Op2Temp(Box::new(move |scope| rv_map(scope, v))),
-          metrics,
-        ),
-        Err(err) => PendingOp(
-          promise_id,
-          id,
-          OpResult::Err(OpError::new(get_class, err.into())),
-          metrics,
-        ),
-      },
-    ));
-    return None;
-  }
-
-  // TODO(mmastrac): We have to poll every future here because that assumption is baked into a large number
-  // of ops. If we can figure out a way around this, we can remove this call to boxed_local and save a malloc per future.
-  let mut pinned = op.map(move |res| (promise_id, id, res)).boxed_local();
-
-  let pinned =
-    match pinned.poll_unpin(&mut Context::from_waker(noop_waker_ref())) {
-      Poll::Pending => pinned,
-      Poll::Ready(res) => {
-        // TODO(mmastrac): optimize this so we don't double-allocate
-        if deferred {
-          ready(res).boxed_local()
-        } else {
-          return Some(res.2);
-        }
-      }
-    };
-
-  let get_class = ctx.get_error_class_fn;
-  ctx
-    .context_state()
-    .pending_ops
-    .borrow_mut()
-    .spawn(pinned.map(move |r| match r.2 {
-      Ok(v) => PendingOp(
-        r.0,
-        r.1,
-        OpResult::Op2Temp(Box::new(move |scope| rv_map(scope, v))),
-        metrics,
-      ),
-      Err(err) => PendingOp(
-        r.0,
-        r.1,
-        OpResult::Err(OpError::new(get_class, err.into())),
-        metrics,
-      ),
-    }));
-  None
+    pending_ops
+      .submit_op_fallible::<_, _, true, false>(ctx, promise_id, op, rv_map)
+  } else if deferred {
+    pending_ops
+      .submit_op_fallible::<_, _, false, true>(ctx, promise_id, op, rv_map)
+  } else {
+    pending_ops
+      .submit_op_fallible::<_, _, false, false>(ctx, promise_id, op, rv_map)
+  }
 }
 
 macro_rules! try_number_some {
diff --git a/ops/Cargo.toml b/ops/Cargo.toml
index 0c7a7eb..3706e2a 100644
--- a/ops/Cargo.toml
+++ b/ops/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "deno_ops"
-version = "0.114.0"
+version = "0.116.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/ops/op2/README.md b/ops/op2/README.md
index 42d5f30..4eac6df 100644
--- a/ops/op2/README.md
+++ b/ops/op2/README.md
@@ -15,6 +15,12 @@ string. At this time there is no way to avoid this copy, though the `op` code
 does attempt to avoid any allocations where possible by making use of a stack
 buffer.
 
+## Fallible `op`s
+
+An `op` function may be declared to return `Result` to indicate that the `op` is
+fallible. The error type must implement `Into<anyhow::Error>`. When the function
+returns `Err`, an exception is thrown.
+
 ## `async` calls
 
 Asynchronous calls are supported in two forms:
diff --git a/ops/op2/dispatch_fast.rs b/ops/op2/dispatch_fast.rs
index ed4697a..4e531b7 100644
--- a/ops/op2/dispatch_fast.rs
+++ b/ops/op2/dispatch_fast.rs
@@ -334,6 +334,8 @@ pub(crate) fn generate_fast_result_early_exit(
     let #result = match #result {
       Ok(#result) => #result,
       Err(err) => {
+        let err = err.into();
+
         // FASTCALL FALLBACK: This is where we set the errors for the slow-call error pickup path. There
         // is no code running between this and the other FASTCALL FALLBACK comment, except some V8 code
         // required to perform the fallback process. This is why the below call is safe.
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 9e137c1..4bd1ede 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,3 +1,3 @@
 [toolchain]
-channel = "1.74.0"
+channel = "1.74.1"
 components = ["rustfmt", "clippy"]
diff --git a/serde_v8/Cargo.toml b/serde_v8/Cargo.toml
index e50c4a7..6e3180e 100644
--- a/serde_v8/Cargo.toml
+++ b/serde_v8/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "serde_v8"
-version = "0.147.0"
+version = "0.149.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/serde_v8/magic/external_pointer.rs b/serde_v8/magic/external_pointer.rs
index 325236c..83d7676 100644
--- a/serde_v8/magic/external_pointer.rs
+++ b/serde_v8/magic/external_pointer.rs
@@ -6,6 +6,7 @@ use super::transl8::impl_magic;
 use super::transl8::FromV8;
 use super::transl8::ToV8;
 
+#[repr(transparent)]
 pub struct ExternalPointer(*mut c_void);
 
 // SAFETY: Nonblocking FFI is user controller and we must trust user to have it right.
@@ -54,3 +55,15 @@ impl From<*const c_void> for ExternalPointer {
     ExternalPointer(value as *mut c_void)
   }
 }
+
+impl From<ExternalPointer> for *mut c_void {
+  fn from(value: ExternalPointer) -> Self {
+    value.0
+  }
+}
+
+impl From<ExternalPointer> for *const c_void {
+  fn from(value: ExternalPointer) -> Self {
+    value.0
+  }
+}


Test patch:
diff --git a/core/modules/tests.rs b/core/modules/tests.rs
index 21fba4f..3f92994 100644
--- a/core/modules/tests.rs
+++ b/core/modules/tests.rs
@@ -4,9 +4,10 @@ use crate::error::exception_to_err_result;
 use crate::modules::loaders::ModuleLoadEventCounts;
 use crate::modules::loaders::TestingModuleLoader;
 use crate::modules::loaders::*;
-use crate::modules::AssertedModuleType;
 use crate::modules::ModuleError;
 use crate::modules::ModuleRequest;
+use crate::modules::ModuleSourceCode;
+use crate::modules::RequestedModuleType;
 use crate::resolve_import;
 use crate::resolve_url;
 use crate::runtime::JsRuntime;
@@ -276,28 +277,28 @@ fn test_recursive_load() {
   let modules = module_map_rc;
 
   assert_eq!(
-    modules.get_id("file:///a.js", AssertedModuleType::JavaScriptOrWasm),
+    modules.get_id("file:///a.js", RequestedModuleType::None),
     Some(a_id)
   );
   let b_id = modules
-    .get_id("file:///b.js", AssertedModuleType::JavaScriptOrWasm)
+    .get_id("file:///b.js", RequestedModuleType::None)
     .unwrap();
   let c_id = modules
-    .get_id("file:///c.js", AssertedModuleType::JavaScriptOrWasm)
+    .get_id("file:///c.js", RequestedModuleType::None)
     .unwrap();
   let d_id = modules
-    .get_id("file:///d.js", AssertedModuleType::JavaScriptOrWasm)
+    .get_id("file:///d.js", RequestedModuleType::None)
     .unwrap();
   assert_eq!(
     modules.get_requested_modules(a_id),
     Some(vec![
       ModuleRequest {
         specifier: "file:///b.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       },
       ModuleRequest {
         specifier: "file:///c.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       },
     ])
   );
@@ -305,14 +306,14 @@ fn test_recursive_load() {
     modules.get_requested_modules(b_id),
     Some(vec![ModuleRequest {
       specifier: "file:///c.js".to_string(),
-      asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+      requested_module_type: RequestedModuleType::None,
     },])
   );
   assert_eq!(
     modules.get_requested_modules(c_id),
     Some(vec![ModuleRequest {
       specifier: "file:///d.js".to_string(),
-      asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+      requested_module_type: RequestedModuleType::None,
     },])
   );
   assert_eq!(modules.get_requested_modules(d_id), Some(vec![]));
@@ -381,7 +382,7 @@ fn test_mods() {
       imports,
       Some(vec![ModuleRequest {
         specifier: "file:///b.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       },])
     );
 
@@ -483,7 +484,7 @@ fn test_json_module() {
       imports,
       Some(vec![ModuleRequest {
         specifier: "file:///c.json".to_string(),
-        asserted_module_type: AssertedModuleType::Json,
+        requested_module_type: RequestedModuleType::Json,
       },])
     );
 
@@ -508,7 +509,7 @@ fn test_json_module() {
       imports,
       Some(vec![ModuleRequest {
         specifier: "file:///c.json".to_string(),
-        asserted_module_type: AssertedModuleType::Json,
+        requested_module_type: RequestedModuleType::Json,
       },])
     );
 
@@ -855,19 +856,18 @@ fn test_circular_load() {
     let modules = module_map_rc;
 
     assert_eq!(
-      modules
-        .get_id("file:///circular1.js", AssertedModuleType::JavaScriptOrWasm),
+      modules.get_id("file:///circular1.js", RequestedModuleType::None),
       Some(circular1_id)
     );
     let circular2_id = modules
-      .get_id("file:///circular2.js", AssertedModuleType::JavaScriptOrWasm)
+      .get_id("file:///circular2.js", RequestedModuleType::None)
       .unwrap();
 
     assert_eq!(
       modules.get_requested_modules(circular1_id),
       Some(vec![ModuleRequest {
         specifier: "file:///circular2.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       }])
     );
 
@@ -875,26 +875,26 @@ fn test_circular_load() {
       modules.get_requested_modules(circular2_id),
       Some(vec![ModuleRequest {
         specifier: "file:///circular3.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       }])
     );
 
     assert!(modules
-      .get_id("file:///circular3.js", AssertedModuleType::JavaScriptOrWasm)
+      .get_id("file:///circular3.js", RequestedModuleType::None)
       .is_some());
     let circular3_id = modules
-      .get_id("file:///circular3.js", AssertedModuleType::JavaScriptOrWasm)
+      .get_id("file:///circular3.js", RequestedModuleType::None)
       .unwrap();
     assert_eq!(
       modules.get_requested_modules(circular3_id),
       Some(vec![
         ModuleRequest {
           specifier: "file:///circular1.js".to_string(),
-          asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+          requested_module_type: RequestedModuleType::None,
         },
         ModuleRequest {
           specifier: "file:///circular2.js".to_string(),
-          asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+          requested_module_type: RequestedModuleType::None,
         }
       ])
     );
@@ -913,69 +913,61 @@ fn test_redirect_load() {
     ..Default::default()
   });
 
-  let fut = async move {
-    let spec = resolve_url("file:///redirect1.js").unwrap();
-    let result = runtime.load_main_module(&spec, None).await;
-    assert!(result.is_ok());
-    let redirect1_id = result.unwrap();
-    #[allow(clippy::let_underscore_future)]
-    let _ = runtime.mod_evaluate(redirect1_id);
-    runtime.run_event_loop(Default::default()).await.unwrap();
-    let l = loads.lock();
-    assert_eq!(
-      l.to_vec(),
-      vec![
-        "file:///redirect1.js",
-        "file:///redirect2.js",
-        "file:///dir/redirect3.js"
-      ]
-    );
+  let fut =
+    async move {
+      let spec = resolve_url("file:///redirect1.js").unwrap();
+      let result = runtime.load_main_module(&spec, None).await;
+      assert!(result.is_ok());
+      let redirect1_id = result.unwrap();
+      #[allow(clippy::let_underscore_future)]
+      let _ = runtime.mod_evaluate(redirect1_id);
+      runtime.run_event_loop(Default::default()).await.unwrap();
+      let l = loads.lock();
+      assert_eq!(
+        l.to_vec(),
+        vec![
+          "file:///redirect1.js",
+          "file:///redirect2.js",
+          "file:///dir/redirect3.js"
+        ]
+      );
 
-    let module_map_rc = runtime.module_map();
-    let modules = module_map_rc;
+      let module_map_rc = runtime.module_map();
+      let modules = module_map_rc;
 
-    assert_eq!(
-      modules
-        .get_id("file:///redirect1.js", AssertedModuleType::JavaScriptOrWasm),
-      Some(redirect1_id)
-    );
+      assert_eq!(
+        modules.get_id("file:///redirect1.js", RequestedModuleType::None),
+        Some(redirect1_id)
+      );
 
-    let redirect2_id = modules
-      .get_id(
-        "file:///dir/redirect2.js",
-        AssertedModuleType::JavaScriptOrWasm,
-      )
-      .unwrap();
-    assert!(modules
-      .is_alias("file:///redirect2.js", AssertedModuleType::JavaScriptOrWasm));
-    assert!(!modules.is_alias(
-      "file:///dir/redirect2.js",
-      AssertedModuleType::JavaScriptOrWasm
-    ));
-    assert_eq!(
-      modules
-        .get_id("file:///redirect2.js", AssertedModuleType::JavaScriptOrWasm),
-      Some(redirect2_id)
-    );
+      let redirect2_id = modules
+        .get_id("file:///dir/redirect2.js", RequestedModuleType::None)
+        .unwrap();
+      assert!(
+        modules.is_alias("file:///redirect2.js", RequestedModuleType::None)
+      );
+      assert!(!modules
+        .is_alias("file:///dir/redirect2.js", RequestedModuleType::None));
+      assert_eq!(
+        modules.get_id("file:///redirect2.js", RequestedModuleType::None),
+        Some(redirect2_id)
+      );
 
-    let redirect3_id = modules
-      .get_id("file:///redirect3.js", AssertedModuleType::JavaScriptOrWasm)
-      .unwrap();
-    assert!(modules.is_alias(
-      "file:///dir/redirect3.js",
-      AssertedModuleType::JavaScriptOrWasm
-    ));
-    assert!(!modules
-      .is_alias("file:///redirect3.js", AssertedModuleType::JavaScriptOrWasm));
-    assert_eq!(
-      modules.get_id(
-        "file:///dir/redirect3.js",
-        AssertedModuleType::JavaScriptOrWasm
-      ),
-      Some(redirect3_id)
-    );
-  }
-  .boxed_local();
+      let redirect3_id = modules
+        .get_id("file:///redirect3.js", RequestedModuleType::None)
+        .unwrap();
+      assert!(
+        modules.is_alias("file:///dir/redirect3.js", RequestedModuleType::None)
+      );
+      assert!(
+        !modules.is_alias("file:///redirect3.js", RequestedModuleType::None)
+      );
+      assert_eq!(
+        modules.get_id("file:///dir/redirect3.js", RequestedModuleType::None),
+        Some(redirect3_id)
+      );
+    }
+    .boxed_local();
 
   futures::executor::block_on(fut);
 }
@@ -1087,20 +1079,17 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
   let modules = module_map_rc;
 
   assert_eq!(
-    modules.get_id(
-      "file:///main_with_code.js",
-      AssertedModuleType::JavaScriptOrWasm
-    ),
+    modules.get_id("file:///main_with_code.js", RequestedModuleType::None),
     Some(main_id)
   );
   let b_id = modules
-    .get_id("file:///b.js", AssertedModuleType::JavaScriptOrWasm)
+    .get_id("file:///b.js", RequestedModuleType::None)
     .unwrap();
   let c_id = modules
-    .get_id("file:///c.js", AssertedModuleType::JavaScriptOrWasm)
+    .get_id("file:///c.js", RequestedModuleType::None)
     .unwrap();
   let d_id = modules
-    .get_id("file:///d.js", AssertedModuleType::JavaScriptOrWasm)
+    .get_id("file:///d.js", RequestedModuleType::None)
     .unwrap();
 
   assert_eq!(
@@ -1108,11 +1097,11 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
     Some(vec![
       ModuleRequest {
         specifier: "file:///b.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       },
       ModuleRequest {
         specifier: "file:///c.js".to_string(),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       }
     ])
   );
@@ -1120,14 +1109,14 @@ if (import.meta.url != 'file:///main_with_code.js') throw Error();
     modules.get_requested_modules(b_id),
     Some(vec![ModuleRequest {
       specifier: "file:///c.js".to_string(),
-      asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+      requested_module_type: RequestedModuleType::None,
     }])
   );
   assert_eq!(
     modules.get_requested_modules(c_id),
     Some(vec![ModuleRequest {
       specifier: "file:///d.js".to_string(),
-      asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+      requested_module_type: RequestedModuleType::None,
     }])
   );
   assert_eq!(modules.get_requested_modules(d_id), Some(vec![]));
@@ -1355,7 +1344,7 @@ async fn no_duplicate_loads() {
           .unwrap()
       };
       let module_source = ModuleSource {
-        code: ModuleCode::from(source_code),
+        code: ModuleSourceCode::String(ModuleCode::from(source_code)),
         module_type: ModuleType::JavaScript,
         module_url_specified: module_specifier.clone().into(),
         module_url_found: found_specifier.map(|s| s.into()),
diff --git a/core/runtime/tests/snapshot.rs b/core/runtime/tests/snapshot.rs
index c83274f..5ec5c69 100644
--- a/core/runtime/tests/snapshot.rs
+++ b/core/runtime/tests/snapshot.rs
@@ -1,7 +1,7 @@
 // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
 use crate::extensions::Op;
-use crate::modules::AssertedModuleType;
 use crate::modules::ModuleInfo;
+use crate::modules::RequestedModuleType;
 use crate::modules::TestingModuleLoader;
 use crate::*;
 use anyhow::Error;
@@ -161,9 +161,9 @@ fn es_snapshot() {
       name: specifier.into(),
       requests: vec![crate::modules::ModuleRequest {
         specifier: format!("file:///{prev}.js"),
-        asserted_module_type: AssertedModuleType::JavaScriptOrWasm,
+        requested_module_type: RequestedModuleType::None,
       }],
-      module_type: AssertedModuleType::JavaScriptOrWasm,
+      module_type: RequestedModuleType::None,
     }
   }
 
@@ -201,7 +201,7 @@ fn es_snapshot() {
     main: false,
     name: specifier.into(),
     requests: vec![],
-    module_type: AssertedModuleType::JavaScriptOrWasm,
+    module_type: RequestedModuleType::None,
   });
 
   modules.extend((1..200).map(|i| create_module(&mut runtime, i, false)));
diff --git a/ops/op2/test_cases/sync/bool_result.out b/ops/op2/test_cases/sync/bool_result.out
index 97cbad4..cd73aa9 100644
--- a/ops/op2/test_cases/sync/bool_result.out
+++ b/ops/op2/test_cases/sync/bool_result.out
@@ -87,6 +87,7 @@ impl op_bool {
         let result = match result {
             Ok(result) => result,
             Err(err) => {
+                let err = err.into();
                 unsafe {
                     opctx.unsafely_set_last_error_for_ops_only(err);
                 }
diff --git a/ops/op2/test_cases/sync/result_external.out b/ops/op2/test_cases/sync/result_external.out
index df4fd35..6111daf 100644
--- a/ops/op2/test_cases/sync/result_external.out
+++ b/ops/op2/test_cases/sync/result_external.out
@@ -82,6 +82,7 @@ impl op_external_with_result {
         let result = match result {
             Ok(result) => result,
             Err(err) => {
+                let err = err.into();
                 unsafe {
                     opctx.unsafely_set_last_error_for_ops_only(err);
                 }
diff --git a/ops/op2/test_cases/sync/result_primitive.out b/ops/op2/test_cases/sync/result_primitive.out
index a6b3010..650d587 100644
--- a/ops/op2/test_cases/sync/result_primitive.out
+++ b/ops/op2/test_cases/sync/result_primitive.out
@@ -82,6 +82,7 @@ impl op_u32_with_result {
         let result = match result {
             Ok(result) => result,
             Err(err) => {
+                let err = err.into();
                 unsafe {
                     opctx.unsafely_set_last_error_for_ops_only(err);
                 }
diff --git a/ops/op2/test_cases/sync/result_void.out b/ops/op2/test_cases/sync/result_void.out
index b1015d3..a8a19a2 100644
--- a/ops/op2/test_cases/sync/result_void.out
+++ b/ops/op2/test_cases/sync/result_void.out
@@ -82,6 +82,7 @@ impl op_void_with_result {
         let result = match result {
             Ok(result) => result,
             Err(err) => {
+                let err = err.into();
                 unsafe {
                     opctx.unsafely_set_last_error_for_ops_only(err);
                 }
@@ -170,7 +171,7 @@ impl op_void_with_result {
         }
     }
     #[inline(always)]
-    pub fn call() -> Result<(), AnyError> {
+    pub fn call() -> std::io::Result<()> {
         Ok(())
     }
 }
diff --git a/ops/op2/test_cases/sync/result_void.rs b/ops/op2/test_cases/sync/result_void.rs
index ae0f793..6e51c91 100644
--- a/ops/op2/test_cases/sync/result_void.rs
+++ b/ops/op2/test_cases/sync/result_void.rs
@@ -2,9 +2,7 @@
 #![deny(warnings)]
 deno_ops_compile_test_runner::prelude!();
 
-use deno_core::error::AnyError;
-
 #[op2(fast)]
-pub fn op_void_with_result() -> Result<(), AnyError> {
+pub fn op_void_with_result() -> std::io::Result<()> {
     Ok(())
 }
diff --git a/testing/checkin/runner/ts_module_loader.rs b/testing/checkin/runner/ts_module_loader.rs
index 125c1b9..365d5df 100644
--- a/testing/checkin/runner/ts_module_loader.rs
+++ b/testing/checkin/runner/ts_module_loader.rs
@@ -17,6 +17,7 @@ use deno_core::ExtensionFileSource;
 use deno_core::ExtensionFileSourceCode;
 use deno_core::ModuleLoader;
 use deno_core::ModuleSource;
+use deno_core::ModuleSourceCode;
 use deno_core::ModuleSourceFuture;
 use deno_core::ModuleSpecifier;
 use deno_core::ModuleType;
@@ -121,7 +122,7 @@ impl ModuleLoader for TypescriptModuleLoader {
       };
       Ok(ModuleSource::new(
         module_type,
-        code.into(),
+        ModuleSourceCode::String(code.into()),
         module_specifier,
       ))
     }
diff --git a/testing/lib.rs b/testing/lib.rs
index 104e7c3..c15b3f0 100644
--- a/testing/lib.rs
+++ b/testing/lib.rs
@@ -38,6 +38,7 @@ unit_test!(
   serialize_deserialize_test,
   tc39_test,
   timer_test,
+  type_test,
 );
 
 // Test the load and run of an entire file within the `checkin` infrastructure.
diff --git a/testing/tsconfig.json b/testing/tsconfig.json
index c93cc57..db07612 100644
--- a/testing/tsconfig.json
+++ b/testing/tsconfig.json
@@ -1,5 +1,6 @@
 {
   "compilerOptions": {
+    "target": "ES2022",
     "baseUrl": ".",
     "paths": {
       "checkin:console": ["checkin/runtime/console.ts"],
diff --git a/testing/unit/type_test.ts b/testing/unit/type_test.ts
new file mode 100644
index 0000000..c30b056
--- /dev/null
+++ b/testing/unit/type_test.ts
@@ -0,0 +1,179 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import * as module from "checkin:testing";
+import { assert, test } from "checkin:testing";
+
+test(function testIsAnyArrayBuffer() {
+  assert(Deno.core.isAnyArrayBuffer(new ArrayBuffer(4)));
+  assert(Deno.core.isAnyArrayBuffer(new SharedArrayBuffer(4)));
+  assert(!Deno.core.isAnyArrayBuffer(new Uint8Array(4)));
+});
+
+test(function testIsArgumentsObject() {
+  let args: IArguments;
+  (function () {
+    args = arguments;
+  })();
+  assert(Deno.core.isArgumentsObject(args));
+  assert(!Deno.core.isArgumentsObject({}));
+});
+
+test(function testIsArrayBuffer() {
+  assert(Deno.core.isArrayBuffer(new ArrayBuffer(4)));
+  assert(!Deno.core.isArrayBuffer(new SharedArrayBuffer(4)));
+  assert(!Deno.core.isArrayBuffer(new Uint8Array(4)));
+});
+
+test(function testIsArrayBufferView() {
+  assert(Deno.core.isArrayBufferView(new DataView(new ArrayBuffer(4))));
+  assert(Deno.core.isArrayBufferView(new Uint8Array(4)));
+  assert(!Deno.core.isArrayBufferView(new ArrayBuffer(4)));
+});
+
+test(function testIsAsyncFunction() {
+  assert(Deno.core.isAsyncFunction(async function () {}));
+  assert(Deno.core.isAsyncFunction(async function* () {}));
+  assert(!Deno.core.isAsyncFunction(function () {}));
+  assert(!Deno.core.isAsyncFunction(function* () {}));
+});
+
+test(function testIsBigIntObject() {
+  assert(Deno.core.isBigIntObject(Object(1n)));
+  assert(!Deno.core.isBigIntObject(1n));
+  assert(!Deno.core.isBigIntObject(1));
+});
+
+test(function testIsBooleanObject() {
+  assert(Deno.core.isBooleanObject(new Boolean(true)));
+  assert(!Deno.core.isBooleanObject(true));
+  assert(!Deno.core.isBooleanObject("true"));
+});
+
+test(function testIsBoxedPrimitive() {
+  assert(Deno.core.isBoxedPrimitive(Object(1n)));
+  assert(Deno.core.isBoxedPrimitive(new Boolean(true)));
+  assert(Deno.core.isBoxedPrimitive(new Number(1)));
+  assert(Deno.core.isBoxedPrimitive(Object(Symbol())));
+  assert(Deno.core.isBoxedPrimitive(new String("str")));
+  assert(!Deno.core.isBoxedPrimitive(1n));
+  assert(!Deno.core.isBoxedPrimitive(true));
+  assert(!Deno.core.isBoxedPrimitive(1));
+  assert(!Deno.core.isBoxedPrimitive(Symbol()));
+  assert(!Deno.core.isBoxedPrimitive("str"));
+});
+
+test(function testIsDataView() {
+  assert(Deno.core.isDataView(new DataView(new ArrayBuffer(4))));
+  assert(!Deno.core.isDataView(new Uint8Array(4)));
+  assert(!Deno.core.isDataView(new ArrayBuffer(4)));
+});
+
+test(function testIsDate() {
+  assert(Deno.core.isDate(new Date()));
+  assert(!Deno.core.isDate({}));
+});
+
+test(function testIsGeneratorFunction() {
+  assert(Deno.core.isGeneratorFunction(async function* () {}));
+  assert(Deno.core.isGeneratorFunction(function* () {}));
+  assert(!Deno.core.isGeneratorFunction(async function () {}));
+  assert(!Deno.core.isGeneratorFunction(function () {}));
+});
+
+test(function testIsGeneratorObject() {
+  const generator = (function* () {})();
+  assert(Deno.core.isGeneratorObject(generator));
+  assert(!Deno.core.isGeneratorObject({}));
+});
+
+test(function testIsMap() {
+  assert(Deno.core.isMap(new Map()));
+  assert(!Deno.core.isMap(new Set()));
+  assert(!Deno.core.isMap(new WeakMap()));
+  assert(!Deno.core.isMap(new WeakSet()));
+});
+
+test(function testIsMapIterator() {
+  const map = new Map();
+  assert(Deno.core.isMapIterator(map.values()));
+  assert(!Deno.core.isMapIterator(map));
+});
+
+test(function testIsModuleNamespaceObject() {
+  assert(Deno.core.isModuleNamespaceObject(module));
+  assert(!Deno.core.isModuleNamespaceObject({}));
+});
+
+test(function testIsNativeError() {
+  assert(Deno.core.isNativeError(new Error()));
+  assert(Deno.core.isNativeError(new TypeError()));
+  assert(!Deno.core.isNativeError({}));
+});
+
+test(function testIsNativeError() {
+  assert(Deno.core.isNumberObject(new Number(1)));
+  assert(!Deno.core.isNumberObject(1));
+});
+
+test(function testIsPromise() {
+  assert(Deno.core.isPromise(new Promise((resolve) => resolve(1))));
+  assert(!Deno.core.isPromise({}));
+});
+
+test(function testIsProxy() {
+  assert(Deno.core.isProxy(new Proxy({}, {})));
+  assert(!Deno.core.isProxy({}));
+});
+
+test(function testIsRegExp() {
+  assert(Deno.core.isRegExp(/foo/));
+  assert(!Deno.core.isRegExp({}));
+});
+
+test(function testIsSet() {
+  assert(Deno.core.isSet(new Set()));
+  assert(!Deno.core.isSet(new Map()));
+  assert(!Deno.core.isSet(new WeakSet()));
+  assert(!Deno.core.isSet(new WeakMap()));
+});
+
+test(function testIsSetIterator() {
+  const set = new Set();
+  assert(Deno.core.isSetIterator(set.values()));
+  assert(!Deno.core.isSetIterator(set));
+});
+
+test(function testIsSharedArrayBuffer() {
+  assert(Deno.core.isSharedArrayBuffer(new SharedArrayBuffer(4)));
+  assert(!Deno.core.isSharedArrayBuffer(new ArrayBuffer(4)));
+  assert(!Deno.core.isSharedArrayBuffer(new Uint8Array(4)));
+});
+
+test(function testIsStringObject() {
+  assert(Deno.core.isStringObject(new String("str")));
+  assert(!Deno.core.isStringObject("str"));
+});
+
+test(function testIsSymbolObject() {
+  assert(Deno.core.isSymbolObject(Object(Symbol())));
+  assert(!Deno.core.isSymbolObject(Symbol()));
+});
+
+test(function testIsTypedArray() {
+  assert(Deno.core.isTypedArray(new Uint8Array(4)));
+  assert(!Deno.core.isTypedArray(new DataView(new ArrayBuffer(4))));
+  assert(!Deno.core.isTypedArray(new ArrayBuffer(4)));
+});
+
+test(function testIsWeakMap() {
+  assert(Deno.core.isWeakMap(new WeakMap()));
+  assert(!Deno.core.isWeakMap(new WeakSet()));
+  assert(!Deno.core.isWeakMap(new Map()));
+  assert(!Deno.core.isWeakMap(new Set()));
+});
+
+test(function testIsWeakSet() {
+  assert(Deno.core.isWeakSet(new WeakSet()));
+  assert(!Deno.core.isWeakSet(new WeakMap()));
+  assert(!Deno.core.isWeakSet(new Set()));
+  assert(!Deno.core.isWeakSet(new Map()));
+});