Skip to content

[oscars-integration] Integrate mark_sweep_branded backend - #5474

Open
shruti2522 wants to merge 2 commits into
boa-dev:dev/oscars-gcfrom
shruti2522:feat/msb-swap
Open

[oscars-integration] Integrate mark_sweep_branded backend#5474
shruti2522 wants to merge 2 commits into
boa-dev:dev/oscars-gcfrom
shruti2522:feat/msb-swap

Conversation

@shruti2522

Copy link
Copy Markdown
Contributor

Stacked on #5460

Integrate oscars's mark_sweep_branded backend across boa_engine, replacing the custom GC with a compile time safe, branded lifetime alternative.

boa_gc now wraps mark_sweep_branded::Gc and MutationContext<'id, 'gc>. Lifetimes are strictly validated at compile time via branding, eliminating runtime tracking overhead.

Bumped oscars to include 5–8 element tuple Trace implementations required by Boa's AST.

Not covered, deliberately

Performance tuning. This PR focuses entirely on soundness and compilation under the new GC model. Benchmarks and optimizations will be done in follow up PRs

@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Aug 10, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Aug 10, 2026
@github-actions github-actions Bot added C-Dependencies Pull requests that update a dependency file 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-AST Issue surrounding the abstract syntax tree 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 10, 2026
@shruti2522 shruti2522 changed the title Integrate mark_sweep_branded backend [oscars-integration] Integrate mark_sweep_branded backend Aug 10, 2026
@shruti2522
shruti2522 force-pushed the feat/msb-swap branch 2 times, most recently from bcfa1a5 to 340c975 Compare August 10, 2026 03:29
@github-actions github-actions Bot added the C-Benchmark Issues and PRs related to the benchmark subsystem. label Aug 11, 2026
@shruti2522
shruti2522 force-pushed the feat/msb-swap branch 3 times, most recently from 5933276 to 40d442a Compare August 11, 2026 22:43
@shruti2522
shruti2522 force-pushed the feat/msb-swap branch 3 times, most recently from 10a76ca to 3495ea6 Compare August 15, 2026 06:05
Copilot AI lite review requested due to automatic review settings August 17, 2026 20:21

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

This PR continues the oscars GC migration by wiring the mark_sweep_branded backend through boa_gc, updating Boa to allocate via a GC context, and adjusting many call sites to compile under the new branded/guard-based APIs.

Changes:

  • Introduces boa_gc::GcContext and threads allocation through Context::alloc()/Context::gc_collector(), replacing many direct MutationContext::dummy() uses.
  • Adds oscars_backend feature plumbing across boa_gc, boa_engine, and boa_string, including a dummy WeakMap shim for oscars.
  • Updates a broad set of engine/runtime code to handle new borrow/guard return types (GcRef, GcRefMut) by dereferencing before cloning.

Reviewed changes

