Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 48 additions & 266 deletions runtime/Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ edition = "2024"

[dependencies]
libc = "1.0.0-alpha.1"
mmap-rs = "0.6.1"
memmap2 = "0.9.7"
dashmap = "7.0.0-rc2"
41 changes: 19 additions & 22 deletions runtime/src/alloca/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
use crate::alloca::{ptr, Object};
use crate::alloca::arena::Arena3;
use crate::alloca::{Cfg, ptr};
use crate::utils::Object;

pub trait ArenaAllocator3<T: Object, U: Arena3> {
const LOG_CAPACITY_SIZE: usize;

const LOG_BLOCK_SIZE: usize;

const LOG_START_ARENA_SIZE: usize;

const LOG_MAX_ARENA_SIZE: usize;

fn new(max_size: usize) -> Self;

fn alloc(&mut self, o: &T) -> ptr;

fn mark_white(&mut self);

fn arena_by_ptr(&mut self, ptr: usize) -> &mut U;

fn mark_gray(&mut self, ptr: ptr);

fn mark_black(&mut self, ptr: ptr);
}
pub trait ArenaAllocator3<U: Arena3> {
fn new(config: &Cfg) -> Self;

fn alloc(&mut self, o: &Object) -> (ptr, bool);

fn mark_white(&mut self);

fn arena_by_ptr(&self, ptr: usize) -> Option<&U>;

fn mut_arena_by_ptr(&mut self, ptr: usize) -> Option<&mut U>;

fn mark_gray(&mut self, ptr: ptr) -> Option<&mut U>;

fn mark_black(&mut self, ptr: ptr) -> Option<&mut U>;

fn sweep(&mut self);
}
64 changes: 36 additions & 28 deletions runtime/src/alloca/arena.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
use crate::alloca::ptr;

pub trait Arena3 {
fn new(start: ptr, size: usize) -> Self;

fn start(&self) -> ptr;

fn cur(&self) -> ptr;

fn add(&mut self, size: usize);

fn size(&self) -> usize;

fn how_much(&self) -> usize;

fn gray_map(&self) ->(ptr, usize);

fn black_map(&self) ->(ptr, usize);

fn clear_mark(&mut self);

fn live(&self) -> bool;

fn on(&mut self);

fn off(&mut self);

fn mark_gray(&mut self, ptr: ptr);

fn mark_black(&mut self, ptr: ptr);
}
fn new(start: ptr, size: usize) -> Self;

fn span_start(&self) -> ptr;

fn cur(&self) -> ptr;

fn add(&mut self, size: usize);

fn size(&self) -> usize;

fn how_much(&self) -> usize;

fn gray_map(&self) -> (ptr, usize);

fn black_map(&self) -> (ptr, usize);

fn clear_mark(&mut self);

fn live(&self) -> bool;

fn alive(&mut self);

fn kill(&mut self);

fn make_live(&mut self);

fn temp_kill(&mut self);

fn mark_gray(&mut self, ptr: ptr);

fn mark_black(&mut self, ptr: ptr);

fn fetch_and_add_in_queue(&mut self) -> bool;

fn fetch_and_take_from_queue(&mut self) -> bool;
}
43 changes: 43 additions & 0 deletions runtime/src/alloca/cfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pub struct Cfg {
pub log_capacity_size: usize,
pub log_block_size: usize,
pub log_start_arena_size: usize,
pub step_arena_size: usize,
pub log_max_arena_size: usize,
pub count_of_tiers: usize,
pub max_size: usize,
pub max_object_size_by_size: fn(usize) -> usize,

pub count_gc_workers: usize,
}

impl Cfg {
pub fn new(
log_capacity_size: usize,
log_block_size: usize,
log_start_arena_size: usize,
log_max_arena_size: usize,
step_arena_size: usize,
max_size: usize,
max_object_size_by_size: fn(usize) -> usize,
count_gc_workers: usize,
) -> Self {
assert!(log_capacity_size > log_block_size);
assert!(log_block_size > log_max_arena_size);
assert!(log_max_arena_size > log_start_arena_size);
assert!(step_arena_size < log_max_arena_size - log_start_arena_size);
assert!(count_gc_workers > 0);

Self {
log_capacity_size,
log_block_size,
log_start_arena_size,
step_arena_size,
log_max_arena_size,
count_of_tiers: ((log_max_arena_size - log_start_arena_size) / step_arena_size) + 1,
max_size,
max_object_size_by_size,
count_gc_workers,
}
}
}
Comment thread
Km1zZzoU marked this conversation as resolved.
Loading