Skip to content
Merged
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
2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2021"
# Metadata for the Ruby repository
[package.metadata.ci-repos.ruby]
repo = "mmtk/ruby" # This is used by actions/checkout, so the format is "owner/repo", not URL.
rev = "2bfc164e05d672cac6dfb5dad303636c6195828a"
rev = "e3be189efb1ddd31949519d9a7201abd7a62a0f2"

[lib]
name = "mmtk_ruby"
Expand Down
9 changes: 7 additions & 2 deletions mmtk/src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::api::RubyMutator;
use crate::{extra_assert, upcalls, Ruby};
use mmtk::scheduler::GCWorker;
use mmtk::util::api_util::NullableObjectReference;
use mmtk::util::{Address, ObjectReference, VMMutatorThread, VMWorkerThread};

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

pub const HIDDEN_SIZE_MASK: usize = 0x0000FFFFFFFFFFFF;

pub const MMTK_WEAK_CONCURRENT_SET_KIND_FSTRING: u8 = 0;
pub const MMTK_WEAK_CONCURRENT_SET_KIND_GLOBAL_SYMBOLS: u8 = 1;

// An opaque type for the C counterpart.
#[allow(non_camel_case_types)]
pub struct st_table;
Expand Down Expand Up @@ -361,8 +365,8 @@ pub struct RubyUpcalls {
pub get_cc_refinement_table_size: extern "C" fn() -> usize,
pub update_cc_refinement_table: extern "C" fn(),
// Get tables for specialized processing
pub get_fstring_table_obj: extern "C" fn() -> ObjectReference,
pub get_global_symbols_table: extern "C" fn() -> *mut st_table,
pub get_fstring_table_obj: extern "C" fn() -> NullableObjectReference,
pub get_global_symbols_table_obj: extern "C" fn() -> NullableObjectReference,
// Detailed st_table info queries and operations
pub st_get_num_entries: extern "C" fn(table: *const st_table) -> usize,
pub st_get_size_info: extern "C" fn(
Expand All @@ -388,6 +392,7 @@ pub struct RubyUpcalls {
set: ObjectReference,
begin: usize,
end: usize,
kind: u8,
stats: *mut ConcurrentSetStats,
),
// Memory protection for code memory
Expand Down
25 changes: 16 additions & 9 deletions mmtk/src/weak_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use mmtk::{
vm::ObjectTracerContext,
};

use crate::{abi::GCThreadTLS, extra_assert, is_mmtk_object_safe, upcalls, Ruby};
use crate::{
abi::{self, GCThreadTLS},
extra_assert, is_mmtk_object_safe, upcalls, Ruby,
};

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

#[repr(u8)]
#[derive(Clone, Copy)]
pub enum WeakConcurrentSetKind {
FString = abi::MMTK_WEAK_CONCURRENT_SET_KIND_FSTRING,
GlobalSymbols = abi::MMTK_WEAK_CONCURRENT_SET_KIND_GLOBAL_SYMBOLS,
}

pub struct WeakProcessor {
/// Objects that needs `obj_free` called when dying.
/// If it is a bottleneck, replace it with a lock-free data structure,
Expand Down Expand Up @@ -80,12 +90,11 @@ impl WeakProcessor {
Box::new(UpdateWbUnprotectedObjectsList) as _,
]);

let forward = crate::mmtk().get_plan().current_gc_may_move_object();

if SPECIALIZE_FSTRING_TABLE_PROCESSING {
concurrent_set_parallel::process_weak_concurrent_set_chunked(
"fstring",
(upcalls().get_fstring_table_obj)(),
(upcalls().get_fstring_table_obj)().into(),
WeakConcurrentSetKind::FString,
worker,
);
} else {
Expand All @@ -94,12 +103,10 @@ impl WeakProcessor {
}

if SPECIALIZE_GLOBAL_SYMBOLS_TABLE_PROCESSING {
st_table_parallel::process_weak_table_chunked(
concurrent_set_parallel::process_weak_concurrent_set_chunked(
"global symbols",
(upcalls().get_global_symbols_table)(),
false,
true,
forward,
(upcalls().get_global_symbols_table_obj)().into(),
WeakConcurrentSetKind::GlobalSymbols,
worker,
);
} else {
Expand Down
16 changes: 13 additions & 3 deletions mmtk/src/weak_proc/concurrent_set_parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ use mmtk::{
util::ObjectReference,
};

use crate::{abi::ConcurrentSetStats, upcalls, Ruby};
use crate::{abi::ConcurrentSetStats, upcalls, weak_proc::WeakConcurrentSetKind, Ruby};

pub fn process_weak_concurrent_set_chunked(
name: &'static str,
set: ObjectReference,
set: Option<ObjectReference>,
kind: WeakConcurrentSetKind,
worker: &mut GCWorker<Ruby>,
) {
let Some(set) = set else {
debug!("Set {name} is empty. Skipping.");
return;
};

let num_entries = (upcalls().concurrent_set_get_num_entries)(set);
let capacity = (upcalls().concurrent_set_get_capacity)(set);
debug!("name: {name}, num_entries: {num_entries}, capacity: {capacity}");
Expand Down Expand Up @@ -44,6 +50,7 @@ pub fn process_weak_concurrent_set_chunked(
set,
begin,
end,
kind: kind as u8,
counter: counter.clone(),
}) as _
})
Expand All @@ -59,6 +66,7 @@ struct UpdateConcurrentSetEntriesParallel {
set: ObjectReference,
begin: usize,
end: usize,
kind: u8,
counter: Arc<AtomicUsize>,
}

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

let mut stats = ConcurrentSetStats::default();
(upcalls().concurrent_set_update_entries_range)(self.set, self.begin, self.end, &mut stats);
(upcalls().concurrent_set_update_entries_range)(
self.set, self.begin, self.end, self.kind, &mut stats,
);

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