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

Commit

Permalink
Merge in 'release/2.0.0' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Feb 12, 2018
2 parents 5867b65 + 7f14336 commit bb01fb0
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 28 deletions.
14 changes: 11 additions & 3 deletions src/vm/eventpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ EventPipeProvider* EventPipe::CreateProvider(const GUID &providerID, EventPipeCa
}
CONTRACTL_END;

return new EventPipeProvider(providerID, pCallbackFunction, pCallbackData);
EventPipeProvider *pProvider = NULL;
if (s_pConfig != NULL)
{
pProvider = s_pConfig->CreateProvider(providerID, pCallbackFunction, pCallbackData);
}

return pProvider;
}

void EventPipe::DeleteProvider(EventPipeProvider *pProvider)
Expand Down Expand Up @@ -276,8 +282,10 @@ void EventPipe::DeleteProvider(EventPipeProvider *pProvider)
else
{
// Delete the provider now.
// NOTE: This will remove it from all of the EventPipe data structures.
delete(pProvider);
if (s_pConfig != NULL)
{
s_pConfig->DeleteProvider(pProvider);
}
}
}
}
Expand Down
53 changes: 50 additions & 3 deletions src/vm/eventpipeconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ EventPipeConfiguration::~EventPipeConfiguration()
MODE_ANY;
}
CONTRACTL_END;

if(m_pConfigProvider != NULL)
{
DeleteProvider(m_pConfigProvider);
}

if(m_pEnabledProviderList != NULL)
{
Expand All @@ -59,7 +64,7 @@ void EventPipeConfiguration::Initialize()
CONTRACTL_END;

// Create the configuration provider.
m_pConfigProvider = EventPipe::CreateProvider(s_configurationProviderID);
m_pConfigProvider = CreateProvider(s_configurationProviderID, NULL, NULL);

// Create the metadata event.
m_pMetadataEvent = m_pConfigProvider->AddEvent(
Expand All @@ -70,6 +75,49 @@ void EventPipeConfiguration::Initialize()
false); /* needStack */
}

EventPipeProvider* EventPipeConfiguration::CreateProvider(const GUID &providerID, EventPipeCallback pCallbackFunction, void *pCallbackData)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;

// Allocate a new provider.
EventPipeProvider *pProvider = new EventPipeProvider(this, providerID, pCallbackFunction, pCallbackData);

// Register the provider with the configuration system.
RegisterProvider(*pProvider);

return pProvider;
}

void EventPipeConfiguration::DeleteProvider(EventPipeProvider *pProvider)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(pProvider != NULL);
}
CONTRACTL_END;

if (pProvider == NULL)
{
return;
}

// Unregister the provider.
UnregisterProvider(*pProvider);

// Free the provider itself.
delete(pProvider);
}


bool EventPipeConfiguration::RegisterProvider(EventPipeProvider &provider)
{
CONTRACTL
Expand Down Expand Up @@ -400,8 +448,7 @@ void EventPipeConfiguration::DeleteDeferredProviders()
EventPipeProvider *pProvider = pElem->GetValue();
if(pProvider->GetDeleteDeferred())
{
// The act of deleting the provider unregisters it and removes it from the list.
delete(pProvider);
DeleteProvider(pProvider);
}

pElem = m_pProviderList->GetNext(pElem);
Expand Down
7 changes: 7 additions & 0 deletions src/vm/eventpipeconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#ifdef FEATURE_PERFTRACING

#include "eventpipe.h"
#include "slist.h"

class EventPipeEnabledProvider;
Expand Down Expand Up @@ -35,6 +36,12 @@ class EventPipeConfiguration
// Perform initialization that cannot be performed in the constructor.
void Initialize();

// Create a new provider.
EventPipeProvider* CreateProvider(const GUID &providerID, EventPipeCallback pCallbackFunction, void *pCallbackData);

// Delete a provider.
void DeleteProvider(EventPipeProvider *pProvider);

// Register a provider.
bool RegisterProvider(EventPipeProvider &provider);

Expand Down
18 changes: 3 additions & 15 deletions src/vm/eventpipeprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

#ifdef FEATURE_PERFTRACING

EventPipeProvider::EventPipeProvider(const GUID &providerID, EventPipeCallback pCallbackFunction, void *pCallbackData)
EventPipeProvider::EventPipeProvider(EventPipeConfiguration *pConfig, const GUID &providerID, EventPipeCallback pCallbackFunction, void *pCallbackData)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(pConfig != NULL);
}
CONTRACTL_END;

Expand All @@ -27,11 +28,7 @@ EventPipeProvider::EventPipeProvider(const GUID &providerID, EventPipeCallback p
m_pEventList = new SList<SListElem<EventPipeEvent*>>();
m_pCallbackFunction = pCallbackFunction;
m_pCallbackData = pCallbackData;
m_pConfig = EventPipe::GetConfiguration();
_ASSERTE(m_pConfig != NULL);

// Register the provider.
m_pConfig->RegisterProvider(*this);
m_pConfig = pConfig;
}

EventPipeProvider::~EventPipeProvider()
Expand All @@ -44,15 +41,6 @@ EventPipeProvider::~EventPipeProvider()
}
CONTRACTL_END;

// Unregister the provider.
// This call is re-entrant.
// NOTE: We don't use the cached event pipe configuration pointer
// in case this runs during shutdown and the configuration has already
// been freed.
EventPipeConfiguration* pConfig = EventPipe::GetConfiguration();
_ASSERTE(pConfig != NULL);
pConfig->UnregisterProvider(*this);

// Free all of the events.
if(m_pEventList != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/vm/eventpipeprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class EventPipeProvider
bool m_deleteDeferred;

// Private constructor because all providers are created through EventPipe::CreateProvider.
EventPipeProvider(const GUID &providerID, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL);
EventPipeProvider(EventPipeConfiguration *pConfig, const GUID &providerID, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL);

public:

Expand Down
12 changes: 6 additions & 6 deletions src/vm/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,12 +987,6 @@ void DestroyThread(Thread *th)
#endif // _TARGET_X86_
#endif // WIN64EXCEPTIONS

if (g_fEEShutDown == 0)
{
th->SetThreadState(Thread::TS_ReportDead);
th->OnThreadTerminate(FALSE);
}

#ifdef FEATURE_PERFTRACING
// Before the thread dies, mark its buffers as no longer owned
// so that they can be cleaned up after the thread dies.
Expand All @@ -1002,6 +996,12 @@ void DestroyThread(Thread *th)
pBufferList->SetOwnedByThread(false);
}
#endif // FEATURE_PERFTRACING

if (g_fEEShutDown == 0)
{
th->SetThreadState(Thread::TS_ReportDead);
th->OnThreadTerminate(FALSE);
}
}

//-------------------------------------------------------------------------
Expand Down

0 comments on commit bb01fb0

Please sign in to comment.