Skip to content

[oscars-integration] Thread MutationContext through buitlin standard library objects - #5479

Merged
nekevss merged 2 commits into
boa-dev:dev/oscars-gcfrom
shruti2522:feat/msb-phase3-builtins
Aug 31, 2026
Merged

[oscars-integration] Thread MutationContext through buitlin standard library objects#5479
nekevss merged 2 commits into
boa-dev:dev/oscars-gcfrom
shruti2522:feat/msb-phase3-builtins

Conversation

@shruti2522

Copy link
Copy Markdown
Contributor

Stacked on #5478, this PR enforces threading MutationContext through all internal builtins, removing previous temporary fallbacks.

Key Changes:

  • Removed *_in methods, temporary methods like JsObject::new_in are gone. Main methods (e.g., JsObject::new) have absorbed their signatures and now require the context.
  • Removed Default for core objects: StandardConstructors, IntrinsicObjects and Intrinsics can no longer use Default::default(); they must be instantiated via uninit(mc)
  • Macros (eg., boa_class) were updated to dynamically fetch context.gc_collector() without violating Rust's mutable borrowing rules.
  • Signatures in the CLI, examples and tests were updated. Detached tests and macros temporarily use &unsafe { boa_gc::MutationContext::global() } to minimize immediate code breakage

@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Aug 17, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Aug 17, 2026
@github-actions github-actions Bot added C-Dependencies Pull requests that update a dependency file C-Benchmark Issues and PRs related to the benchmark subsystem. C-CLI Issues and PRs related to the Boa command line interface. 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 C-GC Issue related to garbage collection C-Intl Changes related to the `Intl` implementation C-Runtime Issues and PRs related to Boa's runtime features labels Aug 17, 2026
@shruti2522 shruti2522 changed the title Feat/msb phase3 builtins [oscars-integration] Thread MutationContext through buitlin standard library objects Aug 17, 2026
@shruti2522
shruti2522 force-pushed the feat/msb-phase3-builtins branch 5 times, most recently from 310be44 to f2ddfe2 Compare August 17, 2026 21:35
@shruti2522
shruti2522 marked this pull request as ready for review August 30, 2026 07:27
@shruti2522
shruti2522 requested a review from jedel1043 as a code owner August 30, 2026 07:27
Copilot AI lite review requested due to automatic review settings August 30, 2026 07:27
@shruti2522
shruti2522 requested review from a team and nekevss as code owners August 30, 2026 07:27

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.

🟡 Changes recommended

There are multiple verified compilation/logic issues in the new MutationContext threading (notably several &&MutationContext argument mismatches and an incorrect in_with value in JSON compilation).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR continues the oscars GC integration by threading a MutationContext/GC allocator handle through engine initialization, compilation, runtime environments, and several builtin/object construction paths, while adding an oscars_backend feature surface to boa_gc and boa_string.

Changes:

  • Introduces boa_gc::GcContext and exposes it on Context (Context::alloc, Context::gc_collector) to centralize GC allocations and collector access.
  • Threads MutationContext through bytecode compilation (ByteCompiler, FunctionCompiler) and multiple VM/module/script/builtin code paths, replacing many MutationContext::dummy() call sites.
  • Adds oscars_backend feature wiring across crates (GC/string/engine), plus supporting glue (dummy/leaky WeakMap, Trace/Finalize adjustments, workflow branch triggers).
