Skip to content

Commit 829de09

Browse files
authored
Rename initialize_header to initialize_object_metadata (#316)
1 parent 33fba23 commit 829de09

File tree

7 files changed

+35
-30
lines changed

7 files changed

+35
-30
lines changed

src/plan/mutator_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<VM: VMBinding> MutatorContext<VM> for Mutator<VM> {
7777
.get_allocator_mut(self.config.allocator_mapping[allocator])
7878
}
7979
.get_space()
80-
.initialize_header(refer, true)
80+
.initialize_object_metadata(refer, true)
8181
}
8282

8383
fn get_tls(&self) -> VMMutatorThread {

src/policy/copyspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<VM: VMBinding> SFT for CopySpace<VM> {
3737
fn is_sane(&self) -> bool {
3838
!self.from_space()
3939
}
40-
fn initialize_header(&self, _object: ObjectReference, _alloc: bool) {}
40+
fn initialize_object_metadata(&self, _object: ObjectReference, _alloc: bool) {}
4141
}
4242

4343
impl<VM: VMBinding> Space<VM> for CopySpace<VM> {

src/policy/immortalspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<VM: VMBinding> SFT for ImmortalSpace<VM> {
4545
fn is_sane(&self) -> bool {
4646
true
4747
}
48-
fn initialize_header(&self, object: ObjectReference, _alloc: bool) {
48+
fn initialize_object_metadata(&self, object: ObjectReference, _alloc: bool) {
4949
let old_value = gc_byte::read_gc_byte::<VM>(object);
5050
let mut new_value = (old_value & GC_MARK_BIT_MASK) | self.mark_state;
5151
if self.header_byte.needs_unlogged_bit {

src/policy/largeobjectspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<VM: VMBinding> SFT for LargeObjectSpace<VM> {
5050
fn is_sane(&self) -> bool {
5151
true
5252
}
53-
fn initialize_header(&self, object: ObjectReference, alloc: bool) {
53+
fn initialize_object_metadata(&self, object: ObjectReference, alloc: bool) {
5454
let old_value = gc_byte::read_gc_byte::<VM>(object);
5555
let mut new_value = (old_value & (!LOS_BIT_MASK)) | self.mark_state;
5656
if alloc {

src/policy/lockfreeimmortalspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<VM: VMBinding> SFT for LockFreeImmortalSpace<VM> {
5454
fn is_sane(&self) -> bool {
5555
unimplemented!()
5656
}
57-
fn initialize_header(&self, _object: ObjectReference, _alloc: bool) {
57+
fn initialize_object_metadata(&self, _object: ObjectReference, _alloc: bool) {
5858
unimplemented!()
5959
}
6060
}

src/policy/mallocspace/global.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ impl<VM: VMBinding> SFT for MallocSpace<VM> {
5252
fn is_sane(&self) -> bool {
5353
true
5454
}
55-
fn initialize_header(&self, object: ObjectReference, _alloc: bool) {
56-
trace!("initialize_header for object {}", object);
55+
fn initialize_object_metadata(&self, object: ObjectReference, _alloc: bool) {
56+
trace!("initialize_object_metadata for object {}", object);
5757
set_alloc_bit(object);
5858
}
5959
}

src/policy/space.rs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,38 @@ use std::marker::PhantomData;
2828

2929
use downcast_rs::Downcast;
3030

31-
/**
32-
* Space Function Table (SFT).
33-
*
34-
* This trait captures functions that reflect _space-specific per-object
35-
* semantics_. These functions are implemented for each object via a special
36-
* space-based dynamic dispatch mechanism where the semantics are _not_
37-
* determined by the object's _type_, but rather, are determined by the _space_
38-
* that the object is in.
39-
*
40-
* The underlying mechanism exploits the fact that spaces use the address space
41-
* at an MMTk chunk granularity with the consequence that each chunk maps to
42-
* exactluy one space, so knowing the chunk for an object reveals its space.
43-
* The dispatch then works by performing simple address arithmetic on the object
44-
* reference to find a chunk index which is used to index a table which returns
45-
* the space. The relevant function is then dispatched against that space
46-
* object.
47-
*
48-
* We use the SFT trait to simplify typing for Rust, so our table is a
49-
* table of SFT rather than Space.
50-
*/
31+
/// Space Function Table (SFT).
32+
///
33+
/// This trait captures functions that reflect _space-specific per-object
34+
/// semantics_. These functions are implemented for each object via a special
35+
/// space-based dynamic dispatch mechanism where the semantics are _not_
36+
/// determined by the object's _type_, but rather, are determined by the _space_
37+
/// that the object is in.
38+
///
39+
/// The underlying mechanism exploits the fact that spaces use the address space
40+
/// at an MMTk chunk granularity with the consequence that each chunk maps to
41+
/// exactluy one space, so knowing the chunk for an object reveals its space.
42+
/// The dispatch then works by performing simple address arithmetic on the object
43+
/// reference to find a chunk index which is used to index a table which returns
44+
/// the space. The relevant function is then dispatched against that space
45+
/// object.
46+
///
47+
/// We use the SFT trait to simplify typing for Rust, so our table is a
48+
/// table of SFT rather than Space.
5149
pub trait SFT {
50+
/// The space name
5251
fn name(&self) -> &str;
52+
/// Is the object live, determined by the policy?
5353
fn is_live(&self, object: ObjectReference) -> bool;
54+
/// Is the object movable, determined by the policy? E.g. the policy is non-moving,
55+
/// or the object is pinned.
5456
fn is_movable(&self) -> bool;
57+
/// Is the object sane? A policy should return false if there is any abnormality about
58+
/// object - the sanity checker will fail if an object is not sane.
5559
#[cfg(feature = "sanity")]
5660
fn is_sane(&self) -> bool;
57-
fn initialize_header(&self, object: ObjectReference, alloc: bool);
61+
/// Initialize object metadata (in the header, or in the side metadata).
62+
fn initialize_object_metadata(&self, object: ObjectReference, alloc: bool);
5863
}
5964

6065
/// Print debug info for SFT. Should be false when committed.
@@ -91,9 +96,9 @@ impl SFT for EmptySpaceSFT {
9196
false
9297
}
9398

94-
fn initialize_header(&self, object: ObjectReference, _alloc: bool) {
99+
fn initialize_object_metadata(&self, object: ObjectReference, _alloc: bool) {
95100
panic!(
96-
"Called initialize_header() on {:x}, which maps to an empty space",
101+
"Called initialize_object_metadata() on {:x}, which maps to an empty space",
97102
object
98103
)
99104
}

0 commit comments

Comments
 (0)