@@ -14,18 +14,18 @@ use crate::types::*;
1414
1515extern "C" {
1616 /// Get end_of_heap
17- pub fn get_hp ( ) -> usize ;
17+ pub ( crate ) fn get_hp ( ) -> usize ;
1818
1919 /// Set end_of_heap
20- pub fn set_hp ( hp : usize ) ;
20+ pub ( crate ) fn set_hp ( hp : usize ) ;
2121
2222 /// Get __heap_base
23- fn get_heap_base ( ) -> usize ;
23+ pub ( crate ) fn get_heap_base ( ) -> usize ;
2424
2525 /// Skewed pointer to a skewed pointer to an array. See closure-table.c for details.
26- fn closure_table_loc ( ) -> SkewedPtr ;
26+ pub ( crate ) fn closure_table_loc ( ) -> SkewedPtr ;
2727
28- fn get_static_roots ( ) -> SkewedPtr ;
28+ pub ( crate ) fn get_static_roots ( ) -> SkewedPtr ;
2929}
3030
3131/// Maximum live data retained in a GC, in bytes.
@@ -88,7 +88,7 @@ pub unsafe extern "C" fn object_size(obj: SkewedPtr) -> Words<u32> {
8888 object_size_ ( obj. unskew ( ) )
8989}
9090
91- unsafe fn object_size_ ( obj : usize ) -> Words < u32 > {
91+ pub ( crate ) unsafe fn object_size_ ( obj : usize ) -> Words < u32 > {
9292 let obj = obj as * const Obj ;
9393 match ( * obj) . tag {
9494 TAG_OBJECT => {
@@ -306,7 +306,6 @@ unsafe fn scav(
306306 }
307307
308308 TAG_ARRAY => {
309- println ! ( 100 , "Scavenging array..." ) ;
310309 let array = obj as * mut Array ;
311310 let array_payload = array. offset ( 1 ) as * mut SkewedPtr ;
312311 for i in 0 ..( * array) . len as isize {
@@ -394,22 +393,23 @@ unsafe fn scav(
394393
395394// We have a special evacuation routine for "static roots" array: we don't evacuate elements of
396395// "static roots", we scavenge them.
397- unsafe fn evac_static_roots (
396+ #[ no_mangle]
397+ pub unsafe extern "C" fn evac_static_roots (
398398 begin_from_space : usize ,
399399 begin_to_space : usize ,
400400 mut end_to_space : usize ,
401401 roots : * const Array ,
402402) -> usize {
403- println ! (
404- 100 ,
405- "evac_static_roots: Evacuating {} roots..." ,
406- ( * roots) . len
407- ) ;
403+ // println!(
404+ // 100,
405+ // "evac_static_roots: Evacuating {} roots...",
406+ // (*roots).len
407+ // );
408408
409409 // Roots are in a static array which we don't evacuate. Only evacuate elements.
410410 for i in 0 ..( * roots) . len {
411411 let obj = array_idx_unchecked ( roots, i) ;
412- println ! ( 100 , "Scavenging root {}: {:#x}" , i, obj. unskew( ) ) ;
412+ // println!(100, "Scavenging root {}: {:#x}", i, obj.unskew());
413413 end_to_space = scav ( begin_from_space, begin_to_space, end_to_space, obj. unskew ( ) ) ;
414414 }
415415 end_to_space
@@ -427,28 +427,28 @@ pub unsafe extern "C" fn rust_collect_garbage() {
427427 let begin_to_space = end_from_space;
428428 let mut end_to_space = begin_to_space;
429429
430- debug_print ( "### Evacuating roots" ) ;
430+ // debug_print("### Evacuating roots");
431431
432432 let static_roots = get_static_roots ( ) . unskew ( ) as * const Array ;
433433
434- println ! (
435- 200 ,
436- "\n ### begin_from_space={:#x}\n \
437- ### end_from_space={:#x}\n \
438- ### begin_to_space={:#x}\n \
439- ### end_to_space={:#x}\n \
440- ### static_roots={:#x}",
441- begin_from_space,
442- end_from_space,
443- begin_to_space,
444- end_to_space,
445- static_roots as usize ,
446- ) ;
434+ // println!(
435+ // 200,
436+ // "\n### begin_from_space={:#x}\n\
437+ // ### end_from_space={:#x}\n\
438+ // ### begin_to_space={:#x}\n\
439+ // ### end_to_space={:#x}\n\
440+ // ### static_roots={:#x}",
441+ // begin_from_space,
442+ // end_from_space,
443+ // begin_to_space,
444+ // end_to_space,
445+ // static_roots as usize,
446+ // );
447447
448448 // Evacuate roots
449449 end_to_space = evac_static_roots ( begin_from_space, begin_to_space, end_to_space, static_roots) ;
450450
451- debug_print ( "### Evacuated static roots, evacuating closure table" ) ;
451+ // debug_print("### Evacuated static roots, evacuating closure table");
452452
453453 end_to_space = evacuate (
454454 begin_from_space,
@@ -489,54 +489,7 @@ pub unsafe extern "C" fn rust_collect_garbage() {
489489 0 ,
490490 ) ;
491491
492- println ! ( 100 , "### GC finished, new hp = {:#x}" , new_hp) ;
493- }
494-
495- unsafe fn print_closure_table ( ) {
496- let closure_tbl = closure_table_loc ( ) . unskew ( ) as * const SkewedPtr ;
497-
498- let len = if ( * closure_tbl) . 0 == 0 {
499- /*
500- println!(
501- 100,
502- "closure table ({:#x} --> {:#x}) not initialized ({})",
503- closure_tbl as usize,
504- (*closure_tbl).0,
505- closure_table_size()
506- );
507- */
508- 0
509- } else {
510- /*
511- println!(
512- 100,
513- "closure table ({:#x} --> {:#x}) size: {} -- {}",
514- closure_tbl as usize,
515- (*closure_tbl).0.wrapping_add(1),
516- (*((*closure_tbl).unskew() as *const Array)).len,
517- closure_table_size()
518- );
519- */
520- ( * ( ( * closure_tbl) . unskew ( ) as * const Array ) ) . len
521- } ;
522-
523- if len == 0 {
524- println ! ( 50 , "### Closure table empty" ) ;
525- return ;
526- }
492+ crate :: dump:: dump_heap ( ) ;
527493
528- let arr = ( * closure_tbl) . unskew ( ) as * const Array ;
529- println ! (
530- 100 ,
531- "### Closure table (table address loc={:#x}, table address={:#x})" ,
532- closure_tbl as usize ,
533- arr as usize
534- ) ;
535- for i in 0 ..len {
536- let elem = array_get ( arr, i) ;
537- if !is_tagged_scalar ( SkewedPtr ( elem as usize ) ) {
538- println ! ( 100 , "{}: {:#x}" , i, elem. wrapping_add( 1 ) ) ;
539- }
540- }
541- println ! ( 50 , "### End of closure table" ) ;
494+ println ! ( 100 , "### GC finished, new hp = {:#x}" , new_hp) ;
542495}
0 commit comments