summaryrefslogtreecommitdiff
path: root/ext/ffi/00_ffi.js
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-12-26 18:30:26 -0700
committerGitHub <noreply@github.com>2023-12-27 02:30:26 +0100
commit0efe438f7c191d8504355e03b27fe7e3055c9387 (patch)
treeb96fe9a897eb6941c87a95a04520662d26c02fbe /ext/ffi/00_ffi.js
parente33c5eb704c22fad69876e87d9b852a4e5072a7a (diff)
perf: remove opAsync (#21690)
`opAsync` requires a lookup by name on each async call. This is a mechanical translation of all opAsync calls to ensureFastOps. The `opAsync` API on Deno.core will be removed at a later time.
Diffstat (limited to 'ext/ffi/00_ffi.js')
-rw-r--r--ext/ffi/00_ffi.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index ef9123442..7cc3bb982 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -33,6 +33,13 @@ const {
SafeWeakMap,
} = primordials;
import { pathFromURL } from "ext:deno_web/00_infra.js";
+const {
+ op_ffi_call_nonblocking,
+ op_ffi_unsafe_callback_ref,
+} = core.ensureFastOps();
+const {
+ op_ffi_call_ptr_nonblocking,
+} = core.ensureFastOps(true);
/**
* @param {BufferSource} source
@@ -275,8 +282,7 @@ class UnsafeFnPointer {
call(...parameters) {
if (this.definition.nonblocking) {
if (this.#structSize === null) {
- return core.opAsync(
- "op_ffi_call_ptr_nonblocking",
+ return op_ffi_call_ptr_nonblocking(
this.pointer,
this.definition,
parameters,
@@ -284,8 +290,7 @@ class UnsafeFnPointer {
} else {
const buffer = new Uint8Array(this.#structSize);
return PromisePrototypeThen(
- core.opAsync(
- "op_ffi_call_ptr_nonblocking",
+ op_ffi_call_ptr_nonblocking(
this.pointer,
this.definition,
parameters,
@@ -420,8 +425,7 @@ class UnsafeCallback {
// Re-refing
core.refOpPromise(this.#refpromise);
} else {
- this.#refpromise = core.opAsync(
- "op_ffi_unsafe_callback_ref",
+ this.#refpromise = op_ffi_unsafe_callback_ref(
this.#rid,
);
}
@@ -508,8 +512,7 @@ class DynamicLibrary {
value: (...parameters) => {
if (isStructResult) {
const buffer = new Uint8Array(structSize);
- const ret = core.opAsync(
- "op_ffi_call_nonblocking",
+ const ret = op_ffi_call_nonblocking(
this.#rid,
symbol,
parameters,
@@ -520,8 +523,7 @@ class DynamicLibrary {
() => buffer,
);
} else {
- return core.opAsync(
- "op_ffi_call_nonblocking",
+ return op_ffi_call_nonblocking(
this.#rid,
symbol,
parameters,