summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorAapo Alasuutari <aapo.alasuutari@gmail.com>2022-08-11 16:56:56 +0300
committerGitHub <noreply@github.com>2022-08-11 15:56:56 +0200
commit2164f6b1eb7216c1045d547c94f26fe3ceaa9403 (patch)
tree056e3d6540ebd0e755650765adcff6b5cc173db8 /runtime/js
parent883269f1f183428f60c54223135d8dd25977b3cd (diff)
perf(ops): Monomorphic sync op calls (#15337)
Welcome to better optimised op calls! Currently opSync is called with parameters of every type and count. This most definitely makes the call megamorphic. Additionally, it seems that spread params leads to V8 not being able to optimise the calls quite as well (apparently Fast Calls cannot be used with spread params). Monomorphising op calls should lead to some improved performance. Now that unwrapping of sync ops results is done on Rust side, this is pretty simple: ``` opSync("op_foo", param1, param2); // -> turns to ops.op_foo(param1, param2); ``` This means sync op calls are now just directly calling the native binding function. When V8 Fast API Calls are enabled, this will enable those to be called on the optimised path. Monomorphising async ops likely requires using callbacks and is left as an exercise to the reader.
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/10_permissions.js8
-rw-r--r--runtime/js/11_workers.js7
-rw-r--r--runtime/js/12_io.js5
-rw-r--r--runtime/js/30_fs.js55
-rw-r--r--runtime/js/30_os.js29
-rw-r--r--runtime/js/40_files.js6
-rw-r--r--runtime/js/40_fs_events.js3
-rw-r--r--runtime/js/40_http.js3
-rw-r--r--runtime/js/40_process.js5
-rw-r--r--runtime/js/40_read_file.js9
-rw-r--r--runtime/js/40_signals.js5
-rw-r--r--runtime/js/40_spawn.js7
-rw-r--r--runtime/js/40_testing.js38
-rw-r--r--runtime/js/40_tty.js7
-rw-r--r--runtime/js/40_write_file.js5
-rw-r--r--runtime/js/99_main.js25
16 files changed, 114 insertions, 103 deletions
diff --git a/runtime/js/10_permissions.js b/runtime/js/10_permissions.js
index 4bf9db752..af66c9d2e 100644
--- a/runtime/js/10_permissions.js
+++ b/runtime/js/10_permissions.js
@@ -5,7 +5,7 @@
const {
Event,
EventTarget,
- Deno: { core },
+ Deno: { core: { ops } },
__bootstrap: { webUtil: { illegalConstructorKey } },
} = window;
const { pathFromURL } = window.__bootstrap.util;
@@ -48,7 +48,7 @@
* @returns {Deno.PermissionState}
*/
function opQuery(desc) {
- return core.opSync("op_query_permission", desc);
+ return ops.op_query_permission(desc);
}
/**
@@ -56,7 +56,7 @@
* @returns {Deno.PermissionState}
*/
function opRevoke(desc) {
- return core.opSync("op_revoke_permission", desc);
+ return ops.op_revoke_permission(desc);
}
/**
@@ -64,7 +64,7 @@
* @returns {Deno.PermissionState}
*/
function opRequest(desc) {
- return core.opSync("op_request_permission", desc);
+ return ops.op_request_permission(desc);
}
class PermissionStatus extends EventTarget {
diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js
index 948542d1c..5e3253dff 100644
--- a/runtime/js/11_workers.js
+++ b/runtime/js/11_workers.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const {
Error,
ObjectPrototypeIsPrototypeOf,
@@ -31,7 +32,7 @@
name,
workerType,
) {
- return core.opSync("op_create_worker", {
+ return ops.op_create_worker({
hasSourceCode,
name,
permissions: serializePermissions(permissions),
@@ -42,11 +43,11 @@
}
function hostTerminateWorker(id) {
- core.opSync("op_host_terminate_worker", id);
+ ops.op_host_terminate_worker(id);
}
function hostPostMessage(id, data) {
- core.opSync("op_host_post_message", id, data);
+ ops.op_host_post_message(id, data);
}
function hostRecvCtrl(id) {
diff --git a/runtime/js/12_io.js b/runtime/js/12_io.js
index ab0839ec6..e41657d96 100644
--- a/runtime/js/12_io.js
+++ b/runtime/js/12_io.js
@@ -7,6 +7,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const {
Uint8Array,
ArrayPrototypePush,
@@ -91,7 +92,7 @@
return 0;
}
- const nread = core.opSync("op_read_sync", rid, buffer);
+ const nread = ops.op_read_sync(rid, buffer);
return nread === 0 ? null : nread;
}
@@ -107,7 +108,7 @@
}
function writeSync(rid, data) {
- return core.opSync("op_write_sync", rid, data);
+ return ops.op_write_sync(rid, data);
}
function write(rid, data) {
diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js
index 51f2c411e..2457713e6 100644
--- a/runtime/js/30_fs.js
+++ b/runtime/js/30_fs.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const {
Date,
DatePrototype,
@@ -15,7 +16,7 @@
const build = window.__bootstrap.build.build;
function chmodSync(path, mode) {
- core.opSync("op_chmod_sync", { path: pathFromURL(path), mode });
+ ops.op_chmod_sync({ path: pathFromURL(path), mode });
}
async function chmod(path, mode) {
@@ -27,7 +28,7 @@
uid,
gid,
) {
- core.opSync("op_chown_sync", { path: pathFromURL(path), uid, gid });
+ ops.op_chown_sync({ path: pathFromURL(path), uid, gid });
}
async function chown(
@@ -45,7 +46,7 @@
fromPath,
toPath,
) {
- core.opSync("op_copy_file_sync", {
+ ops.op_copy_file_sync({
from: pathFromURL(fromPath),
to: pathFromURL(toPath),
});
@@ -62,15 +63,15 @@
}
function cwd() {
- return core.opSync("op_cwd");
+ return ops.op_cwd();
}
function chdir(directory) {
- core.opSync("op_chdir", pathFromURL(directory));
+ ops.op_chdir(pathFromURL(directory));
}
function makeTempDirSync(options = {}) {
- return core.opSync("op_make_temp_dir_sync", options);
+ return ops.op_make_temp_dir_sync(options);
}
function makeTempDir(options = {}) {
@@ -78,7 +79,7 @@
}
function makeTempFileSync(options = {}) {
- return core.opSync("op_make_temp_file_sync", options);
+ return ops.op_make_temp_file_sync(options);
}
function makeTempFile(options = {}) {
@@ -99,7 +100,7 @@
}
function mkdirSync(path, options) {
- core.opSync("op_mkdir_sync", mkdirArgs(path, options));
+ ops.op_mkdir_sync(mkdirArgs(path, options));
}
async function mkdir(
@@ -110,7 +111,7 @@
}
function readDirSync(path) {
- return core.opSync("op_read_dir_sync", pathFromURL(path))[
+ return ops.op_read_dir_sync(pathFromURL(path))[
SymbolIterator
]();
}
@@ -128,7 +129,7 @@
}
function readLinkSync(path) {
- return core.opSync("op_read_link_sync", pathFromURL(path));
+ return ops.op_read_link_sync(pathFromURL(path));
}
function readLink(path) {
@@ -136,7 +137,7 @@
}
function realPathSync(path) {
- return core.opSync("op_realpath_sync", pathFromURL(path));
+ return ops.op_realpath_sync(pathFromURL(path));
}
function realPath(path) {
@@ -147,7 +148,7 @@
path,
options = {},
) {
- core.opSync("op_remove_sync", {
+ ops.op_remove_sync({
path: pathFromURL(path),
recursive: !!options.recursive,
});
@@ -164,7 +165,7 @@
}
function renameSync(oldpath, newpath) {
- core.opSync("op_rename_sync", {
+ ops.op_rename_sync({
oldpath: pathFromURL(oldpath),
newpath: pathFromURL(newpath),
});
@@ -203,7 +204,7 @@
}
function fstatSync(rid) {
- return parseFileInfo(core.opSync("op_fstat_sync", rid));
+ return parseFileInfo(ops.op_fstat_sync(rid));
}
async function fstat(rid) {
@@ -219,7 +220,7 @@
}
function lstatSync(path) {
- const res = core.opSync("op_stat_sync", {
+ const res = ops.op_stat_sync({
path: pathFromURL(path),
lstat: true,
});
@@ -235,7 +236,7 @@
}
function statSync(path) {
- const res = core.opSync("op_stat_sync", {
+ const res = ops.op_stat_sync({
path: pathFromURL(path),
lstat: false,
});
@@ -251,7 +252,7 @@
}
function ftruncateSync(rid, len) {
- core.opSync("op_ftruncate_sync", { rid, len: coerceLen(len) });
+ ops.op_ftruncate_sync({ rid, len: coerceLen(len) });
}
async function ftruncate(rid, len) {
@@ -259,7 +260,7 @@
}
function truncateSync(path, len) {
- core.opSync("op_truncate_sync", { path, len: coerceLen(len) });
+ ops.op_truncate_sync({ path, len: coerceLen(len) });
}
async function truncate(path, len) {
@@ -267,11 +268,11 @@
}
function umask(mask) {
- return core.opSync("op_umask", mask);
+ return ops.op_umask(mask);
}
function linkSync(oldpath, newpath) {
- core.opSync("op_link_sync", { oldpath, newpath });
+ ops.op_link_sync({ oldpath, newpath });
}
async function link(oldpath, newpath) {
@@ -304,7 +305,7 @@
atime,
mtime,
) {
- core.opSync("op_futime_sync", {
+ ops.op_futime_sync({
rid,
atime: toUnixTimeFromEpoch(atime),
mtime: toUnixTimeFromEpoch(mtime),
@@ -328,7 +329,7 @@
atime,
mtime,
) {
- core.opSync("op_utime_sync", {
+ ops.op_utime_sync({
path: pathFromURL(path),
atime: toUnixTimeFromEpoch(atime),
mtime: toUnixTimeFromEpoch(mtime),
@@ -352,7 +353,7 @@
newpath,
options,
) {
- core.opSync("op_symlink_sync", {
+ ops.op_symlink_sync({
oldpath: pathFromURL(oldpath),
newpath: pathFromURL(newpath),
options,
@@ -372,7 +373,7 @@
}
function fdatasyncSync(rid) {
- core.opSync("op_fdatasync_sync", rid);
+ ops.op_fdatasync_sync(rid);
}
async function fdatasync(rid) {
@@ -380,7 +381,7 @@
}
function fsyncSync(rid) {
- core.opSync("op_fsync_sync", rid);
+ ops.op_fsync_sync(rid);
}
async function fsync(rid) {
@@ -388,7 +389,7 @@
}
function flockSync(rid, exclusive) {
- core.opSync("op_flock_sync", rid, exclusive === true);
+ ops.op_flock_sync(rid, exclusive === true);
}
async function flock(rid, exclusive) {
@@ -396,7 +397,7 @@
}
function funlockSync(rid) {
- core.opSync("op_funlock_sync", rid);
+ ops.op_funlock_sync(rid);
}
async function funlock(rid) {
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js
index f9df42305..c3addd043 100644
--- a/runtime/js/30_os.js
+++ b/runtime/js/30_os.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const {
Error,
SymbolFor,
@@ -11,31 +12,31 @@
const windowDispatchEvent = window.dispatchEvent.bind(window);
function loadavg() {
- return core.opSync("op_loadavg");
+ return ops.op_loadavg();
}
function hostname() {
- return core.opSync("op_hostname");
+ return ops.op_hostname();
}
function osRelease() {
- return core.opSync("op_os_release");
+ return ops.op_os_release();
}
function systemMemoryInfo() {
- return core.opSync("op_system_memory_info");
+ return ops.op_system_memory_info();
}
function networkInterfaces() {
- return core.opSync("op_network_interfaces");
+ return ops.op_network_interfaces();
}
function getGid() {
- return core.opSync("op_getgid");
+ return ops.op_getgid();
}
function getUid() {
- return core.opSync("op_getuid");
+ return ops.op_getuid();
}
// This is an internal only method used by the test harness to override the
@@ -48,7 +49,7 @@
function exit(code) {
// Set exit code first so unload event listeners can override it.
if (typeof code === "number") {
- core.opSync("op_set_exit_code", code);
+ ops.op_set_exit_code(code);
} else {
code = 0;
}
@@ -65,33 +66,33 @@
return;
}
- core.opSync("op_exit");
+ ops.op_exit();
throw new Error("Code not reachable");
}
function setEnv(key, value) {
- core.opSync("op_set_env", key, value);
+ ops.op_set_env(key, value);
}
function getEnv(key) {
- return core.opSync("op_get_env", key) ?? undefined;
+ return ops.op_get_env(key) ?? undefined;
}
function deleteEnv(key) {
- core.opSync("op_delete_env", key);
+ ops.op_delete_env(key);
}
const env = {
get: getEnv,
toObject() {
- return core.opSync("op_env");
+ return ops.op_env();
},
set: setEnv,
delete: deleteEnv,
};
function execPath() {
- return core.opSync("op_exec_path");
+ return ops.op_exec_path();
}
window.__bootstrap.os = {
diff --git a/runtime/js/40_files.js b/runtime/js/40_files.js
index d2148be2f..12e406aba 100644
--- a/runtime/js/40_files.js
+++ b/runtime/js/40_files.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const { read, readSync, write, writeSync } = window.__bootstrap.io;
const { ftruncate, ftruncateSync, fstat, fstatSync } = window.__bootstrap.fs;
const { pathFromURL } = window.__bootstrap.util;
@@ -19,7 +20,7 @@
offset,
whence,
) {
- return core.opSync("op_seek_sync", { rid, offset, whence });
+ return ops.op_seek_sync({ rid, offset, whence });
}
function seek(
@@ -36,8 +37,7 @@
) {
checkOpenOptions(options);
const mode = options?.mode;
- const rid = core.opSync(
- "op_open_sync",
+ const rid = ops.op_open_sync(
{ path: pathFromURL(path), options, mode },
);
diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js
index 939d3ac7b..8027c27eb 100644
--- a/runtime/js/40_fs_events.js
+++ b/runtime/js/40_fs_events.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const { BadResourcePrototype, InterruptedPrototype } = core;
const {
ArrayIsArray,
@@ -15,7 +16,7 @@
constructor(paths, options) {
const { recursive } = options;
- this.#rid = core.opSync("op_fs_events_open", { recursive, paths });
+ this.#rid = ops.op_fs_events_open({ recursive, paths });
}
get rid() {
diff --git a/runtime/js/40_http.js b/runtime/js/40_http.js
index 4a8743438..36d810374 100644
--- a/runtime/js/40_http.js
+++ b/runtime/js/40_http.js
@@ -3,10 +3,11 @@
((window) => {
const core = window.__bootstrap.core;
+ const ops = core.ops;
const { HttpConn } = window.__bootstrap.http;
function serveHttp(conn) {
- const rid = core.opSync("op_http_start", conn.rid);
+ const rid = ops.op_http_start(conn.rid);
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
}
diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js
index 7a5284404..e3f6fc7a0 100644
--- a/runtime/js/40_process.js
+++ b/runtime/js/40_process.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const { FsFile } = window.__bootstrap.files;
const { readAll } = window.__bootstrap.io;
const { pathFromURL } = window.__bootstrap.util;
@@ -16,7 +17,7 @@
} = window.__bootstrap.primordials;
function opKill(pid, signo) {
- core.opSync("op_kill", pid, signo);
+ ops.op_kill(pid, signo);
}
function opRunStatus(rid) {
@@ -25,7 +26,7 @@
function opRun(request) {
assert(request.cmd.length > 0);
- return core.opSync("op_run", request);
+ return ops.op_run(request);
}
async function runStatus(rid) {
diff --git a/runtime/js/40_read_file.js b/runtime/js/40_read_file.js
index 8a52e4f70..fd656c1cb 100644
--- a/runtime/js/40_read_file.js
+++ b/runtime/js/40_read_file.js
@@ -3,11 +3,12 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const { pathFromURL } = window.__bootstrap.util;
const { abortSignal } = window.__bootstrap;
function readFileSync(path) {
- return core.opSync("op_readfile_sync", pathFromURL(path));
+ return ops.op_readfile_sync(pathFromURL(path));
}
async function readFile(path, options) {
@@ -15,7 +16,7 @@
let abortHandler;
if (options?.signal) {
options.signal.throwIfAborted();
- cancelRid = core.opSync("op_cancel_handle");
+ cancelRid = ops.op_cancel_handle();
abortHandler = () => core.tryClose(cancelRid);
options.signal[abortSignal.add](abortHandler);
}
@@ -38,7 +39,7 @@
}
function readTextFileSync(path) {
- return core.opSync("op_readfile_text_sync", pathFromURL(path));
+ return ops.op_readfile_text_sync(pathFromURL(path));
}
async function readTextFile(path, options) {
@@ -46,7 +47,7 @@
let abortHandler;
if (options?.signal) {
options.signal.throwIfAborted();
- cancelRid = core.opSync("op_cancel_handle");
+ cancelRid = ops.op_cancel_handle();
abortHandler = () => core.tryClose(cancelRid);
options.signal[abortSignal.add](abortHandler);
}
diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js
index d387b068f..94171628f 100644
--- a/runtime/js/40_signals.js
+++ b/runtime/js/40_signals.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const {
Set,
SymbolFor,
@@ -10,7 +11,7 @@
} = window.__bootstrap.primordials;
function bindSignal(signo) {
- return core.opSync("op_signal_bind", signo);
+ return ops.op_signal_bind(signo);
}
function pollSignal(rid) {
@@ -20,7 +21,7 @@
}
function unbindSignal(rid) {
- core.opSync("op_signal_unbind", rid);
+ ops.op_signal_unbind(rid);
}
// Stores signal listeners and resource data. This has type of
diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js
index 87db84f4b..4fae9e6b7 100644
--- a/runtime/js/40_spawn.js
+++ b/runtime/js/40_spawn.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const { pathFromURL } = window.__bootstrap.util;
const { illegalConstructorKey } = window.__bootstrap.webUtil;
const { add, remove } = window.__bootstrap.abortSignal;
@@ -32,7 +33,7 @@
stderr = "piped",
signal = undefined,
} = {}) {
- const child = core.opSync("op_spawn_child", {
+ const child = ops.op_spawn_child({
cmd: pathFromURL(command),
args: ArrayPrototypeMap(args, String),
cwd: pathFromURL(cwd),
@@ -203,7 +204,7 @@
if (this.#rid === null) {
throw new TypeError("Child process has already terminated.");
}
- core.opSync("op_kill", this.#pid, signo);
+ ops.op_kill(this.#pid, signo);
}
ref() {
@@ -246,7 +247,7 @@
"Piped stdin is not supported for this function, use 'Deno.spawnChild()' instead",
);
}
- const result = core.opSync("op_spawn_sync", {
+ const result = ops.op_spawn_sync({
cmd: pathFromURL(command),
args: ArrayPrototypeMap(args, String),
cwd: pathFromURL(cwd),
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js
index fabdb8dc4..276fef6a6 100644
--- a/runtime/js/40_testing.js
+++ b/runtime/js/40_testing.js
@@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
const { setExitHandler } = window.__bootstrap.os;
const { Console } = window.__bootstrap.console;
const { serializePermissions } = window.__bootstrap.permissions;
@@ -510,14 +511,13 @@
}
function pledgePermissions(permissions) {
- return core.opSync(
- "op_pledge_test_permissions",
+ return ops.op_pledge_test_permissions(
serializePermissions(permissions),
);
}
function restorePermissions(token) {
- core.opSync("op_restore_test_permissions", token);
+ ops.op_restore_test_permissions(token);
}
function withPermissions(fn, permissions) {
@@ -709,7 +709,7 @@
columnNumber: jsError.frames[1].columnNumber,
};
- const { id, filteredOut } = core.opSync("op_register_test", testDesc);
+ const { id, filteredOut } = ops.op_register_test(testDesc);
testDesc.id = id;
testDesc.filteredOut = filteredOut;
@@ -731,7 +731,7 @@
return;
}
- core.opSync("op_bench_check_unstable");
+ ops.op_bench_check_unstable();
let benchDesc;
const defaults = {
ignore: false,
@@ -815,7 +815,7 @@
const AsyncFunction = (async () => {}).constructor;
benchDesc.async = AsyncFunction === benchDesc.fn.constructor;
- const { id, filteredOut } = core.opSync("op_register_bench", benchDesc);
+ const { id, filteredOut } = ops.op_register_bench(benchDesc);
benchDesc.id = id;
benchDesc.filteredOut = filteredOut;
@@ -1016,20 +1016,20 @@
function getTestOrigin() {
if (origin == null) {
- origin = core.opSync("op_get_test_origin");
+ origin = ops.op_get_test_origin();
}
return origin;
}
function getBenchOrigin() {
if (origin == null) {
- origin = core.opSync("op_get_bench_origin");
+ origin = ops.op_get_bench_origin();
}
return origin;
}
function benchNow() {
- return core.opSync("op_bench_now");
+ return ops.op_bench_now();
}
// This function is called by Rust side if we're in `deno test` or
@@ -1051,7 +1051,7 @@
(desc) => !desc.filteredOut,
);
- core.opSync("op_dispatch_test_event", {
+ ops.op_dispatch_test_event({
plan: {
origin,
total: filtered.length,
@@ -1079,11 +1079,11 @@
}
for (const desc of filtered) {
- core.opSync("op_dispatch_test_event", { wait: desc.id });
+ ops.op_dispatch_test_event({ wait: desc.id });
const earlier = DateNow();
const result = await runTest(desc);
const elapsed = DateNow() - earlier;
- core.opSync("op_dispatch_test_event", {
+ ops.op_dispatch_test_event({
result: [desc.id, result, elapsed],
});
}
@@ -1096,7 +1096,7 @@
const originalConsole = globalThis.console;
globalThis.console = new Console((s) => {
- core.opSync("op_dispatch_bench_event", { output: s });
+ ops.op_dispatch_bench_event({ output: s });
});
const only = ArrayPrototypeFilter(benchDescs, (bench) => bench.only);
@@ -1120,7 +1120,7 @@
(a, b) => groups.indexOf(a.group) - groups.indexOf(b.group),
);
- core.opSync("op_dispatch_bench_event", {
+ ops.op_dispatch_bench_event({
plan: {
origin,
total: filtered.length,
@@ -1131,8 +1131,8 @@
for (const desc of filtered) {
desc.baseline = !!desc.baseline;
- core.opSync("op_dispatch_bench_event", { wait: desc.id });
- core.opSync("op_dispatch_bench_event", {
+ ops.op_dispatch_bench_event({ wait: desc.id });
+ ops.op_dispatch_bench_event({
result: [desc.id, await runBench(desc)],
});
}
@@ -1173,7 +1173,7 @@
if (state.reportedWait) {
return;
}
- core.opSync("op_dispatch_test_event", { stepWait: desc.id });
+ ops.op_dispatch_test_event({ stepWait: desc.id });
state.reportedWait = true;
}
@@ -1194,7 +1194,7 @@
} else {
result = state.status;
}
- core.opSync("op_dispatch_test_event", {
+ ops.op_dispatch_test_event({
stepResult: [desc.id, result, state.elapsed],
});
state.reportedResult = true;
@@ -1293,7 +1293,7 @@
stepDesc.parent = desc;
stepDesc.rootId = rootId;
stepDesc.rootName = rootName;
- const { id } = core.opSync("op_register_test_step", stepDesc);
+ const { id } = ops.op_register_test_step(stepDesc);
stepDesc.id = id;
const state = {
context: createTestContext(stepDesc),
diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js
index 1abed5f25..9cf351cc0 100644
--- a/runtime/js/40_tty.js
+++ b/runtime/js/40_tty.js
@@ -3,13 +3,14 @@
((window) => {
const core = window.Deno.core;
+ const ops = core.ops;
function consoleSize(rid) {
- return core.opSync("op_console_size", rid);
+ return ops.op_console_size(rid);
}
function isatty(rid) {
- return core.opSync("op_isatty", rid);
+ return ops.op_isatty(rid);
}
const DEFAULT_SET_RAW_OPTIONS = {
@@ -18,7 +19,7 @@
function setRaw(rid, mode, options = {}) {
const rOptions = { ...DEFAULT_SET_RAW_OPTIONS, ...options };
- core.opSync("op_set_raw", { rid, mode, options: rOptions });
+ ops.op_set_raw({ rid, mode, options: rOptions });
}
window.__bootstrap.tty = {
diff --git a/runtime/js/40_write_file.js b/runtime/js/40_write_file.js
index 462d71266..893b8b2c3 100644
--- a/runtime/js/40_write_file.js
+++ b/runtime/js/40_write_file.js
@@ -2,6 +2,7 @@
"use strict";
((window) => {
const core = window.__bootstrap.core;
+ const ops = core.ops;
const { abortSignal } = window.__bootstrap;
const { pathFromURL } = window.__bootstrap.util;
@@ -11,7 +12,7 @@
options = {},
) {
options.signal?.throwIfAborted();
- core.opSync("op_write_file_sync", {
+ ops.op_write_file_sync({
path: pathFromURL(path),
data,
mode: options.mode,
@@ -29,7 +30,7 @@
let abortHandler;
if (options.signal) {
options.signal.throwIfAborted();
- cancelRid = core.opSync("op_cancel_handle");
+ cancelRid = ops.op_cancel_handle();
abortHandler = () => core.tryClose(cancelRid);
options.signal[abortSignal.add](abortHandler);
}
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index b397fcb47..cbc5c1b5b 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -10,6 +10,7 @@ delete Intl.v8BreakIterator;
((window) => {
const core = Deno.core;
+ const ops = core.ops;
const {
ArrayPrototypeIndexOf,
ArrayPrototypePush,
@@ -103,7 +104,7 @@ delete Intl.v8BreakIterator;
}
isClosing = true;
- core.opSync("op_worker_close");
+ ops.op_worker_close();
}
function postMessage(message, transferOrOptions = {}) {
@@ -133,7 +134,7 @@ delete Intl.v8BreakIterator;
}
const { transfer } = options;
const data = serializeJsMessageData(message, transfer);
- core.opSync("op_worker_post_message", data);
+ ops.op_worker_post_message(data);
}
let isClosing = false;
@@ -184,7 +185,7 @@ delete Intl.v8BreakIterator;
let loadedMainWorkerScript = false;
function importScripts(...urls) {
- if (core.opSync("op_worker_get_type") === "module") {
+ if (ops.op_worker_get_type() === "module") {
throw new TypeError("Can't import scripts in a module worker.");
}
@@ -204,8 +205,7 @@ delete Intl.v8BreakIterator;
// imported scripts, so we use `loadedMainWorkerScript` to distinguish them.
// TODO(andreubotella) Refactor worker creation so the main script isn't
// loaded with `importScripts()`.
- const scripts = core.opSync(
- "op_worker_sync_fetch",
+ const scripts = ops.op_worker_sync_fetch(
parsedUrls,
!loadedMainWorkerScript,
);
@@ -220,7 +220,7 @@ delete Intl.v8BreakIterator;
}
function opMainModule() {
- return core.opSync("op_main_module");
+ return ops.op_main_module();
}
function formatException(error) {
@@ -243,7 +243,7 @@ delete Intl.v8BreakIterator;
core.setMacrotaskCallback(timers.handleTimerMacrotask);
core.setMacrotaskCallback(promiseRejectMacrotaskCallback);
core.setWasmStreamingCallback(fetch.handleWasmStreaming);
- core.opSync("op_set_format_exception_callback", formatException);
+ ops.op_set_format_exception_callback(formatException);
version.setVersions(
runtimeOptions.denoVersion,
runtimeOptions.v8Version,
@@ -569,13 +569,13 @@ delete Intl.v8BreakIterator;
function promiseRejectCallback(type, promise, reason) {
switch (type) {
case 0: {
- core.opSync("op_store_pending_promise_exception", promise, reason);
+ ops.op_store_pending_promise_exception(promise, reason);
ArrayPrototypePush(pendingRejections, promise);
WeakMapPrototypeSet(pendingRejectionsReasons, promise, reason);
break;
}
case 1: {
- core.opSync("op_remove_pending_promise_exception", promise);
+ ops.op_remove_pending_promise_exception(promise);
const index = ArrayPrototypeIndexOf(pendingRejections, promise);
if (index > -1) {
ArrayPrototypeSplice(pendingRejections, index, 1);
@@ -594,8 +594,7 @@ delete Intl.v8BreakIterator;
function promiseRejectMacrotaskCallback() {
while (pendingRejections.length > 0) {
const promise = ArrayPrototypeShift(pendingRejections);
- const hasPendingException = core.opSync(
- "op_has_pending_promise_exception",
+ const hasPendingException = ops.op_has_pending_promise_exception(
promise,
);
const reason = WeakMapPrototypeGet(pendingRejectionsReasons, promise);
@@ -613,7 +612,7 @@ delete Intl.v8BreakIterator;
const errorEventCb = (event) => {
if (event.error === reason) {
- core.opSync("op_remove_pending_promise_exception", promise);
+ ops.op_remove_pending_promise_exception(promise);
}
};
// Add a callback for "error" event - it will be dispatched
@@ -626,7 +625,7 @@ delete Intl.v8BreakIterator;
// If event was not prevented (or "unhandledrejection" listeners didn't
// throw) we will let Rust side handle it.
if (event.defaultPrevented) {
- core.opSync("op_remove_pending_promise_exception", promise);
+ ops.op_remove_pending_promise_exception(promise);
}
}
return true;