Skip to content

Commit 6ea8248

Browse files
authored
Fix the build with BACKGROUND_GC turned off (#77328)
1 parent 16e4b9a commit 6ea8248

File tree

4 files changed

+69
-16
lines changed

4 files changed

+69
-16
lines changed

src/coreclr/debug/daccess/request.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2702,13 +2702,27 @@ ClrDataAccess::GetGCHeapStaticData(struct DacpGcHeapDetails *detailsData)
27022702

27032703
detailsData->lowest_address = PTR_CDADDR(g_lowest_address);
27042704
detailsData->highest_address = PTR_CDADDR(g_highest_address);
2705-
detailsData->current_c_gc_state = (CLRDATA_ADDRESS)*g_gcDacGlobals->current_c_gc_state;
2705+
if (IsBackgroundGCEnabled())
2706+
{
2707+
detailsData->current_c_gc_state = (CLRDATA_ADDRESS)*g_gcDacGlobals->current_c_gc_state;
2708+
detailsData->mark_array = (CLRDATA_ADDRESS)*g_gcDacGlobals->mark_array;
2709+
detailsData->next_sweep_obj = (CLRDATA_ADDRESS)*g_gcDacGlobals->next_sweep_obj;
2710+
detailsData->background_saved_lowest_address = (CLRDATA_ADDRESS)*g_gcDacGlobals->background_saved_lowest_address;
2711+
detailsData->background_saved_highest_address = (CLRDATA_ADDRESS)*g_gcDacGlobals->background_saved_highest_address;
2712+
}
2713+
else
2714+
{
2715+
detailsData->current_c_gc_state = 0;
2716+
detailsData->mark_array = -1;
2717+
detailsData->next_sweep_obj = 0;
2718+
detailsData->background_saved_lowest_address = 0;
2719+
detailsData->background_saved_highest_address = 0;
2720+
}
27062721

27072722
detailsData->alloc_allocated = (CLRDATA_ADDRESS)*g_gcDacGlobals->alloc_allocated;
27082723
detailsData->ephemeral_heap_segment = (CLRDATA_ADDRESS)*g_gcDacGlobals->ephemeral_heap_segment;
27092724
detailsData->card_table = PTR_CDADDR(g_card_table);
2710-
detailsData->mark_array = (CLRDATA_ADDRESS)*g_gcDacGlobals->mark_array;
2711-
detailsData->next_sweep_obj = (CLRDATA_ADDRESS)*g_gcDacGlobals->next_sweep_obj;
2725+
27122726
if (IsRegionGCEnabled())
27132727
{
27142728
// with regions, we don't have these variables anymore
@@ -2718,11 +2732,17 @@ ClrDataAccess::GetGCHeapStaticData(struct DacpGcHeapDetails *detailsData)
27182732
}
27192733
else
27202734
{
2721-
detailsData->saved_sweep_ephemeral_seg = (CLRDATA_ADDRESS)*g_gcDacGlobals->saved_sweep_ephemeral_seg;
2722-
detailsData->saved_sweep_ephemeral_start = (CLRDATA_ADDRESS)*g_gcDacGlobals->saved_sweep_ephemeral_start;
2735+
if (IsBackgroundGCEnabled())
2736+
{
2737+
detailsData->saved_sweep_ephemeral_seg = (CLRDATA_ADDRESS)*g_gcDacGlobals->saved_sweep_ephemeral_seg;
2738+
detailsData->saved_sweep_ephemeral_start = (CLRDATA_ADDRESS)*g_gcDacGlobals->saved_sweep_ephemeral_start;
2739+
}
2740+
else
2741+
{
2742+
detailsData->saved_sweep_ephemeral_seg = 0;
2743+
detailsData->saved_sweep_ephemeral_start = 0;
2744+
}
27232745
}
2724-
detailsData->background_saved_lowest_address = (CLRDATA_ADDRESS)*g_gcDacGlobals->background_saved_lowest_address;
2725-
detailsData->background_saved_highest_address = (CLRDATA_ADDRESS)*g_gcDacGlobals->background_saved_highest_address;
27262746

27272747
// get bounds for the different generations
27282748
for (unsigned int i=0; i < DAC_NUMBERGENERATIONS; i++)

src/coreclr/debug/daccess/request_common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ inline bool IsRegionGCEnabled()
108108
return (g_gcDacGlobals->minor_version_number & 1) != 0;
109109
}
110110

111+
inline bool IsBackgroundGCEnabled()
112+
{
113+
return (g_gcDacGlobals->minor_version_number & 2) == 0;
114+
}
115+
111116
// Load an instance of dac_gc_heap for the heap pointed by heap.
112117
// Fields that does not exist in the current gc_heap instance is zero initialized.
113118
// Return the dac_gc_heap object.

src/coreclr/debug/daccess/request_svr.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,28 @@ ClrDataAccess::ServerGCHeapDetails(CLRDATA_ADDRESS heapAddr, DacpGcHeapDetails *
135135

136136
detailsData->lowest_address = PTR_CDADDR(g_lowest_address);
137137
detailsData->highest_address = PTR_CDADDR(g_highest_address);
138-
detailsData->current_c_gc_state = c_gc_state_free;
139-
if (g_gcDacGlobals->current_c_gc_state != NULL)
138+
if (IsBackgroundGCEnabled())
140139
{
141140
detailsData->current_c_gc_state = (CLRDATA_ADDRESS)*g_gcDacGlobals->current_c_gc_state;
141+
detailsData->mark_array = (CLRDATA_ADDRESS)pHeap->mark_array;
142+
detailsData->next_sweep_obj = (CLRDATA_ADDRESS)pHeap->next_sweep_obj;
143+
detailsData->background_saved_lowest_address = (CLRDATA_ADDRESS)pHeap->background_saved_lowest_address;
144+
detailsData->background_saved_highest_address = (CLRDATA_ADDRESS)pHeap->background_saved_highest_address;
142145
}
146+
else
147+
{
148+
detailsData->current_c_gc_state = 0;
149+
detailsData->mark_array = -1;
150+
detailsData->next_sweep_obj = 0;
151+
detailsData->background_saved_lowest_address = 0;
152+
detailsData->background_saved_highest_address = 0;
153+
}
154+
143155
// now get information specific to this heap (server mode gives us several heaps; we're getting
144156
// information about only one of them.
145157
detailsData->alloc_allocated = (CLRDATA_ADDRESS)pHeap->alloc_allocated;
146158
detailsData->ephemeral_heap_segment = (CLRDATA_ADDRESS)dac_cast<TADDR>(pHeap->ephemeral_heap_segment);
147159
detailsData->card_table = (CLRDATA_ADDRESS)pHeap->card_table;
148-
detailsData->mark_array = (CLRDATA_ADDRESS)pHeap->mark_array;
149-
detailsData->next_sweep_obj = (CLRDATA_ADDRESS)pHeap->next_sweep_obj;
150160
if (IsRegionGCEnabled())
151161
{
152162
// with regions, we don't have these variables anymore
@@ -156,11 +166,17 @@ ClrDataAccess::ServerGCHeapDetails(CLRDATA_ADDRESS heapAddr, DacpGcHeapDetails *
156166
}
157167
else
158168
{
159-
detailsData->saved_sweep_ephemeral_seg = (CLRDATA_ADDRESS)dac_cast<TADDR>(pHeap->saved_sweep_ephemeral_seg);
160-
detailsData->saved_sweep_ephemeral_start = (CLRDATA_ADDRESS)pHeap->saved_sweep_ephemeral_start;
169+
if (IsBackgroundGCEnabled())
170+
{
171+
detailsData->saved_sweep_ephemeral_seg = (CLRDATA_ADDRESS)dac_cast<TADDR>(pHeap->saved_sweep_ephemeral_seg);
172+
detailsData->saved_sweep_ephemeral_start = (CLRDATA_ADDRESS)pHeap->saved_sweep_ephemeral_start;
173+
}
174+
else
175+
{
176+
detailsData->saved_sweep_ephemeral_seg = 0;
177+
detailsData->saved_sweep_ephemeral_start = 0;
178+
}
161179
}
162-
detailsData->background_saved_lowest_address = (CLRDATA_ADDRESS)pHeap->background_saved_lowest_address;
163-
detailsData->background_saved_highest_address = (CLRDATA_ADDRESS)pHeap->background_saved_highest_address;
164180

165181
// get bounds for the different generations
166182
for (unsigned int i=0; i < DAC_NUMBERGENERATIONS; i++)

src/coreclr/gc/gc.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11821,7 +11821,11 @@ void gc_heap::init_heap_segment (heap_segment* seg, gc_heap* hp
1182111821
#ifndef USE_REGIONS
1182211822
bool existing_region_p = false;
1182311823
#endif //!USE_REGIONS
11824+
#ifdef BACKGROUND_GC
1182411825
seg->flags = existing_region_p ? (seg->flags & heap_segment_flags_ma_committed) : 0;
11826+
#else
11827+
seg->flags = 0;
11828+
#endif
1182511829
heap_segment_next (seg) = 0;
1182611830
heap_segment_plan_allocated (seg) = heap_segment_mem (seg);
1182711831
heap_segment_allocated (seg) = heap_segment_mem (seg);
@@ -30867,7 +30871,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
3086730871
}
3086830872
region = heap_segment_next (region);
3086930873
}
30870-
30874+
#ifdef BACKGROUND_GC
3087130875
if (oh == soh)
3087230876
{
3087330877
heap_segment* freeable = hp->freeable_soh_segment;
@@ -30889,6 +30893,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
3088930893
freeable = heap_segment_next (freeable);
3089030894
}
3089130895
}
30896+
#endif //BACKGROUND_GC
3089230897
}
3089330898
if (i >= max_generation)
3089430899
{
@@ -44443,6 +44448,7 @@ void gc_heap::verify_regions (bool can_verify_gen_num, bool concurrent_p)
4444344448
heap_hard_limit)
4444444449
{
4444544450
int oh = i - max_generation;
44451+
#ifdef BACKGROUND_GC
4444644452
if (oh == soh)
4444744453
{
4444844454
heap_segment* freeable = freeable_soh_segment;
@@ -44464,6 +44470,7 @@ void gc_heap::verify_regions (bool can_verify_gen_num, bool concurrent_p)
4446444470
freeable = heap_segment_next (freeable);
4446544471
}
4446644472
}
44473+
#endif //BACKGROUND_GC
4446744474
#ifdef MULTIPLE_HEAPS
4446844475
#ifdef _DEBUG
4446944476
size_t total_accounted = committed_by_oh_per_heap[i - max_generation];
@@ -47590,6 +47597,7 @@ size_t GCHeap::ApproxTotalBytesInUse(BOOL small_heap_only)
4759047597

4759147598
int stop_gen_index = max_generation;
4759247599

47600+
#ifdef BACKGROUND_GC
4759347601
if (gc_heap::current_c_gc_state == c_gc_state_planning)
4759447602
{
4759547603
// During BGC sweep since we can be deleting SOH segments, we avoid walking the segment
@@ -47598,6 +47606,7 @@ size_t GCHeap::ApproxTotalBytesInUse(BOOL small_heap_only)
4759847606
totsize = pGenGCHeap->background_soh_size_end_mark - generation_free_list_space (oldest_gen) - generation_free_obj_space (oldest_gen);
4759947607
stop_gen_index--;
4760047608
}
47609+
#endif //BACKGROUND_GC
4760147610

4760247611
for (int i = (max_generation - 1); i <= stop_gen_index; i++)
4760347612
{
@@ -49161,6 +49170,9 @@ void PopulateDacVars(GcDacVars *gcDacVars)
4916149170
#ifdef USE_REGIONS
4916249171
gcDacVars->minor_version_number |= 1;
4916349172
#endif //USE_REGIONS
49173+
#ifndef BACKGROUND_GC
49174+
gcDacVars->minor_version_number |= 2;
49175+
#endif //!BACKGROUND_GC
4916449176
gcDacVars->built_with_svr = &g_built_with_svr_gc;
4916549177
gcDacVars->build_variant = &g_build_variant;
4916649178
gcDacVars->gc_structures_invalid_cnt = const_cast<int32_t*>(&GCScan::m_GcStructuresInvalidCnt);

0 commit comments

Comments
 (0)