Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 49 additions & 8 deletions majit/majit-gc/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7135,15 +7135,35 @@ impl MiniMarkGC {
self.oldgen_nonmoving_active = true;
self.oldgen_nonmoving_young_marks.clear();

if self.gc_state == GcState::Scanning {
self.start_incremental_cycle();
}
// `do_collect_full` / incminimark.py `gc_step_until` first finishes
// an in-progress major, then starts a fresh cycle whose root snapshot
// is taken at the explicit collection boundary. The non-moving twin
// owes the same ordering: merely finishing an older cycle can retain
// an object which became unreachable after that cycle began.
if self.gc_state != GcState::Scanning {
self.gc_step_until_scanning();
self.clear_oldgen_nonmoving_young_marks();
}
self.start_incremental_cycle();
// Keep this oldgen-only entry stop-the-world: it may enter while
// MARKING or SWEEPING, but always returns after the complete cycle.
self.gc_step_until_scanning();

// Strictly-last: clear VISITED on every young object greyed this cycle
// (the oldgen sweep already cleared it on old-gen survivors).
self.clear_oldgen_nonmoving_young_marks();
self.oldgen_nonmoving_active = false;

// This entry has no upstream counterpart, but it is a public collection
// entry point and it can queue mirrors, so it owes the same schedule.
self.rrc_invoke_callback();
}

/// Clear the nursery VISITED bits accumulated by one non-moving major.
/// A fresh explicit cycle must begin with those bits clear or its marker
/// will mistake the preceding cycle's young survivors for already-traced
/// objects and skip their old-generation children.
fn clear_oldgen_nonmoving_young_marks(&mut self) {
let marks = std::mem::take(&mut self.oldgen_nonmoving_young_marks);
for addr in marks {
// Nothing moved and nothing young was freed, so each addr is still
Expand All @@ -7154,11 +7174,6 @@ impl MiniMarkGC {
unsafe { (*hdr).clear_flag(flags::VISITED) };
}
}
self.oldgen_nonmoving_active = false;

// This entry has no upstream counterpart, but it is a public collection
// entry point and it can queue mirrors, so it owes the same schedule.
self.rrc_invoke_callback();
}

fn gc_step_until_scanning(&mut self) {
Expand Down Expand Up @@ -13811,6 +13826,32 @@ cache size\t: 8192 kB\n";
gc.roots.clear();
}

/// An explicit non-moving collection must use roots observed at the call,
/// not merely finish an incremental cycle whose root snapshot predates a
/// release. This is the non-moving counterpart of `do_collect_full`'s
/// initial `gc_step_until_scanning_with_minors` followed by a fresh cycle.
#[test]
fn nonmoving_major_starts_fresh_after_finishing_an_in_progress_cycle() {
let mut gc = test_gc(4096);
let tid = gc.register_type(TypeInfo::simple(16));
let object = gc.alloc_in_oldgen_clear(tid, GcHeader::SIZE + 16);
let mut root = object;
unsafe { gc.roots.add(&mut root) };

// Seed the in-progress cycle while `object` is live, then release it.
gc.major_collection_step();
assert_ne!(gc.gc_state, GcState::Scanning);
gc.roots.clear();

gc.do_collect_oldgen_nonmoving();

assert_eq!(
gc.oldgen.object_count(),
0,
"the explicit collection's fresh root snapshot must sweep object"
);
}

/// A non-moving major must run `invalidate_old_weakrefs` (reads the
/// target's VISITED) BEFORE the nursery-VISITED clear, so an old weakref
/// whose target is a live nursery object is kept, not spuriously nulled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ fn count_program(n: i64) -> Vec<i64> {
}

static COMPILES: AtomicU32 = AtomicU32::new(0);
// Both tests install the same capture-free compile callback, hence share the
// process-global counter. Rust runs sibling tests concurrently; keep each
// reset/run/read interval indivisible just as
// `jit_interp_halt_arm_post_loop_expression::run` does for its probe.
static PROBE_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());

