summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-01-29 22:02:26 +0100
committerGitHub <noreply@github.com>2024-01-29 22:02:26 +0100
commit345423cf7697326258ce8b32f681910f4a2f77de (patch)
tree484dd157be01e3dc0d4f34f28526dac1804d0250 /ext
parent909986fa6ed3404e76590438b387391a6c213e46 (diff)
refactor: Use virtul ops module (#22175)
Follow up to #22157. This leaves us with 4 usages of `ensureFastOps()` in `deno` itself. There's also about 150 usages of `Deno.core.ops.<op_name>` left as well.
Diffstat (limited to 'ext')
-rw-r--r--ext/console/01_console.js4
-rw-r--r--ext/fetch/26_fetch.js5
-rw-r--r--ext/ffi/00_ffi.js4
-rw-r--r--ext/fs/30_fs.js4
-rw-r--r--ext/io/12_io.js5
-rw-r--r--ext/net/01_net.js4
-rw-r--r--ext/node/polyfills/01_require.js6
-rw-r--r--ext/node/polyfills/_util/os.ts5
-rw-r--r--ext/node/polyfills/child_process.ts6
-rw-r--r--ext/node/polyfills/http.ts8
-rw-r--r--ext/node/polyfills/internal/console/constructor.mjs5
-rw-r--r--ext/node/polyfills/internal/crypto/_randomFill.mjs5
-rw-r--r--ext/node/polyfills/internal/crypto/diffiehellman.ts5
-rw-r--r--ext/node/polyfills/internal/crypto/keygen.ts7
-rw-r--r--ext/node/polyfills/internal/crypto/random.ts6
-rw-r--r--ext/node/polyfills/internal_binding/constants.ts5
-rw-r--r--ext/node/polyfills/process.ts5
-rw-r--r--ext/node/polyfills/tty.js6
-rw-r--r--ext/node/polyfills/worker_threads.ts4
-rw-r--r--ext/web/06_streams.js6
-rw-r--r--ext/webgpu/00_init.js5
21 files changed, 33 insertions, 77 deletions
diff --git a/ext/console/01_console.js b/ext/console/01_console.js
index 101b7ed1c..b851b4035 100644
--- a/ext/console/01_console.js
+++ b/ext/console/01_console.js
@@ -28,11 +28,11 @@ const {
isWeakMap,
isWeakSet,
} = core;
-const {
+import {
op_get_constructor_name,
op_get_non_index_property_names,
op_preview_entries,
-} = core.ensureFastOps(true);
+} from "ext:core/ops";
const {
Array,
ArrayBufferPrototypeGetByteLength,
diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js
index baad62731..9f90156c5 100644
--- a/ext/fetch/26_fetch.js
+++ b/ext/fetch/26_fetch.js
@@ -13,13 +13,10 @@
import { core, primordials } from "ext:core/mod.js";
import {
op_fetch,
+ op_fetch_send,
op_wasm_streaming_feed,
op_wasm_streaming_set_url,
} from "ext:core/ops";
-// TODO(bartlomieju): this ops is also used in `ext/node/polyfills/http.ts`.
-const {
- op_fetch_send,
-} = core.ensureFastOps(true);
const {
ArrayPrototypePush,
ArrayPrototypeSplice,
diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js
index 58d0b75f4..a572ed61c 100644
--- a/ext/ffi/00_ffi.js
+++ b/ext/ffi/00_ffi.js
@@ -6,7 +6,7 @@ const {
isDataView,
isTypedArray,
} = core;
-const {
+import {
op_ffi_buf_copy_into,
op_ffi_call_nonblocking,
op_ffi_call_ptr,
@@ -36,7 +36,7 @@ const {
op_ffi_unsafe_callback_close,
op_ffi_unsafe_callback_create,
op_ffi_unsafe_callback_ref,
-} = core.ensureFastOps(true);
+} from "ext:core/ops";
const {
ArrayBufferIsView,
ArrayBufferPrototypeGetByteLength,
diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js
index 7d2f848d2..9343b6ec4 100644
--- a/ext/fs/30_fs.js
+++ b/ext/fs/30_fs.js
@@ -6,6 +6,7 @@ const {
internalRidSymbol,
} = core;
import {
+ op_cancel_handle,
op_fs_chdir,
op_fs_chmod_async,
op_fs_chmod_sync,
@@ -73,9 +74,6 @@ import {
op_fs_write_file_sync,
} from "ext:core/ops";
const {
- op_cancel_handle,
-} = core.ensureFastOps(true);
-const {
ArrayPrototypeFilter,
Date,
DatePrototypeGetTime,
diff --git a/ext/io/12_io.js b/ext/io/12_io.js
index acb54f648..70b639d45 100644
--- a/ext/io/12_io.js
+++ b/ext/io/12_io.js
@@ -5,10 +5,7 @@
// Thank you! We love Go! <3
import { core, internals, primordials } from "ext:core/mod.js";
-const {
- op_stdin_set_raw,
- op_is_terminal,
-} = core.ensureFastOps(true);
+import { op_is_terminal, op_stdin_set_raw } from "ext:core/ops";
const {
Uint8Array,
ArrayPrototypePush,
diff --git a/ext/net/01_net.js b/ext/net/01_net.js
index 29b9d29fc..1523f5aa5 100644
--- a/ext/net/01_net.js
+++ b/ext/net/01_net.js
@@ -7,6 +7,7 @@ const {
internalRidSymbol,
} = core;
import {
+ op_cancel_handle,
op_dns_resolve,
op_net_accept_tcp,
op_net_accept_unix,
@@ -28,9 +29,6 @@ import {
op_set_nodelay,
} from "ext:core/ops";
const {
- op_cancel_handle,
-} = core.ensureFastOps(true);
-const {
Error,
Number,
ObjectPrototypeIsPrototypeOf,
diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js
index 9d0258e0b..81af7062a 100644
--- a/ext/node/polyfills/01_require.js
+++ b/ext/node/polyfills/01_require.js
@@ -4,6 +4,7 @@
import { core, internals, primordials } from "ext:core/mod.js";
import {
+ op_napi_open,
op_require_as_file_path,
op_require_break_on_next_statement,
op_require_init_paths,
@@ -16,6 +17,7 @@ import {
op_require_path_is_absolute,
op_require_path_resolve,
op_require_proxy_path,
+ op_require_read_closest_package_json,
op_require_read_file,
op_require_read_package_scope,
op_require_real_path,
@@ -27,10 +29,6 @@ import {
op_require_try_self_parent_path,
} from "ext:core/ops";
const {
- op_napi_open,
- op_require_read_closest_package_json,
-} = core.ensureFastOps(true);
-const {
ArrayIsArray,
ArrayPrototypeIncludes,
ArrayPrototypeIndexOf,
diff --git a/ext/node/polyfills/_util/os.ts b/ext/node/polyfills/_util/os.ts
index 8a3d9edf4..421d5d9da 100644
--- a/ext/node/polyfills/_util/os.ts
+++ b/ext/node/polyfills/_util/os.ts
@@ -1,9 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { core } from "ext:core/mod.js";
-const {
- op_node_build_os,
-} = core.ensureFastOps(true);
+import { op_node_build_os } from "ext:core/ops";
export type OSType =
| "windows"
diff --git a/ext/node/polyfills/child_process.ts b/ext/node/polyfills/child_process.ts
index 1d070d1ef..2182361e9 100644
--- a/ext/node/polyfills/child_process.ts
+++ b/ext/node/polyfills/child_process.ts
@@ -6,14 +6,12 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
-import { core, internals } from "ext:core/mod.js";
+import { internals } from "ext:core/mod.js";
import {
op_bootstrap_unstable_args,
op_node_child_ipc_pipe,
-} from "ext:core/ops";
-const {
op_npm_process_state,
-} = core.ensureFastOps(true);
+} from "ext:core/ops";
import {
ChildProcess,
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index d3d51a324..0c6501d87 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -4,11 +4,11 @@
// deno-lint-ignore-file prefer-primordials
import { core } from "ext:core/mod.js";
-import { op_fetch_response_upgrade, op_node_http_request } from "ext:core/ops";
-// TODO(bartlomieju): this ops is also used in `ext/fetch/26_fetch.js`.
-const {
+import {
+ op_fetch_response_upgrade,
op_fetch_send,
-} = core.ensureFastOps(true);
+ op_node_http_request,
+} from "ext:core/ops";
import { TextEncoder } from "ext:deno_web/08_text_encoding.js";
import { setTimeout } from "ext:deno_web/02_timers.js";
diff --git a/ext/node/polyfills/internal/console/constructor.mjs b/ext/node/polyfills/internal/console/constructor.mjs
index 45bca6675..caf6d144d 100644
--- a/ext/node/polyfills/internal/console/constructor.mjs
+++ b/ext/node/polyfills/internal/console/constructor.mjs
@@ -4,10 +4,7 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
-import { core } from "ext:core/mod.js";
-const {
- op_preview_entries,
-} = core.ensureFastOps(true);
+import { op_preview_entries } from "ext:core/ops";
// Mock trace for now
const trace = () => {};
diff --git a/ext/node/polyfills/internal/crypto/_randomFill.mjs b/ext/node/polyfills/internal/crypto/_randomFill.mjs
index cb61e27ef..5de756536 100644
--- a/ext/node/polyfills/internal/crypto/_randomFill.mjs
+++ b/ext/node/polyfills/internal/crypto/_randomFill.mjs
@@ -3,11 +3,10 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
-import { core } from "ext:core/mod.js";
-const {
+import {
op_node_generate_secret,
op_node_generate_secret_async,
-} = core.ensureFastOps(true);
+} from "ext:core/ops";
import {
MAX_SIZE as kMaxUint32,
diff --git a/ext/node/polyfills/internal/crypto/diffiehellman.ts b/ext/node/polyfills/internal/crypto/diffiehellman.ts
index bba01e2c4..4b105e575 100644
--- a/ext/node/polyfills/internal/crypto/diffiehellman.ts
+++ b/ext/node/polyfills/internal/crypto/diffiehellman.ts
@@ -4,17 +4,14 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
-import { core } from "ext:core/mod.js";
import {
op_node_dh_compute_secret,
op_node_dh_generate2,
op_node_ecdh_compute_public_key,
op_node_ecdh_compute_secret,
op_node_ecdh_generate_keys,
-} from "ext:core/ops";
-const {
op_node_gen_prime,
-} = core.ensureFastOps(true);
+} from "ext:core/ops";
import { notImplemented } from "ext:deno_node/_utils.ts";
import {
diff --git a/ext/node/polyfills/internal/crypto/keygen.ts b/ext/node/polyfills/internal/crypto/keygen.ts
index cdb94d222..f3263aecf 100644
--- a/ext/node/polyfills/internal/crypto/keygen.ts
+++ b/ext/node/polyfills/internal/crypto/keygen.ts
@@ -29,7 +29,6 @@ import {
import { Buffer } from "node:buffer";
import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts";
-import { core } from "ext:core/mod.js";
import {
op_node_dh_generate,
op_node_dh_generate_async,
@@ -43,13 +42,11 @@ import {
op_node_ed25519_generate_async,
op_node_generate_rsa,
op_node_generate_rsa_async,
+ op_node_generate_secret,
+ op_node_generate_secret_async,
op_node_x25519_generate,
op_node_x25519_generate_async,
} from "ext:core/ops";
-const {
- op_node_generate_secret,
- op_node_generate_secret_async,
-} = core.ensureFastOps(true);
function validateGenerateKey(
type: "hmac" | "aes",
diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts
index 0c8273bdf..4219414dc 100644
--- a/ext/node/polyfills/internal/crypto/random.ts
+++ b/ext/node/polyfills/internal/crypto/random.ts
@@ -4,18 +4,16 @@
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
-import { core, primordials } from "ext:core/mod.js";
+import { primordials } from "ext:core/mod.js";
import {
op_node_check_prime,
op_node_check_prime_async,
op_node_check_prime_bytes,
op_node_check_prime_bytes_async,
+ op_node_gen_prime,
op_node_gen_prime_async,
} from "ext:core/ops";
const {
- op_node_gen_prime,
-} = core.ensureFastOps(true);
-const {
StringPrototypePadStart,
StringPrototypeToString,
} = primordials;
diff --git a/ext/node/polyfills/internal_binding/constants.ts b/ext/node/polyfills/internal_binding/constants.ts
index 4a6a90608..ccb0ba570 100644
--- a/ext/node/polyfills/internal_binding/constants.ts
+++ b/ext/node/polyfills/internal_binding/constants.ts
@@ -1,9 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { core } from "ext:core/mod.js";
-const {
- op_node_build_os,
-} = core.ensureFastOps(true);
+import { op_node_build_os } from "ext:core/ops";
let os: {
dlopen: {
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts
index 40433a91f..312b8e845 100644
--- a/ext/node/polyfills/process.ts
+++ b/ext/node/polyfills/process.ts
@@ -5,10 +5,7 @@
// deno-lint-ignore-file prefer-primordials
import { core, internals } from "ext:core/mod.js";
-import { op_geteuid, op_process_abort } from "ext:core/ops";
-const {
- op_set_exit_code,
-} = core.ensureFastOps(true);
+import { op_geteuid, op_process_abort, op_set_exit_code } from "ext:core/ops";
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
import { EventEmitter } from "node:events";
diff --git a/ext/node/polyfills/tty.js b/ext/node/polyfills/tty.js
index eae1db2d9..b2260a47e 100644
--- a/ext/node/polyfills/tty.js
+++ b/ext/node/polyfills/tty.js
@@ -1,12 +1,10 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { core, primordials } from "ext:core/mod.js";
+import { primordials } from "ext:core/mod.js";
const {
Error,
} = primordials;
-const {
- op_is_terminal,
-} = core.ensureFastOps(true);
+import { op_is_terminal } from "ext:core/ops";
import { ERR_INVALID_FD } from "ext:deno_node/internal/errors.ts";
import { LibuvStreamWrap } from "ext:deno_node/internal_binding/stream_wrap.ts";
diff --git a/ext/node/polyfills/worker_threads.ts b/ext/node/polyfills/worker_threads.ts
index 4092cac51..785bf021d 100644
--- a/ext/node/polyfills/worker_threads.ts
+++ b/ext/node/polyfills/worker_threads.ts
@@ -5,9 +5,7 @@
// deno-lint-ignore-file prefer-primordials
import { core, internals } from "ext:core/mod.js";
-const {
- op_require_read_closest_package_json,
-} = core.ensureFastOps(true);
+import { op_require_read_closest_package_json } from "ext:core/ops";
import { isAbsolute, resolve } from "node:path";
import { notImplemented } from "ext:deno_node/_utils.ts";
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js
index e99c8fa1b..fa9e4b59e 100644
--- a/ext/web/06_streams.js
+++ b/ext/web/06_streams.js
@@ -15,6 +15,8 @@ const {
} = core;
import {
op_arraybuffer_was_detached,
+ // TODO(mmastrac): use readAll
+ op_read_all,
op_readable_stream_resource_allocate,
op_readable_stream_resource_allocate_sized,
op_readable_stream_resource_await_close,
@@ -26,10 +28,6 @@ import {
op_transfer_arraybuffer,
} from "ext:core/ops";
const {
- // TODO(mmastrac): use readAll
- op_read_all,
-} = core.ensureFastOps(true);
-const {
ArrayBuffer,
ArrayBufferIsView,
ArrayBufferPrototypeGetByteLength,
diff --git a/ext/webgpu/00_init.js b/ext/webgpu/00_init.js
index d33230e58..b7014bd45 100644
--- a/ext/webgpu/00_init.js
+++ b/ext/webgpu/00_init.js
@@ -1,9 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { core } from "ext:core/mod.js";
-const {
- op_lazy_load_esm,
-} = core.ensureFastOps(true);
+import { op_lazy_load_esm } from "ext:core/ops";
let webgpu;