Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add Medium GC Profiling & ICorProfilerInfo::GetObjectReferences #24156

Merged
merged 1 commit into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/gc/env/gcenv.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class GCToEEInterface
static void DiagUpdateGenerationBounds();
static void DiagGCEnd(size_t index, int gen, int reason, bool fConcurrent);
static void DiagWalkFReachableObjects(void* gcContext);
static void DiagWalkSurvivors(void* gcContext);
static void DiagWalkSurvivors(void* gcContext, bool fCompacting);
static void DiagWalkLOHSurvivors(void* gcContext);
static void DiagWalkBGCSurvivors(void* gcContext);
static void StompWriteBarrier(WriteBarrierParameters* args);
Expand Down
21 changes: 19 additions & 2 deletions src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23060,7 +23060,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
assert (generation_allocation_segment (consing_gen) ==
ephemeral_heap_segment);

GCToEEInterface::DiagWalkSurvivors(__this);
GCToEEInterface::DiagWalkSurvivors(__this, true);

relocate_phase (condemned_gen_number, first_condemned_address);
compact_phase (condemned_gen_number, first_condemned_address,
Expand Down Expand Up @@ -23270,7 +23270,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
fix_older_allocation_area (older_gen);
}

GCToEEInterface::DiagWalkSurvivors(__this);
GCToEEInterface::DiagWalkSurvivors(__this, false);

gen0_big_free_spaces = 0;
make_free_lists (condemned_gen_number);
Expand Down Expand Up @@ -37212,6 +37212,23 @@ void GCHeap::DiagWalkObject (Object* obj, walk_fn fn, void* context)
}
}

void GCHeap::DiagWalkObject2 (Object* obj, walk_fn2 fn, void* context)
{
uint8_t* o = (uint8_t*)obj;
if (o)
{
go_through_object_cl (method_table (o), o, size(o), oo,
{
mjsabby marked this conversation as resolved.
Show resolved Hide resolved
if (*oo)
{
if (!fn (obj, oo, context))
return;
}
}
);
}
}
mjsabby marked this conversation as resolved.
Show resolved Hide resolved

void GCHeap::DiagWalkSurvivorsWithType (void* gc_context, record_surv_fn fn, void* diag_context, walk_surv_type type)
{
gc_heap* hp = (gc_heap*)gc_context;
Expand Down
4 changes: 2 additions & 2 deletions src/gc/gcenv.ee.standalone.inl
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ inline void GCToEEInterface::DiagWalkFReachableObjects(void* gcContext)
g_theGCToCLR->DiagWalkFReachableObjects(gcContext);
}

inline void GCToEEInterface::DiagWalkSurvivors(void* gcContext)
inline void GCToEEInterface::DiagWalkSurvivors(void* gcContext, bool fCompacting)
{
assert(g_theGCToCLR != nullptr);
g_theGCToCLR->DiagWalkSurvivors(gcContext);
g_theGCToCLR->DiagWalkSurvivors(gcContext, fCompacting);
}

inline void GCToEEInterface::DiagWalkLOHSurvivors(void* gcContext)
Expand Down
1 change: 1 addition & 0 deletions src/gc/gcimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class GCHeap : public IGCHeapInternal
bool ShouldRestartFinalizerWatchDog();

void DiagWalkObject (Object* obj, walk_fn fn, void* context);
void DiagWalkObject2 (Object* obj, walk_fn2 fn, void* context);
void SetFinalizeRunOnShutdown(bool value);

public: // FIX
Expand Down
2 changes: 1 addition & 1 deletion src/gc/gcinterface.ee.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class IGCToCLR {
// gives the diagnostics code a chance to run. This includes LOH if we are
// compacting LOH.
virtual
void DiagWalkSurvivors(void* gcContext) = 0;
void DiagWalkSurvivors(void* gcContext, bool fCompacting) = 0;

// During a full GC after we discover what objects to survive on LOH,
// gives the diagnostics code a chance to run.
Expand Down
4 changes: 4 additions & 0 deletions src/gc/gcinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ typedef enum
} GCHeapType;

