Skip to content

Commit 005d477

Browse files
committed
Be aware of key/value weakness and forwarding
1 parent ad8b29a commit 005d477

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

mmtk/src/abi.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,14 @@ pub struct RubyUpcalls {
389389
entries_bound: *mut libc::size_t,
390390
bins_num: *mut libc::size_t,
391391
),
392-
pub st_update_entries_range:
393-
extern "C" fn(table: *mut st_table, begin: libc::size_t, end: libc::size_t),
392+
pub st_update_entries_range: extern "C" fn(
393+
table: *mut st_table,
394+
begin: libc::size_t,
395+
end: libc::size_t,
396+
weak_keys: bool,
397+
weak_records: bool,
398+
forward: bool,
399+
),
394400
pub st_update_bins_range:
395401
extern "C" fn(table: *mut st_table, begin: libc::size_t, end: libc::size_t),
396402
}

mmtk/src/utils.rs

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pub struct AfterAll {
5555
packets: AtomicRefCell<Vec<Box<dyn GCWork<Ruby>>>>,
5656
}
5757

58+
unsafe impl Sync for AfterAll {}
59+
5860
impl AfterAll {
5961
pub fn new(stage: WorkBucketStage) -> Self {
6062
Self {

mmtk/src/weak_proc.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,34 @@ impl WeakProcessor {
7676
Box::new(UpdateWbUnprotectedObjectsList) as _,
7777
]);
7878

79+
let forward = crate::mmtk().get_plan().current_gc_may_move_object();
80+
7981
// Experimenting with frozen strings table
8082
Self::process_weak_table_chunked(
8183
"frozen strings",
8284
(upcalls().get_frozen_strings_table)(),
85+
true,
86+
false,
87+
forward,
8388
worker,
8489
);
8590

8691
Self::process_weak_table_chunked(
8792
"global symbols",
8893
(upcalls().get_global_symbols_table)(),
94+
false,
95+
true,
96+
forward,
8997
worker,
9098
);
9199
}
92100

93101
pub fn process_weak_table_chunked(
94102
name: &str,
95103
table: *mut st_table,
104+
weak_keys: bool,
105+
weak_values: bool,
106+
forward: bool,
96107
worker: &mut GCWorker<Ruby>,
97108
) {
98109
let mut entries_start = 0;
@@ -118,6 +129,9 @@ impl WeakProcessor {
118129
table,
119130
begin,
120131
end,
132+
weak_keys,
133+
weak_values,
134+
forward,
121135
after_all,
122136
}) as _
123137
})
@@ -281,6 +295,9 @@ struct UpdateTableEntriesParallel {
281295
table: *mut st_table,
282296
begin: usize,
283297
end: usize,
298+
weak_keys: bool,
299+
weak_values: bool,
300+
forward: bool,
284301
after_all: Arc<AfterAll>,
285302
}
286303

@@ -291,7 +308,14 @@ impl UpdateTableEntriesParallel {}
291308
impl GCWork<Ruby> for UpdateTableEntriesParallel {
292309
fn do_work(&mut self, worker: &mut GCWorker<Ruby>, _mmtk: &'static mmtk::MMTK<Ruby>) {
293310
debug!("Updating entries of {} table", self.name);
294-
(upcalls().st_update_entries_range)(self.table, self.begin, self.end);
311+
(upcalls().st_update_entries_range)(
312+
self.table,
313+
self.begin,
314+
self.end,
315+
self.weak_keys,
316+
self.weak_values,
317+
self.forward,
318+
);
295319
debug!("Done updating entries of {} table", self.name);
296320
self.after_all.count_down(worker);
297321
}

0 commit comments

Comments
 (0)