Repository: denoland/deno_core
Pull request #840 (2024-07-23 23:48:39)

feat: v8 12.8
includes exciting new features we can use:
- https://github.com/denoland/rusty_v8/pull/1542
- https://github.com/denoland/rusty_v8/pull/1543
- CPED in 12.8


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index bca0e4d..6c5452c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -555,7 +555,7 @@ dependencies = [
 
 [[package]]
 name = "deno_core"
-version = "0.298.0"
+version = "0.299.0"
 dependencies = [
  "anyhow",
  "bencher",
@@ -624,7 +624,7 @@ dependencies = [
 
 [[package]]
 name = "deno_ops"
-version = "0.174.0"
+version = "0.175.0"
 dependencies = [
  "pretty_assertions",
  "prettyplease",
@@ -666,9 +666,9 @@ dependencies = [
 
 [[package]]
 name = "deno_unsync"
-version = "0.3.10"
+version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3c8b95582c2023dbb66fccc37421b374026f5915fa507d437cb566904db9a3a"
+checksum = "03ee1607db298c8f12124b345a52d5f2f504a7504c9d535f1d8f07127b237010"
 dependencies = [
  "parking_lot",
  "tokio",
@@ -1841,7 +1841,7 @@ dependencies = [
 
 [[package]]
 name = "serde_v8"
-version = "0.207.0"
+version = "0.208.0"
 dependencies = [
  "bencher",
  "num-bigint",
@@ -2728,9 +2728,9 @@ dependencies = [
 
 [[package]]
 name = "v8"
-version = "0.99.0"
+version = "0.100.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa3fc0608a78f0c7d4ec88025759cb78c90a29984b48540060355a626ae329c1"
+checksum = "393945ec4b535f31c59f048ad3fb1c3b56d432d5f8d2379cbf9f2506bf2b037f"
 dependencies = [
  "bindgen",
  "bitflags",
diff --git a/Cargo.toml b/Cargo.toml
index 7b9fe09..437d961 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,14 +19,14 @@ repository = "https://github.com/denoland/deno_core"
 
 [workspace.dependencies]
 # Local dependencies
-deno_core = { version = "0.298.0", path = "./core" }
-deno_ops = { version = "0.174.0", path = "./ops" }
-serde_v8 = { version = "0.207.0", path = "./serde_v8" }
+deno_core = { version = "0.299.0", path = "./core" }
+deno_ops = { version = "0.175.0", path = "./ops" }
+serde_v8 = { version = "0.208.0", path = "./serde_v8" }
 deno_core_testing = { path = "./testing" }
 
-v8 = { version = "0.99.0", default-features = false }
+v8 = { version = "0.100.0", default-features = false }
 deno_ast = { version = "=0.40.0", features = ["transpiling"] }
-deno_unsync = "0.3.10"
+deno_unsync = "0.4.0"
 deno_core_icudata = "0.0.73"
 
 anyhow = "1"
diff --git a/core/02_error.js b/core/02_error.js
deleted file mode 100644
index 1a7c8c3..0000000
--- a/core/02_error.js
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-"use strict";
-
-((window) => {
-  const core = Deno.core;
-  const {
-    op_format_file_name,
-    op_apply_source_map,
-    op_apply_source_map_filename,
-    op_set_call_site_evals,
-  } = core.ops;
-  const {
-    Error,
-    ArrayPrototypePush,
-    StringPrototypeStartsWith,
-    StringPrototypeEndsWith,
-    Uint8Array,
-    Uint32Array,
-  } = window.__bootstrap.primordials;
-
-  const DATA_URL_ABBREV_THRESHOLD = 150; // keep in sync with ./error.rs
-
-  // Keep in sync with `format_file_name` in ./error.rs
-  function formatFileName(fileName) {
-    if (
-      fileName.startsWith("data:") &&
-      fileName.length > DATA_URL_ABBREV_THRESHOLD
-    ) {
-      return op_format_file_name(fileName);
-    }
-    return fileName;
-  }
-
-  // Keep in sync with `cli/fmt_errors.rs`.
-  function formatLocation(callSite) {
-    if (callSite.isNative) {
-      return "native";
-    }
-    let result = "";
-    if (callSite.fileName) {
-      result += formatFileName(callSite.fileName);
-    } else {
-      if (callSite.isEval) {
-        if (callSite.evalOrigin == null) {
-          throw new Error("assert evalOrigin");
-        }
-        result += `${callSite.evalOrigin}, `;
-      }
-      result += "<anonymous>";
-    }
-    if (callSite.lineNumber !== null) {
-      result += `:${callSite.lineNumber}`;
-      if (callSite.columnNumber !== null) {
-        result += `:${callSite.columnNumber}`;
-      }
-    }
-    return result;
-  }
-
-  // Keep in sync with `cli/fmt_errors.rs`.
-  function formatCallSiteEval(callSite) {
-    let result = "";
-    if (callSite.isAsync) {
-      result += "async ";
-    }
-    if (callSite.isPromiseAll) {
-      result += `Promise.all (index ${callSite.promiseIndex})`;
-      return result;
-    }
-    const isMethodCall = !(callSite.isToplevel || callSite.isConstructor);
-    if (isMethodCall) {
-      if (callSite.functionName) {
-        if (callSite.typeName) {
-          if (
-            !StringPrototypeStartsWith(callSite.functionName, callSite.typeName)
-          ) {
-            result += `${callSite.typeName}.`;
-          }
-        }
-        result += callSite.functionName;
-        if (callSite.methodName) {
-          if (
-            !StringPrototypeEndsWith(callSite.functionName, callSite.methodName)
-          ) {
-            result += ` [as ${callSite.methodName}]`;
-          }
-        }
-      } else {
-        if (callSite.typeName) {
-          result += `${callSite.typeName}.`;
-        }
-        if (callSite.methodName) {
-          result += callSite.methodName;
-        } else {
-          result += "<anonymous>";
-        }
-      }
-    } else if (callSite.isConstructor) {
-      result += "new ";
-      if (callSite.functionName) {
-        result += callSite.functionName;
-      } else {
-        result += "<anonymous>";
-      }
-    } else if (callSite.functionName) {
-      result += callSite.functionName;
-    } else {
-      result += formatLocation(callSite);
-      return result;
-    }
-
-    result += ` (${formatLocation(callSite)})`;
-    return result;
-  }
-
-  const applySourceMapRetBuf = new Uint32Array(2);
-  const applySourceMapRetBufView = new Uint8Array(applySourceMapRetBuf.buffer);
-
-  function prepareStackTrace(error, callSites) {
-    const message = error.message !== undefined ? error.message : "";
-    const name = error.name !== undefined ? error.name : "Error";
-    let stack;
-    if (name != "" && message != "") {
-      stack = `${name}: ${message}`;
-    } else if ((name || message) != "") {
-      stack = name || message;
-    } else {
-      stack = "";
-    }
-    const callSiteEvals = [];
-    for (let i = 0; i < callSites.length; ++i) {
-      const v8CallSite = callSites[i];
-      const callSite = {
-        this: v8CallSite.getThis(),
-        typeName: v8CallSite.getTypeName(),
-        function: v8CallSite.getFunction(),
-        functionName: v8CallSite.getFunctionName(),
-        methodName: v8CallSite.getMethodName(),
-        fileName: v8CallSite.getFileName(),
-        lineNumber: v8CallSite.getLineNumber(),
-        columnNumber: v8CallSite.getColumnNumber(),
-        evalOrigin: v8CallSite.getEvalOrigin(),
-        isToplevel: v8CallSite.isToplevel(),
-        isEval: v8CallSite.isEval(),
-        isNative: v8CallSite.isNative(),
-        isConstructor: v8CallSite.isConstructor(),
-        isAsync: v8CallSite.isAsync(),
-        isPromiseAll: v8CallSite.isPromiseAll(),
-        promiseIndex: v8CallSite.getPromiseIndex(),
-      };
-      let res = 0;
-      if (
-        callSite.fileName !== null && callSite.lineNumber !== null &&
-        callSite.columnNumber !== null
-      ) {
-        res = op_apply_source_map(
-          callSite.fileName,
-          callSite.lineNumber,
-          callSite.columnNumber,
-          applySourceMapRetBufView,
-        );
-      }
-      if (res >= 1) {
-        callSite.lineNumber = applySourceMapRetBuf[0];
-        callSite.columnNumber = applySourceMapRetBuf[1];
-      }
-      if (res >= 2) {
-        callSite.fileName = op_apply_source_map_filename();
-      }
-      ArrayPrototypePush(callSiteEvals, callSite);
-      stack += `\n    at ${formatCallSiteEval(callSite)}`;
-    }
-    op_set_call_site_evals(error, callSiteEvals);
-    return stack;
-  }
-
-  Error.prepareStackTrace = prepareStackTrace;
-})(this);
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 2d86c58..d0c464a 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "deno_core"
-version = "0.298.0"
+version = "0.299.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/core/error.rs b/core/error.rs
index 7eacc75..79988fd 100644
--- a/core/error.rs
+++ b/core/error.rs
@@ -6,6 +6,7 @@ use std::fmt;
 use std::fmt::Debug;
 use std::fmt::Display;
 use std::fmt::Formatter;
+use std::fmt::Write as _;
 
 use anyhow::Error;
 
@@ -210,6 +211,90 @@ pub struct JsStackFrame {
   pub promise_index: Option<i64>,
 }
 
+/// Applies source map to the given location
+fn apply_source_map<'a>(
+  source_mapper: &mut crate::source_map::SourceMapper,
+  file_name: Cow<'a, str>,
+  line_number: i64,
+  column_number: i64,
+) -> (Cow<'a, str>, i64, i64) {
+  match source_mapper.apply_source_map(
+    &file_name,
+    line_number as u32,
+    column_number as u32,
+  ) {
+    SourceMapApplication::Unchanged => (file_name, line_number, column_number),
+    SourceMapApplication::LineAndColumn {
+      line_number,
+      column_number,
+    } => (file_name, line_number.into(), column_number.into()),
+    SourceMapApplication::LineAndColumnAndFileName {
+      file_name,
+      line_number,
+      column_number,
+    } => (file_name.into(), line_number.into(), column_number.into()),
+  }
+}
+
+/// Parses an eval origin string from V8, returning
+/// the contents before the location,
+/// (the file name, line number, and column number), and
+/// the contents after the location.
+///
+/// # Example
+/// ```ignore
+/// assert_eq!(
+///   parse_eval_origin("eval at foo (bar at (file://a.ts:1:2))"),
+///   Some(("eval at foo (bar at (", ("file://a.ts", 1, 2), "))")),
+/// );
+/// ```
+///
+fn parse_eval_origin(
+  eval_origin: &str,
+) -> Option<(&str, (&str, i64, i64), &str)> {
+  // The eval origin string we get from V8 looks like
+  // `eval at ${function_name} (${origin})`
+  // where origin can be either a file name, like
+  // "eval at foo (file:///path/to/script.ts:1:2)"
+  // or a nested eval origin, like
+  // "eval at foo (eval at bar (file:///path/to/script.ts:1:2))"
+  //
+  let eval_at = "eval at ";
+  // only the innermost eval origin can have location info, so find the last
+  // "eval at", then continue parsing the rest of the string
+  let mut innermost_start = eval_origin.rfind(eval_at)? + eval_at.len();
+  // skip over the function name
+  innermost_start += eval_origin[innermost_start..].find('(')? + 1;
+  if innermost_start >= eval_origin.len() {
+    // malformed
+    return None;
+  }
+
+  // from the right, split by ":" to get the column number, line number, file name
+  // (in that order, since we're iterating from the right). e.g.
+  // eval at foo (eval at bar (file://foo.ts:1:2))
+  //                           ^^^^^^^^^^^^^ ^ ^^^
+  let mut parts = eval_origin[innermost_start..].rsplitn(3, ':');
+  // the part with the column number will include extra stuff, the actual number ends at
+  // the closing paren
+  let column_number_with_rest = parts.next()?;
+  let column_number_end = column_number_with_rest.find(')')?;
+  let column_number = column_number_with_rest[..column_number_end]
+    .parse::<i64>()
+    .ok()?;
+  let line_number = parts.next()?.parse::<i64>().ok()?;
+  let file_name = parts.next()?;
+  // The column number starts after the last occurring ":".
+  let column_start = eval_origin.rfind(':')? + 1;
+  // the innermost origin ends at the end of the column number
+  let innermost_end = column_start + column_number_end;
+  Some((
+    &eval_origin[..innermost_start],
+    (file_name, line_number, column_number),
+    &eval_origin[innermost_end..],
+  ))
+}
+
 impl JsStackFrame {
   pub fn from_location(
     file_name: Option<String>,
@@ -234,6 +319,63 @@ impl JsStackFrame {
     }
   }
 
+  /// Creates a `JsStackFrame` from a `CallSite`` JS object,
+  /// provided by V8.
+  fn from_callsite_object<'s>(
+    scope: &mut v8::HandleScope<'s>,
+    callsite: v8::Local<'s, v8::Object>,
+  ) -> Option<Self> {
+    macro_rules! call {
+      ($key: ident : $t: ty) => {{
+        let res = call_method(scope, callsite, $key, &[])?;
+        let res: $t = serde_v8::from_v8(scope, res).ok()?;
+        res
+      }};
+      ($key: ident) => { call!($key : _) };
+    }
+
+    let state = JsRuntime::state_from(scope);
+    let mut source_mapper = state.source_mapper.borrow_mut();
+    // apply source map
+    let (file_name, line_number, column_number) = match (
+      call!(GET_FILE_NAME : Option<String>),
+      call!(GET_LINE_NUMBER),
+      call!(GET_COLUMN_NUMBER),
+    ) {
+      (Some(f), Some(l), Some(c)) => {
+        let (file_name, line_num, col_num) =
+          apply_source_map(&mut source_mapper, f.into(), l, c);
+        (Some(file_name.into_owned()), Some(line_num), Some(col_num))
+      }
+      (f, l, c) => (f, l, c),
+    };
+
+    // apply source map to the eval origin, if the error originates from `eval`ed code
+    let eval_origin = call!(GET_EVAL_ORIGIN: Option<String>).and_then(|o| {
+      let (before, (file, line, col), after) = parse_eval_origin(&o)?;
+      let (file, line, col) =
+        apply_source_map(&mut source_mapper, file.into(), line, col);
+      Some(format!("{before}{file}:{line}:{col}{after}"))
+    });
+
+    Some(Self {
+      file_name,
+      line_number,
+      column_number,
+      eval_origin,
+      type_name: call!(GET_TYPE_NAME),
+      function_name: call!(GET_FUNCTION_NAME),
+      method_name: call!(GET_METHOD_NAME),
+      is_top_level: call!(IS_TOPLEVEL),
+      is_eval: call!(IS_EVAL),
+      is_native: call!(IS_NATIVE),
+      is_constructor: call!(IS_CONSTRUCTOR),
+      is_async: call!(IS_ASYNC),
+      is_promise_all: call!(IS_PROMISE_ALL),
+      promise_index: call!(GET_PROMISE_INDEX),
+    })
+  }
+
   /// Gets the source mapped stack frame corresponding to the
   /// (script_resource_name, line_number, column_number) from a v8 message.
   /// For non-syntax errors, it should also correspond to the first stack frame.
@@ -244,35 +386,18 @@ impl JsStackFrame {
     let f = message.get_script_resource_name(scope)?;
     let f: v8::Local<v8::String> = f.try_into().ok()?;
     let f = f.to_rust_string_lossy(scope);
-    let l = message.get_line_number(scope)? as u32;
+    let l = message.get_line_number(scope)? as i64;
     // V8's column numbers are 0-based, we want 1-based.
-    let c = message.get_start_column() as u32 + 1;
+    let c = message.get_start_column() as i64 + 1;
     let state = JsRuntime::state_from(scope);
     let mut source_mapper = state.source_mapper.borrow_mut();
-    match source_mapper.apply_source_map(&f, l, c) {
-      SourceMapApplication::Unchanged => Some(JsStackFrame::from_location(
-        Some(f),
-        Some(l.into()),
-        Some(c.into()),
-      )),
-      SourceMapApplication::LineAndColumn {
-        line_number,
-        column_number,
-      } => Some(JsStackFrame::from_location(
-        Some(f),
-        Some(line_number.into()),
-        Some(column_number.into()),
-      )),
-      SourceMapApplication::LineAndColumnAndFileName {
-        file_name,
-        line_number,
-        column_number,
-      } => Some(JsStackFrame::from_location(
-        Some(file_name),
-        Some(line_number.into()),
-        Some(column_number.into()),
-      )),
-    }
+    let (file_name, line_num, col_num) =
+      apply_source_map(&mut source_mapper, f.into(), l, c);
+    Some(JsStackFrame::from_location(
+      Some(file_name.into_owned()),
+      Some(line_num),
+      Some(col_num),
+    ))
   }
 
   pub fn maybe_format_location(&self) -> Option<String> {
@@ -295,6 +420,22 @@ fn get_property<'a>(
   object.get(scope, key.into())
 }
 
+fn call_method<'a, T>(
+  scope: &mut v8::HandleScope<'a>,
+  object: v8::Local<v8::Object>,
+  key: FastStaticString,
+  args: &[v8::Local<'a, v8::Value>],
+) -> Option<v8::Local<'a, T>>
+where
+  v8::Local<'a, T>: TryFrom<v8::Local<'a, v8::Value>>,
+{
+  get_property(scope, object, key)?
+    .try_cast::<v8::Function>()
+    .ok()?
+    .call(scope, object.into(), args)
+    .and_then(|v| v8::Local::try_from(v).ok())
+}
+
 #[derive(Default, serde::Deserialize)]
 pub(crate) struct NativeJsError {
   pub name: Option<String>,
@@ -458,7 +599,16 @@ impl JsError {
 
       // Convert them into Vec<JsStackFrame>
       let mut frames: Vec<JsStackFrame> = match frames_v8 {
-        Some(frames_v8) => serde_v8::from_v8(scope, frames_v8.into()).unwrap(),
+        Some(frames_v8) => {
+          let mut buf = Vec::with_capacity(frames_v8.length() as usize);
+          for i in 0..frames_v8.length() {
+            let callsite = frames_v8.get_index(scope, i).unwrap().cast();
+            buf.push(
+              JsStackFrame::from_callsite_object(scope, callsite).unwrap(),
+            );
+          }
+          buf
+        }
         None => vec![],
       };
       let mut source_line = None;
@@ -780,6 +930,410 @@ pub fn throw_type_error(scope: &mut v8::HandleScope, message: impl AsRef<str>) {
   scope.throw_exception(exception);
 }
 
+v8_static_strings::v8_static_strings! {
+  ERROR = "Error",
+  GET_FILE_NAME = "getFileName",
+  GET_THIS = "getThis",
+  GET_TYPE_NAME = "getTypeName",
+  GET_FUNCTION = "getFunction",
+  GET_FUNCTION_NAME = "getFunctionName",
+  GET_METHOD_NAME = "getMethodName",
+  GET_LINE_NUMBER = "getLineNumber",
+  GET_COLUMN_NUMBER = "getColumnNumber",
+  GET_EVAL_ORIGIN = "getEvalOrigin",
+  IS_TOPLEVEL = "isToplevel",
+  IS_EVAL = "isEval",
+  IS_NATIVE = "isNative",
+  IS_CONSTRUCTOR = "isConstructor",
+  IS_ASYNC = "isAsync",
+  IS_PROMISE_ALL = "isPromiseAll",
+  GET_PROMISE_INDEX = "getPromiseIndex",
+  PREPARE_STACK_TRACE = "prepareStackTrace",
+  ORIGINAL = "_orig",
+}
+
+#[inline(always)]
+pub(crate) fn original_call_site_key<'a>(
+  scope: &mut v8::HandleScope<'a>,
+) -> v8::Local<'a, v8::Private> {
+  let name = ORIGINAL.v8_string(scope);
+  v8::Private::for_api(scope, Some(name))
+}
+
+fn make_patched_callsite<'s>(
+  scope: &mut v8::HandleScope<'s>,
+  callsite: v8::Local<'s, v8::Object>,
+  template: v8::Local<'s, v8::ObjectTemplate>,
+) -> v8::Local<'s, v8::Object> {
+  let out_obj = template.new_instance(scope).unwrap();
+  let orig_key = original_call_site_key(scope);
+  out_obj.set_private(scope, orig_key, callsite.into());
+  out_obj
+}
+
+/// Creates a template for a `Callsite`-like object, with
+/// a patched `getFileName`.
+/// Effectively:
+/// ```js
+/// const kOriginalCallsite = Symbol("_original");
+/// {
+///   [kOriginalCallsite]: originalCallSite,
+///   getLineNumber() {
+///     return this[kOriginalCallsite].getLineNumber();
+///   },
+///   // etc
+///   getFileName() {
+///     const fileName = this[kOriginalCallsite].getFileName();
+///     return fileUrlToPath(fileName);
+///   }
+/// }
+/// ```
+pub(crate) fn make_callsite_template<'s>(
+  scope: &mut v8::HandleScope<'s>,
+) -> v8::Local<'s, v8::ObjectTemplate> {
+  let template = v8::ObjectTemplate::new(scope);
+
+  // effectively
+  // `$field() { return this[kOriginalCallsite].$field() }`
+  macro_rules! make_delegate {
+    ($scope: ident, $template: ident, [$($field: ident),+ $(,)?]) => {
+      $(
+        {
+          let key = $field.v8_string($scope).into();
+          $template.set_with_attr(
+            key,
+            v8::FunctionBuilder::<v8::FunctionTemplate>::new(
+              |scope: &mut v8::HandleScope<'_>,
+              args: v8::FunctionCallbackArguments<'_>,
+              mut rv: v8::ReturnValue<'_>| {
+                let orig_key = original_call_site_key(scope);
+                let orig = args.this().get_private(scope, orig_key).unwrap();
+                let key = $field.v8_string(scope).into();
+                let orig_ret = orig
+                  .cast::<v8::Object>()
+                  .get(scope, key)
+                  .unwrap()
+                  .cast::<v8::Function>()
+                  .call(scope, orig, &[]);
+                rv.set(orig_ret.unwrap_or_else(|| v8::undefined(scope).into()));
+              },
+            )
+            .build($scope)
+            .into(),
+            v8::PropertyAttribute::DONT_DELETE
+            | v8::PropertyAttribute::DONT_ENUM
+            | v8::PropertyAttribute::READ_ONLY,
+          );
+        }
+      )+
+    };
+  }
+
+  // delegate to the original callsite object
+  make_delegate!(
+    scope,
+    template,
+    [
+      // excludes getFileName, which we'll override below
+      GET_THIS,
+      GET_TYPE_NAME,
+      GET_FUNCTION,
+      GET_FUNCTION_NAME,
+      GET_METHOD_NAME,
+      GET_LINE_NUMBER,
+      GET_COLUMN_NUMBER,
+      GET_EVAL_ORIGIN,
+      IS_TOPLEVEL,
+      IS_EVAL,
+      IS_NATIVE,
+      IS_CONSTRUCTOR,
+      IS_ASYNC,
+      IS_PROMISE_ALL,
+      GET_PROMISE_INDEX,
+    ]
+  );
+
+  let get_file_name_key = GET_FILE_NAME.v8_string(scope).into();
+  template.set_with_attr(
+    get_file_name_key,
+    v8::FunctionBuilder::<v8::FunctionTemplate>::new(
+      |scope: &mut v8::HandleScope<'_>,
+       args: v8::FunctionCallbackArguments<'_>,
+       mut rv: v8::ReturnValue<'_>| {
+        // lookup the original call site object
+        let orig_key = original_call_site_key(scope);
+        let orig = args.this().get_private(scope, orig_key).unwrap().cast();
+        // call getFileName
+        let orig_ret =
+          call_method::<v8::String>(scope, orig, GET_FILE_NAME, &[]);
+        if let Some(ret_val) = orig_ret {
+          // strip off `file://`
+          let string = ret_val.to_rust_string_lossy(scope);
+          let file_name = if string.starts_with("file://") {
+            Url::parse(&string)
+              .unwrap()
+              .to_file_path()
+              .unwrap()
+              .to_string_lossy()
+              .into_owned()
+          } else {
+            string
+          };
+          let v8_str =
+            crate::FastString::from(file_name).v8_string(scope).into();
+          rv.set(v8_str);
+        }
+      },
+    )
+    .build(scope)
+    .into(),
+    v8::PropertyAttribute::DONT_DELETE
+      | v8::PropertyAttribute::DONT_ENUM
+      | v8::PropertyAttribute::READ_ONLY,
+  );
+
+  template
+}
+
+// called by V8 whenever a stack trace is created.
+// note that this is called _instead_ of `Error.prepareStackTrace`
+// so we have to explicitly call it to keep user code wrking
+pub fn prepare_stack_trace_callback<'s>(
+  scope: &mut v8::HandleScope<'s>,
+  error: v8::Local<'s, v8::Value>,
+  callsites: v8::Local<'s, v8::Array>,
+) -> v8::Local<'s, v8::Value> {
+  // stash the callsites on the error object. this is used by `JsError::from_exception_inner`
+  // to get more details on an error, because the v8 StackFrame API is missing some info.
+  if let Ok(obj) = error.try_cast::<v8::Object>() {
+    let key = call_site_evals_key(scope);
+    obj.set_private(scope, key, callsites.into());
+  }
+
+  // `globalThis.Error.prepareStackTrace`
+  let global = scope.get_current_context().global(scope);
+  let global_error = get_property(scope, global, ERROR).unwrap().cast();
+  let prepare_fn = get_property(scope, global_error, PREPARE_STACK_TRACE)
+    .and_then(|f| f.try_cast::<v8::Function>().ok());
+
+  if let Some(prepare_fn) = prepare_fn {
+    // User defined `Error.prepareStackTrace`.
+    // Patch the callsites to have file paths, then call
+    // the user's function
+    let len = callsites.length();
+    let mut patched = Vec::with_capacity(len as usize);
+    let template = JsRuntime::state_from(scope)
+      .callsite_template
+      .borrow()
+      .clone()
+      .unwrap();
+    let template = v8::Local::new(scope, template);
+    for i in 0..len {
+      let callsite =
+        callsites.get_index(scope, i).unwrap().cast::<v8::Object>();
+      patched.push(make_patched_callsite(scope, callsite, template).into());
+    }
+    let patched_callsites = v8::Array::new_with_elements(scope, &patched);
+
+    // call the user's `prepareStackTrace` with our patched "callsite" objects
+    let this = global_error.into();
+    let args = &[error, patched_callsites.into()];
+    return prepare_fn
+      .call(scope, this, args)
+      .unwrap_or_else(|| v8::undefined(scope).into());
+  }
+
+  // no user defined `prepareStackTrace`, just call our default
+  format_stack_trace(scope, error, callsites)
+}
+
+fn format_stack_trace<'s>(
+  scope: &mut v8::HandleScope<'s>,
+  error: v8::Local<'s, v8::Value>,
+  callsites: v8::Local<'s, v8::Array>,
+) -> v8::Local<'s, v8::Value> {
+  let mut result = String::new();
+
+  if let Ok(obj) = error.try_cast() {
+    // Write out the error name + message, if any
+    let msg = get_property(scope, obj, v8_static_strings::MESSAGE)
+      .filter(|v| !v.is_undefined())
+      .map(|v| v.to_rust_string_lossy(scope))
+      .unwrap_or_default();
+    let name = get_property(scope, obj, v8_static_strings::NAME)
+      .filter(|v| !v.is_undefined())
+      .map(|v| v.to_rust_string_lossy(scope))
+      .unwrap_or_else(|| "Error".to_string());
+
+    match (!msg.is_empty(), !name.is_empty()) {
+      (true, true) => write!(result, "{}: {}", name, msg).unwrap(),
+      (true, false) => write!(result, "{}", msg).unwrap(),
+      (false, true) => write!(result, "{}", name).unwrap(),
+      (false, false) => {}
+    }
+  }
+
+  // format each stack frame
+  for i in 0..callsites.length() {
+    let callsite = callsites.get_index(scope, i).unwrap().cast::<v8::Object>();
+    let frame = JsStackFrame::from_callsite_object(scope, callsite).unwrap();
+    write!(result, "\n    at {}", format_frame::<NoAnsiColors>(&frame))
+      .unwrap();
+  }
+
+  let result = v8::String::new(scope, &result).unwrap();
+  result.into()
+}
+
+/// Formats an error without using ansi colors.
+pub struct NoAnsiColors;
+
+#[derive(Debug, Clone, Copy)]
+/// Part of an error stack trace
+pub enum ErrorElement {
+  /// An anonymous file or method name
+  Anonymous,
+  /// Text signifying a native stack frame
+  NativeFrame,
+  /// A source line number
+  LineNumber,
+  /// A source column number
+  ColumnNumber,
+  /// The name of a function (or method)
+  FunctionName,
+  /// The name of a source file
+  FileName,
+  /// The origin of an error coming from `eval`ed code
+  EvalOrigin,
+  /// Text signifying a call to `Promise.all`
+  PromiseAll,
+}
+
+/// Applies formatting to various parts of error stack traces.
+///
+/// This is to allow the `deno` crate to reuse `format_frame` and
+/// `format_location` but apply ANSI colors for terminal output,
+/// without adding extra dependencies to `deno_core`.
+pub trait ErrorFormat {
+  fn fmt_element(element: ErrorElement, s: &str) -> Cow<'_, str>;
+}
+
+impl ErrorFormat for NoAnsiColors {
+  fn fmt_element(_element: ErrorElement, s: &str) -> Cow<'_, str> {
+    s.into()
+  }
+}
+
+pub fn format_location<F: ErrorFormat>(frame: &JsStackFrame) -> String {
+  use ErrorElement::*;
+  let _internal = frame
+    .file_name
+    .as_ref()
+    .map(|f| f.starts_with("ext:"))
+    .unwrap_or(false);
+  if frame.is_native {
+    return F::fmt_element(NativeFrame, "native").to_string();
+  }
+  let mut result = String::new();
+  let file_name = frame.file_name.clone().unwrap_or_default();
+  if !file_name.is_empty() {
+    result += &F::fmt_element(FileName, &format_file_name(&file_name))
+  } else {
+    if frame.is_eval {
+      result += &(F::fmt_element(
+        ErrorElement::EvalOrigin,
+        frame.eval_origin.as_ref().unwrap(),
+      )
+      .to_string()
+        + ", ");
+    }
+    result += &F::fmt_element(Anonymous, "<anonymous>");
+  }
+  if let Some(line_number) = frame.line_number {
+    write!(
+      result,
+      ":{}",
+      F::fmt_element(LineNumber, &line_number.to_string())
+    )
+    .unwrap();
+    if let Some(column_number) = frame.column_number {
+      write!(
+        result,
+        ":{}",
+        F::fmt_element(ColumnNumber, &column_number.to_string())
+      )
+      .unwrap();
+    }
+  }
+  result
+}
+
+pub fn format_frame<F: ErrorFormat>(frame: &JsStackFrame) -> String {
+  use ErrorElement::*;
+  let _internal = frame
+    .file_name
+    .as_ref()
+    .map(|f| f.starts_with("ext:"))
+    .unwrap_or(false);
+  let is_method_call =
+    !(frame.is_top_level.unwrap_or_default() || frame.is_constructor);
+  let mut result = String::new();
+  if frame.is_async {
+    result += "async ";
+  }
+  if frame.is_promise_all {
+    result += &F::fmt_element(
+      PromiseAll,
+      &format!(
+        "Promise.all (index {})",
+        frame.promise_index.unwrap_or_default()
+      ),
+    );
+    return result;
+  }
+  if is_method_call {
+    let mut formatted_method = String::new();
+    if let Some(function_name) = &frame.function_name {
+      if let Some(type_name) = &frame.type_name {
+        if !function_name.starts_with(type_name) {
+          write!(formatted_method, "{type_name}.").unwrap();
+        }
+      }
+      formatted_method += function_name;
+      if let Some(method_name) = &frame.method_name {
+        if !function_name.ends_with(method_name) {
+          write!(formatted_method, " [as {method_name}]").unwrap();
+        }
+      }
+    } else {
+      if let Some(type_name) = &frame.type_name {
+        write!(formatted_method, "{type_name}.").unwrap();
+      }
+      if let Some(method_name) = &frame.method_name {
+        formatted_method += method_name
+      } else {
+        formatted_method += "<anonymous>";
+      }
+    }
+    result += F::fmt_element(FunctionName, &formatted_method).as_ref();
+  } else if frame.is_constructor {
+    result += "new ";
+    if let Some(function_name) = &frame.function_name {
+      write!(result, "{}", F::fmt_element(FunctionName, function_name))
+        .unwrap();
+    } else {
+      result += F::fmt_element(Anonymous, "<anonymous>").as_ref();
+    }
+  } else if let Some(function_name) = &frame.function_name {
+    result += F::fmt_element(FunctionName, function_name).as_ref();
+  } else {
+    result += &format_location::<F>(frame);
+    return result;
+  }
+  write!(result, " ({})", format_location::<F>(frame)).unwrap();
+  result
+}
+
 #[cfg(test)]
 mod tests {
   use super::*;
@@ -817,4 +1371,57 @@ mod tests {
       format_file_name("file:///%E6%9D%B1%E4%BA%AC/%F0%9F%A6%95.ts");
     assert_eq!(file_name, "file:///東京/🦕.ts");
   }
+
+  #[test]
+  fn test_parse_eval_origin() {
+    let cases = [
+      (
+        "eval at <anonymous> (file://path.ts:1:2)",
+        Some(("eval at <anonymous> (", ("file://path.ts", 1, 2), ")")),
+      ),
+      (
+        // malformed
+        "eval at (s:1:2",
+        None,
+      ),
+      (
+        // malformed
+        "at ()", None,
+      ),
+      (
+        // url with parens
+        "eval at foo (http://website.zzz/my-script).ts:1:2)",
+        Some((
+          "eval at foo (",
+          ("http://website.zzz/my-script).ts", 1, 2),
+          ")",
+        )),
+      ),
+      (
+        // nested
+        "eval at foo (eval at bar (file://path.ts:1:2))",
+        Some(("eval at foo (eval at bar (", ("file://path.ts", 1, 2), "))")),
+      ),
+    ];
+    for (input, expect) in cases {
+      match expect {
+        Some((
+          expect_before,
+          (expect_file, expect_line, expect_col),
+          expect_after,
+        )) => {
+          let (before, (file_name, line_number, column_number), after) =
+            parse_eval_origin(input).unwrap();
+          assert_eq!(before, expect_before);
+          assert_eq!(file_name, expect_file);
+          assert_eq!(line_number, expect_line);
+          assert_eq!(column_number, expect_col);
+          assert_eq!(after, expect_after);
+        }
+        None => {
+          assert!(parse_eval_origin(input).is_none());
+        }
+      }
+    }
+  }
 }
