Skip to content

Commit

Permalink
nuke region0.rs; change type of use_stable_regions arg to u32 (bool, …
Browse files Browse the repository at this point in the history
…really); change assert in get_region0 to debug assert for perf
  • Loading branch information
crusso committed Aug 16, 2023
1 parent 557419c commit db9038b
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion rts/motoko-rts/src/gc/copying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsafe fn copying_gc<M: Memory>(mem: &mut M) {
|hp| linear_memory::set_hp_unskewed(hp),
ic::get_static_roots(),
crate::continuation_table::continuation_table_loc(),
crate::region0::region0_get_ptr_loc(),
crate::region::region0_get_ptr_loc(),
// note_live_size
|live_size| ic::MAX_LIVE = ::core::cmp::max(ic::MAX_LIVE, live_size),
// note_reclaimed
Expand Down
2 changes: 1 addition & 1 deletion rts/motoko-rts/src/gc/generational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ unsafe fn generational_gc<M: Memory>(mem: &mut M) {
let old_limits = get_limits();
let roots = Roots {
static_roots: ic::get_static_roots(),
region0_ptr_loc: crate::region0::region0_get_ptr_loc(),
region0_ptr_loc: crate::region::region0_get_ptr_loc(),
continuation_table_ptr_loc: crate::continuation_table::continuation_table_loc(),
};
let heap = Heap {
Expand Down
2 changes: 1 addition & 1 deletion rts/motoko-rts/src/gc/incremental/roots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub unsafe fn root_set() -> Roots {
Roots {
static_roots: ic::get_static_roots(),
continuation_table_location: crate::continuation_table::continuation_table_loc(),
region0_ptr_location: crate::region0::region0_get_ptr_loc(),
region0_ptr_location: crate::region::region0_get_ptr_loc(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion rts/motoko-rts/src/gc/mark_compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ unsafe fn compacting_gc<M: Memory>(mem: &mut M) {
|hp| linear_memory::set_hp_unskewed(hp),
ic::get_static_roots(),
crate::continuation_table::continuation_table_loc(),
crate::region0::region0_get_ptr_loc(),
crate::region::region0_get_ptr_loc(),
// note_live_size
|live_size| ic::MAX_LIVE = ::core::cmp::max(ic::MAX_LIVE, live_size),
// note_reclaimed
Expand Down
2 changes: 0 additions & 2 deletions rts/motoko-rts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub mod principal_id;
pub mod region;
//#[cfg(feature = "ic")]
mod stable_mem;
//#[cfg(feature = "ic")]
pub mod region0;
mod static_checks;
pub mod stream;
pub mod text;
Expand Down
15 changes: 14 additions & 1 deletion rts/motoko-rts/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,19 @@ unsafe fn region_reserve_id_span<M: Memory>(
}
}

#[ic_mem_fn]
pub unsafe fn region0_get<M: Memory>(_mem: &mut M) -> Value {
debug_assert_ne!(REGION_0, NO_REGION);
REGION_0
}

// Expose Region0 object to GC algorithms as root
#[allow(dead_code)]
#[cfg(feature = "ic")]
pub(crate) unsafe fn region0_get_ptr_loc() -> *mut Value {
&mut REGION_0
}

#[ic_mem_fn]
pub unsafe fn region_new<M: Memory>(mem: &mut M) -> Value {
match crate::stable_mem::get_version() {
Expand Down Expand Up @@ -675,7 +688,7 @@ pub(crate) unsafe fn region_migration_from_regions_plus<M: Memory>(mem: &mut M)
// region manager migration/initialization, with pre-existing stable data.
//
#[ic_mem_fn]
pub(crate) unsafe fn region_init<M: Memory>(mem: &mut M, use_stable_regions: i32) {
pub(crate) unsafe fn region_init<M: Memory>(mem: &mut M, use_stable_regions: u32) {
debug_assert!(meta_data::offset::FREE < meta_data::offset::BLOCK_ZERO);
match crate::stable_mem::get_version() {
VERSION_NO_STABLE_MEMORY => {
Expand Down
18 changes: 0 additions & 18 deletions rts/motoko-rts/src/region0.rs

This file was deleted.

2 changes: 1 addition & 1 deletion test/bench/ok/heap-32.drun-run-opt.ok
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: (50_227, +30_261_252, 620_394_339)
debug.print: (50_227, +30_261_252, 620_394_352)
debug.print: (50_070, +32_992_212, 671_304_527)
ingress Completed: Reply: 0x4449444c0000
2 changes: 1 addition & 1 deletion test/bench/ok/heap-32.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: (50_227, +30_261_252, 667_797_563)
debug.print: (50_227, +30_261_252, 667_797_588)
debug.print: (50_070, +32_992_212, 720_521_435)
ingress Completed: Reply: 0x4449444c0000
2 changes: 1 addition & 1 deletion test/bench/ok/region0-mem.drun-run-opt.ok
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: {heap_diff = 0; instr_diff = 5_549_064_476}
debug.print: {heap_diff = 0; instr_diff = 5_196_742_940}
ingress Completed: Reply: 0x4449444c0000
2 changes: 1 addition & 1 deletion test/bench/ok/region0-mem.drun-run.ok
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101
ingress Completed: Reply: 0x4449444c0000
debug.print: {heap_diff = 0; instr_diff = 5_863_637_298}
debug.print: {heap_diff = 0; instr_diff = 5_561_647_410}
ingress Completed: Reply: 0x4449444c0000

0 comments on commit db9038b

Please sign in to comment.