Skip to content

[oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments - #5460

Open
shruti2522 wants to merge 1 commit into
boa-dev:dev/oscars-gcfrom
shruti2522:integration4
Open

[oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments#5460
shruti2522 wants to merge 1 commit into
boa-dev:dev/oscars-gcfrom
shruti2522:integration4

Conversation

@shruti2522

Copy link
Copy Markdown
Contributor

follow up to #5458

Implemented next part of the oscars GC migration.

  • added Context::gc() to wrap token access. in the final phases of integration, we would only have to update this one spot.
  • threaded MutationContext by value into the environments api (push_lexical, push_function, etc)
  • fixed some mutable aliasing issues in the eval and json modules
  • also enabled ci workflow for dev/oscars-gc branch

@github-actions github-actions Bot added C-Tests Issues and PRs related to the tests. C-Builtins PRs and Issues related to builtins/intrinsics C-VM Issues and PRs related to the Boa Virtual Machine. C-Actions Pull requests that update Github Actions code Waiting On Review Waiting on reviews from the maintainers labels Jul 26, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Jul 26, 2026
@shruti2522 shruti2522 changed the title refactor: thread MutationContext token to resolve Gc borrow conflicts in environments refactor: thread MutationContext token, resolve Gc borrow conflicts in environments Jul 26, 2026
@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,073 51,072 -1
Ignored 1,482 1,482 0
Failed 570 571 +1
Panics 0 0 0
Conformance 96.14% 96.14% -0.00%
Broken tests (1):
test/intl402/DateTimeFormat/constructor-options-fractionalSecondDigits-valid.js (previously Passed)

Tested main commit: f54077467b4b01eb0fe221cfff470a8546ebe36c
Tested PR commit: 64b57065aa7e5cea6682ce8a2b6a944dc79293b8
Compare commits: f540774...64b5706

@github-actions github-actions Bot added the C-GC Issue related to garbage collection label Jul 26, 2026
@github-actions github-actions Bot added C-Dependencies Pull requests that update a dependency file C-AST Issue surrounding the abstract syntax tree C-Intl Changes related to the `Intl` implementation labels Aug 9, 2026
@github-actions github-actions Bot added the C-Runtime Issues and PRs related to Boa's runtime features label Aug 9, 2026
@shruti2522 shruti2522 changed the title refactor: thread MutationContext token, resolve Gc borrow conflicts in environments [oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments Aug 10, 2026
@shruti2522
shruti2522 marked this pull request as ready for review August 10, 2026 03:07
@shruti2522
shruti2522 requested review from a team, jedel1043 and nekevss as code owners August 10, 2026 03:07
@github-actions github-actions Bot added C-Parser Issues surrounding the parser C-Benchmark Issues and PRs related to the benchmark subsystem. C-CLI Issues and PRs related to the Boa command line interface. C-Javascript Pull requests that update Javascript code labels Aug 10, 2026
@shruti2522
shruti2522 force-pushed the integration4 branch 2 times, most recently from 3d4dae3 to 292bef6 Compare August 10, 2026 17:52
@shruti2522 shruti2522 changed the title [oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments [WIP][oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments Aug 12, 2026
@shruti2522
shruti2522 force-pushed the integration4 branch 14 times, most recently from 06db6a6 to 913c716 Compare August 13, 2026 08:32
@shruti2522
shruti2522 marked this pull request as ready for review August 14, 2026 03:50
@shruti2522
shruti2522 requested a lite review from Copilot August 14, 2026 03:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 80 out of 81 changed files in this pull request and generated 3 comments.

Suppressed comments (7)

core/engine/src/builtins/set/ordered_set.rs:20

  • Trace implementation is effectively a no-op, so OrderedSet won't mark any JsValue keys. This can lead to use-after-free under the mark-sweep GC backend and is inconsistent with the existing MapKey/JsValue storage.
unsafe impl Trace for OrderedSet {
    custom_trace!(this, mark, {
        // Values in an IndexSet cannot be mutably borrowed. Since this is a null collector, we skip
    });
}

core/engine/src/builtins/map/ordered_map.rs:50

  • Trace only marks values, not keys. OrderedMap stores GC-managed keys (MapKey::Key(JsValue)), so omitting key tracing can allow keys (and the objects they reference) to be collected prematurely under the mark-sweep backend.
unsafe impl<V: Trace> Trace for OrderedMap<V> {
    custom_trace!(this, mark, {
        for v in this.map.values() {
            mark(v);
        }
    });
}

core/engine/src/object/shape/shared_shape/forward_transition.rs:102

  • Using .copied() here forces WeakGc<SharedShapeInner> to be Copy, which breaks compilation with the mark-sweep GC backend. Prefer .cloned() for backend-agnostic code.
    .github/workflows/test262.yml:20
  • This disables the entire test262 job for every PR/event (if: false). If this is only meant to temporarily reduce CI load on dev/oscars-gc, consider scoping the condition to that branch; otherwise it removes an important correctness gate for all PRs.
  run_test262:
    if: false
    name: Run the test262 test suite

core/engine/Cargo.toml:16

  • oscars_backend becomes enabled by default for boa_engine. This is a major behavioral change (e.g. null collector semantics + dummy WeakMap) that affects all downstream users who rely on default features, and it also makes it harder to compare regressions vs the existing mark-sweep backend.
[features]
default = ["float16", "xsum", "temporal", "oscars_backend"]

core/gc/Cargo.toml:26

  • boa_gc now enables oscars_backend by default. Since the oscars null collector has very different semantics than the existing GC (and currently disables/changes weak structures), flipping the default is likely to be a breaking change for crates that depend on boa_gc with default features.
    Cargo.toml:275
  • Adding a workspace-level [patch."https://github.com/boa-dev/boa.git"] causes all consumers to override boa_string for that git source, which is surprising and can break downstream dependency resolution. This kind of patch is usually kept in a local dev config or confined to a non-workspace crate (e.g. fuzz).
[patch."https://github.com/boa-dev/boa.git"]
boa_string = { path = "core/string" }

Comment thread core/engine/src/vm/code_block.rs
Comment thread core/engine/src/object/shape/shared_shape/forward_transition.rs
Comment thread core/gc/src/oscars_weak_map.rs
@shruti2522
shruti2522 force-pushed the integration4 branch 2 times, most recently from 43e10a6 to 4d8d942 Compare August 14, 2026 06:58
@shruti2522
shruti2522 requested a lite review from Copilot August 14, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 78 out of 79 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

core/gc/src/pointers/weak_map.rs:70

  • WeakMap::get_value calls Ephemeron::value using MutationContext::dummy(), which bypasses the token requirement and makes this API usable without providing a real MutationContext. That defeats the purpose of threading MutationContext through APIs and makes it harder to audit which code paths rely on the dummy token.

Comment thread core/gc/src/pointers/mutation_context.rs
Comment thread core/engine/src/object/jsobject.rs
Comment thread core/engine/src/builtins/weak_map/mod.rs
@shruti2522 shruti2522 changed the title [WIP][oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments [oscars-integration] Thread MutationContext token, resolve Gc borrow conflicts in environments Aug 15, 2026
@shruti2522

Copy link
Copy Markdown
Contributor Author

@nekevss @jedel1043 this one ready for review, we can merge this

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

Labels

C-Actions Pull requests that update Github Actions code C-AST Issue surrounding the abstract syntax tree C-Benchmark Issues and PRs related to the benchmark subsystem. C-Builtins PRs and Issues related to builtins/intrinsics C-CLI Issues and PRs related to the Boa command line interface. C-Dependencies Pull requests that update a dependency file C-FFI Foreign Function Interface, to be able to use Boa from a different language, such as C C-GC Issue related to garbage collection C-Intl Changes related to the `Intl` implementation C-Javascript Pull requests that update Javascript code C-Parser Issues surrounding the parser C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. C-WebAssembly Anything related to using Boa with Wasm Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants