Add IsFrozenObject Profiler API (#24239)
authorMukul Sabharwal <mjsabby@gmail.com>
Thu, 25 Apr 2019 22:34:19 +0000 (15:34 -0700)
committerMaoni Stephens <Maoni0@users.noreply.github.com>
Thu, 25 Apr 2019 22:34:19 +0000 (15:34 -0700)
src/inc/corprof.idl
src/pal/prebuilt/inc/corprof.h
src/vm/proftoeeinterfaceimpl.cpp
src/vm/proftoeeinterfaceimpl.h

index 25a6201..b34fd31 100644 (file)
@@ -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);
 }
 
 /*
index f5f8413..0963b03 100644 (file)
@@ -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;
+        
     };
     
     
@@ -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;
 
@@ -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 */
 
 
index db331f4..74985a7 100644 (file)
@@ -6856,6 +6856,42 @@ HRESULT ProfToEEInterfaceImpl::GetObjectReferences(ObjectID objectId, ULONG32 cN
 }
 
 /*
+ * 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
  *
  * This function describes to a profiler the internal layout of a string.
index 2445c43..d41eec9 100644 (file)
@@ -609,6 +609,8 @@ public:
         ObjectID references[],
         SIZE_T offsets[]);
 
+    COM_METHOD IsFrozenObject(ObjectID objectId, BOOL *pbFrozen);
+
     // end ICorProfilerInfo10
 
 protected: