Skip to content

script: ClearKeptObjects in microtask checkpoint - #48739

Merged
jdm merged 1 commit into
servo:mainfrom
jschwe:jschwender/job_queue_clear
Oct 9, 2026
Merged

jdm merged 1 commit into
servo:mainfrom
jschwe:jschwender/job_queue_clear

Conversation

@jschwe

@jschwe jschwe commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Testing: Should be covered by existing tests (not starting to crash). mach try

@jschwe
jschwe requested a review from gterzian as a code owner October 8, 2026 08:46
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 8, 2026
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Oct 9, 2026
@jdm
jdm added this pull request to the merge queue Oct 9, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 9, 2026
@jdm
jdm added this pull request to the merge queue Oct 9, 2026
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Oct 9, 2026
Merged via the queue into servo:main with commit 10c8149 Oct 9, 2026
43 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 9, 2026
@jschwe
jschwe deleted the jschwender/job_queue_clear branch October 9, 2026 04:31
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 9, 2026
Testing: Should be covered by existing tests (not starting to crash).
[mach try](https://github.com/jschwe/servo/actions/runs/37752139247)

Signed-off-by: Jonathan Schwender <[email protected]>
(cherry picked from commit 10c8149)

----

Fork note: backport of upstream 10c8149 (servo#48739), which landed after
base/2026-10-08. Without ClearKeptObjects() (step 6 of
https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint),
SpiderMonkey keeps the target of every WeakRef that was created or
dereferenced alive forever.
Drop at the next sync: every later base contains 10c8149, so this
commit applies empty and becomes a `Superseded-by: 10c8149`
placeholder (runbook decision 3).

Validation: Release builds of ohos-main and of ohos-main plus this patch alone, headless servoshell with `--pref=dom_testutils_enabled=true`, two runs each. A page that adds and removes 50 empty same-origin iframes, keeps a WeakRef to each document and calls `TestUtils.gc()`: 50/50 documents still alive without the patch, 0/50 with it. WPT with patches 47 to 49: `./mach test-wpt --release --processes 6 html/webappapis/timers html/browsers/browsing-the-web html/browsers/history page-visibility performance-timeline js workers html/webappapis/scripting/event-loops user-timing` (1029 tests): 1023 as expected. The other 6 are flaky or broken on plain ohos-main too (A/B repeats, plain ohos-main vs with the patches): navigation-unload-same-origin-fragment.html FAIL 6/10 vs 7/10; cross-origin-top-navigation-with-user-activation-in-parent.window.html TIMEOUT 23/30 vs 29/30 (18/20 vs 20/20 in the interleaved rounds); location_replace_session_history.html (expected TIMEOUT) ends in ERROR, TIMEOUT or CRASH on both, 28/2/0 vs 22/5/3 of 30; same-document-refresh.html PASS 9/10 vs 10/10 (stale FAIL expectation); form-submit-cross-frame.html FAIL 2/10 vs 0/10; iframe-src-204.html FAIL once in the full run, 0/10 vs 0/10 in repeats. `./mach fmt` and `./mach test-tidy` are clean.
AI-assisted: Yes (agent session; the agent cherry-picked upstream commit 10c8149 without code changes and added the fork-style part of this message below the dashed line: fork note, Validation and these trailers)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 10, 2026
Testing: Should be covered by existing tests (not starting to crash).
[mach try](https://github.com/jschwe/servo/actions/runs/37752139247)

Signed-off-by: Jonathan Schwender <[email protected]>
(cherry picked from commit 10c8149)

----

Fork note: backport of upstream 10c8149 (servo#48739), which landed after
base/2026-10-08. Without ClearKeptObjects() (step 6 of
https://html.spec.whatwg.org/multipage/#perform-a-microtask-checkpoint),
SpiderMonkey keeps the target of every WeakRef that was created or
dereferenced alive forever.
Drop at the next sync: every later base contains 10c8149, so this
commit applies empty and becomes a `Superseded-by: 10c8149`
placeholder (runbook decision 3).

Validation: Release builds of ohos-main and of ohos-main plus this patch alone, headless servoshell with `--pref=dom_testutils_enabled=true`, two runs each. A page that adds and removes 50 empty same-origin iframes, keeps a WeakRef to each document and calls `TestUtils.gc()`: 50/50 documents still alive without the patch, 0/50 with it. WPT with patches 47 to 49: `./mach test-wpt --release --processes 6 html/webappapis/timers html/browsers/browsing-the-web html/browsers/history page-visibility performance-timeline js workers html/webappapis/scripting/event-loops user-timing` (1029 tests): 1023 as expected. The other 6 are flaky or broken on plain ohos-main too (A/B repeats, plain ohos-main vs with the patches): navigation-unload-same-origin-fragment.html FAIL 6/10 vs 7/10; cross-origin-top-navigation-with-user-activation-in-parent.window.html TIMEOUT 23/30 vs 29/30 (18/20 vs 20/20 in the interleaved rounds); location_replace_session_history.html (expected TIMEOUT) ends in ERROR, TIMEOUT or CRASH on both, 28/2/0 vs 22/5/3 of 30; same-document-refresh.html PASS 9/10 vs 10/10 (stale FAIL expectation); form-submit-cross-frame.html FAIL 2/10 vs 0/10; iframe-src-204.html FAIL once in the full run, 0/10 vs 0/10 in repeats. `./mach fmt` and `./mach test-tidy` are clean.
AI-assisted: Yes (agent session; the agent cherry-picked upstream commit 10c8149 without code changes and added the fork-style part of this message below the dashed line: fork note, Validation and these trailers)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 10, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 10, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
Signed-off-by: Jonathan Schwender <[email protected]>
hhhwsqhhh pushed a commit to hhhwsqhhh/servo that referenced this pull request Oct 12, 2026
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 13, 2026
Dropped in favour of upstream 10c8149 (servo#48739), which this commit
backported and which every base from base/2026-10-13 on contains.
Equivalence: `git log --cherry-mark base/2026-10-13...pre-sync/2026-10-13`
marks this commit `=` (identical patch-id to 10c8149), and it applies
empty on base/2026-10-13. Verified by the sync of 2026-10-13.

This empty placeholder is removed in the next sync's fold step.

Superseded-by: 10c8149
Validation: applies empty on base/2026-10-13; patch-id identity with 10c8149 (`git log --cherry-mark`). The leak checks of the original Validation were not re-run on plain upstream; equivalence rests on the identical patch.
AI-assisted: Yes (agent session; 2026-10-13 sync -- applied empty, since upstream 10c8149 is the identical patch; kept as a placeholder)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 13, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change)
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 22, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change)
AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934))
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Oct 30, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change)
AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934))
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 9, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change)
AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934))
AI-assisted: Yes (agent session; 2026-11-09 sync -- the task-end sweep sits in upstream's renamed handle_messages() loop; the feature next to upstream's subtlecrypto (servo#48860))
Signed-off-by: Jonathan Schwender <[email protected]>
jschwe added a commit to openharmony-rs/servo-ohos that referenced this pull request Nov 10, 2026
With the js-quickjs feature, Servo runs on servo-quickjs
(https://github.com/openharmony-rs/servo-quickjs), which implements the
mozjs API on QuickJS. The feature builds only with mozjs patched to the
shim, e.g. in .cargo/config.toml:

    [patch.crates-io]
    mozjs = { git = "https://github.com/openharmony-rs/servo-quickjs", rev = "..." }

QuickJS frees objects by reference counting and collects cycles, so
under js-quickjs:
- Dom<T> and DomRoot<T> hold a reference count on their target, also
  when the target's reflector is set later (a DissimilarOriginWindow's
  WindowProxy), and roots go through no root list;
- the reflector of a DOM object holds none on its own object, and is
  neither traced nor released by the Heap drop barrier; the reflector of
  a TracedPromise holds a counted, traced one;
- finalizers drop the Dom<T> fields of an object while the collector
  knows which objects it frees, so WindowProxy finalizes through
  finalize_common;
- live Trusted references are counted until swept, and the shim's
  autorelease pool is drained between tasks, on the script thread and
  on worker threads;
- reflectors are initialized before they are rooted, DOM objects are
  left alone once the runtime is destroyed, and the Debugger API is
  left out.

Under SpiderMonkey, WindowProxy's finalizer does what it did before, and
MutDom and MutNullableDom no longer copy Dom<T> bitwise, which is
equivalent.

Fork note: experimental, to evaluate QuickJS as the engine of a smaller
profile (servo-quickjs docs/design.md). All QuickJS code is behind the
feature, and the QuickJS workflow builds it and runs WPT with it. Not
meant for upstream in this form.

Rebasing: under js-quickjs a Dom<T> holds a count, so a bitwise copy of
one, as upstream's ptr::read in MutDom and MutNullableDom was, releases
it twice. This must find nothing; clone or borrow instead:

    git grep ptr::read components/script_bindings components/script

Removing such a copy can leave a crown unrooted_must_root expectation
unfulfilled, which fails the Linux CI build (-D warnings) but no local
build. Check with crown installed from the tree (cargo install --path
support/crown):

    RUSTFLAGS="-D warnings" ./mach check --use-crown

Validation: On ohos-main 8fab166, before folding: servo-quickjs `just test`, `just test-verify` and `just test-asan` (79 tests each) and `just fuzz-smoke 60` pass; `./mach fmt` and `./mach test-tidy` are clean, and servoshell builds without warnings with and without js-quickjs. WPT with debug builds of the same commit, QuickJS with QJS_VERIFY_TRACING=1 against SpiderMonkey, `--processes 2`, html/semantics/scripting-1, html/webappapis/microtask-queuing, html/webappapis/scripting, import-maps, workers/modules, webidl and dom/events (1087 tests): no panics or verifier aborts; worse with QuickJS only the three dynamic-import/microtasks/basic variants, which time out in a debug build and pass with `--timeout-multiplier 4`; better on 3 tests. On af58e60: release builds with both engines, the QuickJS one through the QuickJS workflow's patch step (servo-quickjs 0605066), and `./mach smoketest` passes with both. The worker sweep was added after these runs, from the ownership review: with it, 1000 XHRs in a worker no longer leave 1000 XMLHttpRequest objects alive (probe build of the spike). Full WPT on this stack, release builds with servo-quickjs ed76452, 58,101 tests, then 3 reruns per engine of every difference: outside the WebAssembly-dependent tests, QuickJS is consistently worse only in the three autoplay-*-permissions-policy tests, two WebGL conformance tests that time out on SpiderMonkey without JIT too, and single subtests of structured-cloning-error-stack and localeCompare (no Intl on desktop). After a review of these fixes, workers also release the pool after each batch, not only before the next one. With servo-quickjs 3286cd6, release build: `./mach smoketest` passes, and 2138 tests (cross-origin objects, WindowProxy, Location, history, windows, forms, structured cloning, WebIDL, DOM, fetch responses, workers) match the full run's QuickJS results, except one subtest that now passes and three tests that are flaky with SpiderMonkey too. Rebased onto 7f6279e (the TimerListener and closed-pipeline leak fixes, and servo#48739, which this stack had carried as a backport): release builds with both engines and a checked-release QuickJS build pass the smoketest without warnings, and 2464 WPT tests (the 2138 above plus timers, iframes and cross-document navigation) match the full run's QuickJS results, except one test now passing, as on SpiderMonkey, and two customizable-select tests that are flaky on both engines (select-appearance-hover crashed once under load and fails 5 of 5 alone on both). `RUSTFLAGS="-D warnings" ./mach check --use-crown`, as the Linux CI job builds, passes: the crown expectation on `MutNullableDom::get_unrooted` went away with the `ptr::read` it covered.
AI-assisted: Yes (agent session; agent sessions wrote and tested the js-quickjs commits, and the agent folded them into this patch and added the worker sweep)
AI-assisted: Yes (agent session; 2026-10-13 sync -- mechanical conflict resolution in components/servo/Cargo.toml, next to upstream's new default_tooling feature (servo#47255), no semantic change)
AI-assisted: Yes (agent session; 2026-10-22 sync -- mechanical conflict resolution, no semantic change: the `js-quickjs` features next to upstream's new `default` lines of servo and servoshell (servo#48934))
AI-assisted: Yes (agent session; 2026-11-09 sync -- the task-end sweep sits in upstream's renamed handle_messages() loop; the feature next to upstream's subtlecrypto (servo#48860))
Signed-off-by: Jonathan Schwender <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants