Skip to content

Commit

Permalink
🤖 Upgrade mmtk to 0.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
oovm committed Mar 9, 2024
1 parent 78ef781 commit de55b25
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 44 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolve = "2"
members = ["projects/*"]
default-members = [
"projects/zero-gc",
Expand Down
4 changes: 2 additions & 2 deletions projects/zero-gc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ authors = ["Aster <[email protected]>"]
description = "Pauseless GC in Rust"
repository = "https://github.com/nyar-vm/zero-gc"
documentation = "https://docs.rs/zgc"
readme = "Readme.md"
readme = "readme.md"
license = "MPL-2.0"
edition = "2021"
exclude = ["package.json", "tests/**"]

[dependencies]
#bitflags = "2.3.1"
mmtk = "0.23.0"

[dev-dependencies]

Expand Down
10 changes: 0 additions & 10 deletions projects/zero-gc/src/barrier/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// bitflags! {
// #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
// pub struct LoadBarrier: u8 {
// const Finalizable = 0b00000001;
// const Remapped = 0b00000010;
// const Marked1 = 0b00000100;
// const Marked0 = 0b00001000;
// }
// }

use std::fmt::{Debug, Formatter, Pointer};
use std::ptr::from_raw_parts;

Expand Down
315 changes: 283 additions & 32 deletions projects/zero-gc/src/gc_head/mod.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,289 @@
use std::fmt::{Debug, Formatter};
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use mmtk::{Mutator, MutatorContext, Plan};
use mmtk::util::copy::{CopySemantics, GCWorkerCopyContext};
use mmtk::util::{Address, ObjectReference, VMMutatorThread, VMThread, VMWorkerThread};
use mmtk::vm::{ActivePlan, Collection, EdgeVisitor, GCThreadContext, ObjectModel, ReferenceGlue, RootsWorkFactory, Scanning, VMBinding, VMGlobalLogBitSpec, VMLocalForwardingBitsSpec, VMLocalForwardingPointerSpec, VMLocalLOSMarkNurserySpec, VMLocalMarkBitSpec};
use mmtk::vm::edge_shape::{Edge, MemorySlice};


use crate::GcPointer;

/// A typed gc object.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct Gc<T> {
/// Pointer to the head
head: GcPointer,
/// Pointer to the data
size: usize,
/// Phantom data
typing: PhantomData<T>,
}

impl<T> Gc<T> {
/// Create a new gc object from the data
pub fn new(value: T) -> Self {
Self {
head: GcPointer::make(&value),
size: std::mem::size_of::<T>(),
typing: PhantomData::default(),
}
}
}

/// The world.
#[derive(Copy, Clone, Debug)]
pub struct TheWorld {}

/// The world control.
#[derive(Copy, Clone, Debug)]
pub struct TheWorldControl {
/// The world
pub initiating_heap_occupancy_percent: u8,

pub struct GcArea {}

pub struct GcObjectModel {}

pub struct GcScanning {}

pub struct GcCollection {}

pub struct GcPlan {}

pub struct GcGlue {}

pub struct GcEdge {}

pub struct GcEdgeIterator {}

pub struct GcSlice {}

impl VMBinding for GcArea {
type VMObjectModel = GcObjectModel;
type VMScanning = GcScanning;
type VMCollection = GcCollection;
type VMActivePlan = GcPlan;
type VMReferenceGlue = GcGlue;
type VMEdge = GcEdge;
type VMMemorySlice = GcSlice;
}

impl ObjectModel<GcArea> for GcObjectModel {
const GLOBAL_LOG_BIT_SPEC: VMGlobalLogBitSpec = VMGlobalLogBitSpec::side_first();
const LOCAL_FORWARDING_POINTER_SPEC: VMLocalForwardingPointerSpec = VMLocalForwardingPointerSpec::side_first();
const LOCAL_FORWARDING_BITS_SPEC: VMLocalForwardingBitsSpec = VMLocalForwardingBitsSpec::side_first();
const LOCAL_MARK_BIT_SPEC: VMLocalMarkBitSpec = VMLocalMarkBitSpec::side_first();
const LOCAL_LOS_MARK_NURSERY_SPEC: VMLocalLOSMarkNurserySpec = VMLocalLOSMarkNurserySpec::side_first();

fn copy(from: ObjectReference, semantics: CopySemantics, copy_context: &mut GCWorkerCopyContext<GcArea>) -> ObjectReference {
todo!()
}

fn copy_to(from: ObjectReference, to: ObjectReference, region: Address) -> Address {
todo!()
}

fn get_reference_when_copied_to(from: ObjectReference, to: Address) -> ObjectReference {
todo!()
}

fn get_current_size(object: ObjectReference) -> usize {
todo!()
}

fn get_size_when_copied(object: ObjectReference) -> usize {
todo!()
}

fn get_align_when_copied(object: ObjectReference) -> usize {
todo!()
}

fn get_align_offset_when_copied(object: ObjectReference) -> isize {
todo!()
}

fn get_type_descriptor(reference: ObjectReference) -> &'static [i8] {
todo!()
}

const OBJECT_REF_OFFSET_LOWER_BOUND: isize = 0;

fn ref_to_object_start(object: ObjectReference) -> Address {
todo!()
}

fn ref_to_header(object: ObjectReference) -> Address {
todo!()
}

fn ref_to_address(object: ObjectReference) -> Address {
todo!()
}

fn address_to_ref(addr: Address) -> ObjectReference {
todo!()
}

fn dump_object(object: ObjectReference) {
todo!()
}
}

impl Scanning<GcArea> for GcScanning {
fn scan_object<EV: EdgeVisitor<GcArea::VMEdge>>(tls: VMWorkerThread, object: ObjectReference, edge_visitor: &mut EV) {
todo!()
}

fn notify_initial_thread_scan_complete(partial_scan: bool, tls: VMWorkerThread) {
todo!()
}

fn scan_thread_roots(tls: VMWorkerThread, factory: impl RootsWorkFactory<GcArea::VMEdge>) {
todo!()
}

fn scan_thread_root(tls: VMWorkerThread, mutator: &'static mut Mutator<GcArea>, factory: impl RootsWorkFactory<GcArea::VMEdge>) {
todo!()
}

fn scan_vm_specific_roots(tls: VMWorkerThread, factory: impl RootsWorkFactory<GcArea::VMEdge>) {
todo!()
}

fn supports_return_barrier() -> bool {
todo!()
}

fn prepare_for_roots_re_scanning() {
todo!()
}
}

impl Collection<GcArea> for GcCollection {
fn stop_all_mutators<F>(tls: VMWorkerThread, mutator_visitor: F) where F: FnMut(&'static mut Mutator<GcArea>) {
todo!()
}

fn resume_mutators(tls: VMWorkerThread) {
todo!()
}

fn block_for_gc(tls: VMMutatorThread) {
todo!()
}

fn spawn_gc_thread(tls: VMThread, ctx: GCThreadContext<GcArea>) {
todo!()
}

fn prepare_mutator<T: MutatorContext<GcArea>>(tls_worker: VMWorkerThread, tls_mutator: VMMutatorThread, m: &T) {
todo!()
}
}

impl ActivePlan<GcArea> for GcPlan {
fn global() -> &'static dyn Plan<VM=GcArea> {
todo!()
}

fn is_mutator(tls: VMThread) -> bool {
todo!()
}

fn mutator(tls: VMMutatorThread) -> &'static mut Mutator<GcArea> {
todo!()
}

fn reset_mutator_iterator() {
todo!()
}

fn get_next_mutator() -> Option<&'static mut Mutator<GcArea>> {
todo!()
}

fn number_of_mutators() -> usize {
todo!()
}
}

impl ReferenceGlue<GcArea> for GcGlue {
type FinalizableType = ObjectReference;

fn get_referent(object: ObjectReference) -> ObjectReference {
todo!()
}

fn set_referent(reff: ObjectReference, referent: ObjectReference) {
todo!()
}

fn enqueue_references(references: &[ObjectReference], tls: VMWorkerThread) {
todo!()
}
}

impl Copy for GcEdge {}

impl Clone for GcEdge {
fn clone(&self) -> Self {
todo!()
}
}

impl Debug for GcEdge {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
todo!()
}
}

impl PartialEq for GcEdge {
fn eq(&self, other: &Self) -> bool {
todo!()
}
}

impl Eq for GcEdge {}

impl Hash for GcEdge {
fn hash<H: Hasher>(&self, state: &mut H) {
todo!()
}
}

impl Edge for GcEdge {
fn load(&self) -> ObjectReference {
todo!()
}

fn store(&self, object: ObjectReference) {
todo!()
}
}

impl Debug for GcSlice {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
todo!()
}
}

impl PartialEq for GcSlice {
fn eq(&self, other: &Self) -> bool {
todo!()
}
}

impl Eq for GcSlice {}

impl Clone for GcSlice {
fn clone(&self) -> Self {
todo!()
}
}

impl Hash for GcSlice {
fn hash<H: Hasher>(&self, state: &mut H) {
todo!()
}
}

impl Iterator for GcEdgeIterator {
type Item = GcEdge;

fn next(&mut self) -> Option<Self::Item> {
todo!()
}
}

impl MemorySlice for GcSlice {
type Edge = GcEdge;
type EdgeIterator = GcEdgeIterator;

fn iter_edges(&self) -> Self::EdgeIterator {
todo!()
}

fn start(&self) -> Address {
todo!()
}

fn bytes(&self) -> usize {
todo!()
}

fn copy(src: &Self, tgt: &Self) {
todo!()
}
}

0 comments on commit de55b25

Please sign in to comment.