Functions | |
static void | _tm_gc_clear_stats () |
Clear GC stats. | |
void | _tm_gc_full_type_inner (tm_type *type) |
Force a full GC for a specific type. | |
void | _tm_gc_full_inner () |
Force a full GC sequence. | |
void | tm_gc_full () |
Force a full GC. |
static void _tm_gc_clear_stats | ( | ) | [static] |
Clear GC stats.
Definition at line 1666 of file tm.c.
References tm_data::blocks_allocated_since_gc, tm_data::blocks_in_use_after_gc, tm_data::bytes_allocated_since_gc, tm_data::bytes_in_use_after_gc, tm_data::n, tm_data::nodes_allocated_since_gc, tm_data::nodes_in_use_after_gc, tm, tm_b, tm_B, tm_NU, tm_TOTAL, and tm_WHITE.
Referenced by _tm_gc_full_type_inner().
01667 { 01668 tm.blocks_allocated_since_gc = 0; 01669 tm.blocks_in_use_after_gc = tm.n[tm_B]; 01670 01671 tm.nodes_allocated_since_gc = 0; 01672 tm.nodes_in_use_after_gc = tm.n[tm_NU] = tm.n[tm_TOTAL] - tm.n[tm_WHITE]; 01673 01674 tm.bytes_allocated_since_gc = 0; 01675 tm.bytes_in_use_after_gc = tm.n[tm_b]; 01676 }
void _tm_gc_full_inner | ( | ) |
Force a full GC sequence.
Definition at line 1749 of file tm.c.
References _tm_gc_full_type_inner().
Referenced by tm_alloc(), and tm_gc_full().
01750 { 01751 _tm_gc_full_type_inner(0); 01752 }
void _tm_gc_full_type_inner | ( | tm_type * | type | ) |
Force a full GC for a specific type.
Unmark all marked nodes.
Scan all roots, mark pointers.
Scan all marked nodes.
Sweep the unmarked nodes.
Unmark all marked nodes.
Possibly sweep some blocks.
Start tm_ALLOC phase.
Clear GC stats.
Definition at line 1689 of file tm.c.
References _tm_block_sweep_some(), _tm_gc_clear_stats(), _tm_node_scan_all(), _tm_node_sweep_all(), _tm_node_unmark_all(), _tm_phase_init(), _tm_root_scan_all(), _tm_sweep_is_error, tm_data::n, tm, tm_ALLOC, tm_assert_test, tm_BLACK, tm_ECRU, tm_GREY, tm_msg(), tm_ROOT, tm_SCAN, tm_SWEEP, tm_time_stat_begin(), tm_time_stat_end(), tm_UNMARK, and tm_data::ts_gc_inner.
Referenced by _tm_gc_full_inner().
01690 { 01691 int try = 0; 01692 01693 tm_msg("gc {\n"); 01694 01695 #if tm_TIME_STAT 01696 tm_time_stat_begin(&tm.ts_gc_inner); 01697 #endif 01698 01699 _tm_sweep_is_error = 0; 01700 01701 /* Try this twice: */ 01702 while ( try ++ < 1 ) { 01703 /*! Unmark all marked nodes. */ 01704 _tm_phase_init(tm_UNMARK); 01705 _tm_node_unmark_all(); 01706 tm_assert_test(tm.n[tm_BLACK] == 0); 01707 01708 /*! Scan all roots, mark pointers. */ 01709 _tm_phase_init(tm_ROOT); 01710 _tm_root_scan_all(); 01711 01712 /*! Scan all marked nodes. */ 01713 _tm_phase_init(tm_SCAN); 01714 _tm_node_scan_all(); 01715 tm_assert_test(tm.n[tm_GREY] == 0); 01716 01717 /*! Sweep the unmarked nodes. */ 01718 _tm_phase_init(tm_SWEEP); 01719 _tm_node_sweep_all(); 01720 tm_assert_test(tm.n[tm_ECRU] == 0); 01721 01722 /*! Unmark all marked nodes. */ 01723 _tm_phase_init(tm_UNMARK); 01724 _tm_node_unmark_all(); 01725 tm_assert_test(tm.n[tm_BLACK] == 0); 01726 01727 /*! Possibly sweep some blocks. */ 01728 while ( _tm_block_sweep_some() ) { 01729 } 01730 01731 /*! Start tm_ALLOC phase. */ 01732 _tm_phase_init(tm_ALLOC); 01733 } 01734 01735 /*! Clear GC stats. */ 01736 _tm_gc_clear_stats(); 01737 01738 #if tm_TIME_STAT 01739 tm_time_stat_end(&tm.ts_gc_inner); 01740 #endif 01741 01742 tm_msg("gc }\n"); 01743 }
void tm_gc_full | ( | ) |
Force a full GC.
May stop world.
Force a full GC.
Definition at line 184 of file user.c.
References _tm_clear_some_stack_words, _tm_gc_full_inner(), _tm_set_stack_ptr(), tm_data::inited, tm, tm_init(), tm_time_stat_begin(), tm_time_stat_end(), and tm_data::ts_gc.
00185 { 00186 void *ptr = 0; 00187 00188 if ( ! tm.inited ) { 00189 tm_init(0, (char***) ptr, 0); 00190 } 00191 00192 #if tm_TIME_STAT 00193 tm_time_stat_begin(&tm.ts_gc); 00194 #endif 00195 00196 _tm_clear_some_stack_words(); 00197 _tm_set_stack_ptr(&ptr); 00198 00199 _tm_gc_full_inner(); 00200 00201 #if tm_TIME_STAT 00202 tm_time_stat_end(&tm.ts_gc); 00203 #endif 00204 }