Fix alignment
This commit is contained in:
parent
3f76318ba1
commit
cdab71fda1
4 changed files with 24 additions and 11 deletions
|
@ -32,6 +32,7 @@ static METADATA: GCMetadata<BenchVM> = GCMetadata {
|
|||
instance_size: size_of::<Node>(),
|
||||
compute_size: None,
|
||||
alignment: 16,
|
||||
compute_alignment: None,
|
||||
};
|
||||
|
||||
struct BenchVM {
|
||||
|
|
|
@ -33,7 +33,7 @@ use crate::{
|
|||
};
|
||||
use easy_bitfield::*;
|
||||
use mmtk::{
|
||||
util::Address,
|
||||
util::{options::PlanSelector, Address},
|
||||
vm::{
|
||||
slot::{SimpleSlot, UnimplementedMemorySlice},
|
||||
ObjectTracer,
|
||||
|
@ -326,6 +326,7 @@ struct MarkStackMeta<'a> {
|
|||
static CONSERVATIVE_METADATA: GCMetadata<BDWGC> = GCMetadata {
|
||||
alignment: 8,
|
||||
instance_size: 0,
|
||||
compute_alignment: None,
|
||||
compute_size: Some(|object| {
|
||||
let header = object.header::<BDWGC>().metadata();
|
||||
ObjectSize::decode(header.meta) * BDWGC::MIN_ALIGNMENT
|
||||
|
@ -508,10 +509,10 @@ pub static mut GC_VERBOSE: i32 = 0;
|
|||
static BUILDER: LazyLock<Mutex<MMTKBuilder>> = LazyLock::new(|| {
|
||||
Mutex::new({
|
||||
let mut builder = MMTKBuilder::new();
|
||||
builder
|
||||
.options
|
||||
.plan
|
||||
.set(mmtk::util::options::PlanSelector::Immix);
|
||||
builder.options.read_env_var_settings();
|
||||
if !matches!(*builder.options.plan, PlanSelector::Immix | PlanSelector::MarkSweep) {
|
||||
builder.options.plan.set(PlanSelector::Immix);
|
||||
}
|
||||
builder
|
||||
})
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ pub struct GCMetadata<VM: VirtualMachine> {
|
|||
pub instance_size: usize,
|
||||
pub compute_size: Option<fn(VMKitObject) -> usize>,
|
||||
pub alignment: usize,
|
||||
pub compute_alignment: Option<fn(VMKitObject) -> usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -3,12 +3,12 @@ use crate::threading::Thread;
|
|||
use crate::{mm::MemoryManager, VirtualMachine};
|
||||
use atomic::Atomic;
|
||||
use core::ops::Range;
|
||||
use std::hash::Hash;
|
||||
use mmtk::util::{
|
||||
constants::LOG_BYTES_IN_ADDRESS, conversions::raw_align_up, Address, ObjectReference,
|
||||
};
|
||||
use mmtk::vm::slot::{MemorySlice, SimpleSlot, Slot};
|
||||
use std::fmt;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use super::{
|
||||
|
@ -127,8 +127,18 @@ impl VMKitObject {
|
|||
/// # Returns
|
||||
///
|
||||
/// * `usize` - The alignment of the object.
|
||||
pub fn alignment<VM: VirtualMachine>(&self) -> usize {
|
||||
self.header::<VM>().metadata().gc_metadata().alignment
|
||||
pub fn alignment<VM: VirtualMachine>(self) -> usize {
|
||||
let alignment = self.header::<VM>().metadata().gc_metadata().alignment;
|
||||
if alignment == 0 {
|
||||
return self
|
||||
.header::<VM>()
|
||||
.metadata()
|
||||
.gc_metadata()
|
||||
.compute_alignment
|
||||
.map(|f| f(self))
|
||||
.unwrap_or(VM::MAX_ALIGNMENT);
|
||||
}
|
||||
alignment
|
||||
}
|
||||
|
||||
/// Returns the number of bytes used by the `VMKitObject`.
|
||||
|
@ -644,11 +654,11 @@ impl<SL: SlotExtra> Eq for SimpleMemorySlice<SL> {}
|
|||
|
||||
impl<SL: SlotExtra> Clone for SimpleMemorySlice<SL> {
|
||||
fn clone(&self) -> Self {
|
||||
Self { range: self.range.clone() }
|
||||
Self {
|
||||
range: self.range.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub struct SimpleMemorySliceRangeIterator<SL: SlotExtra = SimpleSlot> {
|
||||
cursor: Address,
|
||||
|
|
Loading…
Add table
Reference in a new issue