@@ -72,7 +72,7 @@ extern value caml_fl_merge; /* Defined in freelist.c. */
72
72
redarkening required */
73
73
static char * redarken_first_chunk = NULL ;
74
74
75
- static char * sweep_chunk , * sweep_limit ;
75
+ static char * sweep_chunk ;
76
76
static double p_backlog = 0.0 ; /* backlog for the gc speedup parameter */
77
77
78
78
int caml_gc_subphase ; /* Subphase_{mark_roots,mark_main,mark_final} */
@@ -397,7 +397,6 @@ static void init_sweep_phase(void)
397
397
caml_gc_phase = Phase_sweep ;
398
398
sweep_chunk = caml_heap_start ;
399
399
caml_gc_sweep_hp = sweep_chunk ;
400
- sweep_limit = sweep_chunk + Chunk_size (sweep_chunk );
401
400
caml_fl_wsz_at_phase_change = caml_fl_cur_wsz ;
402
401
if (caml_major_gc_hook ) (* caml_major_gc_hook )();
403
402
}
@@ -698,21 +697,24 @@ static void clean_slice (intnat work)
698
697
699
698
static void sweep_slice (intnat work )
700
699
{
701
- char * hp ;
700
+ char * hp , * sweep_hp , * limit ;
702
701
header_t hd ;
703
702
704
703
caml_gc_message (0x40 , "Sweeping %"
705
704
ARCH_INTNAT_PRINTF_FORMAT "d words\n" , work );
705
+ sweep_hp = caml_gc_sweep_hp ;
706
+ limit = sweep_chunk + Chunk_size (sweep_chunk );
706
707
while (work > 0 ){
707
- if (caml_gc_sweep_hp < sweep_limit ){
708
- hp = caml_gc_sweep_hp ;
708
+ if (sweep_hp < limit ){
709
+ caml_prefetch (sweep_hp + 4000 );
710
+ hp = sweep_hp ;
709
711
hd = Hd_hp (hp );
710
712
work -= Whsize_hd (hd );
711
- caml_gc_sweep_hp += Bhsize_hd (hd );
713
+ sweep_hp += Bhsize_hd (hd );
712
714
switch (Color_hd (hd )){
713
715
case Caml_white :
714
- caml_gc_sweep_hp =
715
- (char * )caml_fl_merge_block (Val_hp (hp ), sweep_limit );
716
+ caml_gc_sweep_hp = sweep_hp ;
717
+ sweep_hp = (char * ) caml_fl_merge_block (Val_hp (hp ), limit );
716
718
break ;
717
719
case Caml_blue :
718
720
/* Only the blocks of the free-list are blue. See [freelist.c]. */
@@ -723,21 +725,23 @@ static void sweep_slice (intnat work)
723
725
Hd_hp (hp ) = Whitehd_hd (hd );
724
726
break ;
725
727
}
726
- CAMLassert (caml_gc_sweep_hp <= sweep_limit );
728
+ CAMLassert (sweep_hp <= limit );
727
729
}else {
728
730
sweep_chunk = Chunk_next (sweep_chunk );
729
731
if (sweep_chunk == NULL ){
730
732
/* Sweeping is done. */
733
+ caml_gc_sweep_hp = sweep_hp ;
731
734
++ Caml_state -> stat_major_collections ;
732
735
work = 0 ;
733
736
caml_gc_phase = Phase_idle ;
734
737
caml_request_minor_gc ();
735
738
}else {
736
- caml_gc_sweep_hp = sweep_chunk ;
737
- sweep_limit = sweep_chunk + Chunk_size (sweep_chunk );
739
+ sweep_hp = sweep_chunk ;
740
+ limit = sweep_chunk + Chunk_size (sweep_chunk );
738
741
}
739
742
}
740
743
}
744
+ caml_gc_sweep_hp = sweep_hp ;
741
745
}
742
746
743
747
/* The main entry point for the major GC. Called about once for each
@@ -1085,7 +1089,6 @@ void caml_finalise_heap (void)
1085
1089
caml_gc_phase = Phase_sweep ;
1086
1090
sweep_chunk = caml_heap_start ;
1087
1091
caml_gc_sweep_hp = sweep_chunk ;
1088
- sweep_limit = sweep_chunk + Chunk_size (sweep_chunk );
1089
1092
while (caml_gc_phase == Phase_sweep )
1090
1093
sweep_slice (LONG_MAX );
1091
1094
}
0 commit comments