summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/js/10_permissions.js9
-rw-r--r--runtime/js/12_io.js5
-rw-r--r--runtime/js/30_fs.js3
-rw-r--r--runtime/js/40_process.js6
-rw-r--r--runtime/js/40_signals.js6
-rw-r--r--runtime/js/40_spawn.js6
-rw-r--r--runtime/js/99_main.js6
7 files changed, 30 insertions, 11 deletions
diff --git a/runtime/js/10_permissions.js b/runtime/js/10_permissions.js
index f048a5d62..cf2fdde7d 100644
--- a/runtime/js/10_permissions.js
+++ b/runtime/js/10_permissions.js
@@ -20,6 +20,7 @@
PromiseResolve,
PromiseReject,
ReflectHas,
+ SafeArrayIterator,
SymbolFor,
TypeError,
} = window.__bootstrap.primordials;
@@ -233,7 +234,9 @@
function serializePermissions(permissions) {
if (typeof permissions == "object" && permissions != null) {
const serializedPermissions = {};
- for (const key of ["read", "write", "run", "ffi"]) {
+ for (
+ const key of new SafeArrayIterator(["read", "write", "run", "ffi"])
+ ) {
if (ArrayIsArray(permissions[key])) {
serializedPermissions[key] = ArrayPrototypeMap(
permissions[key],
@@ -243,7 +246,9 @@
serializedPermissions[key] = permissions[key];
}
}
- for (const key of ["env", "hrtime", "net", "sys"]) {
+ for (
+ const key of new SafeArrayIterator(["env", "hrtime", "net", "sys"])
+ ) {
if (ArrayIsArray(permissions[key])) {
serializedPermissions[key] = ArrayPrototypeSlice(permissions[key]);
} else {
diff --git a/runtime/js/12_io.js b/runtime/js/12_io.js
index db83343bf..c8fc002fc 100644
--- a/runtime/js/12_io.js
+++ b/runtime/js/12_io.js
@@ -12,6 +12,7 @@
Uint8Array,
ArrayPrototypePush,
MathMin,
+ SafeArrayIterator,
TypedArrayPrototypeSubarray,
TypedArrayPrototypeSet,
} = window.__bootstrap.primordials;
@@ -156,14 +157,14 @@
function concatBuffers(buffers) {
let totalLen = 0;
- for (const buf of buffers) {
+ for (const buf of new SafeArrayIterator(buffers)) {
totalLen += buf.byteLength;
}
const contents = new Uint8Array(totalLen);
let n = 0;
- for (const buf of buffers) {
+ for (const buf of new SafeArrayIterator(buffers)) {
TypedArrayPrototypeSet(contents, buf, n);
n += buf.byteLength;
}
diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js
index 4a78ebcad..242e480b3 100644
--- a/runtime/js/30_fs.js
+++ b/runtime/js/30_fs.js
@@ -9,6 +9,7 @@
DatePrototype,
MathTrunc,
ObjectPrototypeIsPrototypeOf,
+ SafeArrayIterator,
SymbolAsyncIterator,
SymbolIterator,
Function,
@@ -211,7 +212,7 @@
let offset = 0;
let str =
'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {';
- for (let [name, type] of ObjectEntries(types)) {
+ for (let [name, type] of new SafeArrayIterator(ObjectEntries(types))) {
const optional = type.startsWith("?");
if (optional) type = type.slice(1);
diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js
index 51cae9e66..f837b2b4c 100644
--- a/runtime/js/40_process.js
+++ b/runtime/js/40_process.js
@@ -13,6 +13,7 @@
ArrayPrototypeSlice,
TypeError,
ObjectEntries,
+ SafeArrayIterator,
String,
} = window.__bootstrap.primordials;
@@ -111,7 +112,10 @@
stdin = "inherit",
}) {
if (cmd[0] != null) {
- cmd = [pathFromURL(cmd[0]), ...ArrayPrototypeSlice(cmd, 1)];
+ cmd = [
+ pathFromURL(cmd[0]),
+ ...new SafeArrayIterator(ArrayPrototypeSlice(cmd, 1)),
+ ];
}
const res = opRun({
cmd: ArrayPrototypeMap(cmd, String),
diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js
index 94171628f..71ead71c7 100644
--- a/runtime/js/40_signals.js
+++ b/runtime/js/40_signals.js
@@ -5,7 +5,9 @@
const core = window.Deno.core;
const ops = core.ops;
const {
+ SafeSetIterator,
Set,
+ SetPrototypeDelete,
SymbolFor,
TypeError,
} = window.__bootstrap.primordials;
@@ -60,7 +62,7 @@
checkSignalListenerType(listener);
const sigData = getSignalData(signo);
- sigData.listeners.delete(listener);
+ SetPrototypeDelete(sigData.listeners, listener);
if (sigData.listeners.size === 0 && sigData.rid) {
unbindSignal(sigData.rid);
@@ -73,7 +75,7 @@
if (await pollSignal(sigData.rid)) {
return;
}
- for (const listener of sigData.listeners) {
+ for (const listener of new SafeSetIterator(sigData.listeners)) {
listener();
}
}
diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js
index 0f26313a6..9d4aa3e9f 100644
--- a/runtime/js/40_spawn.js
+++ b/runtime/js/40_spawn.js
@@ -10,6 +10,7 @@
const {
ArrayPrototypeMap,
ObjectEntries,
+ ObjectPrototypeIsPrototypeOf,
String,
TypeError,
PromisePrototypeThen,
@@ -21,6 +22,7 @@
readableStreamForRidUnrefable,
readableStreamForRidUnrefableRef,
readableStreamForRidUnrefableUnref,
+ ReadableStreamPrototype,
writableStreamForRid,
} = window.__bootstrap.streams;
@@ -65,7 +67,9 @@
}
function collectOutput(readableStream) {
- if (!(readableStream instanceof ReadableStream)) {
+ if (
+ !(ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, readableStream))
+ ) {
return null;
}
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index 1eb71339f..901cb136f 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -19,6 +19,7 @@ delete Intl.v8BreakIterator;
ArrayPrototypeMap,
DateNow,
Error,
+ ErrorPrototype,
FunctionPrototypeCall,
FunctionPrototypeBind,
ObjectAssign,
@@ -32,6 +33,7 @@ delete Intl.v8BreakIterator;
SymbolFor,
SymbolIterator,
PromisePrototypeThen,
+ SafeArrayIterator,
SafeWeakMap,
TypeError,
WeakMapPrototypeDelete,
@@ -204,7 +206,7 @@ delete Intl.v8BreakIterator;
);
loadedMainWorkerScript = true;
- for (const { url, script } of scripts) {
+ for (const { url, script } of new SafeArrayIterator(scripts)) {
const err = core.evalContext(script, url)[1];
if (err !== null) {
throw err.thrown;
@@ -217,7 +219,7 @@ delete Intl.v8BreakIterator;
}
function formatException(error) {
- if (error instanceof Error) {
+ if (ObjectPrototypeIsPrototypeOf(ErrorPrototype, error)) {
return null;
} else if (typeof error == "string") {
return `Uncaught ${