Copilot reviewed 79 out of 80 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/macros/tests/gcd_callback.rs Updates test to use MutationContext::global() and adjusts lints.
tests/fuzz/Cargo.toml Adds a local patch override for boa_string in fuzz crate.
examples/src/bin/jstypedarray.rs Updates example allocation to use MutationContext::global().
examples/src/bin/derive.rs Adds dead_code allow to keep example compiling.
core/string/src/tests.rs Replaces assert!(.. == ..) with assert_eq! for clearer failures.
core/string/src/lib.rs Adds oscars Trace/Finalize impls for JsString behind oscars_backend.
core/string/src/builder.rs Small refactors/attributes around latin1 conversion code paths.
core/string/Cargo.toml Adds optional oscars dep + oscars_backend feature.
core/runtime/src/test262.rs Adjusts downcast/clone patterns for new guard-based borrows.
core/runtime/src/microtask/tests.rs Derefs borrow guards before cloning logs.
core/runtime/src/console/tests.rs Derefs borrow guards; loosens some log substring assertions.
core/runtime/src/abort/mod.rs Derefs borrow guard before cloning abort reason.
core/macros/src/lib.rs Updates Trace derive implementation to better handle ref bindings and cloning.
core/interner/src/sym.rs Switches Sym to #[derive(Trace)] with #[unsafe_ignore_trace] field.
core/gc/src/trace.rs Wraps custom trace bodies in an unsafe block for consistency.
core/gc/src/test/weak.rs Updates ephemeron size test for new Gc<'_, T> form.
core/gc/src/pointers/weak_map.rs Adds WeakMap::get_value() helper.
core/gc/src/pointers/mutation_context.rs Makes dummy() const; adds global() alias.
core/gc/src/oscars_weak_map.rs Adds oscars-backend dummy/leaky WeakMap implementation.
core/gc/src/lib.rs Switches oscars backend exports to mark_sweep_branded, adds type_id_of, macros, and weak map shim.
core/gc/src/context.rs Adds GcContext abstraction used by Context::alloc()/gc_collector().
core/gc/src/cell.rs Assertion style cleanup (assert_eq!, debug_assert_eq!).
core/gc/Cargo.toml Updates feature wiring and oscars dependency; adds typeid optional dep.
core/engine/src/vm/tests.rs Disables a GC-stress test under oscars_backend.
core/engine/src/vm/opcode/push/environment.rs Threads global mutation context into environment pushes; uses Context::alloc() in one path.
core/engine/src/vm/opcode/function.rs Explicitly types closure arg to satisfy inference under new API.
core/engine/src/vm/opcode/await/mod.rs Uses Context::alloc() for captures; adjusts clone usage.
core/engine/src/vm/mod.rs Switches initial CodeBlock allocation to MutationContext::global().
core/engine/src/vm/inline_cache/mod.rs Adds an explicit Shape binding to satisfy type expectations.
core/engine/src/vm/code_block.rs Adds clippy allow for clone_on_copy on constants accessor.
core/engine/src/value/integer.rs Assertion style cleanup (assert_eq!/assert_ne!).
core/engine/src/value/inner/nan_boxed.rs Adjusts raw pointer handling to match new JsObject::{into_raw,from_raw} signatures.
core/engine/src/value/inner/legacy.rs Updates trace match style to avoid borrowing patterns.
core/engine/src/value/equality.rs Assertion style cleanup (debug_assert_eq!).
core/engine/src/script.rs Allocates script internals and compiled code via Context::alloc().
core/engine/src/realm.rs Uses MutationContext::global() for realm/env allocations.
core/engine/src/object/shape/unique_shape.rs Updates allocations/upgrades to global(); derefs guard before cloning prototype.
core/engine/src/object/shape/shared_shape/mod.rs Updates allocations/upgrades; disables tests under oscars_backend.
core/engine/src/object/shape/shared_shape/forward_transition.rs Updates WeakGc::new calls; disables tests under oscars_backend; adds clippy allows.
core/engine/src/object/mod.rs Documents TypeId differences between Any and oscars typeid.
core/engine/src/object/jsobject.rs Changes raw object pointer API to *const (); uses global() for allocations.
core/engine/src/object/builtins/jsweakset.rs Constructs weak set map with context.gc_collector().
core/engine/src/object/builtins/jsweakmap.rs Constructs weak map with context.gc_collector().
core/engine/src/object/builtins/jstypedarray.rs Updates docs to use context.alloc(...) in example.
core/engine/src/object/builtins/jspromise.rs Uses Context::alloc() for promise state; adds Clone for JsFuture.
core/engine/src/native_function/mod.rs Updates closure allocation and downcast cloning patterns for guard-based borrows.
core/engine/src/native_function/continuation.rs Updates coroutine closure allocation for global() and new from_raw typing.
core/engine/src/module/synthetic.rs Uses Context::alloc() for compiled code; threads mutation context into env stack.
core/engine/src/module/source.rs Uses Context::alloc() for compiled module code; threads mutation context into env stack.
core/engine/src/module/mod.rs Uses Context::alloc() for module repr; updates a test to deref borrow guard before cloning.
core/engine/src/module/loader/mod.rs Adds GC derives on module cache key used in GcRefCell map.
core/engine/src/lib.rs Adds clippy allows to accommodate Gc being Copy under oscars backend.
core/engine/src/host_defined.rs Relaxes Finalize bound for HostDefined<T>.
core/engine/src/error/mod.rs Updates downcast clone patterns; minor trace match style change.
core/engine/src/environments/runtime/mod.rs Threads mutation context into env stack push APIs; uses global() for env nodes.
core/engine/src/context/mod.rs Adds GcContext to Context, plus alloc()/gc_collector() helpers.
core/engine/src/bytecompiler/function.rs Switches code block allocation to MutationContext::global().
core/engine/src/bytecompiler/class.rs Switches multiple code block allocations to MutationContext::global().
core/engine/src/builtins/weak/weak_ref.rs Uses context.gc_collector() for weak refs; disables tests under oscars_backend.
core/engine/src/builtins/weak_set/mod.rs Uses context.gc_collector(); disables tests under oscars_backend.
core/engine/src/builtins/weak_map/mod.rs Migrates weak map storage access patterns; uses get_value(); adjusts borrows for oscars.
core/engine/src/builtins/set/ordered_set.rs Minor trace loop variable rename cleanup.
core/engine/src/builtins/promise/mod.rs Uses Context::alloc() for multiple GC allocations.
core/engine/src/builtins/json/mod.rs Uses Context::alloc() for compiled code; derefs guard before cloning bigint.
core/engine/src/builtins/intl/locale/utils.rs Derefs guard before cloning locale.
core/engine/src/builtins/intl/locale/mod.rs Derefs guard before cloning locale in maximize/minimize.
core/engine/src/builtins/intl/list_format/mod.rs Assertion style cleanup (assert_eq!).
core/engine/src/builtins/generator/mod.rs Updates trace match style to avoid borrowing patterns.
core/engine/src/builtins/function/mod.rs Threads mutation context into environment stack pushes.
core/engine/src/builtins/function/arguments.rs Derefs environment guard before calling .get(...); adds clippy allows.
core/engine/src/builtins/finalization_registry/tests.rs Disables miri tests under oscars_backend.
core/engine/src/builtins/finalization_registry/mod.rs Updates weak GC usage to context.gc_collector()/global(), adjusts register/unregister signatures.
core/engine/Cargo.toml Adds oscars_backend feature wiring to gc/string crates.
Cargo.toml Adds typeid dependency and patches boa_string for git URL builds.
Cargo.lock Updates oscars git revision and adds typeid + feature deps.
.github/workflows/webassembly.yml Enables workflow on dev/oscars-gc branch.
.github/workflows/test262.yml Enables workflow on dev/oscars-gc branch; skips job when targeting that base branch.
.github/workflows/rust.yml Enables workflow on dev/oscars-gc branch.
.github/workflows/pull_request.yml Enables workflow on dev/oscars-gc branch.
Suppressed comments (1)

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

  • Deriving boa_gc::Trace for ModuleCacheKey will likely fail because PathBuf and Box<[ImportAttribute]> don't implement Trace (and they don't contain GC pointers anyway). Since this key is stored inside a GC-traced GcRefCell<FxHashMap<...>>, it should use an empty trace implementation and explicitly ignore the non-GC fields.
#[derive(Debug, Clone, PartialEq, Eq, Hash, boa_gc::Trace, boa_gc::Finalize)]
struct ModuleCacheKey {
    path: PathBuf,
    attributes: Box<[ImportAttribute]>,
}

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

Comment thread core/gc/src/context.rs
Comment on lines +30 to +34
pub fn gc_collector(&self) -> &MutationContext<'static, 'static> {
// Just return a dummy global mutation context
// This is safe for the bridge phase.
unimplemented!("Not supported natively without closure yet, use MutationContext::global()")
}

pub(crate) kept_alive: Vec<JsObject>,

pub gc: boa_gc::GcContext,
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-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. Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants