@@ -14,18 +14,18 @@ use crate::types::*;
14
14
15
15
extern "C" {
16
16
/// Get end_of_heap
17
- pub fn get_hp ( ) -> usize ;
17
+ pub ( crate ) fn get_hp ( ) -> usize ;
18
18
19
19
/// Set end_of_heap
20
- pub fn set_hp ( hp : usize ) ;
20
+ pub ( crate ) fn set_hp ( hp : usize ) ;
21
21
22
22
/// Get __heap_base
23
- fn get_heap_base ( ) -> usize ;
23
+ pub ( crate ) fn get_heap_base ( ) -> usize ;
24
24
25
25
/// 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 ;
27
27
28
- fn get_static_roots ( ) -> SkewedPtr ;
28
+ pub ( crate ) fn get_static_roots ( ) -> SkewedPtr ;
29
29
}
30
30
31
31
/// Maximum live data retained in a GC, in bytes.
@@ -88,7 +88,7 @@ pub unsafe extern "C" fn object_size(obj: SkewedPtr) -> Words<u32> {
88
88
object_size_ ( obj. unskew ( ) )
89
89
}
90
90
91
- unsafe fn object_size_ ( obj : usize ) -> Words < u32 > {
91
+ pub ( crate ) unsafe fn object_size_ ( obj : usize ) -> Words < u32 > {
92
92
let obj = obj as * const Obj ;
93
93
match ( * obj) . tag {
94
94
TAG_OBJECT => {
@@ -306,7 +306,6 @@ unsafe fn scav(
306
306
}
307
307
308
308
TAG_ARRAY => {
309
- println ! ( 100 , "Scavenging array..." ) ;
310
309
let array = obj as * mut Array ;
311
310
let array_payload = array. offset ( 1 ) as * mut SkewedPtr ;
312
311
for i in 0 ..( * array) . len as isize {
@@ -394,22 +393,23 @@ unsafe fn scav(
394
393
395
394
// We have a special evacuation routine for "static roots" array: we don't evacuate elements of
396
395
// "static roots", we scavenge them.
397
- unsafe fn evac_static_roots (
396
+ #[ no_mangle]
397
+ pub unsafe extern "C" fn evac_static_roots (
398
398
begin_from_space : usize ,
399
399
begin_to_space : usize ,
400
400
mut end_to_space : usize ,
401
401
roots : * const Array ,
402
402
) -> 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
+ // );
408
408
409
409
// Roots are in a static array which we don't evacuate. Only evacuate elements.
410
410
for i in 0 ..( * roots) . len {
411
411
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());
413
413
end_to_space = scav ( begin_from_space, begin_to_space, end_to_space, obj. unskew ( ) ) ;
414
414
}
415
415
end_to_space
@@ -427,28 +427,28 @@ pub unsafe extern "C" fn rust_collect_garbage() {
427
427
let begin_to_space = end_from_space;
428
428
let mut end_to_space = begin_to_space;
429
429
430
- debug_print ( "### Evacuating roots" ) ;
430
+ // debug_print("### Evacuating roots");
431
431
432
432
let static_roots = get_static_roots ( ) . unskew ( ) as * const Array ;
433
433
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
+ // );
447
447
448
448
// Evacuate roots
449
449
end_to_space = evac_static_roots ( begin_from_space, begin_to_space, end_to_space, static_roots) ;
450
450
451
- debug_print ( "### Evacuated static roots, evacuating closure table" ) ;
451
+ // debug_print("### Evacuated static roots, evacuating closure table");
452
452
453
453
end_to_space = evacuate (
454
454
begin_from_space,
@@ -489,54 +489,7 @@ pub unsafe extern "C" fn rust_collect_garbage() {
489
489
0 ,
490
490
) ;
491
491
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 ( ) ;
527
493
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) ;
542
495
}
0 commit comments