diff options
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/_brotli.js | 6 | ||||
-rw-r--r-- | ext/node/polyfills/_zlib_binding.mjs | 6 | ||||
-rw-r--r-- | ext/node/polyfills/http.ts | 9 | ||||
-rw-r--r-- | ext/node/polyfills/http2.ts | 35 | ||||
-rw-r--r-- | ext/node/polyfills/internal/child_process.ts | 9 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/_randomFill.mjs | 5 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/hkdf.ts | 5 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/keygen.ts | 32 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/pbkdf2.ts | 4 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/scrypt.ts | 6 |
10 files changed, 70 insertions, 47 deletions
diff --git a/ext/node/polyfills/_brotli.js b/ext/node/polyfills/_brotli.js index 6f77bb341..bf099759b 100644 --- a/ext/node/polyfills/_brotli.js +++ b/ext/node/polyfills/_brotli.js @@ -7,9 +7,11 @@ import { zlib as constants } from "ext:deno_node/internal_binding/constants.ts"; import { TextEncoder } from "ext:deno_web/08_text_encoding.js"; import { Transform } from "node:stream"; import { Buffer } from "node:buffer"; - const { core } = globalThis.__bootstrap; const { ops } = core; +const { + op_brotli_compress_async, +} = core.ensureFastOps(); const enc = new TextEncoder(); const toU8 = (input) => { @@ -119,7 +121,7 @@ export function brotliCompress( } const { quality, lgwin, mode } = oneOffCompressOptions(options); - core.opAsync("op_brotli_compress_async", buf, quality, lgwin, mode) + op_brotli_compress_async(buf, quality, lgwin, mode) .then((result) => callback(null, result)) .catch((err) => callback(err)); } diff --git a/ext/node/polyfills/_zlib_binding.mjs b/ext/node/polyfills/_zlib_binding.mjs index 30bd1400a..9cece7feb 100644 --- a/ext/node/polyfills/_zlib_binding.mjs +++ b/ext/node/polyfills/_zlib_binding.mjs @@ -45,6 +45,9 @@ export const UNZIP = 7; const { core } = globalThis.__bootstrap; const { ops } = core; +const { + op_zlib_write_async, +} = core.ensureFastOps(); const writeResult = new Uint32Array(2); @@ -117,8 +120,7 @@ class Zlib { out_off, out_len, ) { - core.opAsync( - "op_zlib_write_async", + op_zlib_write_async( this.#handle, flush ?? Z_NO_FLUSH, input, diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index e49f71702..8b7bcc21f 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -60,6 +60,10 @@ import { timerId } from "ext:deno_web/03_abort_signal.js"; import { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js"; import { resourceForReadableStream } from "ext:deno_web/06_streams.js"; import { TcpConn } from "ext:deno_net/01_net.js"; +const { + op_fetch_response_upgrade, + op_fetch_send, +} = core.ensureFastOps(); enum STATUS_CODES { /** RFC 7231, 6.2.1 */ @@ -656,7 +660,7 @@ class ClientRequest extends OutgoingMessage { (async () => { try { - const res = await core.opAsync("op_fetch_send", this._req.requestRid); + const res = await op_fetch_send(this._req.requestRid); try { cb?.(); } catch (_) { @@ -710,8 +714,7 @@ class ClientRequest extends OutgoingMessage { throw new Error("not implemented CONNECT"); } - const upgradeRid = await core.opAsync( - "op_fetch_response_upgrade", + const upgradeRid = await op_fetch_response_upgrade( res.responseRid, ); assert(typeof res.remoteAddrIp !== "undefined"); diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index bab607b80..e3bba25e0 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -45,6 +45,14 @@ import { _checkIsHttpToken } from "ext:deno_node/_http_common.ts"; const { op_http2_connect, + op_http2_client_get_response, + op_http2_client_get_response_body_chunk, + op_http2_client_get_response_trailers, + op_http2_client_request, + op_http2_client_reset_stream, + op_http2_client_send_data, + op_http2_client_send_trailers, + op_http2_poll_client_connection, } = core.ensureFastOps(); const kSession = Symbol("session"); @@ -389,8 +397,7 @@ export class ClientHttp2Session extends Http2Session { this[kDenoConnRid] = connRid; (async () => { try { - const promise = core.opAsync( - "op_http2_poll_client_connection", + const promise = op_http2_poll_client_connection( this[kDenoConnRid], ); this[kPollConnPromise] = promise; @@ -725,8 +732,7 @@ async function clientHttp2Request( reqHeaders, ); - return await core.opAsync( - "op_http2_client_request", + return await op_http2_client_request( session[kDenoClientRid], pseudoHeaders, reqHeaders, @@ -786,8 +792,7 @@ export class ClientHttp2Stream extends Duplex { session[kDenoClientRid], this.#rid, ); - const response = await core.opAsync( - "op_http2_client_get_response", + const response = await op_http2_client_get_response( this.#rid, ); debugHttp2(">>> after get response", response); @@ -907,8 +912,7 @@ export class ClientHttp2Stream extends Duplex { this.#requestPromise .then(() => { debugHttp2(">>> _write", this.#rid, data, encoding, callback); - return core.opAsync( - "op_http2_client_send_data", + return op_http2_client_send_data( this.#rid, data, ); @@ -967,15 +971,13 @@ export class ClientHttp2Stream extends Duplex { debugHttp2(">>> read"); (async () => { - const [chunk, finished] = await core.opAsync( - "op_http2_client_get_response_body_chunk", + const [chunk, finished] = await op_http2_client_get_response_body_chunk( this[kDenoResponse].bodyRid, ); debugHttp2(">>> chunk", chunk, finished, this[kDenoResponse].bodyRid); if (chunk === null) { - const trailerList = await core.opAsync( - "op_http2_client_get_response_trailers", + const trailerList = await op_http2_client_get_response_trailers( this[kDenoResponse].bodyRid, ); if (trailerList) { @@ -1030,8 +1032,7 @@ export class ClientHttp2Stream extends Duplex { stream[kState].flags &= ~STREAM_FLAGS_HAS_TRAILERS; debugHttp2("sending trailers", this.#rid, trailers); - core.opAsync( - "op_http2_client_send_trailers", + op_http2_client_send_trailers( this.#rid, trailerList, ).then(() => { @@ -1207,8 +1208,7 @@ function finishCloseStream(stream, code) { if (stream.pending) { stream.push(null); stream.once("ready", () => { - core.opAsync( - "op_http2_client_reset_stream", + op_http2_client_reset_stream( stream[kDenoRid], code, ).then(() => { @@ -1224,8 +1224,7 @@ function finishCloseStream(stream, code) { }); } else { stream.resume(); - core.opAsync( - "op_http2_client_reset_stream", + op_http2_client_reset_stream( stream[kDenoRid], code, ).then(() => { diff --git a/ext/node/polyfills/internal/child_process.ts b/ext/node/polyfills/internal/child_process.ts index 39c7633e4..7f40ce94b 100644 --- a/ext/node/polyfills/internal/child_process.ts +++ b/ext/node/polyfills/internal/child_process.ts @@ -43,8 +43,11 @@ import { import { kEmptyObject } from "ext:deno_node/internal/util.mjs"; import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs"; import process from "node:process"; - const core = globalThis.__bootstrap.core; +const { + op_node_ipc_read, + op_node_ipc_write, +} = core.ensureFastOps(); export function mapValues<T, O>( record: Readonly<Record<string, T>>, @@ -1079,7 +1082,7 @@ export function setupChannel(target, ipc) { if (!target.connected || target.killed) { return; } - const msg = await core.opAsync("op_node_ipc_read", ipc); + const msg = await op_node_ipc_read(ipc); if (msg == null) { // Channel closed. target.disconnect(); @@ -1124,7 +1127,7 @@ export function setupChannel(target, ipc) { notImplemented("ChildProcess.send with handle"); } - core.opAsync("op_node_ipc_write", ipc, message) + op_node_ipc_write(ipc, message) .then(() => { if (callback) { process.nextTick(callback, null); diff --git a/ext/node/polyfills/internal/crypto/_randomFill.mjs b/ext/node/polyfills/internal/crypto/_randomFill.mjs index 6afc654b4..7f66cfb4b 100644 --- a/ext/node/polyfills/internal/crypto/_randomFill.mjs +++ b/ext/node/polyfills/internal/crypto/_randomFill.mjs @@ -11,6 +11,9 @@ import { isAnyArrayBuffer, isArrayBufferView } from "node:util/types"; import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts"; const { core } = globalThis.__bootstrap; const { ops } = core; +const { + op_node_generate_secret_async, +} = core.ensureFastOps(); const kBufferMaxLength = 0x7fffffff; @@ -52,7 +55,7 @@ export default function randomFill( assertOffset(offset, buf.length); assertSize(size, offset, buf.length); - core.opAsync("op_node_generate_secret_async", Math.floor(size)) + op_node_generate_secret_async(Math.floor(size)) .then( (randomData) => { const randomBuf = Buffer.from(randomData.buffer); diff --git a/ext/node/polyfills/internal/crypto/hkdf.ts b/ext/node/polyfills/internal/crypto/hkdf.ts index 4454b0488..8f3e8c7a9 100644 --- a/ext/node/polyfills/internal/crypto/hkdf.ts +++ b/ext/node/polyfills/internal/crypto/hkdf.ts @@ -33,6 +33,9 @@ import { const { core } = globalThis.__bootstrap; const { ops } = core; +const { + op_node_hkdf_async, +} = core.ensureFastOps(); const validateParameters = hideStackFrames((hash, key, salt, info, length) => { validateString(hash, "digest"); @@ -109,7 +112,7 @@ export function hkdf( validateFunction(callback, "callback"); - core.opAsync("op_node_hkdf_async", hash, key, salt, info, length) + op_node_hkdf_async(hash, key, salt, info, length) .then((okm) => callback(null, okm.buffer)) .catch((err) => callback(new ERR_CRYPTO_INVALID_DIGEST(err), undefined)); } diff --git a/ext/node/polyfills/internal/crypto/keygen.ts b/ext/node/polyfills/internal/crypto/keygen.ts index 29a062e00..f757f5eaf 100644 --- a/ext/node/polyfills/internal/crypto/keygen.ts +++ b/ext/node/polyfills/internal/crypto/keygen.ts @@ -31,6 +31,16 @@ import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts"; const { core } = globalThis.__bootstrap; const { ops } = core; +const { + op_node_dh_generate_async, + op_node_dh_generate_group_async, + op_node_dsa_generate_async, + op_node_ec_generate_async, + op_node_generate_rsa_async, + op_node_generate_secret_async, + op_node_ed25519_generate_async, + op_node_x25519_generate_async, +} = core.ensureFastOps(); function validateGenerateKey( type: "hmac" | "aes", @@ -81,7 +91,7 @@ export function generateKey( validateFunction(callback, "callback"); const { length } = options; - core.opAsync("op_node_generate_secret_async", Math.floor(length / 8)).then( + op_node_generate_secret_async(Math.floor(length / 8)).then( (key) => { callback(null, new SecretKeyObject(setOwnedKey(key))); }, @@ -799,8 +809,7 @@ function createJob(mode, type, options) { publicExponent, ); } else { - return core.opAsync( - "op_node_generate_rsa_async", + return op_node_generate_rsa_async( modulusLength, publicExponent, ); @@ -855,8 +864,7 @@ function createJob(mode, type, options) { publicExponent, ); } else { - return core.opAsync( - "op_node_generate_rsa_async", + return op_node_generate_rsa_async( modulusLength, publicExponent, ); @@ -877,8 +885,7 @@ function createJob(mode, type, options) { if (mode === kSync) { return ops.op_node_dsa_generate(modulusLength, divisorLength); } - return core.opAsync( - "op_node_dsa_generate_async", + return op_node_dsa_generate_async( modulusLength, divisorLength, ); @@ -900,20 +907,20 @@ function createJob(mode, type, options) { if (mode === kSync) { return ops.op_node_ec_generate(namedCurve); } else { - return core.opAsync("op_node_ec_generate_async", namedCurve); + return op_node_ec_generate_async(namedCurve); } } case "ed25519": { if (mode === kSync) { return ops.op_node_ed25519_generate(); } - return core.opAsync("op_node_ed25519_generate_async"); + return op_node_ed25519_generate_async(); } case "x25519": { if (mode === kSync) { return ops.op_node_x25519_generate(); } - return core.opAsync("op_node_x25519_generate_async"); + return op_node_x25519_generate_async(); } case "ed448": case "x448": { @@ -939,7 +946,7 @@ function createJob(mode, type, options) { if (mode === kSync) { return ops.op_node_dh_generate_group(group); } else { - return core.opAsync("op_node_dh_generate_group_async", group); + return op_node_dh_generate_group_async(group); } } @@ -966,8 +973,7 @@ function createJob(mode, type, options) { if (mode === kSync) { return ops.op_node_dh_generate(prime, primeLength ?? 0, g); } else { - return core.opAsync( - "op_node_dh_generate_async", + return op_node_dh_generate_async( prime, primeLength ?? 0, g, diff --git a/ext/node/polyfills/internal/crypto/pbkdf2.ts b/ext/node/polyfills/internal/crypto/pbkdf2.ts index f177d153a..50cc3a83e 100644 --- a/ext/node/polyfills/internal/crypto/pbkdf2.ts +++ b/ext/node/polyfills/internal/crypto/pbkdf2.ts @@ -8,6 +8,7 @@ import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts"; const { core } = globalThis.__bootstrap; const { ops } = core; +const { op_node_pbkdf2_async } = core.ensureFastOps(); export const MAX_ALLOC = Math.pow(2, 30) - 1; @@ -77,8 +78,7 @@ export function pbkdf2( throw new TypeError("Bad key length"); } - core.opAsync( - "op_node_pbkdf2_async", + op_node_pbkdf2_async( password, salt, iterations, diff --git a/ext/node/polyfills/internal/crypto/scrypt.ts b/ext/node/polyfills/internal/crypto/scrypt.ts index e87cdb856..2ceac5139 100644 --- a/ext/node/polyfills/internal/crypto/scrypt.ts +++ b/ext/node/polyfills/internal/crypto/scrypt.ts @@ -31,6 +31,9 @@ import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts"; const { core } = globalThis.__bootstrap; const { ops } = core; +const { + op_node_scrypt_async, +} = core.ensureFastOps(); type Opts = Partial<{ N: number; @@ -110,8 +113,7 @@ export function scrypt( } try { - core.opAsync( - "op_node_scrypt_async", + op_node_scrypt_async( password, salt, keylen, |