Skip to content

Commit

Permalink
Add IsFrozenObject Profiler API (dotnet#24239)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjsabby authored and Maoni0 committed Apr 25, 2019
1 parent e302634 commit 1445820
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/inc/corprof.idl
Original file line number Diff line number Diff line change
Expand Up @@ -3929,6 +3929,9 @@ 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[]);

// Given an ObjectID, determines whether it is in a read only segment.
HRESULT IsFrozenObject(ObjectID objectId, BOOL *pbFrozen);
}

/*
Expand Down
12 changes: 12 additions & 0 deletions src/pal/prebuilt/inc/corprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -15191,6 +15191,10 @@ EXTERN_C const IID IID_ICorProfilerInfo10;
ObjectID references[ ],
SIZE_T offsets[ ]) = 0;

virtual HRESULT STDMETHODCALLTYPE IsFrozenObject(
ObjectID objectId,
BOOL *pbFrozen) = 0;

};


Expand Down Expand Up @@ -15784,6 +15788,11 @@ EXTERN_C const IID IID_ICorProfilerInfo10;
ObjectID references[ ],
SIZE_T offsets[ ]);

HRESULT ( STDMETHODCALLTYPE *IsFrozenObject )(
ICorProfilerInfo10 * This,
ObjectID objectId,
BOOL *pbFrozen);

END_INTERFACE
} ICorProfilerInfo10Vtbl;

Expand Down Expand Up @@ -16089,6 +16098,9 @@ EXTERN_C const IID IID_ICorProfilerInfo10;
#define ICorProfilerInfo10_GetObjectReferences(This,objectId,cNumReferences,pcNumReferences,references,offsets) \
( (This)->lpVtbl -> GetObjectReferences(This,objectId,cNumReferences,pcNumReferences,references,offsets) )

#define ICorProfilerInfo10_IsFrozenObject(This,objectId,pbFrozen) \
( (This)->lpVtbl -> IsFrozenObject(This,objectId,pbFrozen) )

#endif /* COBJMACROS */


Expand Down
36 changes: 36 additions & 0 deletions src/vm/proftoeeinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6855,6 +6855,42 @@ HRESULT ProfToEEInterfaceImpl::GetObjectReferences(ObjectID objectId, ULONG32 cN
return S_OK;
}

/*
* IsFrozenObject
*
* Determines whether the object is in a read-only segment
*
* Parameters:
* objectId - object id of interest
*
* Returns:
* S_OK if successful
*
*/
HRESULT ProfToEEInterfaceImpl::IsFrozenObject(ObjectID objectId, BOOL *pbFrozen)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
EE_THREAD_NOT_REQUIRED;
CANNOT_TAKE_LOCK;
}
CONTRACTL_END;

PROFILER_TO_CLR_ENTRYPOINT_SYNC_EX(
kP2EEAllowableAfterAttach,
(LF_CORPROF,
LL_INFO1000,
"**PROF: IsFrozenObject 0x%p.\n",
objectId));

*pbFrozen = GCHeapUtilities::GetGCHeap()->IsInFrozenSegment((Object*)objectId) ? TRUE : FALSE;

return S_OK;
}

/*
* GetStringLayout
*
Expand Down
2 changes: 2 additions & 0 deletions src/vm/proftoeeinterfaceimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ class ProfToEEInterfaceImpl : public ICorProfilerInfo10
ObjectID references[],
SIZE_T offsets[]);

COM_METHOD IsFrozenObject(ObjectID objectId, BOOL *pbFrozen);

// end ICorProfilerInfo10

protected:
Expand Down

0 comments on commit 1445820

Please sign in to comment.