未验证 提交 7b26bfb5 编写于 作者: E Elinor Fung 提交者: GitHub

Remove some unnecessary indirection to...

Remove some unnecessary indirection to DiagnosticServerAdapter/EventPipeAdapter in nativeaot (#90132)
上级 32a8c2d8
......@@ -64,6 +64,8 @@
#ifndef __GCENV_BASE_INCLUDED__
#include <cstdint>
//
// This macro returns val rounded up as necessary to be a multiple of alignment; alignment must be a power of 2
//
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
void EventPipeAdapter_Initialize() {}
void EventPipe_Initialize() {}
bool DiagnosticServerAdapter_Initialize() { return false; }
void DiagnosticServerAdapter_PauseForDiagnosticsMonitor() {}
bool DiagnosticServer_Initialize() { return false; }
void DiagnosticServer_PauseForDiagnosticsMonitor() {}
void EventPipeAdapter_FinishInitialize() {}
void EventPipe_FinishInitialize() {}
void EventPipe_ThreadShutdown() { }
void EventPipeAdapter_Shutdown() {}
bool DiagnosticServerAdapter_Shutdown() { return false; }
void EventPipe_Shutdown() {}
bool DiagnosticServer_Shutdown() { return false; }
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "eventpipeadapter.h"
#include "diagnosticserveradapter.h"
#include <eventpipe/ep.h>
#include <eventpipe/ep-rt-aot.h>
#include <eventpipe/ds-server.h>
void EventPipeAdapter_Initialize() { EventPipeAdapter::Initialize(); }
void EventPipe_Initialize() { ep_init(); }
bool DiagnosticServerAdapter_Initialize() { return DiagnosticServerAdapter::Initialize(); }
void DiagnosticServerAdapter_PauseForDiagnosticsMonitor() { DiagnosticServerAdapter::PauseForDiagnosticsMonitor();}
bool DiagnosticServer_Initialize() { return ds_server_init(); }
void DiagnosticServer_PauseForDiagnosticsMonitor() { ds_server_pause_for_diagnostics_monitor(); }
void EventPipeAdapter_FinishInitialize() { EventPipeAdapter::FinishInitialize(); }
void EventPipe_FinishInitialize() { ep_finish_init(); }
void EventPipe_ThreadShutdown() { ep_rt_aot_thread_exited(); }
void EventPipeAdapter_Shutdown() { EventPipeAdapter::Shutdown(); }
bool DiagnosticServerAdapter_Shutdown() { return DiagnosticServerAdapter::Shutdown(); }
void EventPipe_Shutdown() { ep_shutdown(); }
bool DiagnosticServer_Shutdown() { return ds_server_shutdown(); }
......@@ -5,19 +5,18 @@
#define EVENTPIPE_INTERFACE_H
// Initialize EventPipe
void EventPipeAdapter_Initialize();
void EventPipe_Initialize();
// Initialize DS
bool DiagnosticServerAdapter_Initialize();
void DiagnosticServerAdapter_PauseForDiagnosticsMonitor();
bool DiagnosticServer_Initialize();
void DiagnosticServer_PauseForDiagnosticsMonitor();
void EventPipeAdapter_FinishInitialize();
void EventPipe_FinishInitialize();
void EventPipe_ThreadShutdown();
void EventPipeAdapter_Shutdown();
bool DiagnosticServerAdapter_Shutdown();
void EventPipe_Shutdown();
bool DiagnosticServer_Shutdown();
void EventTracing_Initialize();
#endif //EVENTPIPE_INTERFACE_H
\ No newline at end of file
......@@ -17,6 +17,10 @@
#include <sal.h>
#include <stdarg.h>
#ifdef TARGET_UNIX
#include <pthread.h>
#endif
#include "CommonTypes.h"
#include "CommonMacros.h"
#include "gcenv.structs.h" // CRITICAL_SECTION
......
......@@ -4,7 +4,12 @@
#ifndef __StackFrameIterator_h__
#define __StackFrameIterator_h__
#include "CommonMacros.h"
#include "ICodeManager.h"
#include "PalRedhawk.h" // NATIVE_CONTEXT
#include "regdisplay.h"
#include "forward_declarations.h"
struct ExInfo;
typedef DPTR(ExInfo) PTR_ExInfo;
......@@ -22,6 +27,7 @@ struct EHEnum
EHEnumState m_state;
};
class StackFrameIterator;
EXTERN_C FC_BOOL_RET FASTCALL RhpSfiInit(StackFrameIterator* pThis, PAL_LIMITED_CONTEXT* pStackwalkCtx, CLR_BOOL instructionFault);
EXTERN_C FC_BOOL_RET FASTCALL RhpSfiNext(StackFrameIterator* pThis, uint32_t* puExCollideClauseIdx, CLR_BOOL* pfUnwoundReversePInvoke);
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifndef DIAGNOSTIC_SERVER_ADAPTER_H
#define DIAGNOSTIC_SERVER_ADAPTER_H
#if defined(FEATURE_PERFTRACING)
#include <eventpipe/ds-server.h>
class DiagnosticServerAdapter final
{
public:
static inline bool Initialize()
{
return ds_server_init();
}
static inline bool Shutdown()
{
return ds_server_shutdown();
}
NOINLINE static void PauseForDiagnosticsMonitor()
{
return ds_server_pause_for_diagnostics_monitor();
}
static void ResumeRuntimeStartup()
{
return ds_server_resume_runtime_startup();
}
static bool IsPausedInRuntimeStartup()
{
return ds_server_is_paused_in_startup();
}
};
#endif // FEATURE_PERFTRACING
#endif // DIAGNOSTIC_SERVER_ADAPTER_H
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "common.h"
#include "eventpipeadapter.h"
#include "CommonTypes.h"
#include "CommonMacros.h"
#include "PalRedhawk.h"
#ifdef FEATURE_PERFTRACING
#include <eventpipe/ep.h>
#include "gcenv.h"
#include "regdisplay.h"
#include "StackFrameIterator.h"
#include "thread.h"
#include "SpinLock.h"
#ifdef FEATURE_PERFTRACING
struct EventPipeEventInstanceData;
struct EventPipeSessionInfo;
EXTERN_C NATIVEAOT_API uint64_t __cdecl RhEventPipeInternal_Enable(
LPCWSTR outputFile,
const WCHAR* outputFile,
EventPipeSerializationFormat format,
uint32_t circularBufferSizeInMB,
/* COR_PRF_EVENTPIPE_PROVIDER_CONFIG */ const void * pProviders,
......@@ -31,7 +28,7 @@ EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_Disable(uint64_t session
}
EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_CreateProvider(
LPCWSTR providerName,
const WCHAR* providerName,
EventPipeCallback pCallbackFunc,
void* pCallbackContext)
{
......@@ -50,7 +47,7 @@ EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_DefineEvent(
return 0;
}
EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_GetProvider(LPCWSTR providerName)
EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_GetProvider(const WCHAR* providerName)
{
return 0;
}
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "eventpipeadapter.h"
#include "CommonTypes.h"
#include "CommonMacros.h"
#include "PalRedhawk.h"
#ifdef FEATURE_PERFTRACING
......@@ -78,7 +80,7 @@ EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIOPack
{
}
EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown(LPCWSTR exceptionTypeName, LPCWSTR exceptionMessage, void* faultingIP, HRESULT hresult)
EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown(const WCHAR* exceptionTypeName, const WCHAR* exceptionMessage, void* faultingIP, HRESULT hresult)
{
}
......
......@@ -107,7 +107,6 @@ list(APPEND GEN_EVENTPIPE_SOURCES
list(APPEND AOT_EVENTPIPE_MANAGED_TO_NATIVE_SOURCES
${RUNTIME_DIR}/eventpipeinternal.cpp
${RUNTIME_DIR}/eventpipeadapter.h
${RUNTIME_DIR}/diagnosticserveradapter.h
${RUNTIME_DIR}/EnabledEventPipeInterface.cpp
${RUNTIME_DIR}/runtimeeventinternal.cpp
)
......
......@@ -6,9 +6,11 @@
// @TODO: Audit native events in NativeAOT Runtime
#include <common.h>
#include "eventpipeadapter.h"
#include "eventtrace_context.h"
#include "gcheaputilities.h"
#include <gcenv.h>
#include <eventpipeadapter.h>
#include <eventtrace_context.h>
#include <gcheaputilities.h>
#ifndef ERROR_WRITE_FAULT
#define ERROR_WRITE_FAULT 29L
......@@ -3011,7 +3013,7 @@ void InitDotNETRuntime(void)
bool DotNETRuntimeProvider_IsEnabled(unsigned char level, unsigned long long keyword)
{
if (!EventPipeAdapter::Enabled())
if (!ep_enabled())
return false;
EVENTPIPE_TRACE_CONTEXT& context = MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_DOTNET_Context.EventPipeProvider;
......
......@@ -17,28 +17,12 @@
#include <eventpipe/ep-event-payload.h>
#include <eventpipe/ep-buffer-manager.h>
#include "gcenv.h"
#include "regdisplay.h"
#include "StackFrameIterator.h"
#include "thread.h"
#include "holder.h"
#include "SpinLock.h"
#include "CommonTypes.h"
class EventPipeAdapter final
{
public:
static inline void Initialize()
{
CONTRACTL
{
NOTHROW;
}
CONTRACTL_END;
ep_init();
}
static inline EventPipeProvider * CreateProvider(LPCWSTR providerName, EventPipeCallback callback, void* pCallbackContext = nullptr)
static inline EventPipeProvider * CreateProvider(const WCHAR* providerName, EventPipeCallback callback, void* pCallbackContext = nullptr)
{
ep_char8_t *providerNameUTF8 = ep_rt_utf16_to_utf8_string(reinterpret_cast<const ep_char16_t *>(providerName), -1);
EventPipeProvider * provider = ep_create_provider (providerNameUTF8, callback, pCallbackContext);
......@@ -46,66 +30,6 @@ public:
return provider;
}
static inline void DeleteProvider (EventPipeProvider * provider)
{
ep_delete_provider (provider);
}
static inline void FinishInitialize()
{
CONTRACTL
{
NOTHROW;
}
CONTRACTL_END;
ep_finish_init();
}
static inline void Shutdown()
{
ep_shutdown();
}
static inline bool Enabled()
{
STATIC_CONTRACT_NOTHROW;
return ep_enabled();
}
static inline void Disable(EventPipeSessionID id)
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
ep_disable(id);
}
static inline EventPipeProvider * GetProvider (LPCWSTR providerName)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
if (!providerName)
return NULL;
ep_char8_t *providerNameUTF8 = ep_rt_utf16_to_utf8_string(reinterpret_cast<const ep_char16_t *>(providerName), -1);
EventPipeProvider * provider = ep_get_provider (providerNameUTF8);
ep_rt_utf8_string_free(providerNameUTF8);
return provider;
}
static inline EventPipeEvent * AddEvent(
EventPipeProvider *provider,
uint32_t eventID,
......
......@@ -3,12 +3,7 @@
#include "common.h"
#include "eventpipeadapter.h"
#include "gcenv.h"
#include "regdisplay.h"
#include "StackFrameIterator.h"
#include "thread.h"
#include "SpinLock.h"
#include "PalRedhawk.h"
#ifdef FEATURE_PERFTRACING
......@@ -17,7 +12,7 @@ struct EventPipeEventInstanceData
void *ProviderID;
unsigned int EventID;
unsigned int ThreadID;
LARGE_INTEGER TimeStamp;
int64_t TimeStamp;
GUID ActivityId;
GUID RelatedActivityId;
const uint8_t *Payload;
......@@ -40,7 +35,7 @@ struct EventPipeProviderConfigurationNative
};
EXTERN_C NATIVEAOT_API uint64_t __cdecl RhEventPipeInternal_Enable(
LPCWSTR outputFile,
const WCHAR* outputFile,
EventPipeSerializationFormat format,
uint32_t circularBufferSizeInMB,
/* COR_PRF_EVENTPIPE_PROVIDER_CONFIG */ const void * pProviders,
......@@ -102,11 +97,11 @@ EXTERN_C NATIVEAOT_API uint64_t __cdecl RhEventPipeInternal_Enable(
EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_Disable(uint64_t sessionID)
{
EventPipeAdapter::Disable(sessionID);
ep_disable(sessionID);
}
EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_CreateProvider(
LPCWSTR providerName,
const WCHAR* providerName,
EventPipeCallback pCallbackFunc,
void* pCallbackContext)
{
......@@ -133,10 +128,17 @@ EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_DefineEvent(
return reinterpret_cast<intptr_t>(pEvent);
}
EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_GetProvider(LPCWSTR providerName)
EXTERN_C NATIVEAOT_API intptr_t __cdecl RhEventPipeInternal_GetProvider(const WCHAR* providerName)
{
EventPipeProvider* pProvider = EventPipeAdapter::GetProvider(providerName);
return reinterpret_cast<intptr_t>(pProvider);
EventPipeProvider * provider = NULL;
if (providerName)
{
ep_char8_t *providerNameUTF8 = ep_rt_utf16_to_utf8_string(reinterpret_cast<const ep_char16_t *>(providerName), -1);
provider = ep_get_provider (providerNameUTF8);
ep_rt_utf8_string_free(providerNameUTF8);
}
return reinterpret_cast<intptr_t>(provider);
}
EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_DeleteProvider(intptr_t provHandle)
......@@ -144,7 +146,7 @@ EXTERN_C NATIVEAOT_API void __cdecl RhEventPipeInternal_DeleteProvider(intptr_t
if (provHandle != 0)
{
EventPipeProvider *pProvider = reinterpret_cast<EventPipeProvider *>(provHandle);
EventPipeAdapter::DeleteProvider(pProvider);
ep_delete_provider(pProvider);
}
}
......@@ -251,7 +253,7 @@ EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_GetNextEvent(uint
pInstance->ProviderID = ep_event_get_provider(ep_event_instance_get_ep_event(pNextInstance));
pInstance->EventID = ep_event_get_event_id(ep_event_instance_get_ep_event(pNextInstance));
pInstance->ThreadID = static_cast<uint32_t>(ep_event_get_event_id(ep_event_instance_get_ep_event(pNextInstance)));
pInstance->TimeStamp.QuadPart = ep_event_instance_get_timestamp(pNextInstance);
pInstance->TimeStamp = ep_event_instance_get_timestamp(pNextInstance);
pInstance->ActivityId = *reinterpret_cast<const GUID *>(ep_event_instance_get_activity_id_cref(pNextInstance));
pInstance->RelatedActivityId = *reinterpret_cast<const GUID *>(ep_event_instance_get_related_activity_id_cref(pNextInstance));
pInstance->Payload = ep_event_instance_get_data(pNextInstance);
......@@ -267,7 +269,7 @@ EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_SignalSession(uin
if (!session)
return false;
return ep_rt_wait_event_set (ep_session_get_wait_event (session));
return ep_rt_wait_event_set (ep_session_get_wait_event (session));
}
EXTERN_C NATIVEAOT_API UInt32_BOOL __cdecl RhEventPipeInternal_WaitForSessionSignal(uint64_t sessionID, int32_t timeoutMs)
......
......@@ -14,6 +14,11 @@
#include <cstddef>
#include <string.h>
#ifdef TARGET_UNIX
#include <pthread.h>
#endif
#include "rhassert.h"
#include "sal.h"
#include "gcenv.structs.h"
#include "gcenv.interlocked.h"
......
......@@ -3,8 +3,6 @@
#ifndef _TARGETPTRS_H_
#define _TARGETPTRS_H_
typedef DPTR(class MethodTable) PTR_EEType;
#ifdef TARGET_AMD64
typedef uint64_t UIntTarget;
#elif defined(TARGET_X86)
......@@ -19,11 +17,7 @@ typedef uint32_t UIntTarget;
#error unexpected target architecture
#endif
typedef PTR_UInt8 TgtPTR_UInt8;
typedef PTR_UInt32 TgtPTR_UInt32;
typedef void * TgtPTR_Void;
typedef PTR_EEType TgtPTR_EEType;
typedef class Thread * TgtPTR_Thread;
typedef struct CORINFO_Object * TgtPTR_CORINFO_Object;
#endif // !_TARGETPTRS_H_
......@@ -6,6 +6,7 @@
//
// This header contains binder-generated data structures that the runtime consumes.
//
#include "daccess.h" // DPTR
#include "TargetPtrs.h"
class MethodTable;
......
......@@ -6,6 +6,8 @@
#if defined(TARGET_X86) || defined(TARGET_AMD64)
#include "PalRedhawkCommon.h" // Fp128
struct REGDISPLAY
{
PTR_UIntNative pRax;
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "eventpipeadapter.h"
#include "gcenv.h"
#ifdef FEATURE_PERFTRACING
......@@ -90,7 +90,7 @@ EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogThreadPoolIOPack
FireEtwThreadPoolIOPack(NativeOverlapped, Overlapped, ClrInstanceID);
}
EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown(LPCWSTR exceptionTypeName, LPCWSTR exceptionMessage, void* faultingIP, HRESULT hresult)
EXTERN_C NATIVEAOT_API void __cdecl NativeRuntimeEventSource_LogExceptionThrown(const WCHAR* exceptionTypeName, const WCHAR* exceptionMessage, void* faultingIP, HRESULT hresult)
{
FireEtwExceptionThrown_V1(exceptionTypeName,
exceptionMessage,
......
......@@ -100,10 +100,10 @@ static bool InitDLL(HANDLE hPalInstance)
#ifdef FEATURE_PERFTRACING
// Initialize EventPipe
EventPipeAdapter_Initialize();
EventPipe_Initialize();
// Initialize DS
DiagnosticServerAdapter_Initialize();
DiagnosticServerAdapter_PauseForDiagnosticsMonitor();
DiagnosticServer_Initialize();
DiagnosticServer_PauseForDiagnosticsMonitor();
#endif
#ifdef FEATURE_EVENT_TRACE
EventTracing_Initialize();
......@@ -157,7 +157,7 @@ static bool InitDLL(HANDLE hPalInstance)
// Finish setting up rest of EventPipe - specifically enable SampleProfiler if it was requested at startup.
// SampleProfiler needs to cooperate with the GC which hasn't fully finished setting up in the first part of the
// EventPipe initialization, so this is done after the GC has been fully initialized.
EventPipeAdapter_FinishInitialize();
EventPipe_FinishInitialize();
#endif
#ifndef USE_PORTABLE_HELPERS
......@@ -309,8 +309,8 @@ static void __cdecl OnProcessExit()
#endif
#ifdef FEATURE_PERFTRACING
EventPipeAdapter_Shutdown();
DiagnosticServerAdapter_Shutdown();
EventPipe_Shutdown();
DiagnosticServer_Shutdown();
#endif
}
......@@ -342,7 +342,7 @@ void RuntimeThreadShutdown(void* thread)
#endif
ThreadStore::DetachCurrentThread();
#ifdef FEATURE_PERFTRACING
EventPipe_ThreadShutdown();
#endif
......
......@@ -4,10 +4,8 @@
#ifndef __thread_h__
#define __thread_h__
#include "regdisplay.h"
#include "StackFrameIterator.h"
#include "forward_declarations.h"
#include "slist.h" // DefaultSListTraits
struct gc_alloc_context;
class RuntimeInstance;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册