File summaries
File Description
tests/macros/tests/gcd_callback.rs Updates test to use MutationContext::global() and adjusts lint allowances.
tests/fuzz/Cargo.toml Adds a patch override for boa_string when running fuzzing workspace standalone.
examples/src/bin/jstypedarray.rs Updates example to use MutationContext::global() bridge.
examples/src/bin/derive.rs Adds crate-level lint allowance.
core/string/src/tests.rs Replaces assert!(.. == ..) with assert_eq! in builder tests.
core/string/src/lib.rs Adds oscars_backend Trace/Finalize impls for JsString.
core/string/src/builder.rs Refactors match-arm formatting and adds clippy allows in latin1 conversion path.
core/string/Cargo.toml Adds optional oscars dependency and oscars_backend feature.
core/runtime/src/test262.rs Adjusts downcast/clone flow for SharedArrayBuffer to match new borrow semantics.
core/runtime/src/microtask/tests.rs Updates log cloning to deref through guard before cloning.
core/runtime/src/console/tests.rs Updates log cloning + loosens table header substring assertions for output differences.
core/runtime/src/abort/mod.rs Updates borrow/clone pattern for oscars backend guard types.
core/macros/src/lib.rs Refactors derive_trace to avoid mutable-by-value argument and adjust implementation generation.
core/interner/src/sym.rs Switches Sym to derive Trace and uses #[unsafe_ignore_trace] field attribute.
core/gc/src/trace.rs Wraps custom_trace! bodies in unsafe {} blocks to satisfy unsafe-op linting.
core/gc/src/test/weak.rs Updates Gc type annotation in size-of test for branded lifetime.
core/gc/src/pointers/weak_map.rs Adds WeakMap::get_value convenience accessor.
core/gc/src/pointers/mutation_context.rs Makes dummy() const and adds global() alias constructor.
core/gc/src/oscars_weak_map.rs Adds dummy/leaky WeakMap for oscars_backend.
core/gc/src/lib.rs Adds oscars backend re-exports, tracing macros, GcContext, and feature gating adjustments.
core/gc/src/context.rs Introduces GcContext with collector access and allocation helper methods.
core/gc/src/cell.rs Converts assertions to assert_eq!/assert_ne! for clearer diagnostics.
core/gc/Cargo.toml Reworks feature flags for oscars backend and propagates feature flags to dependencies.
core/engine/src/vm/tests.rs Disables a GC stress test under oscars_backend.
core/engine/src/vm/opcode/push/environment.rs Threads GC allocator usage through env ops and replaces dummy allocations with context.alloc.
core/engine/src/vm/opcode/function.rs Adds explicit type in closure to satisfy inference under new backend types.
core/engine/src/vm/opcode/await/mod.rs Replaces dummy allocations with context.alloc and fixes capture cloning.
core/engine/src/vm/mod.rs Makes Vm::new require a MutationContext to allocate initial codeblock.
core/engine/src/vm/inline_cache/mod.rs Adds explicit Shape binding to satisfy type inference.
core/engine/src/vm/code_block.rs Adds clippy allow for clone_on_copy.
core/engine/src/value/integer.rs Converts equality assertions to assert_eq!/assert_ne!.
core/engine/src/value/inner/nan_boxed.rs Adjusts raw pointer handling and imports for oscars backend compatibility.
core/engine/src/value/inner/legacy.rs Refactors custom_trace! match to avoid matching on &this.
core/engine/src/value/equality.rs Converts debug assert to debug_assert_eq!.
core/engine/src/script.rs Switches script inner allocations to context.alloc and threads MutationContext into compilation.
core/engine/src/realm.rs Requires MutationContext for realm creation and allocations.
core/engine/src/object/shape/unique_shape.rs Adds _in variants and threads MutationContext through shape/weak-shape operations.
core/engine/src/object/shape/shared_shape/template.rs Adds _in variants for template shape transitions and object creation.
core/engine/src/object/shape/shared_shape/mod.rs Adds _in transition APIs and threads MutationContext through transitions/weak upgrades.
core/engine/src/object/shape/shared_shape/forward_transition.rs Adds _in insertion helpers and updates weak allocation to use provided context.
core/engine/src/object/shape/root_shape.rs Adds RootShape::new_in and routes default construction through global context.
core/engine/src/object/shape/mod.rs Adds _in variants for transitions and routes old APIs through global context.
core/engine/src/object/mod.rs Documents TypeId usage differences under oscars backend.
core/engine/src/object/jsobject.rs Adds _in constructors and changes raw pointer APIs to untyped *const () for backend compatibility.
core/engine/src/object/builtins/jsweakset.rs Uses context.gc_collector() to initialize weak set backing store.
core/engine/src/object/builtins/jsweakmap.rs Uses context.gc_collector() to initialize weak map backing store.
core/engine/src/object/builtins/jstypedarray.rs Updates doc example to use context.alloc.
core/engine/src/object/builtins/jspromise.rs Uses context.alloc for state allocation; makes JsFuture cloneable.
core/engine/src/object/builtins/jsfunction.rs Adds empty_intrinsic_function_in and routes old API via global context.
core/engine/src/native_function/mod.rs Switches closure allocations to MutationContext::global() and adjusts downcast/clone with guard deref.
core/engine/src/native_function/continuation.rs Switches coroutine allocations to MutationContext::global() and adjusts raw Gc conversions.
core/engine/src/module/synthetic.rs Threads MutationContext into compilation; switches to context.alloc for codeblock allocation.
core/engine/src/module/source.rs Threads MutationContext into compilation; switches to context.alloc for codeblock allocation.
core/engine/src/module/mod.rs Switches module allocations and test data insertion to context.alloc; adjusts guard cloning.
core/engine/src/module/loader/mod.rs Derives GC traits for module cache key used inside GC-traced structures.
core/engine/src/lib.rs Adds clippy allowances expected under oscars backend (Gc becoming Copy, etc.).
core/engine/src/host_defined.rs Relaxes Finalize bound on HostDefined.
core/engine/src/error/mod.rs Updates downcast/clone patterns and custom_trace! match to match new backend semantics.
core/engine/src/environments/runtime/mod.rs Threads MutationContext through environment stack pushes and updates allocation call sites.
core/engine/src/context/mod.rs Adds Context.gc: GcContext, plus alloc/gc_collector; threads MC through realm/vm creation.
core/engine/src/context/intrinsics.rs Removes Default reliance by introducing uninit(mc) constructors and threading MC through templates/constructors.
core/engine/src/bytecompiler/mod.rs Adds McWrapper and stores MutationContext reference in compiler; threads it to nested compilers.
core/engine/src/bytecompiler/function.rs Threads MC through FunctionCompiler::compile and uses it for codeblock allocation.
core/engine/src/bytecompiler/declarations.rs Passes compiler MC into nested function compilation.
core/engine/src/bytecompiler/class.rs Passes compiler MC into nested compilation and uses it for codeblock allocations.
core/engine/src/builtins/weak/weak_ref.rs Uses context.gc_collector() for WeakGc operations and adjusts tests for oscars backend.
core/engine/src/builtins/weak_set/mod.rs Uses context.gc_collector() and disables tests under oscars backend.
core/engine/src/builtins/weak_map/mod.rs Uses context.gc_collector() + new WeakMap::get_value helper; disables tests under oscars backend.
core/engine/src/builtins/uri/mod.rs Adds uninit_in(mc) and routes default via global context.
core/engine/src/builtins/set/ordered_set.rs Refactors custom_trace! loop variable naming to avoid borrow issues.
core/engine/src/builtins/promise/mod.rs Switches multiple allocations to context.alloc for promise state tracking.
core/engine/src/builtins/json/mod.rs Threads MC into ByteCompiler creation and switches codeblock allocation to context.alloc.
core/engine/src/builtins/iterable/mod.rs Adds uninit_in(mc) and routes default via global context.
core/engine/src/builtins/intl/locale/utils.rs Adjusts downcast/clone to deref guard under oscars backend.
core/engine/src/builtins/intl/locale/mod.rs Adjusts downcast/clone to deref guard under oscars backend.
core/engine/src/builtins/intl/list_format/mod.rs Converts assert to assert_eq!.
core/engine/src/builtins/generator/mod.rs Refactors custom_trace! match to avoid matching on &this.
core/engine/src/builtins/function/mod.rs Threads MC into function compilation and updates environment stack calls.
core/engine/src/builtins/function/arguments.rs Adjusts environment deref under oscars backend.
core/engine/src/builtins/finalization_registry/tests.rs Disables miri tests under oscars backend.
core/engine/src/builtins/finalization_registry/mod.rs Uses context.gc_collector() for weak refs/ephemerons and adjusts upgrade/value paths.
core/engine/src/builtins/eval/mod.rs Threads MC into eval compilation and switches codeblock allocation to context.alloc.
core/engine/Cargo.toml Adds oscars_backend feature mapping to GC/string crates.
core/engine/benches/full.rs Updates benchmark realm creation to pass a MutationContext.
Cargo.toml Adds typeid dependency and patches boa_string git source to local path.
Cargo.lock Updates oscars git revision and adds new transitive deps (typeid, etc.).
.github/workflows/webassembly.yml Adds dev/oscars-gc to workflow branch triggers.
.github/workflows/test262.yml Adds dev/oscars-gc triggers and skips test262 job when targeting that base branch.
.github/workflows/rust.yml Adds dev/oscars-gc to workflow branch triggers.
.github/workflows/pull_request.yml Adds dev/oscars-gc to workflow branch triggers.
Review details

