Skip to content

Commit 191c8db

Browse files
committed
Update ruby repo revision
We merged the ruby repo with the master branch. The upstream changed the global symbols table to a concurrent set. We handle it in a way similar to the fstrings table.
1 parent 3d35f50 commit 191c8db

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

mmtk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition = "2021"
1212
# Metadata for the Ruby repository
1313
[package.metadata.ci-repos.ruby]
1414
repo = "mmtk/ruby" # This is used by actions/checkout, so the format is "owner/repo", not URL.
15-
rev = "2bfc164e05d672cac6dfb5dad303636c6195828a"
15+
rev = "e3be189efb1ddd31949519d9a7201abd7a62a0f2"
1616

1717
[lib]
1818
name = "mmtk_ruby"

mmtk/src/abi.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::api::RubyMutator;
22
use crate::{extra_assert, upcalls, Ruby};
33
use mmtk::scheduler::GCWorker;
4+
use mmtk::util::api_util::NullableObjectReference;
45
use mmtk::util::{Address, ObjectReference, VMMutatorThread, VMWorkerThread};
56

67
// For the C binding
@@ -11,6 +12,9 @@ pub const GC_THREAD_KIND_WORKER: libc::c_int = 1;
1112

1213
pub const HIDDEN_SIZE_MASK: usize = 0x0000FFFFFFFFFFFF;
1314

15+
pub const MMTK_WEAK_CONCURRENT_SET_KIND_FSTRING: u8 = 0;
16+
pub const MMTK_WEAK_CONCURRENT_SET_KIND_GLOBAL_SYMBOLS: u8 = 1;
17+
1418
// An opaque type for the C counterpart.
1519
#[allow(non_camel_case_types)]
1620
pub struct st_table;
@@ -361,8 +365,8 @@ pub struct RubyUpcalls {
361365
pub get_cc_refinement_table_size: extern "C" fn() -> usize,
362366
pub update_cc_refinement_table: extern "C" fn(),
363367
// Get tables for specialized processing
364-
pub get_fstring_table_obj: extern "C" fn() -> ObjectReference,
365-
pub get_global_symbols_table: extern "C" fn() -> *mut st_table,
368+
pub get_fstring_table_obj: extern "C" fn() -> NullableObjectReference,
369+
pub get_global_symbols_table_obj: extern "C" fn() -> NullableObjectReference,
366370
// Detailed st_table info queries and operations
367371
pub st_get_num_entries: extern "C" fn(table: *const st_table) -> usize,
368372
pub st_get_size_info: extern "C" fn(
@@ -388,6 +392,7 @@ pub struct RubyUpcalls {
388392
set: ObjectReference,
389393
begin: usize,
390394
end: usize,
395+
kind: u8,
391396
stats: *mut ConcurrentSetStats,
392397
),
393398
// Memory protection for code memory

mmtk/src/weak_proc.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use mmtk::{
66
vm::ObjectTracerContext,
77
};
88

9-
use crate::{abi::GCThreadTLS, extra_assert, is_mmtk_object_safe, upcalls, Ruby};
9+
use crate::{
10+
abi::{self, GCThreadTLS},
11+
extra_assert, is_mmtk_object_safe, upcalls, Ruby,
12+
};
1013

1114
pub mod concurrent_set_parallel;
1215
pub mod st_table_parallel;
@@ -17,6 +20,13 @@ const SPECIALIZE_FSTRING_TABLE_PROCESSING: bool = true;
1720
/// Set this to true to use chunked processing optimization for the global symbols table.
1821
const SPECIALIZE_GLOBAL_SYMBOLS_TABLE_PROCESSING: bool = true;
1922

23+
#[repr(u8)]
24+
#[derive(Clone, Copy)]
25+
pub enum WeakConcurrentSetKind {
26+
FString = abi::MMTK_WEAK_CONCURRENT_SET_KIND_FSTRING,
27+
GlobalSymbols = abi::MMTK_WEAK_CONCURRENT_SET_KIND_GLOBAL_SYMBOLS,
28+
}
29+
2030
pub struct WeakProcessor {
2131
/// Objects that needs `obj_free` called when dying.
2232
/// If it is a bottleneck, replace it with a lock-free data structure,
@@ -80,12 +90,11 @@ impl WeakProcessor {
8090
Box::new(UpdateWbUnprotectedObjectsList) as _,
8191
]);
8292

83-
let forward = crate::mmtk().get_plan().current_gc_may_move_object();
84-
8593
if SPECIALIZE_FSTRING_TABLE_PROCESSING {
8694
concurrent_set_parallel::process_weak_concurrent_set_chunked(
8795
"fstring",
88-
(upcalls().get_fstring_table_obj)(),
96+
(upcalls().get_fstring_table_obj)().into(),
97+
WeakConcurrentSetKind::FString,
8998
worker,
9099
);
91100
} else {
@@ -94,12 +103,10 @@ impl WeakProcessor {
94103
}
95104

96105
if SPECIALIZE_GLOBAL_SYMBOLS_TABLE_PROCESSING {
97-
st_table_parallel::process_weak_table_chunked(
106+
concurrent_set_parallel::process_weak_concurrent_set_chunked(
98107
"global symbols",
99-
(upcalls().get_global_symbols_table)(),
100-
false,
101-
true,
102-
forward,
108+
(upcalls().get_global_symbols_table_obj)().into(),
109+
WeakConcurrentSetKind::GlobalSymbols,
103110
worker,
104111
);
105112
} else {

mmtk/src/weak_proc/concurrent_set_parallel.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ use mmtk::{
88
util::ObjectReference,
99
};
1010

11-
use crate::{abi::ConcurrentSetStats, upcalls, Ruby};
11+
use crate::{abi::ConcurrentSetStats, upcalls, weak_proc::WeakConcurrentSetKind, Ruby};
1212

1313
pub fn process_weak_concurrent_set_chunked(
1414
name: &'static str,
15-
set: ObjectReference,
15+
set: Option<ObjectReference>,
16+
kind: WeakConcurrentSetKind,
1617
worker: &mut GCWorker<Ruby>,
1718
) {
19+
let Some(set) = set else {
20+
debug!("Set {name} is empty. Skipping.");
21+
return;
22+
};
23+
1824
let num_entries = (upcalls().concurrent_set_get_num_entries)(set);
1925
let capacity = (upcalls().concurrent_set_get_capacity)(set);
2026
debug!("name: {name}, num_entries: {num_entries}, capacity: {capacity}");
@@ -44,6 +50,7 @@ pub fn process_weak_concurrent_set_chunked(
4450
set,
4551
begin,
4652
end,
53+
kind: kind as u8,
4754
counter: counter.clone(),
4855
}) as _
4956
})
@@ -59,6 +66,7 @@ struct UpdateConcurrentSetEntriesParallel {
5966
set: ObjectReference,
6067
begin: usize,
6168
end: usize,
69+
kind: u8,
6270
counter: Arc<AtomicUsize>,
6371
}
6472

@@ -82,7 +90,9 @@ impl GCWork<Ruby> for UpdateConcurrentSetEntriesParallel {
8290
);
8391

8492
let mut stats = ConcurrentSetStats::default();
85-
(upcalls().concurrent_set_update_entries_range)(self.set, self.begin, self.end, &mut stats);
93+
(upcalls().concurrent_set_update_entries_range)(
94+
self.set, self.begin, self.end, self.kind, &mut stats,
95+
);
8696

8797
debug!(
8898
"Done updating entries of concurrent set '{}' range {}-{}, live: {}, moved: {}, deleted: {}",

0 commit comments

Comments
 (0)