mmtk/policy/copy_context.rs
1use crate::util::Address;
2use crate::util::ObjectReference;
3use crate::vm::VMBinding;
4
5/// A GC worker's copy allocator for copying GCs.
6/// Each copying policy should provide their implementation of PolicyCopyContext.
7/// If we copy objects from one policy to a different policy, the copy context of the destination
8/// policy should be used. For example, for generational immix, the nursery is CopySpace, and the
9/// mature space is ImmixSpace. When we copy from nursery to mature, ImmixCopyContext should be
10/// used.
11/// Note that this trait should only be implemented with policy specific behaviors. Please
12/// refer to [`crate::util::copy::GCWorkerCopyContext`] which implements common
13/// behaviors for copying.
14pub trait PolicyCopyContext: 'static + Send {
15 type VM: VMBinding;
16 fn prepare(&mut self);
17 fn release(&mut self);
18 fn alloc_copy(
19 &mut self,
20 original: ObjectReference,
21 bytes: usize,
22 align: usize,
23 offset: usize,
24 ) -> Address;
25 fn post_copy(&mut self, _obj: ObjectReference, _bytes: usize);
26}