struct VmState {
regs: Vec<i64>,
Expand Down Expand Up @@ -151,6 +156,7 @@ fn clean_interp(program: &Bytecode) -> i64 {

#[test]
fn a_label_entered_deopt_resumes_at_the_green_pc() {
let _guard = PROBE_LOCK.lock().unwrap_or_else(|e| e.into_inner());
for n in [1_000i64, 1_001] {
let program = count_program(n);
COMPILES.store(0, Ordering::Relaxed);
Expand Down Expand Up @@ -179,6 +185,7 @@ fn a_label_entered_deopt_resumes_at_the_green_pc() {
/// attributed to the compiled tier rather than to the bytecode or the fixture.
#[test]
fn the_same_machine_without_tracing_answers_n() {
let _guard = PROBE_LOCK.lock().unwrap_or_else(|e| e.into_inner());
for n in [1_000i64, 1_001] {
let program = count_program(n);
COMPILES.store(0, Ordering::Relaxed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=468
guard_failures=687
internal_compile_panics=0
loops_aborted=0
loops_compiled=8
Expand Down
5 changes: 4 additions & 1 deletion pyre/bench/synth/bound_method_builtin_fold.dynasm.jitstats
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=468
guard_failures=687
internal_compile_panics=0
loops_aborted=0
loops_compiled=8
Expand Down
5 changes: 4 additions & 1 deletion pyre/bench/synth/bound_method_builtin_fold.wasm.jitstats
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=468
guard_failures=687
internal_compile_panics=0
loops_aborted=0
loops_compiled=8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
bridges_compiled=14
bridges_compiled=10
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=2810
guard_failures=2014
internal_compile_panics=0
loops_aborted=0
loops_compiled=6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
bridges_compiled=14
bridges_compiled=10
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=2810
guard_failures=2014
internal_compile_panics=0
loops_aborted=0
loops_compiled=6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
bridges_compiled=14
bridges_compiled=10
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=2810
guard_failures=2014
internal_compile_panics=0
loops_aborted=0
loops_compiled=6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
bridges_compiled=3
bridges_compiled=2
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=601
guard_failures=401
internal_compile_panics=0
loops_aborted=0
loops_compiled=3
retraces_compiled=0
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
bridges_compiled=3
bridges_compiled=2
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=601
guard_failures=401
internal_compile_panics=0
loops_aborted=0
loops_compiled=3
retraces_compiled=0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=3
bridges_compiled=2
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=601
guard_failures=401
internal_compile_panics=0
loops_aborted=0
loops_compiled=3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=4
bridges_compiled=5
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=807
guard_failures=1007
internal_compile_panics=0
loops_aborted=0
loops_compiled=11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=4
bridges_compiled=5
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=807
guard_failures=1007
internal_compile_panics=0
loops_aborted=0
loops_compiled=11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=4
bridges_compiled=5
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=807
guard_failures=1007
internal_compile_panics=0
loops_aborted=0
loops_compiled=11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=4
bridges_compiled=2
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=604
guard_failures=403
internal_compile_panics=0
loops_aborted=0
loops_compiled=6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=4
bridges_compiled=2
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=604
guard_failures=403
internal_compile_panics=0
loops_aborted=0
loops_compiled=6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bridges_compiled=4
bridges_compiled=2
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
Expand All @@ -11,7 +11,7 @@ fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=604
guard_failures=403
internal_compile_panics=0
loops_aborted=0
loops_compiled=6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
bridges_compiled=12
bridges_compiled=11
descr_set_absent=0
descr_set_ambiguous=0
descr_set_stale_absent=0
fbw_blackhole_adopted_multi_frame=0
fbw_blackhole_adopted_single_frame=0
fbw_escape_plain_fallback=0
fbw_escape_plain_fallback_unclean=0
fbw_midbody_latch_new_unjournaled=0
fbw_rolled_back_with_effects=0
fbw_store_journal_rollback_failed=0
field_pos_attached_misplaced=0
field_pos_spec_misplaced=0
guard_failures=2461
guard_failures=2261
internal_compile_panics=0
loops_aborted=0
loops_compiled=3
retraces_compiled=0
Loading
Loading