Suppressed comments (1)

core/engine/src/module/loader/mod.rs:294

  • Deriving boa_gc::Trace for ModuleCacheKey will require PathBuf and ImportAttribute to implement Trace, but there doesn't appear to be a Trace impl for those types in the repo. Since these fields contain no GC pointers, mark them with #[unsafe_ignore_trace] so the derive doesn't require Trace bounds.
  • Files reviewed: 89/90 changed files
  • Comments generated: 9
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 225 to 227
self.push_env(Environment::Declarative(Gc::new(
&unsafe { boa_gc::MutationContext::dummy() },
&gc,
DeclarativeEnvironment::new(
Comment thread core/engine/src/builtins/json/mod.rs Outdated
Comment on lines +302 to +307
@@ -302,15 +303,14 @@ impl Json {
false,
false,
context.interner_mut(),
in_with,
&gc,
false,
Comment thread core/engine/src/script.rs
Comment on lines 148 to 151
false,
context.interner_mut(),
&mc,
false,
Comment on lines 323 to 325
context.interner_mut(),
&mc,
false,
Comment on lines 1657 to 1659
context.interner_mut(),
&mc,
false,
Comment on lines 285 to 288
false,
context.interner_mut(),
&mc,
in_with,
Comment on lines 672 to 678
context.realm().scope().clone(),
context.realm().scope().clone(),
function.scopes(),
function.contains_direct_eval(),
context.interner_mut(),
&mc,
);
Comment thread core/engine/src/context/mod.rs Outdated
Comment on lines +550 to +553
pub fn create_realm(&mut self) -> JsResult<Realm> {
let realm = Realm::create(self.host_hooks.as_ref(), &self.root_shape)?;
let realm = Realm::create(self.host_hooks.as_ref(), &self.root_shape, &unsafe {
boa_gc::MutationContext::global()
})?;
Comment on lines +66 to +69
let ephemeron = self.get(key)?;
ephemeron
.value(&unsafe { crate::MutationContext::dummy() })
.map(|v| v.clone())
@shruti2522
shruti2522 force-pushed the feat/msb-phase3-builtins branch 2 times, most recently from 3ae36eb to 00f6c4a Compare August 31, 2026 06:24
@shruti2522
shruti2522 force-pushed the feat/msb-phase3-builtins branch from 00f6c4a to e57db95 Compare August 31, 2026 10:48
@nekevss
nekevss merged commit 4cd194e into boa-dev:dev/oscars-gc Aug 31, 2026
21 checks passed
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Aug 31, 2026
nekevss added a commit that referenced this pull request Sep 1, 2026
…l GC state (#5480)

<!---
Thank you for contributing to Boa! Please fill out the template below,
and remove or add any
information as you feel necessary.
--->

follow up to #5479

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Mustafa Senoglu <mmustafasenoglu0@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler Breisacher <matrixfrog@gmail.com>
Co-authored-by: José Julián Espina <jedel0124@gmail.com>
Co-authored-by: Kaustubh Shivarkar <kaustubh.devlop@gmail.com>
Co-authored-by: Hans Larsen <681969+hansl@users.noreply.github.com>
Co-authored-by: Camilo Díaz Repka <camilojdiaz@gmail.com>
Co-authored-by: mmustafasenoglu <mmustafasenoglu0@gmail.com>
Co-authored-by: Vellumic <161718748+Vellumic@users.noreply.github.com>
Co-authored-by: MAN$I VERMA <vmansi756@gmail.com>
Co-authored-by: Tomáš Olvecký <tomas.olvecky@gmail.com>
Co-authored-by: Pratush Shyam Gupt <143210487+psg-19@users.noreply.github.com>
Co-authored-by: Aayush Mainali <aayushmainali.codes@gmail.com>
Co-authored-by: GordonYuanyc <39959912+GordonYuanyc@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: magic-akari <akari.ccino@gmail.com>
Co-authored-by: Nguyen Anh Tu (Elior) <122720156+xcb3d@users.noreply.github.com>
Co-authored-by: Elior Nguyen <anhtunguyendev@wavenet.com.tw>
Co-authored-by: Hitesh <hiteshshonak1@gmail.com>
Co-authored-by: Kumar Tanay <32425567+tkshsbcue@users.noreply.github.com>
Co-authored-by: jedel1043 <jedel@startmail.com>
Co-authored-by: Zaid <161572905+iammdzaidalam@users.noreply.github.com>
Co-authored-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
Co-authored-by: ChrisJr404 <Sintation@gmail.com>
Co-authored-by: Chris (ChrisJr404) <11917633+ChrisJr404@users.noreply.github.com>
Co-authored-by: Haled Odat <8566042+HalidOdat@users.noreply.github.com>
Co-authored-by: Ayush Raj <light1ooo7710@gmail.com>
Co-authored-by: yush-1018 <yush1018@gmail.com>
Co-authored-by: Kevin Ness <nekevss@gmail.com>
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-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-GC Issue related to garbage collection C-Intl Changes related to the `Intl` implementation 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants