Skip to content

Commit

Permalink
Fix deno_webgpu & cts_runner (#5459)
Browse files Browse the repository at this point in the history
* fix cts_runner

* fix
  • Loading branch information
crowlKats authored Apr 1, 2024
1 parent ed7d9de commit c2fb18a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 80 deletions.
88 changes: 64 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ web-sys = "0.3.69"
web-time = "0.2.4"

# deno dependencies
deno_console = "0.125.0"
deno_core = "0.232.0"
deno_url = "0.125.0"
deno_web = "0.156.0"
deno_webidl = "0.125.0"
deno_console = "0.143.0"
deno_core = "0.272.0"
deno_url = "0.143.0"
deno_web = "0.174.0"
deno_webidl = "0.143.0"
deno_webgpu = { version = "0.85.0", path = "./deno_webgpu" }
tokio = "1.36.0"
termcolor = "1.4.1"
Expand Down
11 changes: 4 additions & 7 deletions cts_runner/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//
delete Object.prototype.__proto__;

const core = Deno.core;
const primordials = globalThis.__bootstrap.primordials;
import { core, primordials } from "ext:core/mod.js";
const {
Error,
ObjectDefineProperty,
Expand All @@ -25,9 +24,10 @@ import * as base64 from "ext:deno_web/05_base64.js";
import * as encoding from "ext:deno_web/08_text_encoding.js";
import { Console } from "ext:deno_console/01_console.js";
import * as url from "ext:deno_url/00_url.js";
import DOMException from "ext:deno_web/01_dom_exception.js";
import { DOMException } from "ext:deno_web/01_dom_exception.js";
import * as performance from "ext:deno_web/15_performance.js";
import * as webgpu from "ext:deno_webgpu/01_webgpu.js";
import * as imageData from "ext:deno_web/16_image_data.js";

// imports needed to pass module evaluation
import "ext:deno_url/01_urlpattern.js";
Expand All @@ -42,8 +42,6 @@ import "ext:deno_web/14_compression.js";

let globalThis_;

const { BadResource, Interrupted } = core;

class NotFound extends Error {
constructor(msg) {
super(msg);
Expand Down Expand Up @@ -183,6 +181,7 @@ const windowOrWorkerGlobalScope = {
clearInterval: util.writable(timers.clearInterval),
clearTimeout: util.writable(timers.clearTimeout),
performance: util.writable(performance.performance),
ImageData: core.propNonEnumerable(imageData.ImageData),

GPU: util.nonEnumerable(webgpu.GPU),
GPUAdapter: util.nonEnumerable(webgpu.GPUAdapter),
Expand Down Expand Up @@ -248,10 +247,8 @@ core.registerErrorClass("NotFound", NotFound);
core.registerErrorClass("AlreadyExists", AlreadyExists);
core.registerErrorClass("InvalidData", InvalidData);
core.registerErrorClass("TimedOut", TimedOut);
core.registerErrorClass("Interrupted", Interrupted);
core.registerErrorClass("WriteZero", WriteZero);
core.registerErrorClass("UnexpectedEof", UnexpectedEof);
core.registerErrorClass("BadResource", BadResource);
core.registerErrorClass("NotSupported", NotSupported);
core.registerErrorBuilder(
"DOMExceptionOperationError",
Expand Down
26 changes: 9 additions & 17 deletions cts_runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ mod native {
],
..Default::default()
};
let mut isolate = JsRuntime::new(options);
let mut js_runtime = JsRuntime::new(options);
let args = args_iter.collect::<Vec<String>>();
let cfg = json!({"args": args, "cwd": env::current_dir().unwrap().to_string_lossy() });

{
let context = isolate.main_context();
let scope = &mut isolate.handle_scope();
let context = js_runtime.main_context();
let scope = &mut js_runtime.handle_scope();
let context_local = v8::Local::new(scope, context);
let global_obj = context_local.global(scope);
let bootstrap_str = v8::String::new(scope, "bootstrap").unwrap();
Expand All @@ -65,20 +65,12 @@ mod native {
.unwrap();
}

isolate.op_state().borrow_mut().put(Permissions {});
js_runtime.op_state().borrow_mut().put(Permissions {});

let mod_id = isolate.load_main_module(&specifier, None).await?;
let mod_rx = isolate.mod_evaluate(mod_id);

let rx = tokio::spawn(async move {
match mod_rx.await {
Ok(err @ Err(_)) => err,
_ => Ok(()),
}
});

isolate.run_event_loop(false).await?;
rx.await.unwrap()?;
let mod_id = js_runtime.load_main_es_module(&specifier).await?;
let result = js_runtime.mod_evaluate(mod_id);
js_runtime.run_event_loop(Default::default()).await?;
result.await?;

Ok(())
}
Expand All @@ -87,7 +79,7 @@ mod native {
cts_runner,
deps = [deno_webidl, deno_web],
ops = [op_exit, op_read_file_sync, op_write_file_sync],
esm_entry_point = "ext:cts_runner/bootstrap.js",
esm_entry_point = "ext:cts_runner/src/bootstrap.js",
esm = ["src/bootstrap.js"],
);

Expand Down
Loading

0 comments on commit c2fb18a

Please sign in to comment.