[runtime] NOHANDLES for ves_icall_System_Threading_Thread_GetCurrentThread (mono...
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Fri, 17 Jan 2020 02:57:54 +0000 (21:57 -0500)
committerGitHub <noreply@github.com>
Fri, 17 Jan 2020 02:57:54 +0000 (21:57 -0500)
* [runtime] NOHANDLES for ves_icall_System_Threading_Thread_GetCurrentThread

This function (and its call to mono_handle_new) was showing up in the
flamegraph for some async-heavy benchmarks

Commit migrated from https://github.com/mono/mono/commit/c1498b8d4ce83732d1bab794005cc12f8319053d

src/mono/configure.ac
src/mono/mono/metadata/icall-decl.h
src/mono/mono/metadata/icall-def-netcore.h
src/mono/mono/metadata/icall-def.h
src/mono/mono/metadata/threads.c
src/mono/netcore/System.Private.CoreLib/src/System/Threading/Thread.Mono.cs

index aa43e4e..86993d8 100644 (file)
@@ -63,7 +63,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
 # This line is parsed by tools besides autoconf, such as msvc/mono.winconfig.targets.
 # It should remain in the format they expect.
 #
-MONO_CORLIB_VERSION=8AF7738D-0093-49BA-8C4B-C96C913FCE0F
+MONO_CORLIB_VERSION=1A5E0066-58DC-428A-B21C-0AD6CDAE2789
 
 #
 # Put a quoted #define in config.h.
index de4b213..21881b8 100644 (file)
@@ -82,6 +82,7 @@ ICALL_EXPORT MonoBoolean ves_icall_System_IO_DriveInfo_GetDiskFreeSpace (const g
 ICALL_EXPORT MonoBoolean ves_icall_System_Reflection_AssemblyName_ParseAssemblyName (const char*, MonoAssemblyName*, MonoBoolean*, MonoBoolean* is_token_defined_arg);
 ICALL_EXPORT MonoBoolean ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void);
 ICALL_EXPORT MonoBoolean ves_icall_System_Threading_Thread_YieldInternal (void);
+ICALL_EXPORT void ves_icall_System_Threading_Thread_GetCurrentThread (MonoThread * volatile *);
 ICALL_EXPORT void ves_icall_System_ArgIterator_Setup (MonoArgIterator*, char*, char*);
 ICALL_EXPORT MonoType* ves_icall_System_ArgIterator_IntGetNextArgType (MonoArgIterator*);
 ICALL_EXPORT void ves_icall_System_ArgIterator_IntGetNextArg (MonoArgIterator*, MonoTypedRef*);
index e2acc0a..010a0bf 100644 (file)
@@ -495,7 +495,7 @@ HANDLES(THREAD_15, "GetCurrentOSThreadId", ves_icall_System_Threading_Thread_Get
 HANDLES(THREAD_16, "GetCurrentProcessorNumber", ves_icall_System_Threading_Thread_GetCurrentProcessorNumber, gint32, 0, ())
 HANDLES(THREAD_3, "GetState", ves_icall_System_Threading_Thread_GetState, guint32, 1, (MonoInternalThread))
 HANDLES(THREAD_4, "InitInternal", ves_icall_System_Threading_Thread_InitInternal, void, 1, (MonoThreadObject))
-HANDLES(THREAD_5, "InitializeCurrentThread", ves_icall_System_Threading_Thread_GetCurrentThread, MonoThreadObject, 0, ())
+NOHANDLES(ICALL(THREAD_5, "InitializeCurrentThread_icall", ves_icall_System_Threading_Thread_GetCurrentThread))
 HANDLES(THREAD_6, "InterruptInternal", ves_icall_System_Threading_Thread_Interrupt_internal, void, 1, (MonoThreadObject))
 HANDLES(THREAD_7, "JoinInternal", ves_icall_System_Threading_Thread_Join_internal, MonoBoolean, 2, (MonoThreadObject, int))
 HANDLES(THREAD_8, "SetName_icall", ves_icall_System_Threading_Thread_SetName_icall, void, 3, (MonoInternalThread, const_gunichar2_ptr, gint32))
index 524bb0b..bde11f2 100644 (file)
@@ -1023,7 +1023,7 @@ HANDLES(THREAD_1b, "ByteArrayToRootDomain(byte[])", ves_icall_System_Threading_T
 HANDLES(THREAD_2, "ClrState(System.Threading.InternalThread,System.Threading.ThreadState)", ves_icall_System_Threading_Thread_ClrState, void, 2, (MonoInternalThread, guint32))
 HANDLES(THREAD_2a, "ConstructInternalThread", ves_icall_System_Threading_Thread_ConstructInternalThread, void, 1, (MonoThreadObject))
 HANDLES(THREAD_55, "GetAbortExceptionState", ves_icall_System_Threading_Thread_GetAbortExceptionState, MonoObject, 1, (MonoThreadObject))
-HANDLES(THREAD_60, "GetCurrentThread", ves_icall_System_Threading_Thread_GetCurrentThread, MonoThreadObject, 0, ())
+NOHANDLES(ICALL(THREAD_60, "GetCurrentThread_icall", ves_icall_System_Threading_Thread_GetCurrentThread))
 HANDLES(THREAD_7, "GetDomainID", ves_icall_System_Threading_Thread_GetDomainID, gint32, 0, ())
 HANDLES(THREAD_8, "GetName_internal(System.Threading.InternalThread)", ves_icall_System_Threading_Thread_GetName_internal, MonoString, 1, (MonoInternalThread))
 HANDLES(THREAD_57, "GetPriorityNative", ves_icall_System_Threading_Thread_GetPriority, int, 1, (MonoThreadObject))
index 1915f58..bf9ea97 100644 (file)
@@ -1675,10 +1675,10 @@ ves_icall_System_Threading_Thread_ConstructInternalThread (MonoThreadObjectHandl
 }
 #endif
 
-MonoThreadObjectHandle
-ves_icall_System_Threading_Thread_GetCurrentThread (MonoError *error)
+void
+ves_icall_System_Threading_Thread_GetCurrentThread (MonoThread *volatile* thread)
 {
-       return MONO_HANDLE_NEW (MonoThreadObject, mono_thread_current ());
+       *thread = mono_thread_current ();
 }
 
 static MonoInternalThread*
index 113928f..861dcfc 100644 (file)
@@ -294,7 +294,13 @@ namespace System.Threading
                extern static void InitInternal (Thread thread);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               extern static Thread InitializeCurrentThread ();
+               private extern static void InitializeCurrentThread_icall (ref Thread thread);
+
+               static Thread InitializeCurrentThread () {
+                       Thread thread = null;
+                       InitializeCurrentThread_icall (ref thread);
+                       return thread;
+               }
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                extern void FreeInternal ();