diff --git a/ext/broadcast_channel/01_broadcast_channel.js b/ext/broadcast_channel/01_broadcast_channel.js index 11b65b9b5b..cf3b17ac59 100644 --- a/ext/broadcast_channel/01_broadcast_channel.js +++ b/ext/broadcast_channel/01_broadcast_channel.js @@ -16,7 +16,6 @@ ArrayPrototypeIndexOf, ArrayPrototypeSplice, ArrayPrototypePush, - SafeArrayIterator, Symbol, Uint8Array, } = window.__bootstrap.primordials; @@ -44,7 +43,9 @@ } function dispatch(source, name, data) { - for (const channel of new SafeArrayIterator(channels)) { + for (let i = 0; i < channels.length; ++i) { + const channel = channels[i]; + if (channel === source) continue; // Don't self-send. if (channel[_name] !== name) continue; if (channel[_closed]) continue; diff --git a/ext/cache/01_cache.js b/ext/cache/01_cache.js index 60ed1eb753..ab44c11b5f 100644 --- a/ext/cache/01_cache.js +++ b/ext/cache/01_cache.js @@ -6,7 +6,6 @@ const webidl = window.__bootstrap.webidl; const { Symbol, - SafeArrayIterator, TypeError, ObjectPrototypeIsPrototypeOf, } = window.__bootstrap.primordials; @@ -115,7 +114,8 @@ const varyHeader = getHeader(innerResponse.headerList, "vary"); if (varyHeader) { const fieldValues = varyHeader.split(","); - for (const field of new SafeArrayIterator(fieldValues)) { + for (let i = 0; i < fieldValues.length; ++i) { + const field = fieldValues[i]; if (field.trim() === "*") { throw new TypeError("Vary header must not contain '*'"); } diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 2e54cd1377..e5fe3416a3 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -277,7 +277,8 @@ }` + `${tableChars.rightMiddle}\n`; - for (const row of new SafeArrayIterator(rows)) { + for (let i = 0; i < rows.length; ++i) { + const row = rows[i]; result += `${renderRow(row, columnWidths, columnRightAlign)}\n`; } @@ -995,7 +996,8 @@ } const refMap = new Map(); - for (const cause of new SafeArrayIterator(causes)) { + for (let i = 0; i < causes.length; ++i) { + const cause = causes[i]; if (circular !== undefined) { const index = MapPrototypeGet(circular, cause); if (index !== undefined) { @@ -1172,7 +1174,8 @@ inspectOptions.indentLevel++; - for (const key of new SafeArrayIterator(stringKeys)) { + for (let i = 0; i < stringKeys.length; ++i) { + const key = stringKeys[i]; if (inspectOptions.getters) { let propertyValue; let error = null; @@ -1208,7 +1211,8 @@ } } - for (const key of new SafeArrayIterator(symbolKeys)) { + for (let i = 0; i < symbolKeys.length; ++i) { + const key = symbolKeys[i]; if ( !inspectOptions.showHidden && !propertyIsEnumerable(value, key) @@ -1640,7 +1644,8 @@ currentPart = ""; } - for (const [key, value] of new SafeArrayIterator(rawEntries)) { + for (let i = 0; i < rawEntries.length; ++i) { + const [key, value] = rawEntries[i]; if (key == "background-color") { if (value != null) { css.backgroundColor = value; @@ -1661,11 +1666,9 @@ } } else if (key == "text-decoration-line") { css.textDecorationLine = []; - for ( - const lineType of new SafeArrayIterator( - StringPrototypeSplit(value, /\s+/g), - ) - ) { + const lineTypes = StringPrototypeSplit(value, /\s+/g); + for (let i = 0; i < lineTypes.length; ++i) { + const lineType = lineTypes[i]; if ( ArrayPrototypeIncludes( ["line-through", "overline", "underline"], @@ -1683,11 +1686,9 @@ } else if (key == "text-decoration") { css.textDecorationColor = null; css.textDecorationLine = []; - for ( - const arg of new SafeArrayIterator( - StringPrototypeSplit(value, /\s+/g), - ) - ) { + const args = StringPrototypeSplit(value, /\s+/g); + for (let i = 0; i < args.length; ++i) { + const arg = args[i]; const maybeColor = parseCssColor(arg); if (maybeColor != null) { css.textDecorationColor = maybeColor; @@ -2144,7 +2145,8 @@ } else { const valueObj = value || {}; const keys = properties || ObjectKeys(valueObj); - for (const k of new SafeArrayIterator(keys)) { + for (let i = 0; i < keys.length; ++i) { + const k = keys[i]; if (!primitive && ReflectHas(valueObj, k)) { if (!(ReflectHas(objectValues, k))) { objectValues[k] = ArrayPrototypeFill(new Array(numRows), ""); @@ -2339,7 +2341,9 @@ function wrapConsole(consoleFromDeno, consoleFromV8) { const callConsole = core.callConsole; - for (const key of new SafeArrayIterator(ObjectKeys(consoleFromV8))) { + const keys = ObjectKeys(consoleFromV8); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; if (ObjectPrototypeHasOwnProperty(consoleFromDeno, key)) { consoleFromDeno[key] = FunctionPrototypeBind( callConsole, diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index a2fae2cfeb..54e635522a 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -68,7 +68,8 @@ */ function fillHeaders(headers, object) { if (ArrayIsArray(object)) { - for (const header of new SafeArrayIterator(object)) { + for (let i = 0; i < object.length; ++i) { + const header = object[i]; if (header.length !== 2) { throw new TypeError( `Invalid header. Length must be 2, but is ${header.length}`, @@ -205,7 +206,8 @@ // spec but produce the same result. const headers = {}; const cookies = []; - for (const entry of new SafeArrayIterator(list)) { + for (let i = 0; i < list.length; ++i) { + const entry = list[i]; const name = byteLowerCase(entry[0]); const value = entry[1]; if (value === null) throw new TypeError("Unreachable"); diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js index ad39868741..4ab9556103 100644 --- a/ext/fetch/21_formdata.js +++ b/ext/fetch/21_formdata.js @@ -25,7 +25,6 @@ MathRandom, ObjectPrototypeIsPrototypeOf, Symbol, - SafeArrayIterator, StringFromCharCode, StringPrototypeTrim, StringPrototypeSlice, @@ -163,7 +162,9 @@ context: "Argument 1", }); - for (const entry of new SafeArrayIterator(this[entryList])) { + const entries = this[entryList]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry.name === name) return entry.value; } return null; @@ -184,7 +185,9 @@ }); const returnList = []; - for (const entry of new SafeArrayIterator(this[entryList])) { + const entries = this[entryList]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry.name === name) ArrayPrototypePush(returnList, entry.value); } return returnList; @@ -204,7 +207,9 @@ context: "Argument 1", }); - for (const entry of new SafeArrayIterator(this[entryList])) { + const entries = this[entryList]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry.name === name) return true; } return false; @@ -374,7 +379,8 @@ #parseHeaders(headersText) { const headers = new Headers(); const rawHeaders = StringPrototypeSplit(headersText, "\r\n"); - for (const rawHeader of new SafeArrayIterator(rawHeaders)) { + for (let i = 0; i < rawHeaders.length; ++i) { + const rawHeader = rawHeaders[i]; const sepIndex = StringPrototypeIndexOf(rawHeader, ":"); if (sepIndex < 0) { continue; // Skip this header diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js index 4645ff9ba8..e76914e728 100644 --- a/ext/flash/01_http.js +++ b/ext/flash/01_http.js @@ -31,7 +31,6 @@ PromisePrototype, PromisePrototypeCatch, PromisePrototypeThen, - SafeArrayIterator, SafePromiseAll, TypedArrayPrototypeSubarray, TypeError, @@ -140,7 +139,8 @@ // status-line = HTTP-version SP status-code SP reason-phrase CRLF // Date header: https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.1.2 let str = `HTTP/1.1 ${status} ${statusCodes[status]}\r\nDate: ${date}\r\n`; - for (const [name, value] of new SafeArrayIterator(headerList)) { + for (let i = 0; i < headerList.length; ++i) { + const [name, value] = headerList[i]; // header-field = field-name ":" OWS field-value OWS str += `${name}: ${value}\r\n`; } diff --git a/ext/url/00_url.js b/ext/url/00_url.js index cedc241fe2..5fa0c52bde 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -194,7 +194,9 @@ context: "Argument 1", }); const values = []; - for (const entry of new SafeArrayIterator(this[_list])) { + const entries = this[_list]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry[0] === name) { ArrayPrototypePush(values, entry[1]); } @@ -214,7 +216,9 @@ prefix, context: "Argument 1", }); - for (const entry of new SafeArrayIterator(this[_list])) { + const entries = this[_list]; + for (let i = 0; i < entries.length; ++i) { + const entry = entries[i]; if (entry[0] === name) { return entry[1]; } diff --git a/ext/url/01_urlpattern.js b/ext/url/01_urlpattern.js index eb05743a36..ef7df60e5b 100644 --- a/ext/url/01_urlpattern.js +++ b/ext/url/01_urlpattern.js @@ -20,7 +20,6 @@ RegExp, RegExpPrototypeExec, RegExpPrototypeTest, - SafeArrayIterator, Symbol, SymbolFor, TypeError, @@ -72,7 +71,9 @@ const components = ops.op_urlpattern_parse(input, baseURL); - for (const key of new SafeArrayIterator(ObjectKeys(components))) { + const keys = ObjectKeys(components); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; try { components[key].regexp = new RegExp( components[key].regexpString, @@ -156,7 +157,9 @@ const [values] = res; - for (const key of new SafeArrayIterator(ObjectKeys(values))) { + const keys = ObjectKeys(values); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; if (!RegExpPrototypeTest(this[_components][key].regexp, values[key])) { return false; } @@ -201,8 +204,9 @@ /** @type {URLPatternResult} */ const result = { inputs }; - /** @type {string} */ - for (const key of new SafeArrayIterator(ObjectKeys(values))) { + const keys = ObjectKeys(values); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; /** @type {Component} */ const component = this[_components][key]; const input = values[key]; diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js index 63b82b01f2..031558bee9 100644 --- a/ext/web/01_dom_exception.js +++ b/ext/web/01_dom_exception.js @@ -19,7 +19,6 @@ ObjectEntries, ObjectPrototypeIsPrototypeOf, ObjectSetPrototypeOf, - SafeArrayIterator, Symbol, SymbolFor, } = window.__bootstrap.primordials; @@ -166,37 +165,35 @@ webidl.configurePrototype(DOMException); const DOMExceptionPrototype = DOMException.prototype; - for ( - const [key, value] of new SafeArrayIterator( - ObjectEntries({ - INDEX_SIZE_ERR, - DOMSTRING_SIZE_ERR, - HIERARCHY_REQUEST_ERR, - WRONG_DOCUMENT_ERR, - INVALID_CHARACTER_ERR, - NO_DATA_ALLOWED_ERR, - NO_MODIFICATION_ALLOWED_ERR, - NOT_FOUND_ERR, - NOT_SUPPORTED_ERR, - INUSE_ATTRIBUTE_ERR, - INVALID_STATE_ERR, - SYNTAX_ERR, - INVALID_MODIFICATION_ERR, - NAMESPACE_ERR, - INVALID_ACCESS_ERR, - VALIDATION_ERR, - TYPE_MISMATCH_ERR, - SECURITY_ERR, - NETWORK_ERR, - ABORT_ERR, - URL_MISMATCH_ERR, - QUOTA_EXCEEDED_ERR, - TIMEOUT_ERR, - INVALID_NODE_TYPE_ERR, - DATA_CLONE_ERR, - }), - ) - ) { + const entries = ObjectEntries({ + INDEX_SIZE_ERR, + DOMSTRING_SIZE_ERR, + HIERARCHY_REQUEST_ERR, + WRONG_DOCUMENT_ERR, + INVALID_CHARACTER_ERR, + NO_DATA_ALLOWED_ERR, + NO_MODIFICATION_ALLOWED_ERR, + NOT_FOUND_ERR, + NOT_SUPPORTED_ERR, + INUSE_ATTRIBUTE_ERR, + INVALID_STATE_ERR, + SYNTAX_ERR, + INVALID_MODIFICATION_ERR, + NAMESPACE_ERR, + INVALID_ACCESS_ERR, + VALIDATION_ERR, + TYPE_MISMATCH_ERR, + SECURITY_ERR, + NETWORK_ERR, + ABORT_ERR, + URL_MISMATCH_ERR, + QUOTA_EXCEEDED_ERR, + TIMEOUT_ERR, + INVALID_NODE_TYPE_ERR, + DATA_CLONE_ERR, + }); + for (let i = 0; i < entries.length; ++i) { + const [key, value] = entries[i]; const desc = { value, enumerable: true }; ObjectDefineProperty(DOMException, key, desc); ObjectDefineProperty(DOMException.prototype, key, desc); diff --git a/ext/web/01_mimesniff.js b/ext/web/01_mimesniff.js index f0f02d53a1..2d67d5f954 100644 --- a/ext/web/01_mimesniff.js +++ b/ext/web/01_mimesniff.js @@ -16,7 +16,6 @@ MapPrototypeHas, MapPrototypeSet, RegExpPrototypeTest, - SafeArrayIterator, SafeMapIterator, StringPrototypeReplaceAll, StringPrototypeToLowerCase, @@ -223,7 +222,8 @@ let charset = null; let essence_ = null; let mimeType = null; - for (const value of new SafeArrayIterator(headerValues)) { + for (let i = 0; i < headerValues.length; ++i) { + const value = headerValues[i]; const temporaryMimeType = parseMimeType(value); if ( temporaryMimeType === null || diff --git a/ext/web/02_event.js b/ext/web/02_event.js index 3e7a4d1080..dac126280f 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -428,7 +428,8 @@ Ctor, props, ) { - for (const prop of new SafeArrayIterator(props)) { + for (let i = 0; i < props.length; ++i) { + const prop = props[i]; ReflectDefineProperty(Ctor.prototype, prop, { enumerable: true }); } } @@ -969,7 +970,9 @@ listeners[type] = []; } - for (const listener of new SafeArrayIterator(listeners[type])) { + const listenerList = listeners[type]; + for (let i = 0; i < listenerList.length; ++i) { + const listener = listenerList[i]; if ( ((typeof listener.options === "boolean" && listener.options === options.capture) || @@ -1454,7 +1457,9 @@ colno = jsError.frames[0].columnNumber; } else { const jsError = core.destructureError(new Error()); - for (const frame of new SafeArrayIterator(jsError.frames)) { + const frames = jsError.frames; + for (let i = 0; i < frames.length; ++i) { + const frame = frames[i]; if ( typeof frame.fileName == "string" && !StringPrototypeStartsWith(frame.fileName, "deno:") diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 67fbaa6c9e..81d97218a2 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -42,7 +42,6 @@ queueMicrotask, RangeError, ReflectHas, - SafeArrayIterator, SafePromiseAll, SharedArrayBuffer, Symbol, @@ -858,10 +857,11 @@ } const finalBuffer = new Uint8Array(totalLength); - let i = 0; - for (const chunk of new SafeArrayIterator(chunks)) { - TypedArrayPrototypeSet(finalBuffer, chunk, i); - i += chunk.byteLength; + let offset = 0; + for (let i = 0; i < chunks.length; ++i) { + const chunk = chunks[i]; + TypedArrayPrototypeSet(finalBuffer, chunk, offset); + offset += chunk.byteLength; } return finalBuffer; } @@ -1346,7 +1346,8 @@ if (reader !== undefined && isReadableStreamBYOBReader(reader)) { const readIntoRequests = reader[_readIntoRequests]; reader[_readIntoRequests] = []; - for (const readIntoRequest of new SafeArrayIterator(readIntoRequests)) { + for (let i = 0; i < readIntoRequests.length; ++i) { + const readIntoRequest = readIntoRequests[i]; readIntoRequest.closeSteps(undefined); } } @@ -1372,7 +1373,8 @@ /** @type {Array>} */ const readRequests = reader[_readRequests]; reader[_readRequests] = []; - for (const readRequest of new SafeArrayIterator(readRequests)) { + for (let i = 0; i < readRequests.length; ++i) { + const readRequest = readRequests[i]; readRequest.closeSteps(); } } @@ -1594,7 +1596,8 @@ function readableStreamDefaultReaderErrorReadRequests(reader, e) { const readRequests = reader[_readRequests]; reader[_readRequests] = []; - for (const readRequest of new SafeArrayIterator(readRequests)) { + for (let i = 0; i < readRequests.length; ++i) { + const readRequest = readRequests[i]; readRequest.errorSteps(e); } } @@ -2614,7 +2617,8 @@ function readableStreamBYOBReaderErrorReadIntoRequests(reader, e) { const readIntoRequests = reader[_readIntoRequests]; reader[_readIntoRequests] = []; - for (const readIntoRequest of new SafeArrayIterator(readIntoRequests)) { + for (let i = 0; i < readIntoRequests.length; ++i) { + const readIntoRequest = readIntoRequests[i]; readIntoRequest.errorSteps(e); } } @@ -4238,7 +4242,9 @@ stream[_state] = "errored"; stream[_controller][_errorSteps](); const storedError = stream[_storedError]; - for (const writeRequest of new SafeArrayIterator(stream[_writeRequests])) { + const writeRequests = stream[_writeRequests]; + for (let i = 0; i < writeRequests.length; ++i) { + const writeRequest = writeRequests[i]; writeRequest.reject(storedError); } stream[_writeRequests] = []; diff --git a/ext/web/09_file.js b/ext/web/09_file.js index 92de61e1fa..f789a24d2a 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -26,7 +26,6 @@ MathMin, ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, - SafeArrayIterator, StringPrototypeCharAt, StringPrototypeToLowerCase, StringPrototypeSlice, @@ -95,8 +94,8 @@ /** @param {(BlobReference | Blob)[]} parts */ async function* toIterator(parts) { - for (const part of new SafeArrayIterator(parts)) { - yield* part.stream(); + for (let i = 0; i < parts.length; ++i) { + yield* parts[i].stream(); } } @@ -111,7 +110,8 @@ /** @type {(BlobReference|Blob)[]} */ const processedParts = []; let size = 0; - for (const element of new SafeArrayIterator(parts)) { + for (let i = 0; i < parts.length; ++i) { + const element = parts[i]; if (ObjectPrototypeIsPrototypeOf(ArrayBufferPrototype, element)) { const chunk = new Uint8Array(ArrayBufferPrototypeSlice(element, 0)); ArrayPrototypePush(processedParts, BlobReference.fromUint8Array(chunk)); @@ -159,7 +159,9 @@ * @returns {string[]} */ function getParts(blob, bag = []) { - for (const part of new SafeArrayIterator(blob[_parts])) { + const parts = blob[_parts]; + for (let i = 0; i < parts.length; ++i) { + const part = parts[i]; if (ObjectPrototypeIsPrototypeOf(BlobPrototype, part)) { getParts(part, bag); } else { @@ -276,7 +278,9 @@ const blobParts = []; let added = 0; - for (const part of new SafeArrayIterator(this[_parts])) { + const parts = this[_parts]; + for (let i = 0; i < parts.length; ++i) { + const part = parts[i]; // don't add the overflow to new blobParts if (added >= span) { // Could maybe be possible to remove variable `added` @@ -600,7 +604,8 @@ const parts = []; let totalSize = 0; - for (const { uuid, size } of new SafeArrayIterator(blobData.parts)) { + for (let i = 0; i < blobData.parts.length; ++i) { + const { uuid, size } = blobData.parts[i]; ArrayPrototypePush(parts, new BlobReference(uuid, size)); totalSize += size; } diff --git a/ext/web/10_filereader.js b/ext/web/10_filereader.js index bd5ee85be6..fb119f43ec 100644 --- a/ext/web/10_filereader.js +++ b/ext/web/10_filereader.js @@ -158,7 +158,8 @@ ); const bytes = new Uint8Array(size); let offs = 0; - for (const chunk of new SafeArrayIterator(chunks)) { + for (let i = 0; i < chunks.length; ++i) { + const chunk = chunks[i]; TypedArrayPrototypeSet(bytes, chunk, offs); offs += chunk.byteLength; } diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index f589ac91fc..8b8aa57ace 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -22,7 +22,6 @@ ArrayPrototypePush, ObjectPrototypeIsPrototypeOf, ObjectSetPrototypeOf, - SafeArrayIterator, Symbol, SymbolFor, SymbolIterator, @@ -205,9 +204,8 @@ const arrayBufferIdsInTransferables = []; const transferredArrayBuffers = []; - for ( - const transferable of new SafeArrayIterator(messageData.transferables) - ) { + for (let i = 0; i < messageData.transferables.length; ++i) { + const transferable = messageData.transferables[i]; switch (transferable.kind) { case "messagePort": { const port = createMessagePort(transferable.data); @@ -217,8 +215,8 @@ } case "arrayBuffer": { ArrayPrototypePush(transferredArrayBuffers, transferable.data); - const i = ArrayPrototypePush(transferables, null); - ArrayPrototypePush(arrayBufferIdsInTransferables, i); + const index = ArrayPrototypePush(transferables, null); + ArrayPrototypePush(arrayBufferIdsInTransferables, index); break; } default: @@ -274,7 +272,8 @@ const serializedTransferables = []; let arrayBufferI = 0; - for (const transferable of new SafeArrayIterator(transferables)) { + for (let i = 0; i < transferables.length; ++i) { + const transferable = transferables[i]; if (ObjectPrototypeIsPrototypeOf(MessagePortPrototype, transferable)) { webidl.assertBranded(transferable, MessagePortPrototype); const id = transferable[_id]; diff --git a/ext/webgpu/src/01_webgpu.js b/ext/webgpu/src/01_webgpu.js index 1c1b15756f..02bdc65621 100644 --- a/ext/webgpu/src/01_webgpu.js +++ b/ext/webgpu/src/01_webgpu.js @@ -316,7 +316,8 @@ context: "Argument 1", }); const requiredFeatures = descriptor.requiredFeatures ?? []; - for (const feature of new SafeArrayIterator(requiredFeatures)) { + for (let i = 0; i < requiredFeatures.length; ++i) { + const feature = requiredFeatures[i]; if (!SetPrototypeHas(this[_adapter].features[_features], feature)) { throw new TypeError( `${prefix}: nonGuaranteedFeatures must be a subset of the adapter features.`, @@ -1046,14 +1047,16 @@ context: "Argument 1", }); const device = assertDevice(this, { prefix, context: "this" }); - for (const entry of new SafeArrayIterator(descriptor.entries)) { - let i = 0; - if (entry.buffer) i++; - if (entry.sampler) i++; - if (entry.texture) i++; - if (entry.storageTexture) i++; + for (let i = 0; i < descriptor.entries.length; ++i) { + const entry = descriptor.entries[i]; - if (i !== 1) { + let count = 0; + if (entry.buffer) count++; + if (entry.sampler) count++; + if (entry.texture) count++; + if (entry.storageTexture) count++; + + if (count !== 1) { throw new Error(); // TODO(@crowlKats): correct error } } @@ -1591,8 +1594,8 @@ device.rid, commandBufferRids, ); - for (const commandBuffer of new SafeArrayIterator(commandBuffers)) { - commandBuffer[_rid] = undefined; + for (let i = 0; i < commandBuffers.length; ++i) { + commandBuffers[i][_rid] = undefined; } device.pushError(err); } @@ -1934,7 +1937,8 @@ if (!mappedRanges) { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } - for (const [buffer, _rid, start] of new SafeArrayIterator(mappedRanges)) { + for (let i = 0; i < mappedRanges.length; ++i) { + const [buffer, _rid, start] = mappedRanges[i]; // TODO(lucacasonato): is this logic correct? const end = start + buffer.byteLength; if ( @@ -2002,7 +2006,8 @@ if (!mappedRanges) { throw new DOMException(`${prefix}: invalid state.`, "OperationError"); } - for (const [buffer, mappedRid] of new SafeArrayIterator(mappedRanges)) { + for (let i = 0; i < mappedRanges.length; ++i) { + const [buffer, mappedRid] = mappedRanges[i]; const { err } = ops.op_webgpu_buffer_unmap( bufferRid, mappedRid, diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index f38618f13f..4f51edfed9 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -60,7 +60,6 @@ ReflectHas, ReflectOwnKeys, RegExpPrototypeTest, - SafeArrayIterator, Set, // TODO(lucacasonato): add SharedArrayBuffer to primordials // SharedArrayBuffer, @@ -633,8 +632,10 @@ function createDictionaryConverter(name, ...dictionaries) { let hasRequiredKey = false; const allMembers = []; - for (const members of new SafeArrayIterator(dictionaries)) { - for (const member of new SafeArrayIterator(members)) { + for (let i = 0; i < dictionaries.length; ++i) { + const members = dictionaries[i]; + for (let j = 0; j < members.length; ++j) { + const member = members[j]; if (member.required) { hasRequiredKey = true; } @@ -649,7 +650,8 @@ }); const defaultValues = {}; - for (const member of new SafeArrayIterator(allMembers)) { + for (let i = 0; i < allMembers.length; ++i) { + const member = allMembers[i]; if (ReflectHas(member, "defaultValue")) { const idlMemberValue = member.defaultValue; const imvType = typeof idlMemberValue; @@ -695,7 +697,8 @@ return idlDict; } - for (const member of new SafeArrayIterator(allMembers)) { + for (let i = 0; i < allMembers.length; ++i) { + const member = allMembers[i]; const key = member.key; let esMemberValue; @@ -821,7 +824,8 @@ } // Slow path if Proxy (e.g: in WPT tests) const keys = ReflectOwnKeys(V); - for (const key of new SafeArrayIterator(keys)) { + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; const desc = ObjectGetOwnPropertyDescriptor(V, key); if (desc !== undefined && desc.enumerable === true) { const typedKey = keyConverter(key, opts); @@ -891,7 +895,9 @@ } function define(target, source) { - for (const key of new SafeArrayIterator(ReflectOwnKeys(source))) { + const keys = ReflectOwnKeys(source); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; const descriptor = ReflectGetOwnPropertyDescriptor(source, key); if (descriptor && !ReflectDefineProperty(target, key, descriptor)) { throw new TypeError(`Cannot redefine property: ${String(key)}`); diff --git a/runtime/js/12_io.js b/runtime/js/12_io.js index b384e15284..f6b2d6b877 100644 --- a/runtime/js/12_io.js +++ b/runtime/js/12_io.js @@ -12,7 +12,6 @@ Uint8Array, ArrayPrototypePush, MathMin, - SafeArrayIterator, TypedArrayPrototypeSubarray, TypedArrayPrototypeSet, } = window.__bootstrap.primordials; @@ -157,14 +156,15 @@ function concatBuffers(buffers) { let totalLen = 0; - for (const buf of new SafeArrayIterator(buffers)) { - totalLen += buf.byteLength; + for (let i = 0; i < buffers.length; ++i) { + totalLen += buffers[i].byteLength; } const contents = new Uint8Array(totalLen); let n = 0; - for (const buf of new SafeArrayIterator(buffers)) { + for (let i = 0; i < buffers.length; ++i) { + const buf = buffers[i]; TypedArrayPrototypeSet(contents, buf, n); n += buf.byteLength; } diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index 897c89a131..770cef1a8a 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -9,7 +9,6 @@ DatePrototype, MathTrunc, ObjectPrototypeIsPrototypeOf, - SafeArrayIterator, SymbolAsyncIterator, SymbolIterator, Function, @@ -212,7 +211,10 @@ let offset = 0; let str = 'const unix = Deno.build.os === "darwin" || Deno.build.os === "linux"; return {'; - for (let [name, type] of new SafeArrayIterator(ObjectEntries(types))) { + const typeEntries = ObjectEntries(types); + for (let i = 0; i < typeEntries.length; ++i) { + let [name, type] = typeEntries[i]; + const optional = type.startsWith("?"); if (optional) type = type.slice(1); diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 2e92d5b5d6..873f371cac 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -33,7 +33,6 @@ delete Intl.v8BreakIterator; SymbolFor, SymbolIterator, PromisePrototypeThen, - SafeArrayIterator, SafeWeakMap, TypeError, WeakMapPrototypeDelete, @@ -206,7 +205,8 @@ delete Intl.v8BreakIterator; ); loadedMainWorkerScript = true; - for (const { url, script } of new SafeArrayIterator(scripts)) { + for (let i = 0; i < scripts.length; ++i) { + const { url, script } = scripts[i]; const err = core.evalContext(script, url)[1]; if (err !== null) { throw err.thrown;