@@ -2532,13 +2532,15 @@ uint8_t** gc_heap::background_mark_stack_array = 0;
2532
2532
2533
2533
size_t gc_heap::background_mark_stack_array_length = 0;
2534
2534
2535
+ BOOL gc_heap::processed_eph_overflow_p = FALSE;
2536
+
2537
+ #ifdef USE_REGIONS
2538
+ BOOL gc_heap::background_overflow_p = FALSE;
2539
+ #else //USE_REGIONS
2535
2540
uint8_t* gc_heap::background_min_overflow_address =0;
2536
2541
2537
2542
uint8_t* gc_heap::background_max_overflow_address =0;
2538
2543
2539
- BOOL gc_heap::processed_eph_overflow_p = FALSE;
2540
-
2541
- #ifndef USE_REGIONS
2542
2544
uint8_t* gc_heap::background_min_soh_overflow_address =0;
2543
2545
2544
2546
uint8_t* gc_heap::background_max_soh_overflow_address =0;
@@ -2548,7 +2550,7 @@ heap_segment* gc_heap::saved_overflow_ephemeral_seg = 0;
2548
2550
heap_segment* gc_heap::saved_sweep_ephemeral_seg = 0;
2549
2551
2550
2552
uint8_t* gc_heap::saved_sweep_ephemeral_start = 0;
2551
- #endif //! USE_REGIONS
2553
+ #endif //USE_REGIONS
2552
2554
2553
2555
Thread* gc_heap::bgc_thread = 0;
2554
2556
@@ -23429,6 +23431,21 @@ void gc_heap::mark_object (uint8_t* o THREAD_NUMBER_DCL)
23429
23431
23430
23432
#ifdef BACKGROUND_GC
23431
23433
23434
+ #ifdef USE_REGIONS
23435
+ void gc_heap::set_background_overflow_p (uint8_t* oo)
23436
+ {
23437
+ heap_segment* overflow_region = get_region_info_for_address (oo);
23438
+ overflow_region->flags |= heap_segment_flags_overflow;
23439
+ dprintf (3,("setting overflow flag for region %p", heap_segment_mem (overflow_region)));
23440
+ #ifdef MULTIPLE_HEAPS
23441
+ gc_heap* overflow_heap = heap_segment_heap (overflow_region);
23442
+ #else
23443
+ gc_heap* overflow_heap = nullptr;
23444
+ #endif
23445
+ overflow_heap->background_overflow_p = TRUE;
23446
+ }
23447
+ #endif //USE_REGIONS
23448
+
23432
23449
void gc_heap::background_mark_simple1 (uint8_t* oo THREAD_NUMBER_DCL)
23433
23450
{
23434
23451
uint8_t** mark_stack_limit = &background_mark_stack_array[background_mark_stack_array_length];
@@ -23495,9 +23512,13 @@ void gc_heap::background_mark_simple1 (uint8_t* oo THREAD_NUMBER_DCL)
23495
23512
}
23496
23513
else
23497
23514
{
23498
- dprintf (3,("mark stack overflow for object %Ix ", (size_t)oo));
23515
+ dprintf (3,("background mark stack overflow for object %Ix ", (size_t)oo));
23516
+ #ifdef USE_REGIONS
23517
+ set_background_overflow_p (oo);
23518
+ #else //USE_REGIONS
23499
23519
background_min_overflow_address = min (background_min_overflow_address, oo);
23500
23520
background_max_overflow_address = max (background_max_overflow_address, oo);
23521
+ #endif //USE_REGIONS
23501
23522
}
23502
23523
}
23503
23524
else
@@ -23609,9 +23630,13 @@ void gc_heap::background_mark_simple1 (uint8_t* oo THREAD_NUMBER_DCL)
23609
23630
}
23610
23631
else
23611
23632
{
23612
- dprintf (3,("mark stack overflow for object %Ix ", (size_t)oo));
23633
+ dprintf (3,("background mark stack overflow for object %Ix ", (size_t)oo));
23634
+ #ifdef USE_REGIONS
23635
+ set_background_overflow_p (oo);
23636
+ #else //USE_REGIONS
23613
23637
background_min_overflow_address = min (background_min_overflow_address, oo);
23614
23638
background_max_overflow_address = max (background_max_overflow_address, oo);
23639
+ #endif //USE_REGIONS
23615
23640
}
23616
23641
}
23617
23642
}
@@ -23887,13 +23912,13 @@ uint8_t* gc_heap::background_first_overflow (uint8_t* min_add,
23887
23912
BOOL concurrent_p,
23888
23913
BOOL small_object_p)
23889
23914
{
23915
+ #ifdef USE_REGIONS
23916
+ return heap_segment_mem (seg);
23917
+ #else
23890
23918
uint8_t* o = 0;
23891
23919
23892
23920
if (small_object_p)
23893
23921
{
23894
- #ifdef USE_REGIONS
23895
- return find_first_object (min_add, heap_segment_mem (seg));
23896
- #else
23897
23922
if (in_range_for_segment (min_add, seg))
23898
23923
{
23899
23924
// min_add was the beginning of gen1 when we did the concurrent
@@ -23919,11 +23944,11 @@ uint8_t* gc_heap::background_first_overflow (uint8_t* min_add,
23919
23944
}
23920
23945
}
23921
23946
}
23922
- #endif //USE_REGIONS
23923
23947
}
23924
23948
23925
23949
o = max (heap_segment_mem (seg), min_add);
23926
23950
return o;
23951
+ #endif //USE_REGIONS
23927
23952
}
23928
23953
23929
23954
void gc_heap::background_process_mark_overflow_internal (uint8_t* min_add, uint8_t* max_add,
@@ -23948,7 +23973,9 @@ void gc_heap::background_process_mark_overflow_internal (uint8_t* min_add, uint8
23948
23973
23949
23974
exclusive_sync* loh_alloc_lock = 0;
23950
23975
23976
+ #ifndef USE_REGIONS
23951
23977
dprintf (2,("Processing Mark overflow [%Ix %Ix]", (size_t)min_add, (size_t)max_add));
23978
+ #endif
23952
23979
#ifdef MULTIPLE_HEAPS
23953
23980
// We don't have each heap scan all heaps concurrently because we are worried about
23954
23981
// multiple threads calling things like find_first_object.
@@ -23981,9 +24008,14 @@ void gc_heap::background_process_mark_overflow_internal (uint8_t* min_add, uint8
23981
24008
#ifdef USE_REGIONS
23982
24009
if (heap_segment_overflow_p (seg))
23983
24010
{
23984
- assert (!concurrent_p);
23985
- current_min_add = max (heap_segment_mem (seg), min_add);
23986
- current_max_add = min (heap_segment_allocated (seg), max_add);
24011
+ seg->flags &= ~heap_segment_flags_overflow;
24012
+ current_min_add = heap_segment_mem (seg);
24013
+ current_max_add = heap_segment_allocated (seg);
24014
+ dprintf (2,("Processing Mark overflow [%Ix %Ix]", (size_t)current_min_add, (size_t)current_max_add));
24015
+ }
24016
+ else
24017
+ {
24018
+ current_min_add = current_max_add = 0;
23987
24019
}
23988
24020
#endif //USE_REGIONS
23989
24021
uint8_t* o = hp->background_first_overflow (current_min_add, seg, concurrent_p, small_object_segments);
@@ -24034,15 +24066,19 @@ void gc_heap::background_process_mark_overflow_internal (uint8_t* min_add, uint8
24034
24066
}
24035
24067
}
24036
24068
24037
- dprintf (2, ("went through overflow objects in segment %Ix (%d) (so far %Id marked)",
24038
- heap_segment_mem (seg), (small_object_segments ? 0 : 1), total_marked_objects));
24039
-
24069
+ #ifdef USE_REGIONS
24070
+ if (current_max_add != 0)
24071
+ #endif //USE_REGIONS
24072
+ {
24073
+ dprintf (2, ("went through overflow objects in segment %Ix (%d) (so far %Id marked)",
24074
+ heap_segment_mem (seg), (small_object_segments ? 0 : 1), total_marked_objects));
24075
+ }
24040
24076
#ifndef USE_REGIONS
24041
24077
if (concurrent_p && (seg == hp->saved_overflow_ephemeral_seg))
24042
24078
{
24043
24079
break;
24044
24080
}
24045
- #endif //USE_REGIONS
24081
+ #endif //! USE_REGIONS
24046
24082
seg = heap_segment_next_in_range (seg);
24047
24083
}
24048
24084
@@ -24071,36 +24107,18 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p)
24071
24107
if (concurrent_p)
24072
24108
{
24073
24109
assert (!processed_eph_overflow_p);
24074
-
24110
+ #ifndef USE_REGIONS
24075
24111
if ((background_max_overflow_address != 0) &&
24076
24112
(background_min_overflow_address != MAX_PTR))
24077
24113
{
24078
- #ifdef USE_REGIONS
24079
- // We don't want to step into the ephemeral regions so remember these regions and
24080
- // be sure to process them later. An FGC cannot happen while we are going through
24081
- // the region lists.
24082
- for (int i = 0; i < max_generation; i++)
24083
- {
24084
- heap_segment* region = generation_start_segment (generation_of (i));
24085
- while (region)
24086
- {
24087
- if ((heap_segment_mem (region) <= background_max_overflow_address) &&
24088
- (heap_segment_allocated (region) >= background_min_overflow_address))
24089
- {
24090
- region->flags |= heap_segment_flags_overflow;
24091
- }
24092
- region = heap_segment_next (region);
24093
- }
24094
- }
24095
- #else //USE_REGIONS
24096
24114
// We have overflow to process but we know we can't process the ephemeral generations
24097
24115
// now (we actually could process till the current gen1 start but since we are going to
24098
24116
// make overflow per segment, for now I'll just stop at the saved gen1 start.
24099
24117
saved_overflow_ephemeral_seg = ephemeral_heap_segment;
24100
24118
background_max_soh_overflow_address = heap_segment_reserved (saved_overflow_ephemeral_seg);
24101
24119
background_min_soh_overflow_address = generation_allocation_start (generation_of (max_generation - 1));
24102
- #endif //USE_REGIONS
24103
24120
}
24121
+ #endif //!USE_REGIONS
24104
24122
}
24105
24123
else
24106
24124
{
@@ -24114,12 +24132,18 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p)
24114
24132
{
24115
24133
// if there was no more overflow we just need to process what we didn't process
24116
24134
// on the saved ephemeral segment.
24135
+ #ifdef USE_REGIONS
24136
+ if (!background_overflow_p)
24137
+ #else
24117
24138
if ((background_max_overflow_address == 0) && (background_min_overflow_address == MAX_PTR))
24139
+ #endif //USE_REGIONS
24118
24140
{
24119
24141
dprintf (2, ("final processing mark overflow - no more overflow since last time"));
24120
24142
grow_mark_array_p = FALSE;
24121
24143
}
24122
- #ifndef USE_REGIONS
24144
+ #ifdef USE_REGIONS
24145
+ background_overflow_p = TRUE;
24146
+ #else
24123
24147
background_min_overflow_address = min (background_min_overflow_address,
24124
24148
background_min_soh_overflow_address);
24125
24149
background_max_overflow_address = max (background_max_overflow_address,
@@ -24131,8 +24155,12 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p)
24131
24155
24132
24156
BOOL overflow_p = FALSE;
24133
24157
recheck:
24158
+ #ifdef USE_REGIONS
24159
+ if (background_overflow_p)
24160
+ #else
24134
24161
if ((! ((background_max_overflow_address == 0)) ||
24135
24162
! ((background_min_overflow_address == MAX_PTR))))
24163
+ #endif
24136
24164
{
24137
24165
overflow_p = TRUE;
24138
24166
@@ -24155,11 +24183,17 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p)
24155
24183
grow_mark_array_p = TRUE;
24156
24184
}
24157
24185
24186
+ #ifdef USE_REGIONS
24187
+ uint8_t* min_add = 0;
24188
+ uint8_t* max_add = 0;
24189
+ background_overflow_p = FALSE;
24190
+ #else
24158
24191
uint8_t* min_add = background_min_overflow_address;
24159
24192
uint8_t* max_add = background_max_overflow_address;
24160
24193
24161
24194
background_max_overflow_address = 0;
24162
24195
background_min_overflow_address = MAX_PTR;
24196
+ #endif
24163
24197
24164
24198
background_process_mark_overflow_internal (min_add, max_add, concurrent_p);
24165
24199
if (!concurrent_p)
@@ -32375,6 +32409,7 @@ void gc_heap::background_scan_dependent_handles (ScanContext *sc)
32375
32409
32376
32410
if (!s_fScanRequired)
32377
32411
{
32412
+ #ifndef USE_REGIONS
32378
32413
uint8_t* all_heaps_max = 0;
32379
32414
uint8_t* all_heaps_min = MAX_PTR;
32380
32415
int i;
@@ -32390,6 +32425,7 @@ void gc_heap::background_scan_dependent_handles (ScanContext *sc)
32390
32425
g_heaps[i]->background_max_overflow_address = all_heaps_max;
32391
32426
g_heaps[i]->background_min_overflow_address = all_heaps_min;
32392
32427
}
32428
+ #endif //!USE_REGIONS
32393
32429
}
32394
32430
32395
32431
dprintf(2, ("Starting all gc thread mark stack overflow processing"));
@@ -32920,12 +32956,14 @@ void gc_heap::background_mark_phase ()
32920
32956
bpromoted_bytes (heap_number) = 0;
32921
32957
static uint32_t num_sizedrefs = 0;
32922
32958
32959
+ #ifdef USE_REGIONS
32960
+ background_overflow_p = FALSE;
32961
+ #else
32923
32962
background_min_overflow_address = MAX_PTR;
32924
32963
background_max_overflow_address = 0;
32925
- #ifndef USE_REGIONS
32926
32964
background_min_soh_overflow_address = MAX_PTR;
32927
32965
background_max_soh_overflow_address = 0;
32928
- #endif //! USE_REGIONS
32966
+ #endif //USE_REGIONS
32929
32967
processed_eph_overflow_p = FALSE;
32930
32968
32931
32969
//set up the mark lists from g_mark_list
@@ -33125,7 +33163,7 @@ void gc_heap::background_mark_phase ()
33125
33163
33126
33164
enable_preemptive ();
33127
33165
33128
- #ifdef MULTIPLE_HEAPS
33166
+ #if defined( MULTIPLE_HEAPS) && !defined(USE_REGIONS)
33129
33167
bgc_t_join.join(this, gc_join_concurrent_overflow);
33130
33168
if (bgc_t_join.joined())
33131
33169
{
@@ -33142,6 +33180,7 @@ void gc_heap::background_mark_phase ()
33142
33180
all_heaps_max = g_heaps[i]->background_max_overflow_address;
33143
33181
if (all_heaps_min > g_heaps[i]->background_min_overflow_address)
33144
33182
all_heaps_min = g_heaps[i]->background_min_overflow_address;
33183
+
33145
33184
}
33146
33185
for (i = 0; i < n_heaps; i++)
33147
33186
{
@@ -33151,7 +33190,7 @@ void gc_heap::background_mark_phase ()
33151
33190
dprintf(3, ("Starting all bgc threads after updating the overflow info"));
33152
33191
bgc_t_join.restart();
33153
33192
}
33154
- #endif //MULTIPLE_HEAPS
33193
+ #endif //MULTIPLE_HEAPS && !USE_REGIONS
33155
33194
33156
33195
disable_preemptive (true);
33157
33196
0 commit comments