typedef bool (* walk_fn)(Object*, void*);
typedef bool (* walk_fn2)(Object*, uint8_t**, void*);
typedef void (* gen_walk_fn)(void* context, int generation, uint8_t* range_start, uint8_t* range_end, uint8_t* range_reserved);
typedef void (* record_surv_fn)(uint8_t* begin, uint8_t* end, ptrdiff_t reloc, void* context, bool compacting_p, bool bgc_p);
typedef void (* fq_walk_fn)(bool, void*);
Expand Down Expand Up @@ -829,6 +830,9 @@ class IGCHeap {
// Walks an object, invoking a callback on each member.
virtual void DiagWalkObject(Object* obj, walk_fn fn, void* context) = 0;

// Walks an object, invoking a callback on each member.
virtual void DiagWalkObject2(Object* obj, walk_fn2 fn, void* context) = 0;

// Walk the heap object by object.
virtual void DiagWalkHeap(walk_fn fn, void* context, int gen_number, bool walk_large_object_heap_p) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/gc/sample/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void GCToEEInterface::DiagWalkFReachableObjects(void* gcContext)
{
}

void GCToEEInterface::DiagWalkSurvivors(void* gcContext)
void GCToEEInterface::DiagWalkSurvivors(void* gcContext, bool fCompacting)
{
}

Expand Down
18 changes: 17 additions & 1 deletion src/inc/corprof.idl
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,15 @@ typedef enum

COR_PRF_HIGH_BASIC_GC = 0x00000010,

// Enables the MovedReferences/MovedReferences2 callback for compacting GCs only.
mjsabby marked this conversation as resolved.
Show resolved Hide resolved
COR_PRF_HIGH_MONITOR_GC_MOVED_OBJECTS = 0x00000020,

COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,

COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED |
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS |
COR_PRF_HIGH_BASIC_GC,
COR_PRF_HIGH_BASIC_GC |
COR_PRF_HIGH_MONITOR_GC_MOVED_OBJECTS,

// MONITOR_IMMUTABLE represents all flags that may only be set during initialization.
// Trying to change any of these flags elsewhere will result in a
Expand Down Expand Up @@ -3915,6 +3919,18 @@ interface ICorProfilerInfo9 : ICorProfilerInfo8
HRESULT GetCodeInfo4(UINT_PTR pNativeCodeStartAddress, ULONG32 cCodeInfos, ULONG32* pcCodeInfos, COR_PRF_CODE_INFO codeInfos[]);
}

[
object,
uuid(2F1B5152-C869-40C9-AA5F-3ABE026BD720),
pointer_default(unique),
local
]
interface ICorProfilerInfo10 : ICorProfilerInfo9
{
// Given an ObjectID, fetches all its object references and offsets (if any).
HRESULT GetObjectReferences(ObjectID objectId, ULONG32 cNumReferences, ULONG32 *pcNumReferences, ObjectID references[], SIZE_T offsets[]);
}

/*
* This interface lets you iterate over methods in the runtime.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/inc/profilepriv.inl
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,20 @@ inline BOOL CORProfilerTrackBasicGC()
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_BASIC_GC));
}

inline BOOL CORProfilerTrackGCMovedObjects()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
}
CONTRACTL_END;

return (CORProfilerPresent() &&
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_GC_MOVED_OBJECTS));
}

#if defined(PROFILING_SUPPORTED) && !defined(CROSSGEN_COMPILE)

#if defined(FEATURE_PROFAPI_ATTACH_DETACH)
Expand Down
5 changes: 4 additions & 1 deletion src/pal/prebuilt/idl/corprof_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo7,0x9AEECC0D,0x63E0,0x4187,0x8C,0x00,0
MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo8,0xC5AC80A6,0x782E,0x4716,0x80,0x44,0x39,0x59,0x8C,0x60,0xCF,0xBF);


MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo9,0X008170DB,0XF8CC,0X4796,0X9A,0X51,0XDC,0X8A,0XA0,0XB4,0X70,0x12);
MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo9,0x008170DB,0xF8CC,0x4796,0x9A,0x51,0xDC,0x8A,0xA0,0xB4,0x70,0x12);


MIDL_DEFINE_GUID(IID, IID_ICorProfilerInfo10,0x2F1B5152,0xC869,0x40C9,0xAA,0x5F,0x3A,0xBE,0x02,0x6B,0xD7,0x20);


MIDL_DEFINE_GUID(IID, IID_ICorProfilerMethodEnum,0xFCCEE788,0x0088,0x454B,0xA8,0x11,0xC9,0x9F,0x29,0x8D,0x19,0x42);
Expand Down
Loading