diff options
author | Andreas Strid <andreas_strid@bredband.net> | 2015-12-21 15:33:18 +0100 |
---|---|---|
committer | Andreas Strid <andreas_strid@bredband.net> | 2016-01-31 17:33:53 +0100 |
commit | 4c375f4ddfb1d35fd57d6f208e9de30350b4dbdd (patch) | |
tree | 2a4aaff0604b37f4bef68fbef46fe4afd7cbbb79 /src/vm | |
parent | 85f256e9b41cac20834d9695675e3ac8694454f9 (diff) | |
download | coreclr-4c375f4ddfb1d35fd57d6f208e9de30350b4dbdd.tar.gz coreclr-4c375f4ddfb1d35fd57d6f208e9de30350b4dbdd.tar.bz2 coreclr-4c375f4ddfb1d35fd57d6f208e9de30350b4dbdd.zip |
Enabling profiling on Unix/OS X.
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/vm/amd64/unixstubs.cpp | 15 | ||||
-rw-r--r-- | src/vm/eetoprofinterfaceimpl.cpp | 5 | ||||
-rw-r--r-- | src/vm/eetoprofinterfaceimpl.h | 3 | ||||
-rw-r--r-- | src/vm/profilermetadataemitvalidator.cpp | 5 | ||||
-rw-r--r-- | src/vm/profilermetadataemitvalidator.h | 3 | ||||
-rw-r--r-- | src/vm/profilingenumerators.h | 61 | ||||
-rw-r--r-- | src/vm/profilinghelper.cpp | 3 | ||||
-rw-r--r-- | src/vm/profilinghelper.h | 6 | ||||
-rw-r--r-- | src/vm/proftoeeinterfaceimpl.cpp | 24 | ||||
-rw-r--r-- | src/vm/proftoeeinterfaceimpl.h | 2 |
11 files changed, 79 insertions, 52 deletions
diff --git a/src/vm/CMakeLists.txt b/src/vm/CMakeLists.txt index 964c987532..a51aac7fa1 100644 --- a/src/vm/CMakeLists.txt +++ b/src/vm/CMakeLists.txt @@ -230,6 +230,7 @@ set(VM_SOURCES_WKS profattachclient.cpp profattachserver.cpp profdetach.cpp + profilermetadataemitvalidator.cpp profilingenumerators.cpp profilinghelper.cpp proftoeeinterfaceimpl.cpp @@ -304,8 +305,7 @@ list(APPEND VM_SOURCES_WKS microsoft.comservices_i.c mngstdinterfaces.cpp notifyexternals.cpp - olecontexthelpers.cpp - profilermetadataemitvalidator.cpp + olecontexthelpers.cpp rcwrefcache.cpp rtlfunctions.cpp runtimecallablewrapper.cpp diff --git a/src/vm/amd64/unixstubs.cpp b/src/vm/amd64/unixstubs.cpp index 280113d4bc..3b9b6ae4f8 100644 --- a/src/vm/amd64/unixstubs.cpp +++ b/src/vm/amd64/unixstubs.cpp @@ -27,6 +27,21 @@ extern "C" PORTABILITY_ASSERT("Implement for PAL"); } + void ProfileEnterNaked(FunctionIDOrClientID functionIDOrClientID) + { + PORTABILITY_ASSERT("Implement for PAL"); + } + + void ProfileLeaveNaked(FunctionIDOrClientID functionIDOrClientID) + { + PORTABILITY_ASSERT("Implement for PAL"); + } + + void ProfileTailcallNaked(FunctionIDOrClientID functionIDOrClientID) + { + PORTABILITY_ASSERT("Implement for PAL"); + } + DWORD getcpuid(DWORD arg, unsigned char result[16]) { DWORD eax; diff --git a/src/vm/eetoprofinterfaceimpl.cpp b/src/vm/eetoprofinterfaceimpl.cpp index 232fc6d883..fce4207cb9 100644 --- a/src/vm/eetoprofinterfaceimpl.cpp +++ b/src/vm/eetoprofinterfaceimpl.cpp @@ -370,6 +370,11 @@ EEToProfInterfaceImpl::CHashTableImpl::CHashTableImpl(ULONG iBuckets) WRAPPER_NO_CONTRACT; } +EEToProfInterfaceImpl::CHashTableImpl::~CHashTableImpl() +{ + WRAPPER_NO_CONTRACT; +} + //--------------------------------------------------------------------------------------- // // Comparison function for hash table of ClassIDs diff --git a/src/vm/eetoprofinterfaceimpl.h b/src/vm/eetoprofinterfaceimpl.h index c87ebfc2ef..04733ad8d1 100644 --- a/src/vm/eetoprofinterfaceimpl.h +++ b/src/vm/eetoprofinterfaceimpl.h @@ -488,7 +488,8 @@ private: { public: CHashTableImpl(ULONG iBuckets); - + virtual ~CHashTableImpl(); + protected: virtual BOOL Cmp(SIZE_T k1, const HASHENTRY * pc2); }; diff --git a/src/vm/profilermetadataemitvalidator.cpp b/src/vm/profilermetadataemitvalidator.cpp index bcd573a938..98f06d3784 100644 --- a/src/vm/profilermetadataemitvalidator.cpp +++ b/src/vm/profilermetadataemitvalidator.cpp @@ -35,6 +35,11 @@ m_cRefCount(0) maxInitialGenericParam = TokenFromRid(m_pInnerInternalImport->GetCountWithTokenKind(mdtGenericParam), mdtGenericParam); } +ProfilerMetadataEmitValidator::~ProfilerMetadataEmitValidator() +{ + LIMITED_METHOD_CONTRACT; +} + //IUnknown HRESULT ProfilerMetadataEmitValidator::QueryInterface(REFIID riid, void** ppInterface) { diff --git a/src/vm/profilermetadataemitvalidator.h b/src/vm/profilermetadataemitvalidator.h index 469edf6e02..7444184e40 100644 --- a/src/vm/profilermetadataemitvalidator.h +++ b/src/vm/profilermetadataemitvalidator.h @@ -15,7 +15,8 @@ class ProfilerMetadataEmitValidator : public IMetaDataEmit2, public IMetaDataAss { public: ProfilerMetadataEmitValidator(IMetaDataEmit* pInnerEmit); - + virtual ~ProfilerMetadataEmitValidator(); + //IUnknown virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppInterface); virtual ULONG STDMETHODCALLTYPE AddRef(); diff --git a/src/vm/profilingenumerators.h b/src/vm/profilingenumerators.h index 5f5d4f487e..19802b98fb 100644 --- a/src/vm/profilingenumerators.h +++ b/src/vm/profilingenumerators.h @@ -29,17 +29,14 @@ // (e.g., ICorProfilerObjectEnum) // Element -- the type of the objects this enumerator returns. // -// pEnumInterfaceIID -- pointer to the class ID for this interface -// (you probably don't need to use this) // -// -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID = &__uuidof(EnumInterface) > +template< typename EnumInterface, typename Element > class ProfilerEnum : public EnumInterface { public: ProfilerEnum(CDynArray< Element >* elements); ProfilerEnum(); - ~ProfilerEnum(); + virtual ~ProfilerEnum(); // IUnknown functions @@ -67,8 +64,14 @@ protected: CDynArray< Element > m_elements; LONG m_refCount; + +private: + static const IID& m_pEnumInterfaceIID; }; +template< typename EnumInterface, typename Element > +const IID& ProfilerEnum< EnumInterface, Element >::m_pEnumInterfaceIID = __uuidof(EnumInterface); + // // // ProfilerEnum implementation @@ -98,8 +101,8 @@ protected: // </TODO> // // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::ProfilerEnum(CDynArray< Element >* elements) : +template< typename EnumInterface, typename Element > +ProfilerEnum< EnumInterface, Element >::ProfilerEnum(CDynArray< Element >* elements) : m_currentElement(0), m_refCount(1) { @@ -120,8 +123,8 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::ProfilerEnum(CDynArra } } -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::ProfilerEnum() : +template< typename EnumInterface, typename Element > +ProfilerEnum< EnumInterface, Element >::ProfilerEnum() : m_currentElement(0), m_refCount(1) { @@ -140,8 +143,8 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::ProfilerEnum() : // Returns // None // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::~ProfilerEnum() +template< typename EnumInterface, typename Element > +ProfilerEnum< EnumInterface, Element >::~ProfilerEnum() { } @@ -160,11 +163,11 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::~ProfilerEnum() // E_NOINTERFACE -- if the enumerator does not implement the requested interface // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > HRESULT -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::QueryInterface(REFIID id, void** pInterface) +ProfilerEnum< EnumInterface, Element >::QueryInterface(REFIID id, void** pInterface) { - if (*pEnumInterfaceIID == id) + if (m_pEnumInterfaceIID == id) { *pInterface = static_cast< EnumInterface* >(this); } @@ -182,16 +185,16 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::QueryInterface(REFIID return S_OK; } -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > ULONG -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::AddRef() +ProfilerEnum< EnumInterface, Element >::AddRef() { return InterlockedIncrement(&m_refCount); } -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > ULONG -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Release() +ProfilerEnum< EnumInterface, Element >::Release() { ULONG refCount = InterlockedDecrement(&m_refCount); @@ -225,9 +228,9 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Release() // try to advance 1 item and return S_OK if it is successful // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > HRESULT -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Next(ULONG elementsRequested, +ProfilerEnum< EnumInterface, Element >::Next(ULONG elementsRequested, Element elements[], ULONG* elementsFetched) { @@ -307,9 +310,9 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Next(ULONG elementsRe // // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > HRESULT -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::GetCount(ULONG* count) +ProfilerEnum< EnumInterface, Element >::GetCount(ULONG* count) { CONTRACTL { @@ -352,9 +355,9 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::GetCount(ULONG* count // before and after calling Skip() // // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > HRESULT -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Skip(ULONG count) +ProfilerEnum< EnumInterface, Element >::Skip(ULONG count) { CONTRACTL { @@ -392,9 +395,9 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Skip(ULONG count) // // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > HRESULT -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Reset() +ProfilerEnum< EnumInterface, Element >::Reset() { CONTRACTL { @@ -424,9 +427,9 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Reset() // E_INVALIDARG -- if pInterface is an invalid pointer // -template< typename EnumInterface, typename Element, const IID* pEnumInterfaceIID > +template< typename EnumInterface, typename Element > HRESULT -ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Clone(EnumInterface** pInterface) +ProfilerEnum< EnumInterface, Element >::Clone(EnumInterface** pInterface) { CONTRACTL { @@ -446,7 +449,7 @@ ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >::Clone(EnumInterface** HRESULT hr = S_OK; EX_TRY { - *pInterface = new ProfilerEnum< EnumInterface, Element, pEnumInterfaceIID >(&m_elements); + *pInterface = new ProfilerEnum< EnumInterface, Element >(&m_elements); } EX_CATCH { diff --git a/src/vm/profilinghelper.cpp b/src/vm/profilinghelper.cpp index 5468e42bb7..b1200aeb60 100644 --- a/src/vm/profilinghelper.cpp +++ b/src/vm/profilinghelper.cpp @@ -289,7 +289,6 @@ void CurrentProfilerStatus::Set(ProfilerStatus newProfStatus) // See code:#LoadUnloadCallbackSynchronization. CRITSEC_COOKIE ProfilingAPIUtility::s_csStatus = NULL; -#ifndef FEATURE_PAL SidBuffer * ProfilingAPIUtility::s_pSidBuffer = NULL; @@ -338,8 +337,6 @@ void ProfilingAPIUtility::AppendSupplementaryInformation(int iStringResource, SS iStringResource); } -#endif // !FEATURE_PAL - //--------------------------------------------------------------------------------------- // // Helper function to log publicly-viewable errors about profiler loading and diff --git a/src/vm/profilinghelper.h b/src/vm/profilinghelper.h index ce35d6f418..836a76eafc 100644 --- a/src/vm/profilinghelper.h +++ b/src/vm/profilinghelper.h @@ -38,9 +38,7 @@ enum ProfAPIFaultFlags }; #endif // _DEBUG -#ifndef FEATURE_PAL class SidBuffer; -#endif // !FEATURE_PAL //--------------------------------------------------------------------------------------- // Static-only class to coordinate initialization of the various profiling API @@ -83,11 +81,9 @@ private: kAttachLoad, }; -#ifndef FEATURE_PAL // Allocated lazily the first time it's needed, and then remains allocated until the // process exits. static SidBuffer * s_pSidBuffer; -#endif // !FEATURE_PAL // See code:ProfilingAPIUtility::InitializeProfiling#LoadUnloadCallbackSynchronization static CRITSEC_COOKIE s_csStatus; @@ -107,9 +103,7 @@ private: static HRESULT ProfilerCLSIDFromString(__inout_z LPWSTR wszClsid, CLSID * pClsid); static HRESULT AttemptLoadProfilerForStartup(); -#ifndef FEATURE_PAL static void AppendSupplementaryInformation(int iStringResource, SString * pString); -#endif // !FEATURE_PAL static void LogProfEventVA( int iStringResourceID, diff --git a/src/vm/proftoeeinterfaceimpl.cpp b/src/vm/proftoeeinterfaceimpl.cpp index 0c6e31d482..55ce080ddd 100644 --- a/src/vm/proftoeeinterfaceimpl.cpp +++ b/src/vm/proftoeeinterfaceimpl.cpp @@ -1157,6 +1157,7 @@ BOOL HeapWalkHelper(Object * pBO, void * pvContext) (ObjectID *) arrObjRef); } +#ifdef FEATURE_EVENT_TRACE if (s_forcedGCInProgress && ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, TRACE_LEVEL_INFORMATION, @@ -1170,6 +1171,7 @@ BOOL HeapWalkHelper(Object * pBO, void * pvContext) (Object **) arrObjRef); } +#endif // FEATURE_EVENT_TRACE // If the data was not allocated on the stack, need to clean it up. if ((arrObjRef != NULL) && !bOnStack) @@ -1298,6 +1300,7 @@ void ScanRootsHelper(Object** ppObject, ScanContext *pSC, uint32_t dwFlags) RootReference2((BYTE *)*ppObject, pPSC->dwEtwRootKind, (EtwGCRootFlags)dwEtwRootFlags, (BYTE *)rootID, &((pPSC)->pHeapId)); } +#ifdef FEATURE_EVENT_TRACE // Notify ETW of the root if (s_forcedGCInProgress && ETW_TRACING_CATEGORY_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, @@ -1313,6 +1316,7 @@ void ScanRootsHelper(Object** ppObject, ScanContext *pSC, uint32_t dwFlags) dwFlags, // dwGCFlags dwEtwRootFlags); } +#endif // FEATURE_EVENT_TRACE } @@ -4792,11 +4796,15 @@ HRESULT ProfToEEInterfaceImpl::ForceGC() LL_INFO1000, "**PROF: ForceGC.\n")); +#ifdef FEATURE_EVENT_TRACE // This helper, used by ETW and profAPI ensures a managed thread gets created for // this thread before forcing the GC (to work around Jupiter issues where it's // expected this thread is already managed before starting the GC). HRESULT hr = ETW::GCLog::ForceGCForDiagnostics(); - +#else // !FEATURE_EVENT_TRACE + HRESULT hr = E_FAIL; +#endif // FEATURE_EVENT_TRACE + // If a Thread object was just created for this thread, remember the fact that it // was a ForceGC() thread, so we can be more lenient when doing // COR_PRF_CALLBACKSTATE_INCALLBACK later on from other APIs @@ -6799,6 +6807,8 @@ StackWalkAction ProfilerStackWalkCallback(CrawlFrame *pCf, PROFILER_STACK_WALK_D return SWA_ABORT; } +#ifdef _TARGET_X86_ + //--------------------------------------------------------------------------------------- // Normally, calling GetFunction() on the frame is sufficient to ensure // HelperMethodFrames are intialized. However, sometimes we need to be able to specify @@ -6859,8 +6869,6 @@ static BOOL EnsureFrameInitialized(Frame * pFrame) return FALSE; } - -#ifdef _TARGET_X86_ //--------------------------------------------------------------------------------------- // // Implements the COR_PRF_SNAPSHOT_X86_OPTIMIZED algorithm called by DoStackSnapshot. @@ -7212,13 +7220,13 @@ HRESULT ProfToEEInterfaceImpl::DoStackSnapshot(ThreadID thread, return E_NOTIMPL; #endif -#ifndef FEATURE_HIJACK +#if !defined(FEATURE_HIJACK) || !defined(PLATFORM_SUPPORTS_SAFE_THREADSUSPEND) // DoStackSnapshot needs Thread::Suspend/ResumeThread functionality. // On platforms w/o support for these APIs return E_NOTIMPL. return E_NOTIMPL; -#else // FEATURE_HIJACK +#else // !defined(FEATURE_HIJACK) || !defined(PLATFORM_SUPPORTS_SAFE_THREADSUSPEND) CONTRACTL { @@ -7405,7 +7413,7 @@ HRESULT ProfToEEInterfaceImpl::DoStackSnapshot(ThreadID thread, _ASSERTE(!"Profiler trying to walk destroyed thread"); EEPOLICY_HANDLE_FATAL_ERROR(CORPROF_E_STACKSNAPSHOT_INVALID_TGT_THREAD); } - + // Thread::SuspendThread() ensures that no one else should try to suspend us // while we're suspending pThreadToSnapshot. // @@ -7656,7 +7664,7 @@ Cleanup: return hr; -#endif // FEATURE_HIJACK +#endif // !defined(FEATURE_HIJACK) || !defined(PLATFORM_SUPPORTS_SAFE_THREADSUSPEND) } @@ -9054,8 +9062,6 @@ HRESULT ProfToEEInterfaceImpl::EnumNgenModuleMethodsInliningThisMethod( PROFILER_TO_CLR_ENTRYPOINT_SYNC_EX(kP2EETriggers, (LF_CORPROF, LL_INFO1000, "**PROF: EnumNgenModuleMethodsInliningThisMethod.\n")); - typedef DPTR(class MethodDesc) PTR_MethodDesc; - if (ppEnum == NULL) { return E_INVALIDARG; diff --git a/src/vm/proftoeeinterfaceimpl.h b/src/vm/proftoeeinterfaceimpl.h index d256788240..1a12d136d3 100644 --- a/src/vm/proftoeeinterfaceimpl.h +++ b/src/vm/proftoeeinterfaceimpl.h @@ -144,7 +144,7 @@ public: static void ObjectRefCallback(void* context, void* objectRefUNSAFE); ProfToEEInterfaceImpl(); - ~ProfToEEInterfaceImpl(); + virtual ~ProfToEEInterfaceImpl(); HRESULT Init(); // IUnknown |