Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
DiagAddNewRegion prototype
  • Loading branch information
cshung committed Aug 26, 2021
commit b0db7d8305bc5797b98ed7eb22d7ec3119bf0ab9
2 changes: 2 additions & 0 deletions src/coreclr/gc/env/gcenv.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class GCToEEInterface
static void UpdateGCEventStatus(int publicLevel, int publicKeywords, int privateLevel, int privateKeywords);
static void LogStressMsg(unsigned level, unsigned facility, const StressLogMsg &msg);
static uint32_t GetCurrentProcessCpuCount();

static void DiagAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved);
};

#endif // __GCENV_EE_H__
11 changes: 11 additions & 0 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16117,18 +16117,29 @@ BOOL gc_heap::soh_try_fit (int gen_number,
fix_youngest_allocation_area();

heap_segment* next_seg = heap_segment_next (ephemeral_heap_segment);
bool new_seg = false;

if (!next_seg)
{
assert (ephemeral_heap_segment == generation_tail_region (generation_of (gen_number)));
next_seg = get_new_region (gen_number);
new_seg = true;
}

if (next_seg)
{
dprintf (REGIONS_LOG, ("eph seg %Ix -> next %Ix",
heap_segment_mem (ephemeral_heap_segment), heap_segment_mem (next_seg)));
ephemeral_heap_segment = next_seg;
if (new_seg)
{
GCToEEInterface::DiagAddNewRegion(
heap_segment_gen_num (next_seg),
heap_segment_mem (next_seg),
heap_segment_allocated (next_seg),
heap_segment_reserved (next_seg)
);
}
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/gc/gcenv.ee.standalone.inl
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,9 @@ inline uint32_t GCToEEInterface::GetCurrentProcessCpuCount()
return g_theGCToCLR->GetCurrentProcessCpuCount();
}

inline void GCToEEInterface::DiagAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved)
{
g_theGCToCLR->DiagAddNewRegion(generation, rangeStart, rangeEnd, rangeEndReserved);
}

#endif // __GCTOENV_EE_STANDALONE_INL__
3 changes: 3 additions & 0 deletions src/coreclr/gc/gcinterface.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ class IGCToCLR {

virtual
uint32_t GetCurrentProcessCpuCount() = 0;

virtual
void DiagAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved) = 0;
};

#endif // _GCINTERFACE_EE_H_
4 changes: 4 additions & 0 deletions src/coreclr/gc/sample/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,7 @@ uint32_t GCToEEInterface::GetCurrentProcessCpuCount()
{
return GCToOSInterface::GetTotalProcessorCount();
}

void GCToEEInterface::DiagAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved)
{
}
2 changes: 2 additions & 0 deletions src/coreclr/vm/eeprofinterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ void __stdcall GarbageCollectionStartedCallback(int generation, BOOL induced);
void __stdcall GarbageCollectionFinishedCallback();

void __stdcall UpdateGenerationBounds();

void __stdcall ProfAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved);
#include "eetoprofinterfaceimpl.h"


Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1732,3 +1732,8 @@ uint32_t GCToEEInterface::GetCurrentProcessCpuCount()
{
return ::GetCurrentProcessCpuCount();
}

void GCToEEInterface::DiagAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved)
{
ProfAddNewRegion(generation, rangeStart, rangeEnd, rangeEndReserved);
}
2 changes: 2 additions & 0 deletions src/coreclr/vm/gcenv.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class GCToEEInterface : public IGCToCLR {

void LogStressMsg(unsigned level, unsigned facility, const StressLogMsg& msg);
uint32_t GetCurrentProcessCpuCount();

void DiagAddNewRegion(int generation, BYTE * rangeStart, BYTE * rangeEnd, BYTE * rangeEndReserved);
};

} // namespace standalone
Expand Down
38 changes: 37 additions & 1 deletion src/coreclr/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ struct GenerationTable
{
ULONG count;
ULONG capacity;
static const ULONG defaultCapacity = 5; // that's the minimum for Gen0-2 + LOH + POH
// Bad code - make it easy to add a record without worry
static const ULONG defaultCapacity = 50000; // that's the minimum for Gen0-2 + LOH + POH
GenerationTable *prev;
GenerationDesc *genDescTable;
#ifdef _DEBUG
Expand Down Expand Up @@ -903,6 +904,37 @@ void __stdcall UpdateGenerationBounds()
RETURN;
}

void __stdcall ProfAddNewRegion(int generation, uint8_t* rangeStart, uint8_t* rangeEnd, uint8_t* rangeEndReserved)
{
CONTRACT_VOID
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY; // can be called even on GC threads
} CONTRACT_END;
#ifdef PROFILING_SUPPORTED
if (CORProfilerTrackGC() || CORProfilerTrackBasicGC())
{
ULONG count = s_currentGenerationTable->count;
if (count < s_currentGenerationTable->capacity)
{
// Bad code - this needs to be thread safe
s_currentGenerationTable->genDescTable[count].generation = generation;
s_currentGenerationTable->genDescTable[count].rangeStart = rangeStart;
s_currentGenerationTable->genDescTable[count].rangeEnd = rangeEnd;
s_currentGenerationTable->genDescTable[count].rangeEndReserved = rangeEndReserved;
s_currentGenerationTable->count = count + 1;
}
else
{
// Bad code - this could happen
assert (false);
}
}
#endif // PROFILING_SUPPORTED
RETURN;
}

#ifdef PROFILING_SUPPORTED

//---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -8858,6 +8890,8 @@ HRESULT ProfToEEInterfaceImpl::GetGenerationBounds(ULONG cObjectRanges,

_ASSERTE(generationTable->magic == GENERATION_TABLE_MAGIC);

// For a large application, we could have lots of regions
// We might be able to optimize if we could merge adjacent regions of the same generation
GenerationDesc *genDescTable = generationTable->genDescTable;
ULONG count = min(generationTable->count, cObjectRanges);
for (ULONG i = 0; i < count; i++)
Expand Down Expand Up @@ -8994,6 +9028,8 @@ HRESULT ProfToEEInterfaceImpl::GetObjectGeneration(ObjectID objectId,

GenerationDesc *genDescTable = generationTable->genDescTable;
ULONG count = generationTable->count;
// For a large application, we could have lots of regions
// Searching sequentially could be slow.
for (ULONG i = 0; i < count; i++)
{
if (genDescTable[i].rangeStart <= (BYTE *)objectId && (BYTE *)objectId < genDescTable[i].rangeEndReserved)
Expand Down