diff options
Diffstat (limited to 'ext/node/polyfills/internal_binding')
-rw-r--r-- | ext/node/polyfills/internal_binding/_libuv_winerror.ts | 7 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/constants.ts | 9 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/stream_wrap.ts | 13 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/udp_wrap.ts | 10 | ||||
-rw-r--r-- | ext/node/polyfills/internal_binding/util.ts | 6 |
5 files changed, 31 insertions, 14 deletions
diff --git a/ext/node/polyfills/internal_binding/_libuv_winerror.ts b/ext/node/polyfills/internal_binding/_libuv_winerror.ts index a62b27a7f..105adfb55 100644 --- a/ext/node/polyfills/internal_binding/_libuv_winerror.ts +++ b/ext/node/polyfills/internal_binding/_libuv_winerror.ts @@ -1,7 +1,10 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -const { ops } = globalThis.__bootstrap.core; +import { core } from "ext:core/mod.js"; +const { + op_node_sys_to_uv_error, +} = core.ensureFastOps(); export function uvTranslateSysError(sysErrno: number): string { - return ops.op_node_sys_to_uv_error(sysErrno); + return op_node_sys_to_uv_error(sysErrno); } diff --git a/ext/node/polyfills/internal_binding/constants.ts b/ext/node/polyfills/internal_binding/constants.ts index 69a2dffeb..4a6a90608 100644 --- a/ext/node/polyfills/internal_binding/constants.ts +++ b/ext/node/polyfills/internal_binding/constants.ts @@ -1,4 +1,10 @@ // 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); + let os: { dlopen: { RTLD_DEEPBIND?: number; @@ -196,8 +202,7 @@ let os: { UV_UDP_REUSEADDR: number; }; -const core = globalThis.__bootstrap.core; -const buildOs = core.ops.op_node_build_os(); +const buildOs = op_node_build_os(); if (buildOs === "darwin") { os = { UV_UDP_REUSEADDR: 4, diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 352bc6a43..87371bf7a 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -30,6 +30,12 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials +import { core } from "ext:core/mod.js"; +const { + op_can_write_vectored, + op_raw_write_vectored, +} = core.ensureFastOps(); + import { TextEncoder } from "ext:deno_web/08_text_encoding.js"; import { Buffer } from "node:buffer"; import { notImplemented } from "ext:deno_node/_utils.ts"; @@ -40,9 +46,6 @@ import { } from "ext:deno_node/internal_binding/async_wrap.ts"; import { codeMap } from "ext:deno_node/internal_binding/uv.ts"; -import { core } from "ext:core/mod.js"; -const { ops } = core; - interface Reader { read(p: Uint8Array): Promise<number | null>; } @@ -204,13 +207,13 @@ export class LibuvStreamWrap extends HandleWrap { // Fast case optimization: two chunks, and all buffers. if ( chunks.length === 2 && allBuffers && supportsWritev && - ops.op_can_write_vectored(rid) + op_can_write_vectored(rid) ) { // String chunks. if (typeof chunks[0] === "string") chunks[0] = Buffer.from(chunks[0]); if (typeof chunks[1] === "string") chunks[1] = Buffer.from(chunks[1]); - ops.op_raw_write_vectored( + op_raw_write_vectored( rid, chunks[0], chunks[1], diff --git a/ext/node/polyfills/internal_binding/udp_wrap.ts b/ext/node/polyfills/internal_binding/udp_wrap.ts index 209c84a23..b78f2a077 100644 --- a/ext/node/polyfills/internal_binding/udp_wrap.ts +++ b/ext/node/polyfills/internal_binding/udp_wrap.ts @@ -24,7 +24,11 @@ // deno-lint-ignore-file prefer-primordials import { core } from "ext:core/mod.js"; -const ops = core.ops; +const { + op_node_unstable_net_listen_udp, + op_node_unstable_net_listen_unixpacket, +} = core.ensureFastOps(); + import { AsyncWrap, providerType, @@ -41,8 +45,8 @@ import * as net from "ext:deno_net/01_net.js"; import { isLinux, isWindows } from "ext:deno_node/_util/os.ts"; const DenoListenDatagram = net.createListenDatagram( - ops.op_node_unstable_net_listen_udp, - ops.op_node_unstable_net_listen_unixpacket, + op_node_unstable_net_listen_udp, + op_node_unstable_net_listen_unixpacket, ); type MessageType = string | Uint8Array | Buffer | DataView; diff --git a/ext/node/polyfills/internal_binding/util.ts b/ext/node/polyfills/internal_binding/util.ts index 721d0964f..b4bcdaef4 100644 --- a/ext/node/polyfills/internal_binding/util.ts +++ b/ext/node/polyfills/internal_binding/util.ts @@ -29,11 +29,13 @@ // deno-lint-ignore-file prefer-primordials import { core } from "ext:core/mod.js"; -const ops = core.ops; +const { + op_node_guess_handle_type, +} = core.ensureFastOps(); const handleTypes = ["TCP", "TTY", "UDP", "FILE", "PIPE", "UNKNOWN"]; export function guessHandleType(fd: number): string { - const type = ops.op_node_guess_handle_type(fd); + const type = op_node_guess_handle_type(fd); return handleTypes[type]; } |