mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
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.
This commit is contained in:
parent
0f9056974f
commit
936d265f8a
32 changed files with 344 additions and 258 deletions
|
@ -1,43 +0,0 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
||||||
|
|
||||||
const addr = Deno.args[0] || "127.0.0.1:4500";
|
|
||||||
const [hostname, port] = addr.split(":");
|
|
||||||
const tcp = Deno.listen({ hostname, port: Number(port) });
|
|
||||||
console.log("Server listening on", addr);
|
|
||||||
|
|
||||||
class Http {
|
|
||||||
id;
|
|
||||||
constructor(id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
[Symbol.asyncIterator]() {
|
|
||||||
return {
|
|
||||||
next: async () => {
|
|
||||||
const reqEvt = await Deno[Deno.internal].core.opAsync(
|
|
||||||
"op_http_accept",
|
|
||||||
this.id,
|
|
||||||
);
|
|
||||||
return { value: reqEvt ?? undefined, done: reqEvt === null };
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for await (const conn of tcp) {
|
|
||||||
const id = Deno[Deno.internal].core.ops.op_http_start(conn.rid);
|
|
||||||
const http = new Http(id);
|
|
||||||
(async () => {
|
|
||||||
for await (const req of http) {
|
|
||||||
if (req == null) continue;
|
|
||||||
const { 0: stream } = req;
|
|
||||||
await Deno[Deno.internal].core.opAsync(
|
|
||||||
"op_http_write_headers",
|
|
||||||
stream,
|
|
||||||
200,
|
|
||||||
[],
|
|
||||||
"Hello World",
|
|
||||||
);
|
|
||||||
Deno[Deno.internal].core.close(stream);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
|
|
@ -1,9 +1,12 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
import { assertEquals, assertThrows } from "./test_util.ts";
|
import { assertEquals, assertThrows } from "./test_util.ts";
|
||||||
import {
|
|
||||||
|
// @ts-ignore This is not publicly typed namespace, but it's there for sure.
|
||||||
|
const {
|
||||||
formatToCronSchedule,
|
formatToCronSchedule,
|
||||||
parseScheduleToString,
|
parseScheduleToString,
|
||||||
} from "../../../ext/cron/01_cron.ts";
|
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
|
||||||
|
} = Deno[Deno.internal];
|
||||||
|
|
||||||
const sleep = (time: number) => new Promise((r) => setTimeout(r, time));
|
const sleep = (time: number) => new Promise((r) => setTimeout(r, time));
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ import {
|
||||||
} from "ext:deno_web/02_event.js";
|
} from "ext:deno_web/02_event.js";
|
||||||
import { defer } from "ext:deno_web/02_timers.js";
|
import { defer } from "ext:deno_web/02_timers.js";
|
||||||
import DOMException from "ext:deno_web/01_dom_exception.js";
|
import DOMException from "ext:deno_web/01_dom_exception.js";
|
||||||
|
const {
|
||||||
|
op_broadcast_recv,
|
||||||
|
op_broadcast_send,
|
||||||
|
} = core.ensureFastOps();
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeIndexOf,
|
ArrayPrototypeIndexOf,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
|
@ -32,7 +36,7 @@ let rid = null;
|
||||||
|
|
||||||
async function recv() {
|
async function recv() {
|
||||||
while (channels.length > 0) {
|
while (channels.length > 0) {
|
||||||
const message = await core.opAsync("op_broadcast_recv", rid);
|
const message = await op_broadcast_recv(rid);
|
||||||
|
|
||||||
if (message === null) {
|
if (message === null) {
|
||||||
break;
|
break;
|
||||||
|
@ -118,7 +122,7 @@ class BroadcastChannel extends EventTarget {
|
||||||
// Send to listeners in other VMs.
|
// Send to listeners in other VMs.
|
||||||
defer(() => {
|
defer(() => {
|
||||||
if (!this[_closed]) {
|
if (!this[_closed]) {
|
||||||
core.opAsync("op_broadcast_send", rid, this[_name], data);
|
op_broadcast_send(rid, this[_name], data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
// @ts-ignore internal api
|
import { core, internals } from "ext:core/mod.js";
|
||||||
const core = Deno.core;
|
const {
|
||||||
|
op_cron_next,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
export function formatToCronSchedule(
|
export function formatToCronSchedule(
|
||||||
value?: number | { exact: number | number[] } | {
|
value?: number | { exact: number | number[] } | {
|
||||||
|
@ -122,7 +124,7 @@ function cron(
|
||||||
return (async () => {
|
return (async () => {
|
||||||
let success = true;
|
let success = true;
|
||||||
while (true) {
|
while (true) {
|
||||||
const r = await core.opAsync("op_cron_next", rid, success);
|
const r = await op_cron_next(rid, success);
|
||||||
if (r === false) {
|
if (r === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -138,4 +140,8 @@ function cron(
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For testing
|
||||||
|
internals.formatToCronSchedule = formatToCronSchedule;
|
||||||
|
internals.parseScheduleToString = parseScheduleToString;
|
||||||
|
|
||||||
export { cron };
|
export { cron };
|
||||||
|
|
|
@ -8,6 +8,16 @@
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
|
const {
|
||||||
|
op_crypto_decrypt,
|
||||||
|
op_crypto_derive_bits,
|
||||||
|
op_crypto_encrypt,
|
||||||
|
op_crypto_generate_key,
|
||||||
|
op_crypto_sign_key,
|
||||||
|
op_crypto_subtle_digest,
|
||||||
|
op_crypto_verify_key,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
import DOMException from "ext:deno_web/01_dom_exception.js";
|
import DOMException from "ext:deno_web/01_dom_exception.js";
|
||||||
|
@ -491,8 +501,7 @@ class SubtleCrypto {
|
||||||
|
|
||||||
algorithm = normalizeAlgorithm(algorithm, "digest");
|
algorithm = normalizeAlgorithm(algorithm, "digest");
|
||||||
|
|
||||||
const result = await core.opAsync(
|
const result = await op_crypto_subtle_digest(
|
||||||
"op_crypto_subtle_digest",
|
|
||||||
algorithm.name,
|
algorithm.name,
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
|
@ -605,7 +614,7 @@ class SubtleCrypto {
|
||||||
|
|
||||||
// 3-5.
|
// 3-5.
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
const plainText = await core.opAsync("op_crypto_decrypt", {
|
const plainText = await op_crypto_decrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "RSA-OAEP",
|
algorithm: "RSA-OAEP",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -626,7 +635,7 @@ class SubtleCrypto {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const plainText = await core.opAsync("op_crypto_decrypt", {
|
const plainText = await op_crypto_decrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "AES-CBC",
|
algorithm: "AES-CBC",
|
||||||
iv: normalizedAlgorithm.iv,
|
iv: normalizedAlgorithm.iv,
|
||||||
|
@ -660,7 +669,7 @@ class SubtleCrypto {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
const cipherText = await core.opAsync("op_crypto_decrypt", {
|
const cipherText = await op_crypto_decrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "AES-CTR",
|
algorithm: "AES-CTR",
|
||||||
keyLength: key[_algorithm].length,
|
keyLength: key[_algorithm].length,
|
||||||
|
@ -728,7 +737,7 @@ class SubtleCrypto {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5-8.
|
// 5-8.
|
||||||
const plaintext = await core.opAsync("op_crypto_decrypt", {
|
const plaintext = await op_crypto_decrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "AES-GCM",
|
algorithm: "AES-GCM",
|
||||||
length: key[_algorithm].length,
|
length: key[_algorithm].length,
|
||||||
|
@ -801,7 +810,7 @@ class SubtleCrypto {
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
const signature = await core.opAsync("op_crypto_sign_key", {
|
const signature = await op_crypto_sign_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "RSASSA-PKCS1-v1_5",
|
algorithm: "RSASSA-PKCS1-v1_5",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -820,7 +829,7 @@ class SubtleCrypto {
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
const signature = await core.opAsync("op_crypto_sign_key", {
|
const signature = await op_crypto_sign_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "RSA-PSS",
|
algorithm: "RSA-PSS",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -857,7 +866,7 @@ class SubtleCrypto {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const signature = await core.opAsync("op_crypto_sign_key", {
|
const signature = await op_crypto_sign_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "ECDSA",
|
algorithm: "ECDSA",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -869,7 +878,7 @@ class SubtleCrypto {
|
||||||
case "HMAC": {
|
case "HMAC": {
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
|
|
||||||
const signature = await core.opAsync("op_crypto_sign_key", {
|
const signature = await op_crypto_sign_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "HMAC",
|
algorithm: "HMAC",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -1297,7 +1306,7 @@ class SubtleCrypto {
|
||||||
}
|
}
|
||||||
|
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
return await core.opAsync("op_crypto_verify_key", {
|
return await op_crypto_verify_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "RSASSA-PKCS1-v1_5",
|
algorithm: "RSASSA-PKCS1-v1_5",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -1313,7 +1322,7 @@ class SubtleCrypto {
|
||||||
}
|
}
|
||||||
|
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
return await core.opAsync("op_crypto_verify_key", {
|
return await op_crypto_verify_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "RSA-PSS",
|
algorithm: "RSA-PSS",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -1323,7 +1332,7 @@ class SubtleCrypto {
|
||||||
}
|
}
|
||||||
case "HMAC": {
|
case "HMAC": {
|
||||||
const hash = key[_algorithm].hash.name;
|
const hash = key[_algorithm].hash.name;
|
||||||
return await core.opAsync("op_crypto_verify_key", {
|
return await op_crypto_verify_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "HMAC",
|
algorithm: "HMAC",
|
||||||
hash,
|
hash,
|
||||||
|
@ -1352,7 +1361,7 @@ class SubtleCrypto {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3-8.
|
// 3-8.
|
||||||
return await core.opAsync("op_crypto_verify_key", {
|
return await op_crypto_verify_key({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "ECDSA",
|
algorithm: "ECDSA",
|
||||||
hash,
|
hash,
|
||||||
|
@ -1739,8 +1748,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const keyData = await core.opAsync(
|
const keyData = await op_crypto_generate_key(
|
||||||
"op_crypto_generate_key",
|
|
||||||
{
|
{
|
||||||
algorithm: "RSA",
|
algorithm: "RSA",
|
||||||
modulusLength: normalizedAlgorithm.modulusLength,
|
modulusLength: normalizedAlgorithm.modulusLength,
|
||||||
|
@ -1799,8 +1807,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const keyData = await core.opAsync(
|
const keyData = await op_crypto_generate_key(
|
||||||
"op_crypto_generate_key",
|
|
||||||
{
|
{
|
||||||
algorithm: "RSA",
|
algorithm: "RSA",
|
||||||
modulusLength: normalizedAlgorithm.modulusLength,
|
modulusLength: normalizedAlgorithm.modulusLength,
|
||||||
|
@ -1863,7 +1870,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
namedCurve,
|
namedCurve,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const keyData = await core.opAsync("op_crypto_generate_key", {
|
const keyData = await op_crypto_generate_key({
|
||||||
algorithm: "EC",
|
algorithm: "EC",
|
||||||
namedCurve,
|
namedCurve,
|
||||||
});
|
});
|
||||||
|
@ -1923,7 +1930,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
namedCurve,
|
namedCurve,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const keyData = await core.opAsync("op_crypto_generate_key", {
|
const keyData = await op_crypto_generate_key({
|
||||||
algorithm: "EC",
|
algorithm: "EC",
|
||||||
namedCurve,
|
namedCurve,
|
||||||
});
|
});
|
||||||
|
@ -2107,7 +2114,7 @@ async function generateKey(normalizedAlgorithm, extractable, usages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3-4.
|
// 3-4.
|
||||||
const keyData = await core.opAsync("op_crypto_generate_key", {
|
const keyData = await op_crypto_generate_key({
|
||||||
algorithm: "HMAC",
|
algorithm: "HMAC",
|
||||||
hash: normalizedAlgorithm.hash.name,
|
hash: normalizedAlgorithm.hash.name,
|
||||||
length,
|
length,
|
||||||
|
@ -4318,7 +4325,7 @@ async function generateKeyAES(normalizedAlgorithm, extractable, usages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
const keyData = await core.opAsync("op_crypto_generate_key", {
|
const keyData = await op_crypto_generate_key({
|
||||||
algorithm: "AES",
|
algorithm: "AES",
|
||||||
length: normalizedAlgorithm.length,
|
length: normalizedAlgorithm.length,
|
||||||
});
|
});
|
||||||
|
@ -4367,7 +4374,7 @@ async function deriveBits(normalizedAlgorithm, baseKey, length) {
|
||||||
|
|
||||||
normalizedAlgorithm.salt = copyBuffer(normalizedAlgorithm.salt);
|
normalizedAlgorithm.salt = copyBuffer(normalizedAlgorithm.salt);
|
||||||
|
|
||||||
const buf = await core.opAsync("op_crypto_derive_bits", {
|
const buf = await op_crypto_derive_bits({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "PBKDF2",
|
algorithm: "PBKDF2",
|
||||||
hash: normalizedAlgorithm.hash.name,
|
hash: normalizedAlgorithm.hash.name,
|
||||||
|
@ -4416,7 +4423,7 @@ async function deriveBits(normalizedAlgorithm, baseKey, length) {
|
||||||
const publicKeyhandle = publicKey[_handle];
|
const publicKeyhandle = publicKey[_handle];
|
||||||
const publicKeyData = WeakMapPrototypeGet(KEY_STORE, publicKeyhandle);
|
const publicKeyData = WeakMapPrototypeGet(KEY_STORE, publicKeyhandle);
|
||||||
|
|
||||||
const buf = await core.opAsync("op_crypto_derive_bits", {
|
const buf = await op_crypto_derive_bits({
|
||||||
key: baseKeyData,
|
key: baseKeyData,
|
||||||
publicKey: publicKeyData,
|
publicKey: publicKeyData,
|
||||||
algorithm: "ECDH",
|
algorithm: "ECDH",
|
||||||
|
@ -4453,7 +4460,7 @@ async function deriveBits(normalizedAlgorithm, baseKey, length) {
|
||||||
|
|
||||||
normalizedAlgorithm.info = copyBuffer(normalizedAlgorithm.info);
|
normalizedAlgorithm.info = copyBuffer(normalizedAlgorithm.info);
|
||||||
|
|
||||||
const buf = await core.opAsync("op_crypto_derive_bits", {
|
const buf = await op_crypto_derive_bits({
|
||||||
key: keyDerivationKey,
|
key: keyDerivationKey,
|
||||||
algorithm: "HKDF",
|
algorithm: "HKDF",
|
||||||
hash: normalizedAlgorithm.hash.name,
|
hash: normalizedAlgorithm.hash.name,
|
||||||
|
@ -4540,7 +4547,7 @@ async function encrypt(normalizedAlgorithm, key, data) {
|
||||||
|
|
||||||
// 3-5.
|
// 3-5.
|
||||||
const hashAlgorithm = key[_algorithm].hash.name;
|
const hashAlgorithm = key[_algorithm].hash.name;
|
||||||
const cipherText = await core.opAsync("op_crypto_encrypt", {
|
const cipherText = await op_crypto_encrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "RSA-OAEP",
|
algorithm: "RSA-OAEP",
|
||||||
hash: hashAlgorithm,
|
hash: hashAlgorithm,
|
||||||
|
@ -4562,7 +4569,7 @@ async function encrypt(normalizedAlgorithm, key, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.
|
// 2.
|
||||||
const cipherText = await core.opAsync("op_crypto_encrypt", {
|
const cipherText = await op_crypto_encrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "AES-CBC",
|
algorithm: "AES-CBC",
|
||||||
length: key[_algorithm].length,
|
length: key[_algorithm].length,
|
||||||
|
@ -4596,7 +4603,7 @@ async function encrypt(normalizedAlgorithm, key, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.
|
// 3.
|
||||||
const cipherText = await core.opAsync("op_crypto_encrypt", {
|
const cipherText = await op_crypto_encrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "AES-CTR",
|
algorithm: "AES-CTR",
|
||||||
keyLength: key[_algorithm].length,
|
keyLength: key[_algorithm].length,
|
||||||
|
@ -4664,7 +4671,7 @@ async function encrypt(normalizedAlgorithm, key, data) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 6-7.
|
// 6-7.
|
||||||
const cipherText = await core.opAsync("op_crypto_encrypt", {
|
const cipherText = await op_crypto_encrypt({
|
||||||
key: keyData,
|
key: keyData,
|
||||||
algorithm: "AES-GCM",
|
algorithm: "AES-GCM",
|
||||||
length: key[_algorithm].length,
|
length: key[_algorithm].length,
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
|
|
||||||
import { core, primordials } from "ext:core/mod.js";
|
import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
|
const {
|
||||||
|
op_fetch_send,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { byteLowerCase } from "ext:deno_web/00_infra.js";
|
import { byteLowerCase } from "ext:deno_web/00_infra.js";
|
||||||
import {
|
import {
|
||||||
|
@ -62,7 +66,7 @@ const REQUEST_BODY_HEADER_NAMES = [
|
||||||
* @returns {Promise<{ status: number, statusText: string, headers: [string, string][], url: string, responseRid: number, error: string? }>}
|
* @returns {Promise<{ status: number, statusText: string, headers: [string, string][], url: string, responseRid: number, error: string? }>}
|
||||||
*/
|
*/
|
||||||
function opFetchSend(rid) {
|
function opFetchSend(rid) {
|
||||||
return core.opAsync("op_fetch_send", rid);
|
return op_fetch_send(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,6 +33,13 @@ const {
|
||||||
SafeWeakMap,
|
SafeWeakMap,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
import { pathFromURL } from "ext:deno_web/00_infra.js";
|
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
|
* @param {BufferSource} source
|
||||||
|
@ -275,8 +282,7 @@ class UnsafeFnPointer {
|
||||||
call(...parameters) {
|
call(...parameters) {
|
||||||
if (this.definition.nonblocking) {
|
if (this.definition.nonblocking) {
|
||||||
if (this.#structSize === null) {
|
if (this.#structSize === null) {
|
||||||
return core.opAsync(
|
return op_ffi_call_ptr_nonblocking(
|
||||||
"op_ffi_call_ptr_nonblocking",
|
|
||||||
this.pointer,
|
this.pointer,
|
||||||
this.definition,
|
this.definition,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -284,8 +290,7 @@ class UnsafeFnPointer {
|
||||||
} else {
|
} else {
|
||||||
const buffer = new Uint8Array(this.#structSize);
|
const buffer = new Uint8Array(this.#structSize);
|
||||||
return PromisePrototypeThen(
|
return PromisePrototypeThen(
|
||||||
core.opAsync(
|
op_ffi_call_ptr_nonblocking(
|
||||||
"op_ffi_call_ptr_nonblocking",
|
|
||||||
this.pointer,
|
this.pointer,
|
||||||
this.definition,
|
this.definition,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -420,8 +425,7 @@ class UnsafeCallback {
|
||||||
// Re-refing
|
// Re-refing
|
||||||
core.refOpPromise(this.#refpromise);
|
core.refOpPromise(this.#refpromise);
|
||||||
} else {
|
} else {
|
||||||
this.#refpromise = core.opAsync(
|
this.#refpromise = op_ffi_unsafe_callback_ref(
|
||||||
"op_ffi_unsafe_callback_ref",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -508,8 +512,7 @@ class DynamicLibrary {
|
||||||
value: (...parameters) => {
|
value: (...parameters) => {
|
||||||
if (isStructResult) {
|
if (isStructResult) {
|
||||||
const buffer = new Uint8Array(structSize);
|
const buffer = new Uint8Array(structSize);
|
||||||
const ret = core.opAsync(
|
const ret = op_ffi_call_nonblocking(
|
||||||
"op_ffi_call_nonblocking",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
symbol,
|
symbol,
|
||||||
parameters,
|
parameters,
|
||||||
|
@ -520,8 +523,7 @@ class DynamicLibrary {
|
||||||
() => buffer,
|
() => buffer,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return core.opAsync(
|
return op_ffi_call_nonblocking(
|
||||||
"op_ffi_call_nonblocking",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
symbol,
|
symbol,
|
||||||
parameters,
|
parameters,
|
||||||
|
|
|
@ -8,7 +8,32 @@ const {
|
||||||
op_fs_truncate_async,
|
op_fs_truncate_async,
|
||||||
op_fs_link_async,
|
op_fs_link_async,
|
||||||
op_fs_flock_async,
|
op_fs_flock_async,
|
||||||
} = Deno.core.ensureFastOps();
|
op_fs_chown_async,
|
||||||
|
op_fs_copy_file_async,
|
||||||
|
op_fs_fdatasync_async,
|
||||||
|
op_fs_fstat_async,
|
||||||
|
op_fs_fsync_async,
|
||||||
|
op_fs_funlock_async,
|
||||||
|
op_fs_futime_async,
|
||||||
|
op_fs_lstat_async,
|
||||||
|
op_fs_make_temp_dir_async,
|
||||||
|
op_fs_make_temp_file_async,
|
||||||
|
op_fs_mkdir_async,
|
||||||
|
op_fs_open_async,
|
||||||
|
op_fs_read_dir_async,
|
||||||
|
op_fs_read_file_async,
|
||||||
|
op_fs_read_file_text_async,
|
||||||
|
op_fs_read_link_async,
|
||||||
|
op_fs_realpath_async,
|
||||||
|
op_fs_remove_async,
|
||||||
|
op_fs_rename_async,
|
||||||
|
op_fs_seek_async,
|
||||||
|
op_fs_stat_async,
|
||||||
|
op_fs_symlink_async,
|
||||||
|
op_fs_utime_async,
|
||||||
|
op_fs_write_file_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
Date,
|
Date,
|
||||||
|
@ -56,8 +81,7 @@ async function chown(
|
||||||
uid,
|
uid,
|
||||||
gid,
|
gid,
|
||||||
) {
|
) {
|
||||||
await core.opAsync(
|
await op_fs_chown_async(
|
||||||
"op_fs_chown_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
uid,
|
uid,
|
||||||
gid,
|
gid,
|
||||||
|
@ -78,8 +102,7 @@ async function copyFile(
|
||||||
fromPath,
|
fromPath,
|
||||||
toPath,
|
toPath,
|
||||||
) {
|
) {
|
||||||
await core.opAsync(
|
await op_fs_copy_file_async(
|
||||||
"op_fs_copy_file_async",
|
|
||||||
pathFromURL(fromPath),
|
pathFromURL(fromPath),
|
||||||
pathFromURL(toPath),
|
pathFromURL(toPath),
|
||||||
);
|
);
|
||||||
|
@ -102,8 +125,7 @@ function makeTempDirSync(options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeTempDir(options = {}) {
|
function makeTempDir(options = {}) {
|
||||||
return core.opAsync(
|
return op_fs_make_temp_dir_async(
|
||||||
"op_fs_make_temp_dir_async",
|
|
||||||
options.dir,
|
options.dir,
|
||||||
options.prefix,
|
options.prefix,
|
||||||
options.suffix,
|
options.suffix,
|
||||||
|
@ -119,8 +141,7 @@ function makeTempFileSync(options = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeTempFile(options = {}) {
|
function makeTempFile(options = {}) {
|
||||||
return core.opAsync(
|
return op_fs_make_temp_file_async(
|
||||||
"op_fs_make_temp_file_async",
|
|
||||||
options.dir,
|
options.dir,
|
||||||
options.prefix,
|
options.prefix,
|
||||||
options.suffix,
|
options.suffix,
|
||||||
|
@ -136,8 +157,7 @@ function mkdirSync(path, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mkdir(path, options) {
|
async function mkdir(path, options) {
|
||||||
await core.opAsync(
|
await op_fs_mkdir_async(
|
||||||
"op_fs_mkdir_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
options?.recursive ?? false,
|
options?.recursive ?? false,
|
||||||
options?.mode,
|
options?.mode,
|
||||||
|
@ -151,8 +171,7 @@ function readDirSync(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readDir(path) {
|
function readDir(path) {
|
||||||
const array = core.opAsync(
|
const array = op_fs_read_dir_async(
|
||||||
"op_fs_read_dir_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
@ -170,7 +189,7 @@ function readLinkSync(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readLink(path) {
|
function readLink(path) {
|
||||||
return core.opAsync("op_fs_read_link_async", pathFromURL(path));
|
return op_fs_read_link_async(pathFromURL(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
function realPathSync(path) {
|
function realPathSync(path) {
|
||||||
|
@ -178,7 +197,7 @@ function realPathSync(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function realPath(path) {
|
function realPath(path) {
|
||||||
return core.opAsync("op_fs_realpath_async", pathFromURL(path));
|
return op_fs_realpath_async(pathFromURL(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeSync(
|
function removeSync(
|
||||||
|
@ -195,8 +214,7 @@ async function remove(
|
||||||
path,
|
path,
|
||||||
options = {},
|
options = {},
|
||||||
) {
|
) {
|
||||||
await core.opAsync(
|
await op_fs_remove_async(
|
||||||
"op_fs_remove_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
!!options.recursive,
|
!!options.recursive,
|
||||||
);
|
);
|
||||||
|
@ -210,8 +228,7 @@ function renameSync(oldpath, newpath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function rename(oldpath, newpath) {
|
async function rename(oldpath, newpath) {
|
||||||
await core.opAsync(
|
await op_fs_rename_async(
|
||||||
"op_fs_rename_async",
|
|
||||||
pathFromURL(oldpath),
|
pathFromURL(oldpath),
|
||||||
pathFromURL(newpath),
|
pathFromURL(newpath),
|
||||||
);
|
);
|
||||||
|
@ -340,11 +357,11 @@ function fstatSync(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fstat(rid) {
|
async function fstat(rid) {
|
||||||
return parseFileInfo(await core.opAsync("op_fs_fstat_async", rid));
|
return parseFileInfo(await op_fs_fstat_async(rid));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function lstat(path) {
|
async function lstat(path) {
|
||||||
const res = await core.opAsync("op_fs_lstat_async", pathFromURL(path));
|
const res = await op_fs_lstat_async(pathFromURL(path));
|
||||||
return parseFileInfo(res);
|
return parseFileInfo(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +371,7 @@ function lstatSync(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stat(path) {
|
async function stat(path) {
|
||||||
const res = await core.opAsync("op_fs_stat_async", pathFromURL(path));
|
const res = await op_fs_stat_async(pathFromURL(path));
|
||||||
return parseFileInfo(res);
|
return parseFileInfo(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,8 +453,7 @@ async function futime(
|
||||||
) {
|
) {
|
||||||
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
||||||
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
||||||
await core.opAsync(
|
await op_fs_futime_async(
|
||||||
"op_fs_futime_async",
|
|
||||||
rid,
|
rid,
|
||||||
atimeSec,
|
atimeSec,
|
||||||
atimeNsec,
|
atimeNsec,
|
||||||
|
@ -469,8 +485,7 @@ async function utime(
|
||||||
) {
|
) {
|
||||||
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
const { 0: atimeSec, 1: atimeNsec } = toUnixTimeFromEpoch(atime);
|
||||||
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
const { 0: mtimeSec, 1: mtimeNsec } = toUnixTimeFromEpoch(mtime);
|
||||||
await core.opAsync(
|
await op_fs_utime_async(
|
||||||
"op_fs_utime_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
atimeSec,
|
atimeSec,
|
||||||
atimeNsec,
|
atimeNsec,
|
||||||
|
@ -496,8 +511,7 @@ async function symlink(
|
||||||
newpath,
|
newpath,
|
||||||
options,
|
options,
|
||||||
) {
|
) {
|
||||||
await core.opAsync(
|
await op_fs_symlink_async(
|
||||||
"op_fs_symlink_async",
|
|
||||||
pathFromURL(oldpath),
|
pathFromURL(oldpath),
|
||||||
pathFromURL(newpath),
|
pathFromURL(newpath),
|
||||||
options?.type,
|
options?.type,
|
||||||
|
@ -509,7 +523,7 @@ function fdatasyncSync(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fdatasync(rid) {
|
async function fdatasync(rid) {
|
||||||
await core.opAsync("op_fs_fdatasync_async", rid);
|
await op_fs_fdatasync_async(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fsyncSync(rid) {
|
function fsyncSync(rid) {
|
||||||
|
@ -517,7 +531,7 @@ function fsyncSync(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fsync(rid) {
|
async function fsync(rid) {
|
||||||
await core.opAsync("op_fs_fsync_async", rid);
|
await op_fs_fsync_async(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flockSync(rid, exclusive) {
|
function flockSync(rid, exclusive) {
|
||||||
|
@ -533,7 +547,7 @@ function funlockSync(rid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function funlock(rid) {
|
async function funlock(rid) {
|
||||||
await core.opAsync("op_fs_funlock_async", rid);
|
await op_fs_funlock_async(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function seekSync(
|
function seekSync(
|
||||||
|
@ -549,7 +563,7 @@ function seek(
|
||||||
offset,
|
offset,
|
||||||
whence,
|
whence,
|
||||||
) {
|
) {
|
||||||
return core.opAsync("op_fs_seek_async", rid, offset, whence);
|
return op_fs_seek_async(rid, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
function openSync(
|
function openSync(
|
||||||
|
@ -570,8 +584,7 @@ async function open(
|
||||||
options,
|
options,
|
||||||
) {
|
) {
|
||||||
if (options) checkOpenOptions(options);
|
if (options) checkOpenOptions(options);
|
||||||
const rid = await core.opAsync(
|
const rid = await op_fs_open_async(
|
||||||
"op_fs_open_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
|
@ -716,8 +729,7 @@ async function readFile(path, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const read = await core.opAsync(
|
const read = await op_fs_read_file_async(
|
||||||
"op_fs_read_file_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
cancelRid,
|
cancelRid,
|
||||||
);
|
);
|
||||||
|
@ -747,8 +759,7 @@ async function readTextFile(path, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const read = await core.opAsync(
|
const read = await op_fs_read_file_text_async(
|
||||||
"op_fs_read_file_text_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
cancelRid,
|
cancelRid,
|
||||||
);
|
);
|
||||||
|
@ -805,8 +816,7 @@ async function writeFile(
|
||||||
signal: options.signal,
|
signal: options.signal,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await core.opAsync(
|
await op_fs_write_file_async(
|
||||||
"op_fs_write_file_async",
|
|
||||||
pathFromURL(path),
|
pathFromURL(path),
|
||||||
options.mode,
|
options.mode,
|
||||||
options.append ?? false,
|
options.append ?? false,
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import { core, internals, primordials } from "ext:core/mod.js";
|
import { core, internals, primordials } from "ext:core/mod.js";
|
||||||
const { BadResourcePrototype, InterruptedPrototype, ops } = core;
|
const { BadResourcePrototype, InterruptedPrototype, ops } = core;
|
||||||
const { op_http_write } = Deno.core.ensureFastOps();
|
|
||||||
import { InnerBody } from "ext:deno_fetch/22_body.js";
|
import { InnerBody } from "ext:deno_fetch/22_body.js";
|
||||||
import { Event, setEventTargetData } from "ext:deno_web/02_event.js";
|
import { Event, setEventTargetData } from "ext:deno_web/02_event.js";
|
||||||
import { BlobPrototype } from "ext:deno_web/09_file.js";
|
import { BlobPrototype } from "ext:deno_web/09_file.js";
|
||||||
|
@ -64,6 +63,15 @@ const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
Uint8ArrayPrototype,
|
Uint8ArrayPrototype,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
const {
|
||||||
|
op_http_accept,
|
||||||
|
op_http_shutdown,
|
||||||
|
op_http_upgrade,
|
||||||
|
op_http_write,
|
||||||
|
op_http_upgrade_websocket,
|
||||||
|
op_http_write_headers,
|
||||||
|
op_http_write_resource,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const connErrorSymbol = Symbol("connError");
|
const connErrorSymbol = Symbol("connError");
|
||||||
const _deferred = Symbol("upgradeHttpDeferred");
|
const _deferred = Symbol("upgradeHttpDeferred");
|
||||||
|
@ -103,7 +111,7 @@ class HttpConn {
|
||||||
async nextRequest() {
|
async nextRequest() {
|
||||||
let nextRequest;
|
let nextRequest;
|
||||||
try {
|
try {
|
||||||
nextRequest = await core.opAsync("op_http_accept", this.#rid);
|
nextRequest = await op_http_accept(this.#rid);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.close();
|
this.close();
|
||||||
// A connection error seen here would cause disrupted responses to throw
|
// A connection error seen here would cause disrupted responses to throw
|
||||||
|
@ -267,8 +275,7 @@ function createRespondWith(
|
||||||
ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, respBody)
|
ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, respBody)
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
await core.opAsync(
|
await op_http_write_headers(
|
||||||
"op_http_write_headers",
|
|
||||||
streamRid,
|
streamRid,
|
||||||
innerResp.status ?? 200,
|
innerResp.status ?? 200,
|
||||||
innerResp.headerList,
|
innerResp.headerList,
|
||||||
|
@ -308,8 +315,7 @@ function createRespondWith(
|
||||||
}
|
}
|
||||||
reader = respBody.getReader(); // Acquire JS lock.
|
reader = respBody.getReader(); // Acquire JS lock.
|
||||||
try {
|
try {
|
||||||
await core.opAsync(
|
await op_http_write_resource(
|
||||||
"op_http_write_resource",
|
|
||||||
streamRid,
|
streamRid,
|
||||||
resourceBacking.rid,
|
resourceBacking.rid,
|
||||||
);
|
);
|
||||||
|
@ -357,7 +363,7 @@ function createRespondWith(
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
try {
|
try {
|
||||||
await core.opAsync("op_http_shutdown", streamRid);
|
await op_http_shutdown(streamRid);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await reader.cancel(error);
|
await reader.cancel(error);
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -367,7 +373,7 @@ function createRespondWith(
|
||||||
|
|
||||||
const deferred = request[_deferred];
|
const deferred = request[_deferred];
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
const res = await core.opAsync("op_http_upgrade", streamRid);
|
const res = await op_http_upgrade(streamRid);
|
||||||
let conn;
|
let conn;
|
||||||
if (res.connType === "tcp") {
|
if (res.connType === "tcp") {
|
||||||
conn = new TcpConn(res.connRid, remoteAddr, localAddr);
|
conn = new TcpConn(res.connRid, remoteAddr, localAddr);
|
||||||
|
@ -383,8 +389,7 @@ function createRespondWith(
|
||||||
}
|
}
|
||||||
const ws = resp[_ws];
|
const ws = resp[_ws];
|
||||||
if (ws) {
|
if (ws) {
|
||||||
const wsRid = await core.opAsync(
|
const wsRid = await op_http_upgrade_websocket(
|
||||||
"op_http_upgrade_websocket",
|
|
||||||
streamRid,
|
streamRid,
|
||||||
);
|
);
|
||||||
ws[_rid] = wsRid;
|
ws[_rid] = wsRid;
|
||||||
|
|
|
@ -17,6 +17,14 @@ import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
import { ReadableStream } from "ext:deno_web/06_streams.js";
|
import { ReadableStream } from "ext:deno_web/06_streams.js";
|
||||||
const core = Deno.core;
|
const core = Deno.core;
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
|
const {
|
||||||
|
op_kv_atomic_write,
|
||||||
|
op_kv_database_open,
|
||||||
|
op_kv_dequeue_next_message,
|
||||||
|
op_kv_finish_dequeued_message,
|
||||||
|
op_kv_snapshot_read,
|
||||||
|
op_kv_watch_next,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const encodeCursor: (
|
const encodeCursor: (
|
||||||
selector: [Deno.KvKey | null, Deno.KvKey | null, Deno.KvKey | null],
|
selector: [Deno.KvKey | null, Deno.KvKey | null, Deno.KvKey | null],
|
||||||
|
@ -25,7 +33,7 @@ const encodeCursor: (
|
||||||
ops.op_kv_encode_cursor(selector, boundaryKey);
|
ops.op_kv_encode_cursor(selector, boundaryKey);
|
||||||
|
|
||||||
async function openKv(path: string) {
|
async function openKv(path: string) {
|
||||||
const rid = await core.opAsync("op_kv_database_open", path);
|
const rid = await op_kv_database_open(path);
|
||||||
return new Kv(rid, kvSymbol);
|
return new Kv(rid, kvSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +108,7 @@ class Kv {
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(key: Deno.KvKey, opts?: { consistency?: Deno.KvConsistencyLevel }) {
|
async get(key: Deno.KvKey, opts?: { consistency?: Deno.KvConsistencyLevel }) {
|
||||||
const [entries]: [RawKvEntry[]] = await core.opAsync(
|
const [entries]: [RawKvEntry[]] = await op_kv_snapshot_read(
|
||||||
"op_kv_snapshot_read",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
[[
|
[[
|
||||||
null,
|
null,
|
||||||
|
@ -127,8 +134,7 @@ class Kv {
|
||||||
keys: Deno.KvKey[],
|
keys: Deno.KvKey[],
|
||||||
opts?: { consistency?: Deno.KvConsistencyLevel },
|
opts?: { consistency?: Deno.KvConsistencyLevel },
|
||||||
): Promise<Deno.KvEntry<unknown>[]> {
|
): Promise<Deno.KvEntry<unknown>[]> {
|
||||||
const ranges: RawKvEntry[][] = await core.opAsync(
|
const ranges: RawKvEntry[][] = await op_kv_snapshot_read(
|
||||||
"op_kv_snapshot_read",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
keys.map((key) => [
|
keys.map((key) => [
|
||||||
null,
|
null,
|
||||||
|
@ -209,8 +215,7 @@ class Kv {
|
||||||
consistency: Deno.KvConsistencyLevel,
|
consistency: Deno.KvConsistencyLevel,
|
||||||
) => Promise<Deno.KvEntry<unknown>[]> {
|
) => Promise<Deno.KvEntry<unknown>[]> {
|
||||||
return async (selector, cursor, reverse, consistency) => {
|
return async (selector, cursor, reverse, consistency) => {
|
||||||
const [entries]: [RawKvEntry[]] = await core.opAsync(
|
const [entries]: [RawKvEntry[]] = await op_kv_snapshot_read(
|
||||||
"op_kv_snapshot_read",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
[[
|
[[
|
||||||
"prefix" in selector ? selector.prefix : null,
|
"prefix" in selector ? selector.prefix : null,
|
||||||
|
@ -268,10 +273,10 @@ class Kv {
|
||||||
const finishMessageOps = new Map<number, Promise<void>>();
|
const finishMessageOps = new Map<number, Promise<void>>();
|
||||||
while (true) {
|
while (true) {
|
||||||
// Wait for the next message.
|
// Wait for the next message.
|
||||||
const next: { 0: Uint8Array; 1: number } = await core.opAsync(
|
const next: { 0: Uint8Array; 1: number } =
|
||||||
"op_kv_dequeue_next_message",
|
await op_kv_dequeue_next_message(
|
||||||
this.#rid,
|
this.#rid,
|
||||||
);
|
);
|
||||||
if (next === null) {
|
if (next === null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -292,8 +297,7 @@ class Kv {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Exception in queue handler", error);
|
console.error("Exception in queue handler", error);
|
||||||
} finally {
|
} finally {
|
||||||
const promise: Promise<void> = core.opAsync(
|
const promise: Promise<void> = op_kv_finish_dequeued_message(
|
||||||
"op_kv_finish_dequeued_message",
|
|
||||||
handleId,
|
handleId,
|
||||||
success,
|
success,
|
||||||
);
|
);
|
||||||
|
@ -325,7 +329,7 @@ class Kv {
|
||||||
while (true) {
|
while (true) {
|
||||||
let updates;
|
let updates;
|
||||||
try {
|
try {
|
||||||
updates = await core.opAsync("op_kv_watch_next", rid);
|
updates = await op_kv_watch_next(rid);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.tryClose(rid);
|
core.tryClose(rid);
|
||||||
controller.error(err);
|
controller.error(err);
|
||||||
|
@ -768,8 +772,7 @@ async function doAtomicWriteInPlace(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return await core.opAsync(
|
return await op_kv_atomic_write(
|
||||||
"op_kv_atomic_write",
|
|
||||||
rid,
|
rid,
|
||||||
checks,
|
checks,
|
||||||
mutations,
|
mutations,
|
||||||
|
|
|
@ -10,6 +10,23 @@ import {
|
||||||
} from "ext:deno_web/06_streams.js";
|
} from "ext:deno_web/06_streams.js";
|
||||||
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
|
const {
|
||||||
|
op_dns_resolve,
|
||||||
|
op_net_accept_tcp,
|
||||||
|
op_net_accept_unix,
|
||||||
|
op_net_connect_tcp,
|
||||||
|
op_net_connect_unix,
|
||||||
|
op_net_recv_udp,
|
||||||
|
op_net_recv_unixpacket,
|
||||||
|
op_net_send_udp,
|
||||||
|
op_net_send_unixpacket,
|
||||||
|
op_net_set_multi_loopback_udp,
|
||||||
|
op_net_set_multi_ttl_udp,
|
||||||
|
op_net_join_multi_v4_udp,
|
||||||
|
op_net_join_multi_v6_udp,
|
||||||
|
op_net_leave_multi_v4_udp,
|
||||||
|
op_net_leave_multi_v6_udp,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
|
@ -46,7 +63,7 @@ async function resolveDns(query, recordType, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await core.opAsync("op_dns_resolve", {
|
return await op_dns_resolve({
|
||||||
cancelRid,
|
cancelRid,
|
||||||
query,
|
query,
|
||||||
recordType,
|
recordType,
|
||||||
|
@ -200,10 +217,10 @@ class Listener {
|
||||||
let promise;
|
let promise;
|
||||||
switch (this.addr.transport) {
|
switch (this.addr.transport) {
|
||||||
case "tcp":
|
case "tcp":
|
||||||
promise = core.opAsync("op_net_accept_tcp", this.rid);
|
promise = op_net_accept_tcp(this.rid);
|
||||||
break;
|
break;
|
||||||
case "unix":
|
case "unix":
|
||||||
promise = core.opAsync("op_net_accept_unix", this.rid);
|
promise = op_net_accept_unix(this.rid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported transport: ${this.addr.transport}`);
|
throw new Error(`Unsupported transport: ${this.addr.transport}`);
|
||||||
|
@ -294,8 +311,7 @@ class Datagram {
|
||||||
}
|
}
|
||||||
|
|
||||||
async joinMulticastV4(addr, multiInterface) {
|
async joinMulticastV4(addr, multiInterface) {
|
||||||
await core.opAsync(
|
await op_net_join_multi_v4_udp(
|
||||||
"op_net_join_multi_v4_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
addr,
|
addr,
|
||||||
multiInterface,
|
multiInterface,
|
||||||
|
@ -303,22 +319,19 @@ class Datagram {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
leave: () =>
|
leave: () =>
|
||||||
core.opAsync(
|
op_net_leave_multi_v4_udp(
|
||||||
"op_net_leave_multi_v4_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
addr,
|
addr,
|
||||||
multiInterface,
|
multiInterface,
|
||||||
),
|
),
|
||||||
setLoopback: (loopback) =>
|
setLoopback: (loopback) =>
|
||||||
core.opAsync(
|
op_net_set_multi_loopback_udp(
|
||||||
"op_net_set_multi_loopback_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
true,
|
true,
|
||||||
loopback,
|
loopback,
|
||||||
),
|
),
|
||||||
setTTL: (ttl) =>
|
setTTL: (ttl) =>
|
||||||
core.opAsync(
|
op_net_set_multi_ttl_udp(
|
||||||
"op_net_set_multi_ttl_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
ttl,
|
ttl,
|
||||||
),
|
),
|
||||||
|
@ -326,8 +339,7 @@ class Datagram {
|
||||||
}
|
}
|
||||||
|
|
||||||
async joinMulticastV6(addr, multiInterface) {
|
async joinMulticastV6(addr, multiInterface) {
|
||||||
await core.opAsync(
|
await op_net_join_multi_v6_udp(
|
||||||
"op_net_join_multi_v6_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
addr,
|
addr,
|
||||||
multiInterface,
|
multiInterface,
|
||||||
|
@ -335,15 +347,13 @@ class Datagram {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
leave: () =>
|
leave: () =>
|
||||||
core.opAsync(
|
op_net_leave_multi_v6_udp(
|
||||||
"op_net_leave_multi_v6_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
addr,
|
addr,
|
||||||
multiInterface,
|
multiInterface,
|
||||||
),
|
),
|
||||||
setLoopback: (loopback) =>
|
setLoopback: (loopback) =>
|
||||||
core.opAsync(
|
op_net_set_multi_loopback_udp(
|
||||||
"op_net_set_multi_loopback_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
false,
|
false,
|
||||||
loopback,
|
loopback,
|
||||||
|
@ -357,8 +367,7 @@ class Datagram {
|
||||||
let remoteAddr;
|
let remoteAddr;
|
||||||
switch (this.addr.transport) {
|
switch (this.addr.transport) {
|
||||||
case "udp": {
|
case "udp": {
|
||||||
({ 0: nread, 1: remoteAddr } = await core.opAsync(
|
({ 0: nread, 1: remoteAddr } = await op_net_recv_udp(
|
||||||
"op_net_recv_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
buf,
|
buf,
|
||||||
));
|
));
|
||||||
|
@ -367,8 +376,7 @@ class Datagram {
|
||||||
}
|
}
|
||||||
case "unixpacket": {
|
case "unixpacket": {
|
||||||
let path;
|
let path;
|
||||||
({ 0: nread, 1: path } = await core.opAsync(
|
({ 0: nread, 1: path } = await op_net_recv_unixpacket(
|
||||||
"op_net_recv_unixpacket",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
buf,
|
buf,
|
||||||
));
|
));
|
||||||
|
@ -385,15 +393,13 @@ class Datagram {
|
||||||
async send(p, opts) {
|
async send(p, opts) {
|
||||||
switch (this.addr.transport) {
|
switch (this.addr.transport) {
|
||||||
case "udp":
|
case "udp":
|
||||||
return await core.opAsync(
|
return await op_net_send_udp(
|
||||||
"op_net_send_udp",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
{ hostname: opts.hostname ?? "127.0.0.1", port: opts.port },
|
{ hostname: opts.hostname ?? "127.0.0.1", port: opts.port },
|
||||||
p,
|
p,
|
||||||
);
|
);
|
||||||
case "unixpacket":
|
case "unixpacket":
|
||||||
return await core.opAsync(
|
return await op_net_send_unixpacket(
|
||||||
"op_net_send_unixpacket",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
opts.path,
|
opts.path,
|
||||||
p,
|
p,
|
||||||
|
@ -484,8 +490,7 @@ function createListenDatagram(udpOpFn, unixOpFn) {
|
||||||
async function connect(args) {
|
async function connect(args) {
|
||||||
switch (args.transport ?? "tcp") {
|
switch (args.transport ?? "tcp") {
|
||||||
case "tcp": {
|
case "tcp": {
|
||||||
const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
|
const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_tcp(
|
||||||
"op_net_connect_tcp",
|
|
||||||
{
|
{
|
||||||
hostname: args.hostname ?? "127.0.0.1",
|
hostname: args.hostname ?? "127.0.0.1",
|
||||||
port: args.port,
|
port: args.port,
|
||||||
|
@ -496,8 +501,7 @@ async function connect(args) {
|
||||||
return new TcpConn(rid, remoteAddr, localAddr);
|
return new TcpConn(rid, remoteAddr, localAddr);
|
||||||
}
|
}
|
||||||
case "unix": {
|
case "unix": {
|
||||||
const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
|
const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_unix(
|
||||||
"op_net_connect_unix",
|
|
||||||
args.path,
|
args.path,
|
||||||
);
|
);
|
||||||
return new UnixConn(
|
return new UnixConn(
|
||||||
|
|
|
@ -4,13 +4,19 @@ import { core, primordials } from "ext:core/mod.js";
|
||||||
const ops = core.ops;
|
const ops = core.ops;
|
||||||
import { Conn, Listener } from "ext:deno_net/01_net.js";
|
import { Conn, Listener } from "ext:deno_net/01_net.js";
|
||||||
const { Number, TypeError } = primordials;
|
const { Number, TypeError } = primordials;
|
||||||
|
const {
|
||||||
|
op_tls_handshake,
|
||||||
|
op_tls_start,
|
||||||
|
op_net_accept_tls,
|
||||||
|
op_net_connect_tls,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
function opStartTls(args) {
|
function opStartTls(args) {
|
||||||
return core.opAsync("op_tls_start", args);
|
return op_tls_start(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opTlsHandshake(rid) {
|
function opTlsHandshake(rid) {
|
||||||
return core.opAsync("op_tls_handshake", rid);
|
return op_tls_handshake(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
class TlsConn extends Conn {
|
class TlsConn extends Conn {
|
||||||
|
@ -32,8 +38,7 @@ async function connectTls({
|
||||||
if (transport !== "tcp") {
|
if (transport !== "tcp") {
|
||||||
throw new TypeError(`Unsupported transport: '${transport}'`);
|
throw new TypeError(`Unsupported transport: '${transport}'`);
|
||||||
}
|
}
|
||||||
const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
|
const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_connect_tls(
|
||||||
"op_net_connect_tls",
|
|
||||||
{ hostname, port },
|
{ hostname, port },
|
||||||
{ certFile, caCerts, certChain, privateKey, alpnProtocols },
|
{ certFile, caCerts, certChain, privateKey, alpnProtocols },
|
||||||
);
|
);
|
||||||
|
@ -44,8 +49,7 @@ async function connectTls({
|
||||||
|
|
||||||
class TlsListener extends Listener {
|
class TlsListener extends Listener {
|
||||||
async accept() {
|
async accept() {
|
||||||
const { 0: rid, 1: localAddr, 2: remoteAddr } = await core.opAsync(
|
const { 0: rid, 1: localAddr, 2: remoteAddr } = await op_net_accept_tls(
|
||||||
"op_net_accept_tls",
|
|
||||||
this.rid,
|
this.rid,
|
||||||
);
|
);
|
||||||
localAddr.transport = "tcp";
|
localAddr.transport = "tcp";
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub mod raw;
|
||||||
pub mod resolve_addr;
|
pub mod resolve_addr;
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::op2;
|
||||||
use deno_core::OpState;
|
use deno_core::OpState;
|
||||||
use deno_tls::rustls::RootCertStore;
|
use deno_tls::rustls::RootCertStore;
|
||||||
use deno_tls::RootCertStoreProvider;
|
use deno_tls::RootCertStoreProvider;
|
||||||
|
@ -96,6 +97,14 @@ deno_core::extension!(deno_net,
|
||||||
#[cfg(unix)] ops_unix::op_node_unstable_net_listen_unixpacket<P>,
|
#[cfg(unix)] ops_unix::op_node_unstable_net_listen_unixpacket<P>,
|
||||||
#[cfg(unix)] ops_unix::op_net_recv_unixpacket,
|
#[cfg(unix)] ops_unix::op_net_recv_unixpacket,
|
||||||
#[cfg(unix)] ops_unix::op_net_send_unixpacket<P>,
|
#[cfg(unix)] ops_unix::op_net_send_unixpacket<P>,
|
||||||
|
|
||||||
|
#[cfg(not(unix))] op_net_accept_unix,
|
||||||
|
#[cfg(not(unix))] op_net_connect_unix,
|
||||||
|
#[cfg(not(unix))] op_net_listen_unix,
|
||||||
|
#[cfg(not(unix))] op_net_listen_unixpacket,
|
||||||
|
#[cfg(not(unix))] op_node_unstable_net_listen_unixpacket,
|
||||||
|
#[cfg(not(unix))] op_net_recv_unixpacket,
|
||||||
|
#[cfg(not(unix))] op_net_send_unixpacket,
|
||||||
],
|
],
|
||||||
esm = [ "01_net.js", "02_tls.js" ],
|
esm = [ "01_net.js", "02_tls.js" ],
|
||||||
options = {
|
options = {
|
||||||
|
@ -111,3 +120,20 @@ deno_core::extension!(deno_net,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
macro_rules! stub_op {
|
||||||
|
($name:ident) => {
|
||||||
|
#[op2(fast)]
|
||||||
|
fn $name() {
|
||||||
|
panic!("Unsupported on non-unix platforms")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
stub_op!(op_net_accept_unix);
|
||||||
|
stub_op!(op_net_connect_unix);
|
||||||
|
stub_op!(op_net_listen_unix);
|
||||||
|
stub_op!(op_net_listen_unixpacket);
|
||||||
|
stub_op!(op_node_unstable_net_listen_unixpacket);
|
||||||
|
stub_op!(op_net_recv_unixpacket);
|
||||||
|
stub_op!(op_net_send_unixpacket);
|
||||||
|
|
|
@ -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 { TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { Transform } from "node:stream";
|
import { Transform } from "node:stream";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
const { ops } = core;
|
||||||
|
const {
|
||||||
|
op_brotli_compress_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const enc = new TextEncoder();
|
const enc = new TextEncoder();
|
||||||
const toU8 = (input) => {
|
const toU8 = (input) => {
|
||||||
|
@ -119,7 +121,7 @@ export function brotliCompress(
|
||||||
}
|
}
|
||||||
|
|
||||||
const { quality, lgwin, mode } = oneOffCompressOptions(options);
|
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))
|
.then((result) => callback(null, result))
|
||||||
.catch((err) => callback(err));
|
.catch((err) => callback(err));
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,9 @@ export const UNZIP = 7;
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
const { ops } = core;
|
||||||
|
const {
|
||||||
|
op_zlib_write_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const writeResult = new Uint32Array(2);
|
const writeResult = new Uint32Array(2);
|
||||||
|
|
||||||
|
@ -117,8 +120,7 @@ class Zlib {
|
||||||
out_off,
|
out_off,
|
||||||
out_len,
|
out_len,
|
||||||
) {
|
) {
|
||||||
core.opAsync(
|
op_zlib_write_async(
|
||||||
"op_zlib_write_async",
|
|
||||||
this.#handle,
|
this.#handle,
|
||||||
flush ?? Z_NO_FLUSH,
|
flush ?? Z_NO_FLUSH,
|
||||||
input,
|
input,
|
||||||
|
|
|
@ -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 { clearTimeout as webClearTimeout } from "ext:deno_web/02_timers.js";
|
||||||
import { resourceForReadableStream } from "ext:deno_web/06_streams.js";
|
import { resourceForReadableStream } from "ext:deno_web/06_streams.js";
|
||||||
import { TcpConn } from "ext:deno_net/01_net.js";
|
import { TcpConn } from "ext:deno_net/01_net.js";
|
||||||
|
const {
|
||||||
|
op_fetch_response_upgrade,
|
||||||
|
op_fetch_send,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
enum STATUS_CODES {
|
enum STATUS_CODES {
|
||||||
/** RFC 7231, 6.2.1 */
|
/** RFC 7231, 6.2.1 */
|
||||||
|
@ -656,7 +660,7 @@ class ClientRequest extends OutgoingMessage {
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await core.opAsync("op_fetch_send", this._req.requestRid);
|
const res = await op_fetch_send(this._req.requestRid);
|
||||||
try {
|
try {
|
||||||
cb?.();
|
cb?.();
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
|
@ -710,8 +714,7 @@ class ClientRequest extends OutgoingMessage {
|
||||||
throw new Error("not implemented CONNECT");
|
throw new Error("not implemented CONNECT");
|
||||||
}
|
}
|
||||||
|
|
||||||
const upgradeRid = await core.opAsync(
|
const upgradeRid = await op_fetch_response_upgrade(
|
||||||
"op_fetch_response_upgrade",
|
|
||||||
res.responseRid,
|
res.responseRid,
|
||||||
);
|
);
|
||||||
assert(typeof res.remoteAddrIp !== "undefined");
|
assert(typeof res.remoteAddrIp !== "undefined");
|
||||||
|
|
|
@ -45,6 +45,14 @@ import { _checkIsHttpToken } from "ext:deno_node/_http_common.ts";
|
||||||
|
|
||||||
const {
|
const {
|
||||||
op_http2_connect,
|
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();
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const kSession = Symbol("session");
|
const kSession = Symbol("session");
|
||||||
|
@ -389,8 +397,7 @@ export class ClientHttp2Session extends Http2Session {
|
||||||
this[kDenoConnRid] = connRid;
|
this[kDenoConnRid] = connRid;
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const promise = core.opAsync(
|
const promise = op_http2_poll_client_connection(
|
||||||
"op_http2_poll_client_connection",
|
|
||||||
this[kDenoConnRid],
|
this[kDenoConnRid],
|
||||||
);
|
);
|
||||||
this[kPollConnPromise] = promise;
|
this[kPollConnPromise] = promise;
|
||||||
|
@ -725,8 +732,7 @@ async function clientHttp2Request(
|
||||||
reqHeaders,
|
reqHeaders,
|
||||||
);
|
);
|
||||||
|
|
||||||
return await core.opAsync(
|
return await op_http2_client_request(
|
||||||
"op_http2_client_request",
|
|
||||||
session[kDenoClientRid],
|
session[kDenoClientRid],
|
||||||
pseudoHeaders,
|
pseudoHeaders,
|
||||||
reqHeaders,
|
reqHeaders,
|
||||||
|
@ -786,8 +792,7 @@ export class ClientHttp2Stream extends Duplex {
|
||||||
session[kDenoClientRid],
|
session[kDenoClientRid],
|
||||||
this.#rid,
|
this.#rid,
|
||||||
);
|
);
|
||||||
const response = await core.opAsync(
|
const response = await op_http2_client_get_response(
|
||||||
"op_http2_client_get_response",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
);
|
);
|
||||||
debugHttp2(">>> after get response", response);
|
debugHttp2(">>> after get response", response);
|
||||||
|
@ -907,8 +912,7 @@ export class ClientHttp2Stream extends Duplex {
|
||||||
this.#requestPromise
|
this.#requestPromise
|
||||||
.then(() => {
|
.then(() => {
|
||||||
debugHttp2(">>> _write", this.#rid, data, encoding, callback);
|
debugHttp2(">>> _write", this.#rid, data, encoding, callback);
|
||||||
return core.opAsync(
|
return op_http2_client_send_data(
|
||||||
"op_http2_client_send_data",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
data,
|
data,
|
||||||
);
|
);
|
||||||
|
@ -967,15 +971,13 @@ export class ClientHttp2Stream extends Duplex {
|
||||||
debugHttp2(">>> read");
|
debugHttp2(">>> read");
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const [chunk, finished] = await core.opAsync(
|
const [chunk, finished] = await op_http2_client_get_response_body_chunk(
|
||||||
"op_http2_client_get_response_body_chunk",
|
|
||||||
this[kDenoResponse].bodyRid,
|
this[kDenoResponse].bodyRid,
|
||||||
);
|
);
|
||||||
|
|
||||||
debugHttp2(">>> chunk", chunk, finished, this[kDenoResponse].bodyRid);
|
debugHttp2(">>> chunk", chunk, finished, this[kDenoResponse].bodyRid);
|
||||||
if (chunk === null) {
|
if (chunk === null) {
|
||||||
const trailerList = await core.opAsync(
|
const trailerList = await op_http2_client_get_response_trailers(
|
||||||
"op_http2_client_get_response_trailers",
|
|
||||||
this[kDenoResponse].bodyRid,
|
this[kDenoResponse].bodyRid,
|
||||||
);
|
);
|
||||||
if (trailerList) {
|
if (trailerList) {
|
||||||
|
@ -1030,8 +1032,7 @@ export class ClientHttp2Stream extends Duplex {
|
||||||
stream[kState].flags &= ~STREAM_FLAGS_HAS_TRAILERS;
|
stream[kState].flags &= ~STREAM_FLAGS_HAS_TRAILERS;
|
||||||
debugHttp2("sending trailers", this.#rid, trailers);
|
debugHttp2("sending trailers", this.#rid, trailers);
|
||||||
|
|
||||||
core.opAsync(
|
op_http2_client_send_trailers(
|
||||||
"op_http2_client_send_trailers",
|
|
||||||
this.#rid,
|
this.#rid,
|
||||||
trailerList,
|
trailerList,
|
||||||
).then(() => {
|
).then(() => {
|
||||||
|
@ -1207,8 +1208,7 @@ function finishCloseStream(stream, code) {
|
||||||
if (stream.pending) {
|
if (stream.pending) {
|
||||||
stream.push(null);
|
stream.push(null);
|
||||||
stream.once("ready", () => {
|
stream.once("ready", () => {
|
||||||
core.opAsync(
|
op_http2_client_reset_stream(
|
||||||
"op_http2_client_reset_stream",
|
|
||||||
stream[kDenoRid],
|
stream[kDenoRid],
|
||||||
code,
|
code,
|
||||||
).then(() => {
|
).then(() => {
|
||||||
|
@ -1224,8 +1224,7 @@ function finishCloseStream(stream, code) {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
stream.resume();
|
stream.resume();
|
||||||
core.opAsync(
|
op_http2_client_reset_stream(
|
||||||
"op_http2_client_reset_stream",
|
|
||||||
stream[kDenoRid],
|
stream[kDenoRid],
|
||||||
code,
|
code,
|
||||||
).then(() => {
|
).then(() => {
|
||||||
|
|
|
@ -43,8 +43,11 @@ import {
|
||||||
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
||||||
import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
import { getValidatedPath } from "ext:deno_node/internal/fs/utils.mjs";
|
||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
|
|
||||||
const core = globalThis.__bootstrap.core;
|
const core = globalThis.__bootstrap.core;
|
||||||
|
const {
|
||||||
|
op_node_ipc_read,
|
||||||
|
op_node_ipc_write,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
export function mapValues<T, O>(
|
export function mapValues<T, O>(
|
||||||
record: Readonly<Record<string, T>>,
|
record: Readonly<Record<string, T>>,
|
||||||
|
@ -1079,7 +1082,7 @@ export function setupChannel(target, ipc) {
|
||||||
if (!target.connected || target.killed) {
|
if (!target.connected || target.killed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const msg = await core.opAsync("op_node_ipc_read", ipc);
|
const msg = await op_node_ipc_read(ipc);
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
// Channel closed.
|
// Channel closed.
|
||||||
target.disconnect();
|
target.disconnect();
|
||||||
|
@ -1124,7 +1127,7 @@ export function setupChannel(target, ipc) {
|
||||||
notImplemented("ChildProcess.send with handle");
|
notImplemented("ChildProcess.send with handle");
|
||||||
}
|
}
|
||||||
|
|
||||||
core.opAsync("op_node_ipc_write", ipc, message)
|
op_node_ipc_write(ipc, message)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
process.nextTick(callback, null);
|
process.nextTick(callback, null);
|
||||||
|
|
|
@ -11,6 +11,9 @@ import { isAnyArrayBuffer, isArrayBufferView } from "node:util/types";
|
||||||
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
const { ops } = core;
|
||||||
|
const {
|
||||||
|
op_node_generate_secret_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const kBufferMaxLength = 0x7fffffff;
|
const kBufferMaxLength = 0x7fffffff;
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ export default function randomFill(
|
||||||
assertOffset(offset, buf.length);
|
assertOffset(offset, buf.length);
|
||||||
assertSize(size, 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(
|
.then(
|
||||||
(randomData) => {
|
(randomData) => {
|
||||||
const randomBuf = Buffer.from(randomData.buffer);
|
const randomBuf = Buffer.from(randomData.buffer);
|
||||||
|
|
|
@ -33,6 +33,9 @@ import {
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
const { ops } = core;
|
||||||
|
const {
|
||||||
|
op_node_hkdf_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
|
const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
|
||||||
validateString(hash, "digest");
|
validateString(hash, "digest");
|
||||||
|
@ -109,7 +112,7 @@ export function hkdf(
|
||||||
|
|
||||||
validateFunction(callback, "callback");
|
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))
|
.then((okm) => callback(null, okm.buffer))
|
||||||
.catch((err) => callback(new ERR_CRYPTO_INVALID_DIGEST(err), undefined));
|
.catch((err) => callback(new ERR_CRYPTO_INVALID_DIGEST(err), undefined));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,16 @@ import { KeyFormat, KeyType } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
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(
|
function validateGenerateKey(
|
||||||
type: "hmac" | "aes",
|
type: "hmac" | "aes",
|
||||||
|
@ -81,7 +91,7 @@ export function generateKey(
|
||||||
validateFunction(callback, "callback");
|
validateFunction(callback, "callback");
|
||||||
const { length } = options;
|
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) => {
|
(key) => {
|
||||||
callback(null, new SecretKeyObject(setOwnedKey(key)));
|
callback(null, new SecretKeyObject(setOwnedKey(key)));
|
||||||
},
|
},
|
||||||
|
@ -799,8 +809,7 @@ function createJob(mode, type, options) {
|
||||||
publicExponent,
|
publicExponent,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return core.opAsync(
|
return op_node_generate_rsa_async(
|
||||||
"op_node_generate_rsa_async",
|
|
||||||
modulusLength,
|
modulusLength,
|
||||||
publicExponent,
|
publicExponent,
|
||||||
);
|
);
|
||||||
|
@ -855,8 +864,7 @@ function createJob(mode, type, options) {
|
||||||
publicExponent,
|
publicExponent,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return core.opAsync(
|
return op_node_generate_rsa_async(
|
||||||
"op_node_generate_rsa_async",
|
|
||||||
modulusLength,
|
modulusLength,
|
||||||
publicExponent,
|
publicExponent,
|
||||||
);
|
);
|
||||||
|
@ -877,8 +885,7 @@ function createJob(mode, type, options) {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_dsa_generate(modulusLength, divisorLength);
|
return ops.op_node_dsa_generate(modulusLength, divisorLength);
|
||||||
}
|
}
|
||||||
return core.opAsync(
|
return op_node_dsa_generate_async(
|
||||||
"op_node_dsa_generate_async",
|
|
||||||
modulusLength,
|
modulusLength,
|
||||||
divisorLength,
|
divisorLength,
|
||||||
);
|
);
|
||||||
|
@ -900,20 +907,20 @@ function createJob(mode, type, options) {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_ec_generate(namedCurve);
|
return ops.op_node_ec_generate(namedCurve);
|
||||||
} else {
|
} else {
|
||||||
return core.opAsync("op_node_ec_generate_async", namedCurve);
|
return op_node_ec_generate_async(namedCurve);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "ed25519": {
|
case "ed25519": {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_ed25519_generate();
|
return ops.op_node_ed25519_generate();
|
||||||
}
|
}
|
||||||
return core.opAsync("op_node_ed25519_generate_async");
|
return op_node_ed25519_generate_async();
|
||||||
}
|
}
|
||||||
case "x25519": {
|
case "x25519": {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_x25519_generate();
|
return ops.op_node_x25519_generate();
|
||||||
}
|
}
|
||||||
return core.opAsync("op_node_x25519_generate_async");
|
return op_node_x25519_generate_async();
|
||||||
}
|
}
|
||||||
case "ed448":
|
case "ed448":
|
||||||
case "x448": {
|
case "x448": {
|
||||||
|
@ -939,7 +946,7 @@ function createJob(mode, type, options) {
|
||||||
if (mode === kSync) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_dh_generate_group(group);
|
return ops.op_node_dh_generate_group(group);
|
||||||
} else {
|
} 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) {
|
if (mode === kSync) {
|
||||||
return ops.op_node_dh_generate(prime, primeLength ?? 0, g);
|
return ops.op_node_dh_generate(prime, primeLength ?? 0, g);
|
||||||
} else {
|
} else {
|
||||||
return core.opAsync(
|
return op_node_dh_generate_async(
|
||||||
"op_node_dh_generate_async",
|
|
||||||
prime,
|
prime,
|
||||||
primeLength ?? 0,
|
primeLength ?? 0,
|
||||||
g,
|
g,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
const { ops } = core;
|
||||||
|
const { op_node_pbkdf2_async } = core.ensureFastOps();
|
||||||
|
|
||||||
export const MAX_ALLOC = Math.pow(2, 30) - 1;
|
export const MAX_ALLOC = Math.pow(2, 30) - 1;
|
||||||
|
|
||||||
|
@ -77,8 +78,7 @@ export function pbkdf2(
|
||||||
throw new TypeError("Bad key length");
|
throw new TypeError("Bad key length");
|
||||||
}
|
}
|
||||||
|
|
||||||
core.opAsync(
|
op_node_pbkdf2_async(
|
||||||
"op_node_pbkdf2_async",
|
|
||||||
password,
|
password,
|
||||||
salt,
|
salt,
|
||||||
iterations,
|
iterations,
|
||||||
|
|
|
@ -31,6 +31,9 @@ import { HASH_DATA } from "ext:deno_node/internal/crypto/types.ts";
|
||||||
|
|
||||||
const { core } = globalThis.__bootstrap;
|
const { core } = globalThis.__bootstrap;
|
||||||
const { ops } = core;
|
const { ops } = core;
|
||||||
|
const {
|
||||||
|
op_node_scrypt_async,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
type Opts = Partial<{
|
type Opts = Partial<{
|
||||||
N: number;
|
N: number;
|
||||||
|
@ -110,8 +113,7 @@ export function scrypt(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
core.opAsync(
|
op_node_scrypt_async(
|
||||||
"op_node_scrypt_async",
|
|
||||||
password,
|
password,
|
||||||
salt,
|
salt,
|
||||||
keylen,
|
keylen,
|
||||||
|
|
|
@ -19,6 +19,11 @@ const {
|
||||||
op_readable_stream_resource_close,
|
op_readable_stream_resource_close,
|
||||||
op_readable_stream_resource_await_close,
|
op_readable_stream_resource_await_close,
|
||||||
} = core.ensureFastOps();
|
} = core.ensureFastOps();
|
||||||
|
// TODO(mmastrac): use readAll
|
||||||
|
const {
|
||||||
|
op_read_all,
|
||||||
|
} = core.ensureFastOps(true);
|
||||||
|
|
||||||
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
import * as webidl from "ext:deno_webidl/00_webidl.js";
|
||||||
import { structuredClone } from "ext:deno_web/02_structured_clone.js";
|
import { structuredClone } from "ext:deno_web/02_structured_clone.js";
|
||||||
import {
|
import {
|
||||||
|
@ -1065,7 +1070,7 @@ async function readableStreamCollectIntoUint8Array(stream) {
|
||||||
// fast path, read whole body in a single op call
|
// fast path, read whole body in a single op call
|
||||||
try {
|
try {
|
||||||
readableStreamDisturb(stream);
|
readableStreamDisturb(stream);
|
||||||
const promise = core.opAsync("op_read_all", resourceBacking.rid);
|
const promise = op_read_all(resourceBacking.rid);
|
||||||
if (readableStreamIsUnrefable(stream)) {
|
if (readableStreamIsUnrefable(stream)) {
|
||||||
stream[promiseSymbol] = promise;
|
stream[promiseSymbol] = promise;
|
||||||
if (stream[_isUnref]) core.unrefOpPromise(promise);
|
if (stream[_isUnref]) core.unrefOpPromise(promise);
|
||||||
|
|
|
@ -49,6 +49,9 @@ const {
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
import { createFilteredInspectProxy } from "ext:deno_console/01_console.js";
|
||||||
|
const {
|
||||||
|
op_blob_read_part,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
// TODO(lucacasonato): this needs to not be hardcoded and instead depend on
|
// TODO(lucacasonato): this needs to not be hardcoded and instead depend on
|
||||||
// host os.
|
// host os.
|
||||||
|
@ -626,7 +629,7 @@ class BlobReference {
|
||||||
* @returns {AsyncGenerator<Uint8Array>}
|
* @returns {AsyncGenerator<Uint8Array>}
|
||||||
*/
|
*/
|
||||||
async *stream() {
|
async *stream() {
|
||||||
yield core.opAsync("op_blob_read_part", this._id);
|
yield op_blob_read_part(this._id);
|
||||||
|
|
||||||
// let position = 0;
|
// let position = 0;
|
||||||
// const end = this.size;
|
// const end = this.size;
|
||||||
|
@ -634,7 +637,7 @@ class BlobReference {
|
||||||
// const size = MathMin(end - position, 65536);
|
// const size = MathMin(end - position, 65536);
|
||||||
// const chunk = this.slice(position, position + size);
|
// const chunk = this.slice(position, position + size);
|
||||||
// position += chunk.size;
|
// position += chunk.size;
|
||||||
// yield core.opAsync("op_blob_read_part", chunk._id);
|
// yield op_blob_read_part( chunk._id);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,9 @@ const {
|
||||||
SymbolIterator,
|
SymbolIterator,
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
const {
|
||||||
|
op_message_port_recv_message,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
class MessageChannel {
|
class MessageChannel {
|
||||||
/** @type {MessagePort} */
|
/** @type {MessagePort} */
|
||||||
|
@ -147,8 +150,7 @@ class MessagePort extends EventTarget {
|
||||||
if (this[_id] === null) break;
|
if (this[_id] === null) break;
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
data = await core.opAsync(
|
data = await op_message_port_recv_message(
|
||||||
"op_message_port_recv_message",
|
|
||||||
this[_id],
|
this[_id],
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -48,6 +48,12 @@ const {
|
||||||
Uint32ArrayPrototype,
|
Uint32ArrayPrototype,
|
||||||
Uint8Array,
|
Uint8Array,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
const {
|
||||||
|
op_webgpu_buffer_get_map_async,
|
||||||
|
op_webgpu_request_adapter,
|
||||||
|
op_webgpu_request_adapter_info,
|
||||||
|
op_webgpu_request_device,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
const _rid = Symbol("[[rid]]");
|
const _rid = Symbol("[[rid]]");
|
||||||
const _size = Symbol("[[size]]");
|
const _size = Symbol("[[size]]");
|
||||||
|
@ -253,8 +259,7 @@ class GPU {
|
||||||
"Argument 1",
|
"Argument 1",
|
||||||
);
|
);
|
||||||
|
|
||||||
const { err, ...data } = await core.opAsync(
|
const { err, ...data } = await op_webgpu_request_adapter(
|
||||||
"op_webgpu_request_adapter",
|
|
||||||
options.powerPreference,
|
options.powerPreference,
|
||||||
options.forceFallbackAdapter,
|
options.forceFallbackAdapter,
|
||||||
);
|
);
|
||||||
|
@ -343,8 +348,7 @@ class GPUAdapter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rid, features, limits } = await core.opAsync(
|
const { rid, features, limits } = await op_webgpu_request_device(
|
||||||
"op_webgpu_request_device",
|
|
||||||
this[_adapter].rid,
|
this[_adapter].rid,
|
||||||
descriptor.label,
|
descriptor.label,
|
||||||
requiredFeatures,
|
requiredFeatures,
|
||||||
|
@ -382,8 +386,7 @@ class GPUAdapter {
|
||||||
architecture,
|
architecture,
|
||||||
device,
|
device,
|
||||||
description,
|
description,
|
||||||
} = await core.opAsync(
|
} = await op_webgpu_request_adapter_info(
|
||||||
"op_webgpu_request_adapter_info",
|
|
||||||
this[_adapter].rid,
|
this[_adapter].rid,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1949,8 +1952,7 @@ class GPUBuffer {
|
||||||
this[_mapMode] = mode;
|
this[_mapMode] = mode;
|
||||||
this[_state] = "pending";
|
this[_state] = "pending";
|
||||||
const promise = PromisePrototypeThen(
|
const promise = PromisePrototypeThen(
|
||||||
core.opAsync(
|
op_webgpu_buffer_get_map_async(
|
||||||
"op_webgpu_buffer_get_map_async",
|
|
||||||
bufferRid,
|
bufferRid,
|
||||||
device.rid,
|
device.rid,
|
||||||
mode,
|
mode,
|
||||||
|
|
|
@ -30,6 +30,10 @@ import {
|
||||||
MessagePortPrototype,
|
MessagePortPrototype,
|
||||||
serializeJsMessageData,
|
serializeJsMessageData,
|
||||||
} from "ext:deno_web/13_message_port.js";
|
} from "ext:deno_web/13_message_port.js";
|
||||||
|
const {
|
||||||
|
op_host_recv_ctrl,
|
||||||
|
op_host_recv_message,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
function createWorker(
|
function createWorker(
|
||||||
specifier,
|
specifier,
|
||||||
|
@ -58,11 +62,11 @@ function hostPostMessage(id, data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostRecvCtrl(id) {
|
function hostRecvCtrl(id) {
|
||||||
return core.opAsync("op_host_recv_ctrl", id);
|
return op_host_recv_ctrl(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hostRecvMessage(id) {
|
function hostRecvMessage(id) {
|
||||||
return core.opAsync("op_host_recv_message", id);
|
return op_host_recv_message(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Worker extends EventTarget {
|
class Worker extends EventTarget {
|
||||||
|
|
|
@ -9,6 +9,9 @@ const {
|
||||||
SymbolAsyncIterator,
|
SymbolAsyncIterator,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
import { SymbolDispose } from "ext:deno_web/00_infra.js";
|
||||||
|
const {
|
||||||
|
op_fs_events_poll,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
class FsWatcher {
|
class FsWatcher {
|
||||||
#rid = 0;
|
#rid = 0;
|
||||||
|
@ -24,7 +27,7 @@ class FsWatcher {
|
||||||
|
|
||||||
async next() {
|
async next() {
|
||||||
try {
|
try {
|
||||||
const value = await core.opAsync("op_fs_events_poll", this.rid);
|
const value = await op_fs_events_poll(this.rid);
|
||||||
return value ? { value, done: false } : { value: undefined, done: true };
|
return value ? { value, done: false } : { value: undefined, done: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (ObjectPrototypeIsPrototypeOf(BadResourcePrototype, error)) {
|
if (ObjectPrototypeIsPrototypeOf(BadResourcePrototype, error)) {
|
||||||
|
|
|
@ -30,6 +30,10 @@ import {
|
||||||
ReadableStreamPrototype,
|
ReadableStreamPrototype,
|
||||||
writableStreamForRid,
|
writableStreamForRid,
|
||||||
} from "ext:deno_web/06_streams.js";
|
} from "ext:deno_web/06_streams.js";
|
||||||
|
const {
|
||||||
|
op_run_status,
|
||||||
|
op_spawn_wait,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
function opKill(pid, signo, apiName) {
|
function opKill(pid, signo, apiName) {
|
||||||
ops.op_kill(pid, signo, apiName);
|
ops.op_kill(pid, signo, apiName);
|
||||||
|
@ -40,7 +44,7 @@ function kill(pid, signo = "SIGTERM") {
|
||||||
}
|
}
|
||||||
|
|
||||||
function opRunStatus(rid) {
|
function opRunStatus(rid) {
|
||||||
return core.opAsync("op_run_status", rid);
|
return op_run_status(rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function opRun(request) {
|
function opRun(request) {
|
||||||
|
@ -272,7 +276,7 @@ class ChildProcess {
|
||||||
const onAbort = () => this.kill("SIGTERM");
|
const onAbort = () => this.kill("SIGTERM");
|
||||||
signal?.[abortSignal.add](onAbort);
|
signal?.[abortSignal.add](onAbort);
|
||||||
|
|
||||||
const waitPromise = core.opAsync("op_spawn_wait", this.#rid);
|
const waitPromise = op_spawn_wait(this.#rid);
|
||||||
this.#waitPromise = waitPromise;
|
this.#waitPromise = waitPromise;
|
||||||
this.#status = PromisePrototypeThen(waitPromise, (res) => {
|
this.#status = PromisePrototypeThen(waitPromise, (res) => {
|
||||||
signal?.[abortSignal.remove](onAbort);
|
signal?.[abortSignal.remove](onAbort);
|
||||||
|
|
|
@ -9,13 +9,16 @@ const {
|
||||||
SetPrototypeDelete,
|
SetPrototypeDelete,
|
||||||
TypeError,
|
TypeError,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
const {
|
||||||
|
op_signal_poll,
|
||||||
|
} = core.ensureFastOps();
|
||||||
|
|
||||||
function bindSignal(signo) {
|
function bindSignal(signo) {
|
||||||
return ops.op_signal_bind(signo);
|
return ops.op_signal_bind(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pollSignal(rid) {
|
function pollSignal(rid) {
|
||||||
const promise = core.opAsync("op_signal_poll", rid);
|
const promise = op_signal_poll(rid);
|
||||||
core.unrefOpPromise(promise);
|
core.unrefOpPromise(promise);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,8 @@ let isClosing = false;
|
||||||
let globalDispatchEvent;
|
let globalDispatchEvent;
|
||||||
|
|
||||||
async function pollForMessages() {
|
async function pollForMessages() {
|
||||||
|
const { op_worker_recv_message } = core.ensureFastOps();
|
||||||
|
|
||||||
if (!globalDispatchEvent) {
|
if (!globalDispatchEvent) {
|
||||||
globalDispatchEvent = FunctionPrototypeBind(
|
globalDispatchEvent = FunctionPrototypeBind(
|
||||||
globalThis.dispatchEvent,
|
globalThis.dispatchEvent,
|
||||||
|
@ -148,7 +150,7 @@ async function pollForMessages() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
while (!isClosing) {
|
while (!isClosing) {
|
||||||
const data = await core.opAsync("op_worker_recv_message");
|
const data = await op_worker_recv_message();
|
||||||
if (data === null) break;
|
if (data === null) break;
|
||||||
const v = messagePort.deserializeJsMessageData(data);
|
const v = messagePort.deserializeJsMessageData(data);
|
||||||
const message = v[0];
|
const message = v[0];
|
||||||
|
|
Loading…
Reference in a new issue