Skip to content

Update wasi branch to firefox 147_0_4#1

Open
andreiltd wants to merge 10 commits intobytecodealliance:wasi-ff147from
andreiltd:wasi-ff147
Open

Update wasi branch to firefox 147_0_4#1
andreiltd wants to merge 10 commits intobytecodealliance:wasi-ff147from
andreiltd:wasi-ff147

Conversation

@andreiltd
Copy link
Member

This carries our patches on top of FIREFOX_147_0_4_RELEASE

elliottt and others added 7 commits February 19, 2026 23:32
Revert "Bug 1795914 - Remove JS Streams implementation r=jandem"
This reverts commit 4852cc8cc479dd5e4d463360e4d154c246bfccca.

Revert "Bug 1807845 - Remove the dom.streams prefs r=evilpie,emilio"
This reverts commit 15d6982515a191a1fa619038ba4966315d941d60.

Revert "Bug 1755391 - Remove JS Streams implementation of Writable Stream and PipeTo r=jandem"
This reverts commit f83d513364b1dd6112b760c93d7192f9f647d720.

Revert "Bug 1522136 - Remove javascript.options.streams and other legacy prefs. r=mgaudet,webidl,edgar"
This reverts commit c256578f285c499e42a09de03fca0eb480772e7a.

Revert "Bug 1765060 - Remove dead JS streams code. r=mgaudet"
This reverts commit 75cea938648b566b461695be2e7cdd3978be4411.

Revert "Bug 1774691 - Remove unused JSMSGs. r=mgaudet"
This reverts commit b54b83321ed3bc0d73c144889e2e3279a33ee270.

Revert "Bug 1774672 - Remove no longer neaded JS Streams Magic Values r=iain"
This reverts commit d1c4d10de47547ffb088f402207f1c4d05b33f64.

Revert "Bug 1776013 - Consume mfbt SIMD for String builtins r=iain"
This reverts commit f81ba5c480ddd719b276889287f2c56b9b184a48.

Revert "Bug 1779807 - Consume SIMD::memchr64 for array includes/indexof r=iain"
This reverts commit 557de269a9fa1d75158d7abf4d82e0fdb9903ffd.

Add the 'js/Stream.h' include back into 'vm/Runtime.h'

Add JSAPI functions for operating on ReadableStream and WritableStream

This adds a few functions for working with ReadableStream, plus introduces a basic set of ones for working with WritableStreams at all.

This patch also includes updates to some of the doc comments for the existing streams API: for many functions the doc comment said that they assert that a passed `Handle<JSObject*>` is (a wrapper for) a specific type, but in reality the function does a check and throws an error instead of asserting. Since this patch introduces a few functions that actually do assert, it seems important to ensure the different behavior is correctly documented.

Fix bug in ReadableStream#pipeTo that causes a failed assert when two actions get queued that trigger a pipeTo shutdown

This can happen e.g. when closing the readable and then erroring the writable end of the pipe in the same microtask.

The Streams spec guards against this by just making Shutdown and ShutdownWithAction bail early if already shutting down, but the implementation was doing an upwrap of the source or destination stream that fails if not guarded by a shuttingDown check because the streams have already been cleared.

Fix bugs in ReadableStream#pipeTo that prevent proper flushing of all pending write requests when the source is closed

BYOB streams (mozilla-firefox#2)

Co-authored-by: Jake Champion <me@jakechampion.name>

combine the js streams behind one flag
In long-running environments, it's desirable for the embedding to reset the random seed at controlled points in time.

In particular, when running in WASI, a situation can occur where a VM snapshot is taken at build time using [Wizer](https://github.com/bytecodealliance/wizer), which is then loaded and used as the basis for running separate workloads many times over. If `Math.random()` was called during the initialization phase, this would cause all workloads to get the same results for all consecutive calls to `Math.random()`.
This patch allows the use of a JS shell binary, compiled to
`wasm32-wasi` (WASI ABI on WebAssembly), to make use of the Wizer
snapshotting tool to embed JavaScript source with SpiderMonkey to run in
a standalone Wasm module.

If enabled with `--enable-js-shell-wizer`, the shell no longer provides
an interactive REPL; instead, when invoked during the "initialization"
phase of Wizer, it reads JS source on standard input, then
saves JS state (the global, the context, etc) for later. When the
execution is snapshotted and the snapshot is later executed as an
ordinary WASI command, the resume entry-point invokes a JS function
named `main` in the global scope, if any.

An example of how to use this follows:

```
$ echo "function main() { print('hello world'); }" | \
  wizer --allow-wasi -r _start=wizer.resume obj-release/dist/bin/js \
  -o snapshotted.wasm

$ wasmtime snapshotted.wasm
hello world
$
```

Note that embedders of SpiderMonkey on Wasm can and do add their own
Wizer integration; the purpose of this PR is to add a standalone mode
that does not require building SpiderMonkey within another context in
order to evaluate features (such as AOT compilation) that require
snapshotting as a prerequisite. Followup PRs will include test results
derived with this simple Wizer integration.
Not sure why this didn't bite us before, but it does now.
@github-actions
Copy link

(Automated Close) Please do not file pull requests here, see https://firefox-source-docs.mozilla.org/contributing/how_to_submit_a_patch.html

@github-actions github-actions bot closed this Feb 24, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Feb 24, 2026
@andreiltd andreiltd reopened this Feb 24, 2026
@andreiltd andreiltd marked this pull request as draft February 24, 2026 13:13
@andreiltd andreiltd marked this pull request as ready for review February 24, 2026 21:22
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good -- thanks so much for reviving the weval patches+

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants