diff options
| author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2022-08-11 16:56:56 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-11 15:56:56 +0200 |
| commit | 2164f6b1eb7216c1045d547c94f26fe3ceaa9403 (patch) | |
| tree | 056e3d6540ebd0e755650765adcff6b5cc173db8 /cli/tests | |
| parent | 883269f1f183428f60c54223135d8dd25977b3cd (diff) | |
perf(ops): Monomorphic sync op calls (#15337)
Welcome to better optimised op calls! Currently opSync is called with parameters of every type and count. This most definitely makes the call megamorphic. Additionally, it seems that spread params leads to V8 not being able to optimise the calls quite as well (apparently Fast Calls cannot be used with spread params).
Monomorphising op calls should lead to some improved performance. Now that unwrapping of sync ops results is done on Rust side, this is pretty simple:
```
opSync("op_foo", param1, param2);
// -> turns to
ops.op_foo(param1, param2);
```
This means sync op calls are now just directly calling the native binding function. When V8 Fast API Calls are enabled, this will enable those to be called on the optimised path.
Monomorphising async ops likely requires using callbacks and is left as an exercise to the reader.
Diffstat (limited to 'cli/tests')
22 files changed, 24 insertions, 28 deletions
diff --git a/cli/tests/testdata/bench/recursive_permissions_pledge.js b/cli/tests/testdata/bench/recursive_permissions_pledge.js index dcdcbf574..dbba96f26 100644 --- a/cli/tests/testdata/bench/recursive_permissions_pledge.js +++ b/cli/tests/testdata/bench/recursive_permissions_pledge.js @@ -1,8 +1,6 @@ -Deno.core.opSync( - "op_pledge_test_permissions", +Deno.core.ops.op_pledge_test_permissions( "none", ); -Deno.core.opSync( - "op_pledge_test_permissions", +Deno.core.ops.op_pledge_test_permissions( "inherit", ); diff --git a/cli/tests/testdata/op_exit_op_set_exit_code_in_worker.ts b/cli/tests/testdata/op_exit_op_set_exit_code_in_worker.ts index ddc0781eb..b2ed912de 100644 --- a/cli/tests/testdata/op_exit_op_set_exit_code_in_worker.ts +++ b/cli/tests/testdata/op_exit_op_set_exit_code_in_worker.ts @@ -3,7 +3,7 @@ // `self.close()`. // @ts-ignore Deno.core doesn't have type-defs -Deno.core.opSync("op_set_exit_code", 21); +Deno.core.ops.op_set_exit_code(21); const worker = new Worker( import.meta.resolve("./op_exit_op_set_exit_code_worker.js"), diff --git a/cli/tests/testdata/op_exit_op_set_exit_code_worker.js b/cli/tests/testdata/op_exit_op_set_exit_code_worker.js index 54e5cd562..3e6055747 100644 --- a/cli/tests/testdata/op_exit_op_set_exit_code_worker.js +++ b/cli/tests/testdata/op_exit_op_set_exit_code_worker.js @@ -1,4 +1,4 @@ self.onmessage = () => { - Deno.core.opSync("op_set_exit_code", 42); + Deno.core.ops.op_set_exit_code(42); Deno.exit(); }; diff --git a/cli/tests/testdata/set_exit_code_0.ts b/cli/tests/testdata/set_exit_code_0.ts index 7eb14fa3c..362a9f28a 100644 --- a/cli/tests/testdata/set_exit_code_0.ts +++ b/cli/tests/testdata/set_exit_code_0.ts @@ -1,2 +1,2 @@ -Deno.core.opSync("op_set_exit_code", 42); +Deno.core.ops.op_set_exit_code(42); Deno.exit(0); // Takes precedence. diff --git a/cli/tests/testdata/set_exit_code_1.ts b/cli/tests/testdata/set_exit_code_1.ts index 96ec9889c..b10863568 100644 --- a/cli/tests/testdata/set_exit_code_1.ts +++ b/cli/tests/testdata/set_exit_code_1.ts @@ -1,2 +1,2 @@ -Deno.core.opSync("op_set_exit_code", 42); +Deno.core.ops.op_set_exit_code(42); Deno.exit(); diff --git a/cli/tests/testdata/set_exit_code_2.ts b/cli/tests/testdata/set_exit_code_2.ts index a1f2b5d3c..d68812cae 100644 --- a/cli/tests/testdata/set_exit_code_2.ts +++ b/cli/tests/testdata/set_exit_code_2.ts @@ -1,2 +1,2 @@ -Deno.core.opSync("op_set_exit_code", 42); +Deno.core.ops.op_set_exit_code(42); // Exits naturally. diff --git a/cli/tests/testdata/test/recursive_permissions_pledge.js b/cli/tests/testdata/test/recursive_permissions_pledge.js index dcdcbf574..dbba96f26 100644 --- a/cli/tests/testdata/test/recursive_permissions_pledge.js +++ b/cli/tests/testdata/test/recursive_permissions_pledge.js @@ -1,8 +1,6 @@ -Deno.core.opSync( - "op_pledge_test_permissions", +Deno.core.ops.op_pledge_test_permissions( "none", ); -Deno.core.opSync( - "op_pledge_test_permissions", +Deno.core.ops.op_pledge_test_permissions( "inherit", ); diff --git a/cli/tests/testdata/unstable_ffi_1.js b/cli/tests/testdata/unstable_ffi_1.js index a24a00238..8ca6c3a60 100644 --- a/cli/tests/testdata/unstable_ffi_1.js +++ b/cli/tests/testdata/unstable_ffi_1.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_load", { path: "", symbols: {} }); +Deno.core.ops.op_ffi_load({ path: "", symbols: {} }); diff --git a/cli/tests/testdata/unstable_ffi_10.js b/cli/tests/testdata/unstable_ffi_10.js index e8fc9b3f0..83687c584 100644 --- a/cli/tests/testdata/unstable_ffi_10.js +++ b/cli/tests/testdata/unstable_ffi_10.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_i16", 0n); +Deno.core.ops.op_ffi_read_i16(0n); diff --git a/cli/tests/testdata/unstable_ffi_11.js b/cli/tests/testdata/unstable_ffi_11.js index 77c86109a..5538753be 100644 --- a/cli/tests/testdata/unstable_ffi_11.js +++ b/cli/tests/testdata/unstable_ffi_11.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_u32", 0n); +Deno.core.ops.op_ffi_read_u32(0n); diff --git a/cli/tests/testdata/unstable_ffi_12.js b/cli/tests/testdata/unstable_ffi_12.js index 65934a82f..089c9b5b1 100644 --- a/cli/tests/testdata/unstable_ffi_12.js +++ b/cli/tests/testdata/unstable_ffi_12.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_i32", 0n); +Deno.core.ops.op_ffi_read_i32(0n); diff --git a/cli/tests/testdata/unstable_ffi_13.js b/cli/tests/testdata/unstable_ffi_13.js index 0ab43781b..630be2e6d 100644 --- a/cli/tests/testdata/unstable_ffi_13.js +++ b/cli/tests/testdata/unstable_ffi_13.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_u64", 0n); +Deno.core.ops.op_ffi_read_u64(0n); diff --git a/cli/tests/testdata/unstable_ffi_14.js b/cli/tests/testdata/unstable_ffi_14.js index b65a50a20..b04c7865e 100644 --- a/cli/tests/testdata/unstable_ffi_14.js +++ b/cli/tests/testdata/unstable_ffi_14.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_f32", 0n); +Deno.core.ops.op_ffi_read_f32(0n); diff --git a/cli/tests/testdata/unstable_ffi_15.js b/cli/tests/testdata/unstable_ffi_15.js index de9f29168..865f63c75 100644 --- a/cli/tests/testdata/unstable_ffi_15.js +++ b/cli/tests/testdata/unstable_ffi_15.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_f64", 0n); +Deno.core.ops.op_ffi_read_f64(0n); diff --git a/cli/tests/testdata/unstable_ffi_2.js b/cli/tests/testdata/unstable_ffi_2.js index fe3d9d709..7f3f34f37 100644 --- a/cli/tests/testdata/unstable_ffi_2.js +++ b/cli/tests/testdata/unstable_ffi_2.js @@ -1,4 +1,4 @@ -Deno.core.opSync("op_ffi_call_ptr", 0n, { +Deno.core.ops.op_ffi_call_ptr(0n, { name: null, parameters: [], result: "void", diff --git a/cli/tests/testdata/unstable_ffi_4.js b/cli/tests/testdata/unstable_ffi_4.js index 3e05bbf42..8b4f3d75a 100644 --- a/cli/tests/testdata/unstable_ffi_4.js +++ b/cli/tests/testdata/unstable_ffi_4.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_ptr_of", new Uint8Array(0)); +Deno.core.ops.op_ffi_ptr_of(new Uint8Array(0)); diff --git a/cli/tests/testdata/unstable_ffi_5.js b/cli/tests/testdata/unstable_ffi_5.js index dc494023d..d08d8eaa4 100644 --- a/cli/tests/testdata/unstable_ffi_5.js +++ b/cli/tests/testdata/unstable_ffi_5.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_buf_copy_into", 0n, new Uint8Array(0), 0); +Deno.core.ops.op_ffi_buf_copy_into(0n, new Uint8Array(0), 0); diff --git a/cli/tests/testdata/unstable_ffi_6.js b/cli/tests/testdata/unstable_ffi_6.js index c66681225..9e4f1c761 100644 --- a/cli/tests/testdata/unstable_ffi_6.js +++ b/cli/tests/testdata/unstable_ffi_6.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_cstr_read", 0n); +Deno.core.ops.op_ffi_cstr_read(0n); diff --git a/cli/tests/testdata/unstable_ffi_7.js b/cli/tests/testdata/unstable_ffi_7.js index a0c27a71c..96e60f377 100644 --- a/cli/tests/testdata/unstable_ffi_7.js +++ b/cli/tests/testdata/unstable_ffi_7.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_u8", 0n); +Deno.core.ops.op_ffi_read_u8(0n); diff --git a/cli/tests/testdata/unstable_ffi_8.js b/cli/tests/testdata/unstable_ffi_8.js index 7c51f8aa3..187b83891 100644 --- a/cli/tests/testdata/unstable_ffi_8.js +++ b/cli/tests/testdata/unstable_ffi_8.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_i8", 0n); +Deno.core.ops.op_ffi_read_i8(0n); diff --git a/cli/tests/testdata/unstable_ffi_9.js b/cli/tests/testdata/unstable_ffi_9.js index 7798e4d2c..e968e534c 100644 --- a/cli/tests/testdata/unstable_ffi_9.js +++ b/cli/tests/testdata/unstable_ffi_9.js @@ -1 +1 @@ -Deno.core.opSync("op_ffi_read_u16", 0n); +Deno.core.ops.op_ffi_read_u16(0n); diff --git a/cli/tests/unit/opcall_test.ts b/cli/tests/unit/opcall_test.ts index 5e783efc8..970731855 100644 --- a/cli/tests/unit/opcall_test.ts +++ b/cli/tests/unit/opcall_test.ts @@ -44,7 +44,7 @@ Deno.test(async function opsAsyncBadResource() { Deno.test(function opsSyncBadResource() { try { const nonExistingRid = 9999; - Deno.core.opSync("op_read_sync", nonExistingRid, new Uint8Array(0)); + Deno.core.ops.op_read_sync(nonExistingRid, new Uint8Array(0)); } catch (e) { if (!(e instanceof Deno.errors.BadResource)) { throw e; |
