Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0730a11
feat(gc): integrate oscars GC backend into boa_engine
shruti2522 Aug 15, 2026
c80ff49
Migrate to mark_sweep_branded and GcContext abstraction
shruti2522 Aug 15, 2026
bd7e085
Thread MutationContext through core engine and ByteCompiler
shruti2522 Aug 16, 2026
282344b
Thread MutationContext through buitlin standard library objects
shruti2522 Aug 17, 2026
f2ddfe2
Thread MutationContext through core engine and ByteCompiler
shruti2522 Aug 16, 2026
26b7bae
Integrate mark sweep backend and eliminate global GC state
shruti2522 Aug 17, 2026
7a65ccb
Merge branch 'feat/msb-phase3-builtins' into feat/msb-phase4
shruti2522 Aug 18, 2026
516419e
Fix test262 test suite failures for oscars integration
shruti2522 Aug 18, 2026
bc7d8fe
Implement exact rooting via HandleScope
shruti2522 Aug 20, 2026
0efd528
Enable oscars_backend in boa_wasm
shruti2522 Aug 20, 2026
389ac73
fix heap UAF in ListFormat
shruti2522 Aug 23, 2026
0cc9155
fix anchor crash
shruti2522 Aug 23, 2026
3f68447
fix constructor crash
shruti2522 Aug 23, 2026
478ebe6
fix: UAF in Collator::resolved_options and format_to_parts loop
shruti2522 Aug 23, 2026
18f007f
fix: UAF in Intl resolved_options methods across multiple builtins
shruti2522 Aug 23, 2026
fa96371
fix: UAF in PluralRules and Segmenter methods
shruti2522 Aug 23, 2026
b5d4a84
fix: type error in SegmentIterator::next
shruti2522 Aug 23, 2026
5a50231
fix: UAF in RegExpStringIterator and ArrayIterator + serial CI
shruti2522 Aug 23, 2026
38e9a5d
fix: UAF in Generator, StringIterator, SetIterator, MapIterator
shruti2522 Aug 23, 2026
843e41f
fix: UAF in ForInIterator::next and AsyncGeneratorYield opcode
shruti2522 Aug 23, 2026
8a88c82
fix test262
shruti2522 Aug 29, 2026
7836315
fix: point oscars dependency to local fork to include gc integration …
shruti2522 Aug 29, 2026
14d92c1
chore: update oscars dependency to fix GC memory corruption
shruti2522 Aug 29, 2026
096c12a
fix: clippy warnings
shruti2522 Aug 29, 2026
02cd46a
fix: remaining clippy warnings
shruti2522 Aug 29, 2026
9205d34
fix: let_underscore_drop
shruti2522 Aug 29, 2026
0ec143a
Merge remote-tracking branch 'upstream/dev/oscars-gc' into fix-test262
shruti2522 Sep 5, 2026
dec7462
format
shruti2522 Sep 5, 2026
f8c09e6
fix clippy
shruti2522 Sep 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test262.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
run: |
cd boa
mkdir -p ../results/test262
cargo run --release --bin boa_tester -- run -v -o ../results/test262
cargo run --release --bin boa_tester -- run -v --disable-parallelism -o ../results/test262
cd ..
- name: Compare results
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ rand = "0.10.2"
num-integer = "0.1.47"
ryu-js = "1.0.3"
tap = "1.0.1"
thiserror = { version = "2.0.20", default-features = false }
thiserror = { version = "2.0.18", default-features = false }
typeid = "1.0.3"
dashmap = "6.2.1"
num_enum = "0.7.6"
Expand Down
10 changes: 4 additions & 6 deletions core/engine/benches/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

