[oscars-integration] Integrate mark_sweep_branded backend - #5474
Open
shruti2522 wants to merge 2 commits into
Open
[oscars-integration] Integrate mark_sweep_branded backend#5474shruti2522 wants to merge 2 commits into
shruti2522 wants to merge 2 commits into
Conversation
shruti2522
force-pushed
the
feat/msb-swap
branch
from
August 10, 2026 02:22
2509a86 to
5487806
Compare
shruti2522
force-pushed
the
feat/msb-swap
branch
2 times, most recently
from
August 10, 2026 03:29
bcfa1a5 to
340c975
Compare
shruti2522
force-pushed
the
feat/msb-swap
branch
3 times, most recently
from
August 11, 2026 22:43
5933276 to
40d442a
Compare
shruti2522
force-pushed
the
feat/msb-swap
branch
3 times, most recently
from
August 15, 2026 06:05
10a76ca to
3495ea6
Compare
shruti2522
force-pushed
the
feat/msb-swap
branch
from
August 15, 2026 06:31
3495ea6 to
c80ff49
Compare
shruti2522
marked this pull request as ready for review
August 17, 2026 20:21
Contributor
There was a problem hiding this comment.
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::GcContextand threads allocation throughContext::alloc()/Context::gc_collector(), replacing many directMutationContext::dummy()uses. - Adds
oscars_backendfeature plumbing acrossboa_gc,boa_engine, andboa_string, including a dummyWeakMapshim 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::TraceforModuleCacheKeywill likely fail becausePathBufandBox<[ImportAttribute]>don't implementTrace(and they don't contain GC pointers anyway). Since this key is stored inside a GC-tracedGcRefCell<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 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #5460
Integrate oscars's
mark_sweep_brandedbackend acrossboa_engine, replacing the custom GC with a compile time safe, branded lifetime alternative.boa_gcnow wrapsmark_sweep_branded::GcandMutationContext<'id, 'gc>. Lifetimes are strictly validated at compile time via branding, eliminating runtime tracking overhead.Bumped
oscarsto include 5–8 element tupleTraceimplementations 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