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