fn create_realm(c: &mut Criterion) {
c.bench_function("Create Realm", move |b| {
let root_shape = RootShape::new(&boa_gc::MutationContext::global());
let root_shape = RootShape::new(&unsafe { boa_gc::MutationContext::global() });
b.iter(|| {
Realm::create(
&DefaultHooks,
&root_shape,
&boa_gc::MutationContext::global(),
)
Realm::create(&DefaultHooks, &root_shape, &unsafe {
boa_gc::MutationContext::global()
})
});
});
}
Expand Down
47 changes: 34 additions & 13 deletions core/engine/src/builtins/array/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,36 @@ impl ArrayIterator {
///
/// [spec]: https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next
pub(crate) fn next(this: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsValue> {
let object = this.as_object();
let mut array_iterator = object
.as_ref()
.and_then(JsObject::downcast_mut::<Self>)
let object = this
.as_object()
.filter(|o| o.is::<Self>())
.ok_or_else(|| JsNativeError::typ().with_message("`this` is not an ArrayIterator"))?;
let index = array_iterator.next_index;
if array_iterator.done {

// Extract needed fields into a scoped block so the RefMut borrow is dropped
// before any context call. Holding a RefMut<'_, T> across context operations
// is a use-after-free: GC can collect the backing object while the guard is live.
let (index, done, array, kind) = {
let array_iterator = object
.downcast_ref::<Self>()
.expect("already checked that it is an ArrayIterator");
(
array_iterator.next_index,
array_iterator.done,
array_iterator.array.clone(),
array_iterator.kind,
)
};
// RefMut dropped here — safe to use context below.

if done {
return Ok(create_iter_result_object(
JsValue::undefined(),
true,
context,
));
}

let len = if let Some(f) = array_iterator.array.downcast_ref::<TypedArray>() {
let len = if let Some(f) = array.downcast_ref::<TypedArray>() {
let buf = f.viewed_array_buffer().as_buffer();
let Some(buf) = buf
.bytes(std::sync::atomic::Ordering::SeqCst)
Expand All @@ -122,26 +137,32 @@ impl ArrayIterator {

f.array_length(buf.len())
} else {
array_iterator.array.length_of_array_like(context)?
array.length_of_array_like(context)?
};

if index >= len {
array_iterator.done = true;
object.downcast_mut::<Self>().expect("already checked").done = true;
return Ok(create_iter_result_object(
JsValue::undefined(),
true,
context,
));
}
array_iterator.next_index = index + 1;
match array_iterator.kind {

// Write back the incremented index (no borrow held during context calls above).
object
.downcast_mut::<Self>()
.expect("already checked")
.next_index = index + 1;

match kind {
PropertyNameKind::Key => Ok(create_iter_result_object(index.into(), false, context)),
PropertyNameKind::Value => {
let element_value = array_iterator.array.get(index, context)?;
let element_value = array.get(index, context)?;
Ok(create_iter_result_object(element_value, false, context))
}
PropertyNameKind::KeyAndValue => {
let element_value = array_iterator.array.get(index, context)?;
let element_value = array.get(index, context)?;
let result = Array::create_array_from_list([index.into(), element_value], context);
Ok(create_iter_result_object(result.into(), false, context))
}
Expand Down
2 changes: 2 additions & 0 deletions core/engine/src/builtins/array/from_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl Array {
// Coroutine yielded. We need to allocate it for a future execution.
JsPromise::resolve(value, context)?.await_native(
NativeCoroutine::from_copy_closure_with_captures(
context.gc_collector(),
from_array_like,
coroutine_state,
),
Expand Down Expand Up @@ -174,6 +175,7 @@ impl Array {
CoroutineState::Continue(value) => {
JsPromise::resolve(value, context)?.await_native(
NativeCoroutine::from_copy_closure_with_captures(
context.gc_collector(),
from_async_iterator,
coroutine_state,
),
Expand Down
2 changes: 2 additions & 0 deletions core/engine/src/builtins/async_generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ impl AsyncGenerator {
context.realm(),
context.gc_collector(),
NativeFunction::from_copy_closure_with_captures(
context.gc_collector(),
|_this, args, generator, context| {
// a. Assert: generator.[[AsyncGeneratorState]] is draining-queue.
assert_eq!(
Expand Down Expand Up @@ -614,6 +615,7 @@ impl AsyncGenerator {
context.realm(),
context.gc_collector(),
NativeFunction::from_copy_closure_with_captures(
context.gc_collector(),
|_this, args, generator, context| {
// a. Assert: generator.[[AsyncGeneratorState]] is draining-queue.
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions core/engine/src/builtins/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl Eval {
false,
false,
context.interner_mut(),
mc,
&mc,
in_with,
spanned_source_text,
// TODO: Could give more information from previous shadow stack.
Expand Down Expand Up @@ -351,7 +351,7 @@ impl Eval {
let global = frame.realm.environment();
frame
.environments
.push_lexical(lexical_scope.num_bindings_non_local(), global, mc);
.push_lexical(lexical_scope.num_bindings_non_local(), &global, mc);
}

context
Expand Down
2 changes: 0 additions & 2 deletions core/engine/src/builtins/finalization_registry/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// oscars_backend currently implements `boa_gc::force_collect()` as a no-op, which prevents
// the FinalizationRegistry callbacks from being triggered during these tests.
#[cfg(not(feature = "oscars_backend"))]
mod miri {

Expand Down
10 changes: 5 additions & 5 deletions core/engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ impl BuiltInFunctionObject {
function.scopes(),
function.contains_direct_eval(),
context.interner_mut(),
mc,
&mc,
);

let saved = context.vm.frame_mut().environments.pop_to_global();
Expand Down Expand Up @@ -1079,7 +1079,7 @@ pub(crate) fn function_call(
let mc = context.gc_collector();
let frame = context.vm.frame_mut();
let global = frame.realm.environment();
let index = frame.environments.push_lexical(1, global, mc);
let index = frame.environments.push_lexical(1, &global, mc);
frame.environments.put_lexical_value(
BindingLocatorScope::Stack(index),
0,
Expand All @@ -1097,7 +1097,7 @@ pub(crate) fn function_call(
frame.environments.push_function(
scope,
FunctionSlots::new(this, function_object.clone(), None),
global,
&global,
mc,
);
}
Expand Down Expand Up @@ -1191,7 +1191,7 @@ fn function_construct(
let mc = context.gc_collector();
let frame = context.vm.frame_mut();
let global = frame.realm.environment();
let index = frame.environments.push_lexical(1, global, mc);
let index = frame.environments.push_lexical(1, &global, mc);
frame.environments.put_lexical_value(
BindingLocatorScope::Stack(index),
0,
Expand Down Expand Up @@ -1220,7 +1220,7 @@ fn function_construct(
.clone(),
),
),
global,
&global,
mc,
);
}
Expand Down
1 change: 1 addition & 0 deletions core/engine/src/builtins/function/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ fn closure_capture_clone() {
ctx.realm(),
ctx.gc_collector(),
NativeFunction::from_copy_closure_with_captures(
ctx.gc_collector(),
|_, _, captures, context| {
let (string, object) = &captures;

Expand Down
4 changes: 4 additions & 0 deletions core/engine/src/builtins/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl Generator {
// 2. If state is completed, return CreateIterResultObject(undefined, true).
GeneratorState::Completed => {
r#gen.state = GeneratorState::Completed;
drop(r#gen);
return Ok(create_iter_result_object(
JsValue::undefined(),
true,
Expand Down Expand Up @@ -323,6 +324,7 @@ impl Generator {
}
CompletionRecord::Return(value) => {
r#gen.state = GeneratorState::Completed;
drop(r#gen);
Ok(create_iter_result_object(value, true, context))
}
CompletionRecord::Throw(err) => {
Expand Down Expand Up @@ -374,6 +376,7 @@ impl Generator {
// b. Once a generator enters the completed state it never leaves it and its
// associated execution context is never resumed. Any execution state associated
// with generator can be discarded at this point.
drop(r#gen);

// a. If abruptCompletion.[[Type]] is return, then
if let Ok(value) = abrupt_completion {
Expand Down Expand Up @@ -414,6 +417,7 @@ impl Generator {
}
CompletionRecord::Return(value) => {
r#gen.state = GeneratorState::Completed;
drop(r#gen);
Ok(create_iter_result_object(value, true, context))
}
CompletionRecord::Throw(err) => {
Expand Down
Loading
Loading