forked from mmtk/mmtk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobject_model.rs
87 lines (68 loc) · 3.05 KB
/
object_model.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use crate::DummyVM;
use mmtk::util::copy::{CopySemantics, GCWorkerCopyContext};
use mmtk::util::{Address, ObjectReference};
use mmtk::vm::*;
pub struct VMObjectModel {}
/// This is the offset from the allocation result to the object reference for the object.
/// For bindings that this offset is not a constant, you can implement the calculation in the method `ref_to_object_start`, and
/// remove this constant.
pub const OBJECT_REF_OFFSET: usize = 0;
// This is the offset from the object reference to the object header.
// This value is used in `ref_to_header` where MMTk loads header metadata from.
pub const OBJECT_HEADER_OFFSET: usize = 0;
// Documentation: https://docs.mmtk.io/api/mmtk/vm/object_model/trait.ObjectModel.html
impl ObjectModel<DummyVM> for VMObjectModel {
// Global metadata
const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::side_first();
// Local metadata
// Forwarding pointers have to be in the header. It is okay to overwrite the object payload with a forwarding pointer.
// FIXME: The bit offset needs to be set properly.
const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec =
VMLocalForwardingPointerSpec::in_header(0);
// The other metadata can be put in the side metadata.
const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec =
VMLocalForwardingBitsSpec::side_first();
const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec =
VMLocalMarkBitSpec::side_after(Self::LOCAL_FORWARDING_BITS_SPEC.as_spec());
const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec =
VMLocalLOSMarkNurserySpec::side_after(Self::LOCAL_MARK_BIT_SPEC.as_spec());
const OBJECT_REF_OFFSET_LOWER_BOUND: isize = OBJECT_REF_OFFSET as isize;
fn copy(
_from: ObjectReference,
_semantics: CopySemantics,
_copy_context: &mut GCWorkerCopyContext<DummyVM>,
) -> ObjectReference {
unimplemented!()
}
fn copy_to(_from: ObjectReference, _to: ObjectReference, _region: Address) -> Address {
unimplemented!()
}
fn get_current_size(_object: ObjectReference) -> usize {
unimplemented!()
}
fn get_size_when_copied(object: ObjectReference) -> usize {
// FIXME: This assumes the object size is unchanged during copying.
Self::get_current_size(object)
}
fn get_align_when_copied(_object: ObjectReference) -> usize {
unimplemented!()
}
fn get_align_offset_when_copied(_object: ObjectReference) -> usize {
unimplemented!()
}
fn get_reference_when_copied_to(_from: ObjectReference, _to: Address) -> ObjectReference {
unimplemented!()
}
fn get_type_descriptor(_reference: ObjectReference) -> &'static [i8] {
unimplemented!()
}
fn ref_to_object_start(object: ObjectReference) -> Address {
object.to_raw_address().sub(OBJECT_REF_OFFSET)
}
fn ref_to_header(object: ObjectReference) -> Address {
object.to_raw_address().sub(OBJECT_HEADER_OFFSET)
}
fn dump_object(_object: ObjectReference) {
unimplemented!()
}
}