Repository: denoland/deno_core
Pull request #622 (2024-03-01 00:20:07)

refactor(core): execute_script_static -> execute_script
Split out from #620 

We can simplify this embedder-facing API by using a single overload. This reduces the noise of the other PR significantly.

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/denoland/deno_core/pull/622?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 82.04%. Comparing base [(`e42470d`)](https://app.codecov.io/gh/denoland/deno_core/commit/e42470db922eabd75984d82f413c0f043e396dd7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland) to head [(`08e723a`)](https://app.codecov.io/gh/denoland/deno_core/pull/622?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland).


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #622      +/-   ##
==========================================
+ Coverage   82.03%   82.04%   +0.01%     
==========================================
  Files          96       96              
  Lines       23281    23261      -20     
==========================================
- Hits        19098    19084      -14     
+ Misses       4183     4177       -6     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/denoland/deno_core/pull/622?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=denoland).


Patch:
diff --git a/core/benches/ops/async.rs b/core/benches/ops/async.rs
index a30b282..84656ff 100644
--- a/core/benches/ops/async.rs
+++ b/core/benches/ops/async.rs
@@ -138,7 +138,7 @@ fn bench_op(
 
   // Prime the optimizer
   runtime
-    .execute_script("", FastString::Owned(harness.into()))
+    .execute_script("", harness)
     .map_err(err_mapper)
     .unwrap();
   let guard = tokio.enter();
diff --git a/core/benches/ops/sync.rs b/core/benches/ops/sync.rs
index 017acb1..9f483ea 100644
--- a/core/benches/ops/sync.rs
+++ b/core/benches/ops/sync.rs
@@ -191,7 +191,7 @@ fn bench_op(
 
   // Prime the optimizer
   runtime
-    .execute_script("", FastString::Owned(harness.into()))
+    .execute_script("", harness)
     .map_err(err_mapper)
     .unwrap();
   let bench = runtime.execute_script("", ascii_str!("bench")).unwrap();
diff --git a/core/examples/disable_ops.rs b/core/examples/disable_ops.rs
index d5c2ad3..45dc70d 100644
--- a/core/examples/disable_ops.rs
+++ b/core/examples/disable_ops.rs
@@ -24,6 +24,6 @@ fn main() {
 
   // Deno.core.print() will now be a NOP
   runtime
-    .execute_script_static("<usage>", r#"Deno.core.print("I'm broken")"#)
+    .execute_script("<usage>", r#"Deno.core.print("I'm broken")"#)
     .unwrap();
 }
diff --git a/core/examples/eval_js_value.rs b/core/examples/eval_js_value.rs
index fb9c54e..30d4128 100644
--- a/core/examples/eval_js_value.rs
+++ b/core/examples/eval_js_value.rs
@@ -28,7 +28,7 @@ fn eval(
   context: &mut JsRuntime,
   code: &'static str,
 ) -> Result<serde_json::Value, String> {
-  let res = context.execute_script_static("<anon>", code);
+  let res = context.execute_script("<anon>", code);
   match res {
     Ok(global) => {
       let scope = &mut context.handle_scope();
diff --git a/core/examples/hello_world.rs b/core/examples/hello_world.rs
index b57055d..080b632 100644
--- a/core/examples/hello_world.rs
+++ b/core/examples/hello_world.rs
@@ -32,7 +32,7 @@ fn main() {
   // contains a Deno.core object with several functions for interacting with it.
   // You can find its definition in core.js.
   runtime
-    .execute_script_static(
+    .execute_script(
       "<usage>",
       r#"
 // Print helper function, calling Deno.core.print()
diff --git a/core/fast_string.rs b/core/fast_string.rs
index cc1079a..db21aa8 100644
--- a/core/fast_string.rs
+++ b/core/fast_string.rs
@@ -187,6 +187,14 @@ impl PartialEq for FastString {
 
 impl Eq for FastString {}
 
+/// [`FastString`] can be made cheaply from `&'static str` as we know it's owned and don't need to do an
+/// ASCII check.
+impl From<&'static str> for FastString {
+  fn from(value: &'static str) -> Self {
+    FastString::from_static(value)
+  }
+}
+
 /// [`FastString`] can be made cheaply from [`Url`] as we know it's owned and don't need to do an
 /// ASCII check.
 impl From<Url> for FastString {
diff --git a/core/runtime/jsrealm.rs b/core/runtime/jsrealm.rs
index 7770007..7ffb766 100644
--- a/core/runtime/jsrealm.rs
+++ b/core/runtime/jsrealm.rs
@@ -247,34 +247,6 @@ impl JsRealm {
     unsafe { self.0.context.get_unchecked() as *const _ as _ }
   }
 
-  /// Executes traditional JavaScript code (traditional = not ES modules) in the
-  /// realm's context.
-  ///
-  /// For info on the [`v8::Isolate`] parameter, check [`JsRealm#panics`].
-  ///
-  /// The `name` parameter can be a filepath or any other string. E.g.:
-  ///
-  ///   - "/some/file/path.js"
-  ///   - "<anon>"
-  ///   - "[native code]"
-  ///
-  /// The same `name` value can be used for multiple executions.
-  ///
-  /// `Error` can usually be downcast to `JsError`.
-  #[cfg(test)]
-  pub fn execute_script_static(
-    &self,
-    isolate: &mut v8::Isolate,
-    name: &'static str,
-    source_code: &'static str,
-  ) -> Result<v8::Global<v8::Value>, Error> {
-    self.execute_script(
-      isolate,
-      name,
-      ModuleCodeString::from_static(source_code),
-    )
-  }
-
   /// Executes traditional JavaScript code (traditional = not ES modules) in the
   /// realm's context.
   ///
@@ -293,8 +265,9 @@ impl JsRealm {
     &self,
     isolate: &mut v8::Isolate,
     name: &'static str,
-    source_code: ModuleCodeString,
+    source_code: impl Into<ModuleCodeString>,
   ) -> Result<v8::Global<v8::Value>, Error> {
+    let source_code = source_code.into();
     let scope = &mut self.0.handle_scope(isolate);
 
     let source = source_code.v8_string(scope);
diff --git a/core/runtime/jsruntime.rs b/core/runtime/jsruntime.rs
index e723227..f1908d9 100644
--- a/core/runtime/jsruntime.rs
+++ b/core/runtime/jsruntime.rs
@@ -1282,7 +1282,7 @@ impl JsRuntime {
   pub fn execute_script(
     &mut self,
     name: &'static str,
-    source_code: ModuleCodeString,
+    source_code: impl Into<ModuleCodeString>,
   ) -> Result<v8::Global<v8::Value>, Error> {
     let isolate = &mut self.inner.v8_isolate;
     self
@@ -1291,33 +1291,6 @@ impl JsRuntime {
       .execute_script(isolate, name, source_code)
   }
 
-  /// Executes traditional JavaScript code (traditional = not ES modules).
-  ///
-  /// The execution takes place on the current main realm, so it is possible
-  /// to maintain local JS state and invoke this method multiple times.
-  ///
-  /// `name` can be a filepath or any other string, but it is required to be 7-bit ASCII, eg.
-  ///
-  ///   - "/some/file/path.js"
-  ///   - "<anon>"
-  ///   - "[native code]"
-  ///
-  /// The same `name` value can be used for multiple executions.
-  ///
-  /// `Error` can usually be downcast to `JsError`.
-  pub fn execute_script_static(
-    &mut self,
-    name: &'static str,
-    source_code: &'static str,
-  ) -> Result<v8::Global<v8::Value>, Error> {
-    let isolate = &mut self.inner.v8_isolate;
-    self.inner.main_realm.execute_script(
-      isolate,
-      name,
-      ModuleCodeString::from_static(source_code),
-    )
-  }
-
   /// Call a function and return a future resolving with the return value of the
   /// function. If the function returns a promise, the future will resolve only once the
   /// event loop resolves the underlying promise. If the future rejects, the future will
diff --git a/core/runtime/ops.rs b/core/runtime/ops.rs
index f825198..2721913 100644
--- a/core/runtime/ops.rs
+++ b/core/runtime/ops.rs
@@ -521,7 +521,6 @@ mod tests {
   use crate::external::ExternalPointer;
   use crate::op2;
   use crate::runtime::JsRuntimeState;
-  use crate::FastString;
   use crate::JsRuntime;
   use crate::OpState;
   use crate::RuntimeOptions;
@@ -659,39 +658,31 @@ mod tests {
     runtime
       .execute_script(
         "",
-        FastString::Owned(
-          format!(
-            r"
-            const {{ op_test_fail, op_test_print_debug, {op} }} = Deno.core.ensureFastOps();
-            function assert(b) {{
-              if (!b) {{
-                op_test_fail();
-              }}
+        format!(r"
+          const {{ op_test_fail, op_test_print_debug, {op} }} = Deno.core.ensureFastOps();
+          function assert(b) {{
+            if (!b) {{
+              op_test_fail();
             }}
-            function assertErrorContains(e, s) {{
-              assert(String(e).indexOf(s) != -1)
-            }}
-            function log(s) {{
-              op_test_print_debug(String(s))
-            }}
-          "
-          )
-          .into(),
-        ),
+          }}
+          function assertErrorContains(e, s) {{
+            assert(String(e).indexOf(s) != -1)
+          }}
+          function log(s) {{
+            op_test_print_debug(String(s))
+          }}
+        ")
       )
       .map_err(err_mapper)?;
     FAIL.with(|b| b.set(false));
     runtime.execute_script(
       "",
-      FastString::Owned(
-        format!(
-          r"
-      for (let __index__ = 0; __index__ < {repeat}; __index__++) {{
-        {test}
-      }}
-    "
-        )
-        .into(),
+      format!(
+        r"
+        for (let __index__ = 0; __index__ < {repeat}; __index__++) {{
+          {test}
+        }}
+      "
       ),
     )?;
     if FAIL.with(|b| b.get()) {
@@ -716,41 +707,33 @@ mod tests {
     runtime
       .execute_script(
         "",
-        FastString::Owned(
-          format!(
-            r"
-            const {{ op_test_fail, op_test_print_debug, {op} }} = Deno.core.ensureFastOps();
-            function assert(b) {{
-              if (!b) {{
-                op_test_fail();
-              }}
+        format!(r"
+          const {{ op_test_fail, op_test_print_debug, {op} }} = Deno.core.ensureFastOps();
+          function assert(b) {{
+            if (!b) {{
+              op_test_fail();
             }}
-            function assertErrorContains(e, s) {{
-              assert(String(e).indexOf(s) != -1)
-            }}
-            function log(s) {{
-              op_test_print_debug(String(s))
-            }}
-          "
-          )
-          .into(),
-        ),
+          }}
+          function assertErrorContains(e, s) {{
+            assert(String(e).indexOf(s) != -1)
+          }}
+          function log(s) {{
+            op_test_print_debug(String(s))
+          }}
+        ")
       )
       .map_err(err_mapper)?;
     FAIL.with(|b| b.set(false));
     runtime.execute_script(
       "",
-      FastString::Owned(
-        format!(
-          r"
-            (async () => {{
-              for (let __index__ = 0; __index__ < {repeat}; __index__++) {{
-                {test}
-              }}
-            }})()
-          "
-        )
-        .into(),
+      format!(
+        r"
+        (async () => {{
+          for (let __index__ = 0; __index__ < {repeat}; __index__++) {{
+            {test}
+          }}
+        }})()
+      "
       ),
     )?;
 
diff --git a/core/runtime/snapshot.rs b/core/runtime/snapshot.rs
index 09c7f7e..97ff65e 100644
--- a/core/runtime/snapshot.rs
+++ b/core/runtime/snapshot.rs
@@ -178,7 +178,7 @@ pub fn create_snapshot(
       with_runtime_cb(&mut js_runtime);
     }
 
-    js_runtime.execute_script_static("warmup", warmup_script)?;
+    js_runtime.execute_script("warmup", warmup_script)?;
 
     snapshot = js_runtime.snapshot();
   }


Test patch:
diff --git a/core/modules/tests.rs b/core/modules/tests.rs
index fa04287..e78d4bd 100644
--- a/core/modules/tests.rs
+++ b/core/modules/tests.rs
@@ -344,7 +344,7 @@ fn test_mods() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "setup.js",
       r#"
       function assert(cond) {
@@ -426,7 +426,7 @@ fn test_lazy_loaded_esm() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "setup.js",
       r#"
       Deno.core.print("1\n");
@@ -449,7 +449,7 @@ fn test_json_module() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "setup.js",
       r#"
         function assert(cond) {
@@ -942,7 +942,7 @@ async fn dyn_import_err() {
   // Test an erroneous dynamic import where the specified module isn't found.
   poll_fn(move |cx| {
     runtime
-      .execute_script_static(
+      .execute_script(
         "file:///dyn_import2.js",
         r#"
       (async () => {
@@ -974,7 +974,7 @@ async fn dyn_import_ok() {
   poll_fn(move |cx| {
     // Dynamically import mod_b
     runtime
-      .execute_script_static(
+      .execute_script(
         "file:///dyn_import3.js",
         r#"
         (async () => {
@@ -1021,7 +1021,7 @@ async fn dyn_import_borrow_mut_error() {
 
   poll_fn(move |cx| {
     runtime
-      .execute_script_static(
+      .execute_script(
         "file:///dyn_import3.js",
         r#"
         (async () => {
@@ -1434,7 +1434,7 @@ fn dynamic_imports_snapshot() {
   });
 
   //Evaluate the snapshot with an empty function
-  runtime2.execute_script_static("check.js", "true").unwrap();
+  runtime2.execute_script("check.js", "true").unwrap();
 }
 
 #[test]
@@ -1477,7 +1477,7 @@ fn import_meta_snapshot() {
   });
 
   runtime2
-    .execute_script_static(
+    .execute_script(
       "check.js",
       "if (globalThis.url !== 'file:///main_with_code.js') throw Error('x')",
     )
diff --git a/core/runtime/tests/error.rs b/core/runtime/tests/error.rs
index 47ae5fb..82ae74f 100644
--- a/core/runtime/tests/error.rs
+++ b/core/runtime/tests/error.rs
@@ -27,7 +27,7 @@ async fn test_error_builder() {
   });
   poll_fn(move |cx| {
     runtime
-      .execute_script_static(
+      .execute_script(
         "error_builder_test.js",
         include_str!("error_builder_test.js"),
       )
@@ -45,7 +45,7 @@ async fn test_error_builder() {
 fn syntax_error() {
   let mut runtime = JsRuntime::new(Default::default());
   let src = "hocuspocus(";
-  let r = runtime.execute_script_static("i.js", src);
+  let r = runtime.execute_script("i.js", src);
   let e = r.unwrap_err();
   let js_error = e.downcast::<JsError>().unwrap();
   let frame = js_error.frames.first().unwrap();
diff --git a/core/runtime/tests/jsrealm.rs b/core/runtime/tests/jsrealm.rs
index bccf8d4..e34dc13 100644
--- a/core/runtime/tests/jsrealm.rs
+++ b/core/runtime/tests/jsrealm.rs
@@ -28,8 +28,7 @@ fn test_set_format_exception_callback_realms() {
               return `{realm_name} / ${{error}}`;
             }});
           "#
-        )
-        .into(),
+        ),
       )
       .unwrap();
   }
@@ -40,7 +39,7 @@ fn test_set_format_exception_callback_realms() {
       let result = realm.execute_script(
         runtime.v8_isolate(),
         "",
-        format!("throw new Error('{realm_name}');").into(),
+        format!("throw new Error('{realm_name}');"),
       );
       assert!(result.is_err());
 
@@ -57,7 +56,7 @@ fn test_set_format_exception_callback_realms() {
         .execute_script(
           runtime.v8_isolate(),
           "",
-          format!("Promise.reject(new Error('{realm_name}'));").into(),
+          format!("Promise.reject(new Error('{realm_name}'));"),
         )
         .unwrap();
 
@@ -91,7 +90,7 @@ async fn js_realm_ref_unref_ops() {
     let main_realm = runtime.main_realm();
 
     main_realm
-      .execute_script_static(
+      .execute_script(
         runtime.v8_isolate(),
         "",
         r#"
@@ -106,7 +105,7 @@ async fn js_realm_ref_unref_ops() {
     ));
 
     main_realm
-      .execute_script_static(
+      .execute_script(
         runtime.v8_isolate(),
         "",
         r#"
@@ -150,9 +149,7 @@ fn es_snapshot() {
 
   // The module was evaluated ahead of time
   {
-    let global_test = runtime
-      .execute_script_static("", "globalThis.TEST")
-      .unwrap();
+    let global_test = runtime.execute_script("", "globalThis.TEST").unwrap();
     let scope = &mut runtime.handle_scope();
     let global_test = v8::Local::new(scope, global_test);
     assert!(global_test.is_string());
@@ -162,10 +159,7 @@ fn es_snapshot() {
   // The module can be imported
   {
     let test_export_promise = runtime
-      .execute_script_static(
-        "",
-        "import('mod:test').then(module => module.TEST)",
-      )
+      .execute_script("", "import('mod:test').then(module => module.TEST)")
       .unwrap();
     #[allow(deprecated)]
     let test_export =
diff --git a/core/runtime/tests/misc.rs b/core/runtime/tests/misc.rs
index cdd5654..8cb1cf9 100644
--- a/core/runtime/tests/misc.rs
+++ b/core/runtime/tests/misc.rs
@@ -29,23 +29,20 @@ fn icu() {
   // rusty_v8/third_party/icu/common/icudtl.dat
   let mut runtime = JsRuntime::new(Default::default());
   runtime
-    .execute_script_static("a.js", "(new Date()).toLocaleString('ja-JP')")
+    .execute_script("a.js", "(new Date()).toLocaleString('ja-JP')")
     .unwrap();
 }
 
 #[test]
 fn test_execute_script_return_value() {
   let mut runtime = JsRuntime::new(Default::default());
-  let value_global =
-    runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
+  let value_global = runtime.execute_script("a.js", "a = 1 + 2").unwrap();
   {
     let scope = &mut runtime.handle_scope();
     let value = value_global.open(scope);
     assert_eq!(value.integer_value(scope).unwrap(), 3);
   }
-  let value_global = runtime
-    .execute_script_static("b.js", "b = 'foobar'")
-    .unwrap();
+  let value_global = runtime.execute_script("b.js", "b = 'foobar'").unwrap();
   {
     let scope = &mut runtime.handle_scope();
     let value = value_global.open(scope);
@@ -156,7 +153,7 @@ async fn test_resolve_promise(
   #[case] result: Result<i32, &'static str>,
 ) {
   let mut runtime = JsRuntime::new(Default::default());
-  let value_global = runtime.execute_script_static("a.js", script).unwrap();
+  let value_global = runtime.execute_script("a.js", script).unwrap();
   let resolve = runtime.resolve(value_global);
   let out = runtime
     .with_event_loop_promise(resolve, PollEventLoopOptions::default())
@@ -242,11 +239,11 @@ async fn test_resolve_value_generic(
   let mut runtime = JsRuntime::new(Default::default());
   let result_global = if runner == "script" {
     let value_global: v8::Global<v8::Value> =
-      runtime.execute_script_static("a.js", code).unwrap();
+      runtime.execute_script("a.js", code).unwrap();
     #[allow(deprecated)]
     runtime.resolve_value(value_global).await
   } else if runner == "call" {
-    let value_global = runtime.execute_script_static("a.js", code).unwrap();
+    let value_global = runtime.execute_script("a.js", code).unwrap();
     let function: v8::Global<v8::Function> =
       unsafe { std::mem::transmute(value_global) };
     #[allow(deprecated)]
@@ -289,7 +286,7 @@ fn terminate_execution_webassembly() {
   let v8_isolate_handle = runtime.v8_isolate().thread_safe_handle();
 
   // Run an infinite loop in WebAssembly code, which should be terminated.
-  let promise = runtime.execute_script_static("infinite_wasm_loop.js",
+  let promise = runtime.execute_script("infinite_wasm_loop.js",
                                r#"
                                (async () => {
                                 const wasmCode = new Uint8Array([
@@ -313,7 +310,7 @@ fn terminate_execution_webassembly() {
     assert!(ok);
   });
   let err = runtime
-    .execute_script_static(
+    .execute_script(
       "infinite_wasm_loop2.js",
       "globalThis.wasmInstance.exports.infinite_loop();",
     )
@@ -326,7 +323,7 @@ fn terminate_execution_webassembly() {
 
   // Verify that the isolate usable again.
   runtime
-    .execute_script_static("simple.js", "1 + 1")
+    .execute_script("simple.js", "1 + 1")
     .expect("execution should be possible again");
 
   terminator_thread.join().unwrap();
@@ -347,7 +344,7 @@ fn terminate_execution() {
   });
 
   // Rn an infinite loop, which should be terminated.
-  match isolate.execute_script_static("infinite_loop.js", "for(;;) {}") {
+  match isolate.execute_script("infinite_loop.js", "for(;;) {}") {
     Ok(_) => panic!("execution should be terminated"),
     Err(e) => {
       assert_eq!(e.to_string(), "Uncaught Error: execution terminated")
@@ -361,7 +358,7 @@ fn terminate_execution() {
 
   // Verify that the isolate usable again.
   isolate
-    .execute_script_static("simple.js", "1 + 1")
+    .execute_script("simple.js", "1 + 1")
     .expect("execution should be possible again");
 
   terminator_thread.join().unwrap();
@@ -372,7 +369,7 @@ async fn wasm_streaming_op_invocation_in_import() {
   let (mut runtime, _dispatch_count) = setup(Mode::Async);
 
   // Run an infinite loop in WebAssembly code, which should be terminated.
-  runtime.execute_script_static("setup.js",
+  runtime.execute_script("setup.js",
                                r#"
                                 Deno.core.setWasmStreamingCallback((source, rid) => {
                                   Deno.core.ops.op_wasm_streaming_set_url(rid, "file:///foo.wasm");
@@ -381,7 +378,7 @@ async fn wasm_streaming_op_invocation_in_import() {
                                 });
                                "#).unwrap();
 
-  let promise = runtime.execute_script_static("main.js",
+  let promise = runtime.execute_script("main.js",
                             r#"
                              // (module (import "env" "data" (global i64)))
                              const bytes = new Uint8Array([0,97,115,109,1,0,0,0,2,13,1,3,101,110,118,4,100,97,116,97,3,126,0,0,8,4,110,97,109,101,2,1,0]);
@@ -421,7 +418,7 @@ fn inspector() {
   });
   // This was causing a crash
   runtime.op_state().borrow_mut().put(runtime.inspector());
-  runtime.execute_script_static("check.js", "null").unwrap();
+  runtime.execute_script("check.js", "null").unwrap();
 }
 
 #[test]
@@ -499,7 +496,7 @@ fn test_heap_limits() {
     current_limit * 2
   });
   let err = runtime
-    .execute_script_static(
+    .execute_script(
       "script name",
       r#"let s = ""; while(true) { s += "Hello"; }"#,
     )
@@ -548,7 +545,7 @@ fn test_heap_limit_cb_multiple() {
   });
 
   let err = runtime
-    .execute_script_static(
+    .execute_script(
       "script name",
       r#"let s = ""; while(true) { s += "Hello"; }"#,
     )
@@ -566,7 +563,7 @@ async fn test_pump_message_loop() {
   let mut runtime = JsRuntime::new(RuntimeOptions::default());
   poll_fn(move |cx| {
     runtime
-      .execute_script_static(
+      .execute_script(
         "pump_message_loop.js",
         r#"
 function assertEquals(a, b) {
@@ -596,12 +593,12 @@ assertEquals(1, notify_return_value);
 
     // noop script, will resolve promise from first script
     runtime
-      .execute_script_static("pump_message_loop2.js", r#"assertEquals(1, 1);"#)
+      .execute_script("pump_message_loop2.js", r#"assertEquals(1, 1);"#)
       .unwrap();
 
     // check that promise from `Atomics.waitAsync` has been resolved
     runtime
-      .execute_script_static(
+      .execute_script(
         "pump_message_loop3.js",
         r#"assertEquals(globalThis.resolved, true);"#,
       )
@@ -618,7 +615,7 @@ fn test_v8_platform() {
     ..Default::default()
   };
   let mut runtime = JsRuntime::new(options);
-  runtime.execute_script_static("<none>", "").unwrap();
+  runtime.execute_script("<none>", "").unwrap();
 }
 
 #[ignore] // TODO(@littledivy): Fast API ops when snapshot is not loaded.
@@ -626,7 +623,7 @@ fn test_v8_platform() {
 fn test_is_proxy() {
   let mut runtime = JsRuntime::new(RuntimeOptions::default());
   let all_true: v8::Global<v8::Value> = runtime
-    .execute_script_static(
+    .execute_script(
       "is_proxy.js",
       r#"
     (function () {
@@ -658,7 +655,7 @@ async fn test_set_macrotask_callback_set_next_tick_callback() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "macrotasks_and_nextticks.js",
       r#"
       const { op_async_sleep } = Deno.core.ensureFastOps();
@@ -713,7 +710,7 @@ fn test_has_tick_scheduled() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "has_tick_scheduled.js",
       r#"
         Deno.core.setMacrotaskCallback(() => {
@@ -864,7 +861,7 @@ async fn test_promise_rejection_handler_generic(
       .unwrap();
     Some(runtime.mod_evaluate(id))
   } else {
-    runtime.execute_script("", script.into()).unwrap();
+    runtime.execute_script("", script).unwrap();
     None
   };
 
@@ -1197,7 +1194,7 @@ async fn terminate_execution_run_event_loop_js() {
 
   // Create sleep function that waits for 2 seconds.
   runtime
-    .execute_script_static(
+    .execute_script(
       "sleep_code.js",
       r#"
               const { op_async_sleep } = Deno.core.ensureFastOps(); 
@@ -1217,9 +1214,7 @@ async fn terminate_execution_run_event_loop_js() {
   });
 
   // Start waiting period of 2 seconds.
-  runtime
-    .execute_script_static("sleep.js", "sleep()")
-    .unwrap();
+  runtime.execute_script("sleep.js", "sleep()").unwrap();
 
   let err = runtime
     .run_event_loop(Default::default())
@@ -1234,7 +1229,7 @@ async fn terminate_execution_run_event_loop_js() {
 
   // Verify that the isolate usable again.
   runtime
-    .execute_script_static("simple.js", "1 + 1")
+    .execute_script("simple.js", "1 + 1")
     .expect("execution should be possible again");
 
   terminator_thread.join().unwrap();
diff --git a/core/runtime/tests/mod.rs b/core/runtime/tests/mod.rs
index 26ac948..1d31036 100644
--- a/core/runtime/tests/mod.rs
+++ b/core/runtime/tests/mod.rs
@@ -88,7 +88,7 @@ fn setup(mode: Mode) -> (JsRuntime, Arc<AtomicUsize>) {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "setup.js",
       r#"
       function assert(cond) {
diff --git a/core/runtime/tests/ops.rs b/core/runtime/tests/ops.rs
index 10c6d09..ad63985 100644
--- a/core/runtime/tests/ops.rs
+++ b/core/runtime/tests/ops.rs
@@ -49,7 +49,7 @@ async fn test_async_opstate_borrow() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "op_async_borrow.js",
       "const { op_async_borrow } = Deno.core.ensureFastOps(); op_async_borrow();",
     )
@@ -80,7 +80,7 @@ async fn test_sync_op_serialize_object_with_numbers_as_keys() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "op_sync_serialize_object_with_numbers_as_keys.js",
       r#"
 Deno.core.ops.op_sync_serialize_object_with_numbers_as_keys({
@@ -122,7 +122,7 @@ async fn test_async_op_serialize_object_with_numbers_as_keys() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "op_async_serialize_object_with_numbers_as_keys.js",
       r#"
         const { op_async_serialize_object_with_numbers_as_keys } = Deno.core.ensureFastOps();
@@ -156,7 +156,7 @@ fn test_op_return_serde_v8_error() {
     ..Default::default()
   });
   assert!(runtime
-    .execute_script_static(
+    .execute_script(
       "test_op_return_serde_v8_error.js",
       "Deno.core.ops.op_err()"
     )
@@ -182,7 +182,7 @@ fn test_op_high_arity() {
     ..Default::default()
   });
   let r = runtime
-    .execute_script_static("test.js", "Deno.core.ops.op_add_4(1, 2, 3, 4)")
+    .execute_script("test.js", "Deno.core.ops.op_add_4(1, 2, 3, 4)")
     .unwrap();
   let scope = &mut runtime.handle_scope();
   assert_eq!(r.open(scope).integer_value(scope), Some(10));
@@ -207,7 +207,7 @@ fn test_op_disabled() {
   });
   // Disabled op should be replaced with a function that throws.
   let err = runtime
-    .execute_script_static("test.js", "Deno.core.ops.op_foo()")
+    .execute_script("test.js", "Deno.core.ops.op_foo()")
     .unwrap_err();
   assert!(err.to_string().contains("op is disabled"));
 }
@@ -234,7 +234,7 @@ fn test_op_detached_buffer() {
   });
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "test.js",
       r#"
       const a1 = new Uint8Array([1,2,3]);
@@ -266,7 +266,7 @@ fn test_op_detached_buffer() {
     .unwrap();
 
   runtime
-    .execute_script_static(
+    .execute_script(
       "test.js",
       r#"
       const wmem = new WebAssembly.Memory({ initial: 1, maximum: 2 });
@@ -349,14 +349,14 @@ fn ops_in_js_have_proper_names() {
     throw new Error();
   }
   "#;
-  runtime.execute_script_static("test", src).unwrap();
+  runtime.execute_script("test", src).unwrap();
 }
 
 #[tokio::test]
 async fn test_ref_unref_ops() {
   let (mut runtime, _dispatch_count) = setup(Mode::AsyncDeferred);
   runtime
-    .execute_script_static(
+    .execute_script(
       "filename.js",
       r#"
       const { op_test } = Deno.core.ensureFastOps();
@@ -371,7 +371,7 @@ async fn test_ref_unref_ops() {
     assert_eq!(realm.num_unrefed_ops(), 0);
   }
   runtime
-    .execute_script_static(
+    .execute_script(
       "filename.js",
       r#"
       Deno.core.unrefOpPromise(p1);
@@ -385,7 +385,7 @@ async fn test_ref_unref_ops() {
     assert_eq!(realm.num_unrefed_ops(), 2);
   }
   runtime
-    .execute_script_static(
+    .execute_script(
       "filename.js",
       r#"
       Deno.core.refOpPromise(p1);
@@ -404,7 +404,7 @@ async fn test_ref_unref_ops() {
 fn test_dispatch() {
   let (mut runtime, dispatch_count) = setup(Mode::Async);
   runtime
-    .execute_script_static(
+    .execute_script(
       "filename.js",
       r#"
       let control = 42;
@@ -424,7 +424,7 @@ fn test_dispatch() {
 fn test_dispatch_no_zero_copy_buf() {
   let (mut runtime, dispatch_count) = setup(Mode::AsyncZeroCopy(false));
   runtime
-    .execute_script_static(
+    .execute_script(
       "filename.js",
       r#"
       const { op_test } = Deno.core.ensureFastOps();
@@ -439,7 +439,7 @@ fn test_dispatch_no_zero_copy_buf() {
 fn test_dispatch_stack_zero_copy_bufs() {
   let (mut runtime, dispatch_count) = setup(Mode::AsyncZeroCopy(true));
   runtime
-    .execute_script_static(
+    .execute_script(
       "filename.js",
       r#"
       const { op_test } = Deno.core.ensureFastOps();
@@ -455,7 +455,7 @@ fn test_dispatch_stack_zero_copy_bufs() {
 fn test_call_site() {
   let (mut runtime, _) = setup(Mode::Async);
   runtime
-    .execute_script_static(
+    .execute_script(
       "file:///filename.js",
       r#"
       const cs = Deno.core.currentUserCallSite();
@@ -634,7 +634,7 @@ pub async fn test_op_metrics() {
   });
 
   let promise = runtime
-  .execute_script_static(
+  .execute_script(
     "filename.js",
     r#"
     const { op_sync, op_sync_error, op_async, op_async_error, op_async_yield, op_async_yield_error, op_async_deferred, op_async_lazy, op_async_impl_future_error, op_sync_arg_error, op_async_arg_error } = Deno.core.ensureFastOps();
@@ -706,7 +706,7 @@ pub async fn test_op_metrics_summary_tracker() {
   });
 
   let promise = runtime
-  .execute_script_static(
+  .execute_script(
     "filename.js",
     r#"
     const { op_sync, op_sync_error, op_async, op_async_error, op_async_yield, op_async_yield_error, op_async_deferred, op_async_lazy, op_async_impl_future_error, op_sync_arg_error, op_async_arg_error } = Deno.core.ensureFastOps();
diff --git a/core/runtime/tests/snapshot.rs b/core/runtime/tests/snapshot.rs
index dd99271..efeb765 100644
--- a/core/runtime/tests/snapshot.rs
+++ b/core/runtime/tests/snapshot.rs
@@ -16,7 +16,7 @@ use self::runtime::CreateSnapshotOptions;
 fn will_snapshot() {
   let snapshot = {
     let mut runtime = JsRuntimeForSnapshot::new(Default::default());
-    runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
+    runtime.execute_script("a.js", "a = 1 + 2").unwrap();
     runtime.snapshot()
   };
 
@@ -26,7 +26,7 @@ fn will_snapshot() {
     ..Default::default()
   });
   runtime2
-    .execute_script_static("check.js", "if (a != 3) throw Error('x')")
+    .execute_script("check.js", "if (a != 3) throw Error('x')")
     .unwrap();
 }
 
@@ -34,9 +34,7 @@ fn will_snapshot() {
 fn will_snapshot2() {
   let startup_data = {
     let mut runtime = JsRuntimeForSnapshot::new(Default::default());
-    runtime
-      .execute_script_static("a.js", "let a = 1 + 2")
-      .unwrap();
+    runtime.execute_script("a.js", "let a = 1 + 2").unwrap();
     runtime.snapshot()
   };
 
@@ -48,9 +46,9 @@ fn will_snapshot2() {
 
   let startup_data = {
     runtime
-      .execute_script_static("check_a.js", "if (a != 3) throw Error('x')")
+      .execute_script("check_a.js", "if (a != 3) throw Error('x')")
       .unwrap();
-    runtime.execute_script_static("b.js", "b = 2 + 3").unwrap();
+    runtime.execute_script("b.js", "b = 2 + 3").unwrap();
     runtime.snapshot()
   };
 
@@ -61,10 +59,10 @@ fn will_snapshot2() {
       ..Default::default()
     });
     runtime
-      .execute_script_static("check_b.js", "if (b != 5) throw Error('x')")
+      .execute_script("check_b.js", "if (b != 5) throw Error('x')")
       .unwrap();
     runtime
-      .execute_script_static("check2.js", "if (!Deno.core) throw Error('x')")
+      .execute_script("check2.js", "if (!Deno.core) throw Error('x')")
       .unwrap();
   }
 }
@@ -74,7 +72,7 @@ fn test_snapshot_callbacks() {
   let snapshot = {
     let mut runtime = JsRuntimeForSnapshot::new(Default::default());
     runtime
-      .execute_script_static(
+      .execute_script(
         "a.js",
         r#"
         Deno.core.setMacrotaskCallback(() => {
@@ -99,7 +97,7 @@ fn test_snapshot_callbacks() {
     ..Default::default()
   });
   runtime2
-    .execute_script_static("check.js", "if (a != 3) throw Error('x')")
+    .execute_script("check.js", "if (a != 3) throw Error('x')")
     .unwrap();
 }
 
@@ -107,7 +105,7 @@ fn test_snapshot_callbacks() {
 fn test_from_snapshot() {
   let snapshot = {
     let mut runtime = JsRuntimeForSnapshot::new(Default::default());
-    runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
+    runtime.execute_script("a.js", "a = 1 + 2").unwrap();
     runtime.snapshot()
   };
 
@@ -117,7 +115,7 @@ fn test_from_snapshot() {
     ..Default::default()
   });
   runtime2
-    .execute_script_static("check.js", "if (a != 3) throw Error('x')")
+    .execute_script("check.js", "if (a != 3) throw Error('x')")
     .unwrap();
 }
 
@@ -131,7 +129,7 @@ fn test_snapshot_creator() {
       skip_op_registration: false,
       extensions: vec![],
       with_runtime_cb: Some(Box::new(|runtime| {
-        runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
+        runtime.execute_script("a.js", "a = 1 + 2").unwrap();
       })),
     },
     None,
@@ -145,7 +143,7 @@ fn test_snapshot_creator() {
     ..Default::default()
   });
   runtime2
-    .execute_script_static("check.js", "if (a != 3) throw Error('x')")
+    .execute_script("check.js", "if (a != 3) throw Error('x')")
     .unwrap();
 }
 
@@ -163,7 +161,7 @@ fn test_snapshot_creator_warmup() {
       with_runtime_cb: Some(Box::new(move |runtime| {
         c.replace_with(|&mut c| c + 1);
 
-        runtime.execute_script_static("a.js", "a = 1 + 2").unwrap();
+        runtime.execute_script("a.js", "a = 1 + 2").unwrap();
       })),
     },
     Some("const b = 'Hello'"),
@@ -181,7 +179,7 @@ fn test_snapshot_creator_warmup() {
     ..Default::default()
   });
   runtime2
-    .execute_script_static("check.js", "if (a != 3) throw Error('x')")
+    .execute_script("check.js", "if (a != 3) throw Error('x')")
     .unwrap();
 }
 
@@ -312,7 +310,7 @@ fn es_snapshot() {
     const mod = await import("file:///400.js");
     return mod.f400() + " " + Deno.core.ops.op_test();
   })();"#;
-  let val = runtime3.execute_script_static(".", source_code).unwrap();
+  let val = runtime3.execute_script(".", source_code).unwrap();
   #[allow(deprecated)]
   let val = futures::executor::block_on(runtime3.resolve_value(val)).unwrap();
   {
@@ -363,7 +361,7 @@ pub(crate) fn es_snapshot_without_runtime_module_loader() {
 
   // Dynamic imports of ext: from non-ext: modules are not allowed.
   let dyn_import_promise = realm
-    .execute_script_static(
+    .execute_script(
       runtime.v8_isolate(),
       "",
       "import('ext:module_snapshot/test.js')",
@@ -379,7 +377,7 @@ pub(crate) fn es_snapshot_without_runtime_module_loader() {
 
   // But not a new one
   let dyn_import_promise = realm
-    .execute_script_static(
+    .execute_script(
       runtime.v8_isolate(),
       "",
       "import('ext:module_snapshot/test2.js')",