diff --git a/core/lib.rs b/core/lib.rs
index 8014af2..5d246f3 100644
--- a/core/lib.rs
+++ b/core/lib.rs
@@ -161,8 +161,6 @@ pub use crate::runtime::MODULE_MAP_SLOT_INDEX;
 pub use crate::runtime::V8_WRAPPER_OBJECT_INDEX;
 pub use crate::runtime::V8_WRAPPER_TYPE_INDEX;
 pub use crate::source_map::SourceMapData;
-#[allow(deprecated)]
-pub use crate::source_map::SourceMapGetter;
 pub use crate::tasks::V8CrossThreadTaskSpawner;
 pub use crate::tasks::V8TaskSpawner;
 
diff --git a/core/modules/map.rs b/core/modules/map.rs
index 2015b29..fa81420 100644
--- a/core/modules/map.rs
+++ b/core/modules/map.rs
@@ -777,6 +777,13 @@ impl ModuleMap {
       return Err(v8::Global::new(tc_scope, module.get_exception()));
     }
 
+    // FIXME: instantiate_module is called more than it should be,
+    // especially for dynamic imports. As a hack, bail out if the
+    // module status is already being instantiated.
+    if module.get_status() != v8::ModuleStatus::Uninstantiated {
+      return Ok(());
+    }
+
     tc_scope.set_slot(self as *const _);
     let instantiate_result =
       module.instantiate_module(tc_scope, Self::module_resolve_callback);
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index e410796..32764ad 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -117,9 +117,6 @@ builtin_ops! {
   ops_builtin_v8::op_destructure_error,
   ops_builtin_v8::op_dispatch_exception,
   ops_builtin_v8::op_op_names,
-  ops_builtin_v8::op_apply_source_map,
-  ops_builtin_v8::op_apply_source_map_filename,
-  ops_builtin_v8::op_set_call_site_evals,
   ops_builtin_v8::op_current_user_call_site,
   ops_builtin_v8::op_set_format_exception_callback,
   ops_builtin_v8::op_event_loop_has_more_work,
diff --git a/core/ops_builtin_v8.rs b/core/ops_builtin_v8.rs
index e02fe13..5263556 100644
--- a/core/ops_builtin_v8.rs
+++ b/core/ops_builtin_v8.rs
@@ -1,5 +1,4 @@
 // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-use crate::error::call_site_evals_key;
 use crate::error::custom_error;
 use crate::error::is_instance_of_error;
 use crate::error::range_error;
@@ -1040,74 +1039,6 @@ fn write_line_and_col_to_ret_buf(
   ret_buf[4..8].copy_from_slice(&column_number.to_le_bytes());
 }
 
-// Returns:
-// 0: no source mapping performed, use original location
-// 1: mapped line and column, but not file name. new line and column are in
-//    ret_buf, use original file name.
-// 2: mapped line, column, and file name. new line, column, and file name are in
-//    ret_buf. retrieve file name by calling `op_apply_source_map_filename`
-//    immediately after this op returns.
-#[op2(fast)]
-#[smi]
-pub fn op_apply_source_map(
-  state: &JsRuntimeState,
-  #[string] file_name: &str,
-  #[smi] line_number: u32,
-  #[smi] column_number: u32,
-  #[buffer] ret_buf: &mut [u8],
-) -> Result<u8, Error> {
-  if ret_buf.len() != 8 {
-    return Err(type_error("retBuf must be 8 bytes"));
-  }
-  let mut source_mapper = state.source_mapper.borrow_mut();
-  let application =
-    source_mapper.apply_source_map(file_name, line_number, column_number);
-  match application {
-    SourceMapApplication::Unchanged => Ok(0),
-    SourceMapApplication::LineAndColumn {
-      line_number,
-      column_number,
-    } => {
-      write_line_and_col_to_ret_buf(ret_buf, line_number, column_number);
-      Ok(1)
-    }
-    SourceMapApplication::LineAndColumnAndFileName {
-      line_number,
-      column_number,
-      file_name,
-    } => {
-      write_line_and_col_to_ret_buf(ret_buf, line_number, column_number);
-      source_mapper.stashed_file_name.replace(file_name);
-      Ok(2)
-    }
-  }
-}
-
-// Call to retrieve the stashed file name from a previous call to
-// `op_apply_source_map` that returned `2`.
-#[op2]
-#[string]
-pub fn op_apply_source_map_filename(
-  state: &JsRuntimeState,
-) -> Result<String, Error> {
-  state
-    .source_mapper
-    .borrow_mut()
-    .stashed_file_name
-    .take()
-    .ok_or_else(|| type_error("No stashed file name"))
-}
-
-#[op2]
-pub fn op_set_call_site_evals(
-  scope: &mut v8::HandleScope,
-  exception: v8::Local<v8::Object>,
-  value: v8::Local<v8::Value>,
-) {
-  let key = call_site_evals_key(scope);
-  assert!(exception.set_private(scope, key, value).unwrap())
-}
-
 #[op2]
 #[string]
 pub fn op_current_user_call_site(
diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs
index 6c680e1..9ea3ed7 100644
--- a/core/runtime/jsruntime.rs
+++ b/core/runtime/jsruntime.rs
@@ -45,8 +45,6 @@ use crate::runtime::ContextState;
 use crate::runtime::JsRealm;
 use crate::runtime::OpDriverImpl;
 use crate::source_map::SourceMapData;
-#[allow(deprecated)]
-use crate::source_map::SourceMapGetter;
 use crate::source_map::SourceMapper;
 use crate::stats::RuntimeActivityType;
 use crate::Extension;
@@ -325,10 +323,8 @@ pub(crate) static CONTEXT_SETUP_SOURCES: [InternalSourceFile; 2] = [
 
 /// These files are executed when we start setting up extensions. They rely
 /// on ops being already fully set up.
-pub(crate) static BUILTIN_SOURCES: [InternalSourceFile; 2] = [
-  internal_source_file!("01_core.js"),
-  internal_source_file!("02_error.js"),
-];
+pub(crate) static BUILTIN_SOURCES: [InternalSourceFile; 1] =
+  [internal_source_file!("01_core.js")];
 
 /// Executed after `BUILTIN_SOURCES` are executed. Provides a thin ES module
 /// that exports `core`, `internals` and `primordials` objects.
@@ -436,6 +432,7 @@ pub struct JsRuntimeState {
   pub(crate) eval_context_code_cache_ready_cb:
     Option<EvalContextCodeCacheReadyCb>,
   pub(crate) cppgc_template: RefCell<Option<v8::Global<v8::FunctionTemplate>>>,
+  pub(crate) callsite_template: RefCell<Option<v8::Global<v8::ObjectTemplate>>>,
   waker: Arc<AtomicWaker>,
   /// Accessed through [`JsRuntimeState::with_inspector`].
   inspector: RefCell<Option<Rc<RefCell<JsRuntimeInspector>>>>,
@@ -444,11 +441,6 @@ pub struct JsRuntimeState {
 
 #[derive(Default)]
 pub struct RuntimeOptions {
-  /// Source map reference for errors.
-  #[deprecated = "Update `ModuleLoader` trait implementations. This option will be removed in deno_core v0.300.0."]
-  #[allow(deprecated)]
-  pub source_map_getter: Option<Rc<dyn SourceMapGetter>>,
-
   /// Allows to map error type to a string "class" used to represent
   /// error in JavaScript.
   pub get_error_class_fn: Option<GetErrorClassFn>,
@@ -695,9 +687,7 @@ impl JsRuntime {
       .module_loader
       .unwrap_or_else(|| Rc::new(NoopModuleLoader));
 
-    #[allow(deprecated)]
-    let mut source_mapper =
-      SourceMapper::new(loader.clone(), options.source_map_getter);
+    let mut source_mapper = SourceMapper::new(loader.clone());
 
     let mut sources = extension_set::into_sources_and_source_maps(
       options.extension_transpiler.as_deref(),
@@ -745,6 +735,7 @@ impl JsRuntime {
       inspector: None.into(),
       has_inspector: false.into(),
       cppgc_template: None.into(),
+      callsite_template: None.into(),
     });
 
     // ...now we're moving on to ops; set them up, create `OpCtx` for each op
@@ -902,6 +893,12 @@ impl JsRuntime {
     let scope = &mut context_scope;
     let context = v8::Local::new(scope, &main_context);
 
+    let callsite_template = crate::error::make_callsite_template(scope);
+    state_rc
+      .callsite_template
+      .borrow_mut()
+      .replace(v8::Global::new(scope, callsite_template));
+
     // ...followed by creation of `Deno.core` namespace, as well as internal
     // infrastructure to provide JavaScript bindings for ops...
     if init_mode == InitMode::New {
diff --git a/core/runtime/setup.rs b/core/runtime/setup.rs
index 7e935ae..dd44e4a 100644
--- a/core/runtime/setup.rs
+++ b/core/runtime/setup.rs
@@ -149,6 +149,9 @@ pub fn create_isolate(
 
   isolate.set_capture_stack_trace_for_uncaught_exceptions(true, 10);
   isolate.set_promise_reject_callback(bindings::promise_reject_callback);
+  isolate.set_prepare_stack_trace_callback(
+    crate::error::prepare_stack_trace_callback,
+  );
   isolate.set_host_initialize_import_meta_object_callback(
     bindings::host_initialize_import_meta_object_callback,
   );
diff --git a/core/runtime/v8_static_strings.rs b/core/runtime/v8_static_strings.rs
index 9e94214..0fad47f 100644
--- a/core/runtime/v8_static_strings.rs
+++ b/core/runtime/v8_static_strings.rs
@@ -7,6 +7,8 @@ macro_rules! v8_static_strings {
   };
 }
 
+pub(crate) use v8_static_strings;
+
 v8_static_strings!(
   BUILD_CUSTOM_ERROR = "buildCustomError",
   CALL_CONSOLE = "callConsole",
diff --git a/core/source_map.rs b/core/source_map.rs
index 4da0027..316eac7 100644
--- a/core/source_map.rs
+++ b/core/source_map.rs
@@ -2,9 +2,6 @@
 
 //! This mod provides functions to remap a `JsError` based on a source map.
 
-// TODO(bartlomieju): remove once `SourceMapGetter` is removed.
-#![allow(deprecated)]
-
 use crate::resolve_url;
 use crate::ModuleLoader;
 use crate::ModuleName;
@@ -14,17 +11,6 @@ use std::collections::HashMap;
 use std::rc::Rc;
 use std::str;
 
-#[deprecated = "Use `ModuleLoader` methods instead. This trait will be removed in deno_core v0.300.0."]
-pub trait SourceMapGetter {
-  /// Returns the raw source map file.
-  fn get_source_map(&self, file_name: &str) -> Option<Vec<u8>>;
-  fn get_source_line(
-    &self,
-    file_name: &str,
-    line_number: usize,
-  ) -> Option<String>;
-}
-
 #[derive(Debug, PartialEq)]
 pub enum SourceMapApplication {
   /// No mapping was applied, the location is unchanged.
@@ -51,26 +37,17 @@ pub struct SourceMapper {
   source_lines: HashMap<(String, i64), Option<String>>,
 
   loader: Rc<dyn ModuleLoader>,
-  getter: Option<Rc<dyn SourceMapGetter>>,
 
   ext_source_maps: HashMap<ModuleName, SourceMapData>,
-  // This is not the right place for this, but it's the easiest way to make
-  // op_apply_source_map a fast op. This stashing should happen in #[op2].
-  pub(crate) stashed_file_name: Option<String>,
 }
 
 impl SourceMapper {
-  pub fn new(
-    loader: Rc<dyn ModuleLoader>,
-    getter: Option<Rc<dyn SourceMapGetter>>,
-  ) -> Self {
+  pub fn new(loader: Rc<dyn ModuleLoader>) -> Self {
     Self {
       maps: Default::default(),
       source_lines: Default::default(),
       ext_source_maps: Default::default(),
       loader,
-      getter,
-      stashed_file_name: Default::default(),
     }
   }
 
@@ -104,7 +81,6 @@ impl SourceMapper {
     let line_number = line_number - 1;
     let column_number = column_number - 1;
 
-    let getter = self.getter.as_ref();
     let maybe_source_map =
       self.maps.entry(file_name.to_owned()).or_insert_with(|| {
         None
@@ -114,9 +90,6 @@ impl SourceMapper {
           .or_else(|| {
             SourceMap::from_slice(&self.loader.get_source_map(file_name)?).ok()
           })
-          .or_else(|| {
-            SourceMap::from_slice(&getter?.get_source_map(file_name)?).ok()
-          })
       });
 
     let Some(source_map) = maybe_source_map.as_ref() else {
@@ -176,24 +149,9 @@ impl SourceMapper {
       return maybe_source_line.clone();
     }
 
-    // TODO(bartlomieju): shouldn't we cache `None` values to avoid computing it each time, instead of early return?
-    if let Some(source_line) = self
+    let s = self
       .loader
-      .get_source_mapped_source_line(file_name, (line_number - 1) as usize)
-      .filter(|s| s.len() <= Self::MAX_SOURCE_LINE_LENGTH)
-    {
-      // Cache and return
-      self.source_lines.insert(
-        (file_name.to_string(), line_number),
-        Some(source_line.to_string()),
-      );
-      return Some(source_line);
-    }
-
-    // TODO(bartlomieju): remove in deno_core 0.230.0
-    // Fallback to a deprecated API
-    let getter = self.getter.as_ref()?;
-    let s = getter.get_source_line(file_name, (line_number - 1) as usize);
+      .get_source_mapped_source_line(file_name, (line_number - 1) as usize);
     let maybe_source_line =
       s.filter(|s| s.len() <= Self::MAX_SOURCE_LINE_LENGTH);
     // Cache and return
@@ -279,7 +237,7 @@ mod tests {
       },
     );
 
-    let mut source_mapper = SourceMapper::new(Rc::new(loader), None);
+    let mut source_mapper = SourceMapper::new(Rc::new(loader));
 
     // Non-existent file
     let application =
diff --git a/ops/Cargo.toml b/ops/Cargo.toml
index 48cb024..d101bee 100644
--- a/ops/Cargo.toml
+++ b/ops/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "deno_ops"
-version = "0.174.0"
+version = "0.175.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true
diff --git a/serde_v8/Cargo.toml b/serde_v8/Cargo.toml
index f2e8ba6..b4f7ef1 100644
--- a/serde_v8/Cargo.toml
+++ b/serde_v8/Cargo.toml
@@ -2,7 +2,7 @@
 
 [package]
 name = "serde_v8"
-version = "0.207.0"
+version = "0.208.0"
 authors.workspace = true
 edition.workspace = true
 license.workspace = true


Test patch:
diff --git a/.github/workflows/ci-test-valgrind/suppressions.txt b/.github/workflows/ci-test-valgrind/suppressions.txt
index ee24aaa..e378125 100644
--- a/.github/workflows/ci-test-valgrind/suppressions.txt
+++ b/.github/workflows/ci-test-valgrind/suppressions.txt
@@ -30,7 +30,7 @@
 {
    <insert_a_suppression_name_here>
    Memcheck:Value8
-   fun:_ZN2v88internal17InstructionStream16RelocateFromDescERNS0_21WritableJitAllocationEPNS0_4HeapERKNS0_8CodeDescEmRKNS0_22CombinationAssertScopeIJNS0_29PerThreadAssertScopeDebugOnlyILNS0_19PerThreadAssertTypeE0ELb0EEENSA_ILSB_1ELb0EEEEEE
+   fun:_ZN2v88internal17InstructionStream16RelocateFromDescERNS0_21WritableJitAllocationEPNS0_4HeapERKNS0_8CodeDescEmRKNS0_25PerThreadAssertScopeEmptyILb0EJLNS0_19PerThreadAssertTypeE1ELSA_2EEEE
    fun:_ZN2v88internal7Factory11CodeBuilder13BuildInternalEb
    fun:_ZN2v88internal6maglev19MaglevCodeGenerator15BuildCodeObjectEPNS0_12LocalIsolateE
    fun:_ZN2v88internal6maglev14MaglevCompiler12GenerateCodeEPNS0_7IsolateEPNS1_21MaglevCompilationInfoE
diff --git a/core/runtime/tests/misc.rs b/core/runtime/tests/misc.rs
index 6fd9e52..4bc0c94 100644
--- a/core/runtime/tests/misc.rs
+++ b/core/runtime/tests/misc.rs
@@ -1255,7 +1255,7 @@ async fn global_template_middleware() {
     _key: v8::Local<'s, v8::Name>,
     _value: v8::Local<'s, v8::Value>,
     _args: v8::PropertyCallbackArguments<'s>,
-    _rv: v8::ReturnValue,
+    _rv: v8::ReturnValue<()>,
   ) -> v8::Intercepted {
     unsafe {
       CALLS.push("setter".to_string());
@@ -1268,7 +1268,7 @@ async fn global_template_middleware() {
     _key: v8::Local<'s, v8::Name>,
     _descriptor: &v8::PropertyDescriptor,
     _args: v8::PropertyCallbackArguments<'s>,
-    _rv: v8::ReturnValue,
+    _rv: v8::ReturnValue<()>,
   ) -> v8::Intercepted {
     unsafe {
       CALLS.push("definer".to_string());
diff --git a/testing/integration/error_eval_stack/error_eval_stack.out b/testing/integration/error_eval_stack/error_eval_stack.out
new file mode 100644
index 0000000..8c46c06
--- /dev/null
+++ b/testing/integration/error_eval_stack/error_eval_stack.out
@@ -0,0 +1,6 @@
+[ERR] Error
+[ERR]     at eval (eval at <anonymous> (eval at <anonymous> (eval at foo (test:///integration/error_eval_stack/error_eval_stack.ts:5:3))), <anonymous>:1:7)
+[ERR]     at eval (eval at <anonymous> (eval at foo (test:///integration/error_eval_stack/error_eval_stack.ts:5:3)), <anonymous>:1:1)
+[ERR]     at eval (eval at foo (test:///integration/error_eval_stack/error_eval_stack.ts:5:3), <anonymous>:1:1)
+[ERR]     at foo (test:///integration/error_eval_stack/error_eval_stack.ts:5:3)
+[ERR]     at test:///integration/error_eval_stack/error_eval_stack.ts:8:1
diff --git a/testing/integration/error_eval_stack/error_eval_stack.ts b/testing/integration/error_eval_stack/error_eval_stack.ts
new file mode 100644
index 0000000..be67ab0
--- /dev/null
+++ b/testing/integration/error_eval_stack/error_eval_stack.ts
@@ -0,0 +1,8 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+// FAIL
+
+function foo() {
+  eval(`eval("eval('throw new Error()')")`);
+}
+
+foo();
diff --git a/testing/lib.rs b/testing/lib.rs
index 5a6d683..6314e80 100644
--- a/testing/lib.rs
+++ b/testing/lib.rs
@@ -59,6 +59,7 @@ integration_test!(
   error_async_stack,
   error_rejection_catch,
   error_rejection_order,
+  error_eval_stack,
   error_ext_stack,
   error_with_stack,
   error_without_stack,