diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index a75171aeda1b0..e72c4bf950c2c 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -15,7 +15,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
- "version": "9.0.0-prerelease.24452.1",
+ "version": "10.0.0-prerelease.24459.1",
"commands": [
"xharness"
]
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 77c06d86deee3..238887c6bd098 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -316,17 +316,17 @@
https://github.com/dotnet/runtime
7cb32e193a55a95c74fc3bd56501b951b48b700f
-
+
https://github.com/dotnet/xharness
- c2215b88cdac5390888de3e6ad301c113f40ed6c
+ df9b6509e6b3976d158e46c23d72d6acd9f0d326
-
+
https://github.com/dotnet/xharness
- c2215b88cdac5390888de3e6ad301c113f40ed6c
+ df9b6509e6b3976d158e46c23d72d6acd9f0d326
-
+
https://github.com/dotnet/xharness
- c2215b88cdac5390888de3e6ad301c113f40ed6c
+ df9b6509e6b3976d158e46c23d72d6acd9f0d326
https://github.com/dotnet/arcade
diff --git a/eng/Versions.props b/eng/Versions.props
index a6407d4ed6c89..44522b33fd4a5 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -180,9 +180,9 @@
1.4.0
17.4.0-preview-20220707-01
- 9.0.0-prerelease.24452.1
- 9.0.0-prerelease.24452.1
- 9.0.0-prerelease.24452.1
+ 10.0.0-prerelease.24459.1
+ 10.0.0-prerelease.24459.1
+ 10.0.0-prerelease.24459.1
9.0.0-alpha.0.24419.1
3.12.0
4.5.0
diff --git a/eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml b/eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
index a189770cb81be..2ac52ca77eb35 100644
--- a/eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
+++ b/eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
@@ -70,7 +70,7 @@ steps:
displayName: "AOT compile CoreCLR tests"
target: ${{ coalesce(parameters.llvmAotStepContainer, parameters.container) }}
- ${{ if in(parameters.runtimeVariant, 'llvmfullaot', 'minifullaot') }}:
- - script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(logRootNameArg)MonoAot mono_fullaot ${{ parameters.buildConfig }} ${{ parameters.archType }} /p:RuntimeVariant=${{ parameters.runtimeVariant }} -maxcpucount:2
+ - script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(logRootNameArg)MonoAot mono_fullaot ${{ parameters.buildConfig }} ${{ parameters.archType }} /p:RuntimeVariant=${{ parameters.runtimeVariant }} -maxcpucount:1
displayName: "AOT compile CoreCLR tests"
target: ${{ coalesce(parameters.llvmAotStepContainer, parameters.container) }}
- ${{ if eq(parameters.archType, 'arm64') }}:
diff --git a/eng/pipelines/coreclr/runtime-nativeaot-outerloop.yml b/eng/pipelines/coreclr/runtime-nativeaot-outerloop.yml
index 494601a890df1..c39c6d81a45b9 100644
--- a/eng/pipelines/coreclr/runtime-nativeaot-outerloop.yml
+++ b/eng/pipelines/coreclr/runtime-nativeaot-outerloop.yml
@@ -156,7 +156,6 @@ extends:
#
# CoreCLR NativeAOT checked build and Pri0 tests
- # Only when CoreCLR is changed
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
@@ -189,3 +188,37 @@ extends:
parameters:
testGroup: innerloop
liveLibrariesBuildConfig: Release
+
+ #
+ # CoreCLR NativeAOT checked build and Pri0 tests
+ # Test windows_x64 with CET and CFG
+ #
+ - template: /eng/pipelines/common/platform-matrix.yml
+ parameters:
+ jobTemplate: /eng/pipelines/common/global-build-job.yml
+ helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
+ helixQueueGroup: cet
+ buildConfig: Checked
+ platforms:
+ - windows_x64
+ variables:
+ - name: timeoutPerTestInMinutes
+ value: 60
+ - name: timeoutPerTestCollectionInMinutes
+ value: 180
+ jobParameters:
+ timeoutInMinutes: 300 # doesn't normally take this long, but we have had Helix queues backed up for over an hour
+ nameSuffix: NativeAOT_Pri0_CET_CFG
+ buildArgs: -s clr.aot+libs -rc $(_BuildConfig) -lc Release /p:RunAnalyzers=false
+ postBuildSteps:
+ - template: /eng/pipelines/coreclr/nativeaot-post-build-steps.yml
+ parameters:
+ creator: dotnet-bot
+ testBuildArgs: 'nativeaot /p:IlcUseServerGc=false /p:ControlFlowGuard=Guard'
+ liveLibrariesBuildConfig: Release
+ testRunNamePrefixSuffix: NativeAOT_Pri0_CET_CFG_$(_BuildConfig)
+ extraVariablesTemplates:
+ - template: /eng/pipelines/common/templates/runtimes/test-variables.yml
+ parameters:
+ testGroup: innerloop
+ liveLibrariesBuildConfig: Release
\ No newline at end of file
diff --git a/eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml b/eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml
index 8d0590c992196..49e7e517d9c33 100644
--- a/eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml
+++ b/eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml
@@ -105,6 +105,14 @@ extends:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
displayName: Send JsonDocumentFuzzer to OneFuzz
+ - task: onefuzz-task@0
+ inputs:
+ onefuzzOSes: 'Windows'
+ env:
+ onefuzzDropDirectory: $(fuzzerProject)/deployment/NrbfDecoderFuzzer
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+ displayName: Send NrbfDecoderFuzzer to OneFuzz
+
- task: onefuzz-task@0
inputs:
onefuzzOSes: 'Windows'
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs
index 79944b1cca8e6..1029f3e570e33 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs
@@ -117,9 +117,6 @@ internal void InternalPreserveStackTrace()
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void PrepareForForeignExceptionRaise();
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern object? GetFrozenStackTrace(Exception exception);
-
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern uint GetExceptionCount();
@@ -226,9 +223,14 @@ public DispatchState(
}
}
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ExceptionNative_GetFrozenStackTrace")]
+ private static partial void GetFrozenStackTrace(ObjectHandleOnStack exception, ObjectHandleOnStack stackTrace);
+
internal DispatchState CaptureDispatchState()
{
- object? stackTrace = GetFrozenStackTrace(this);
+ Exception _this = this;
+ object? stackTrace = null;
+ GetFrozenStackTrace(ObjectHandleOnStack.Create(ref _this), ObjectHandleOnStack.Create(ref stackTrace));
return new DispatchState(stackTrace,
_remoteStackTraceString, _ipForWatsonBuckets, _watsonBuckets);
diff --git a/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
index 1bd94635a26c7..f8246642b9e61 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
@@ -103,8 +103,8 @@ internal enum GC_ALLOC_FLAGS
GC_ALLOC_PINNED_OBJECT_HEAP = 64,
};
- [MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern Array AllocateNewArray(IntPtr typeHandle, int length, GC_ALLOC_FLAGS flags);
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "GCInterface_AllocateNewArray")]
+ private static partial void AllocateNewArray(IntPtr typeHandlePtr, int length, GC_ALLOC_FLAGS flags, ObjectHandleOnStack ret);
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "GCInterface_GetTotalMemory")]
private static partial long GetTotalMemory();
@@ -791,16 +791,25 @@ public static unsafe T[] AllocateUninitializedArray(int length, bool pinned =
{
return new T[length];
}
-
#endif
}
- // Runtime overrides GC_ALLOC_ZEROING_OPTIONAL if the type contains references, so we don't need to worry about that.
- GC_ALLOC_FLAGS flags = GC_ALLOC_FLAGS.GC_ALLOC_ZEROING_OPTIONAL;
- if (pinned)
- flags |= GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
+ return AllocateNewArrayWorker(length, pinned);
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static T[] AllocateNewArrayWorker(int length, bool pinned)
+ {
+ // Runtime overrides GC_ALLOC_ZEROING_OPTIONAL if the type contains references, so we don't need to worry about that.
+ GC_ALLOC_FLAGS flags = GC_ALLOC_FLAGS.GC_ALLOC_ZEROING_OPTIONAL;
+ if (pinned)
+ {
+ flags |= GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
+ }
- return Unsafe.As(AllocateNewArray(RuntimeTypeHandle.ToIntPtr(typeof(T[]).TypeHandle), length, flags));
+ T[]? result = null;
+ AllocateNewArray(RuntimeTypeHandle.ToIntPtr(typeof(T[]).TypeHandle), length, flags, ObjectHandleOnStack.Create(ref result));
+ return result!;
+ }
}
///
@@ -818,7 +827,9 @@ public static T[] AllocateArray(int length, bool pinned = false) // T[] rathe
flags = GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
}
- return Unsafe.As(AllocateNewArray(RuntimeTypeHandle.ToIntPtr(typeof(T[]).TypeHandle), length, flags));
+ T[]? result = null;
+ AllocateNewArray(RuntimeTypeHandle.ToIntPtr(typeof(T[]).TypeHandle), length, flags, ObjectHandleOnStack.Create(ref result));
+ return result!;
}
[MethodImpl(MethodImplOptions.InternalCall)]
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
index ccd3d9aa9efc5..1ebaa04f8f681 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs
@@ -115,8 +115,6 @@ public override string? CodeBase
}
}
- internal RuntimeAssembly GetNativeHandle() => this;
-
// If the assembly is copied before it is loaded, the codebase will be set to the
// actual file loaded if copiedName is true. If it is false, then the original code base
// is returned.
@@ -263,7 +261,7 @@ public override Type[] GetExportedTypes()
public override IEnumerable DefinedTypes
{
[RequiresUnreferencedCode("Types might be removed")]
- get => GetManifestModule(GetNativeHandle()).GetDefinedTypes();
+ get => GetManifestModule().GetDefinedTypes();
}
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetIsCollectible")]
@@ -324,7 +322,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
public override Module ManifestModule =>
// We don't need to return the "external" ModuleBuilder because
// it is meant to be read-only
- GetManifestModule(GetNativeHandle());
+ GetManifestModule();
public override object[] GetCustomAttributes(bool inherit)
{
@@ -588,7 +586,7 @@ private CultureInfo GetLocale()
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool FCallIsDynamic(RuntimeAssembly assembly);
- public override bool IsDynamic => FCallIsDynamic(GetNativeHandle());
+ public override bool IsDynamic => FCallIsDynamic(this);
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetSimpleName")]
private static partial void GetSimpleName(QCallAssembly assembly, StringHandleOnStack retSimpleName);
@@ -701,8 +699,24 @@ public override Module[] GetLoadedModules(bool getResourceModules)
return GetModulesInternal(false, getResourceModules);
}
+ private RuntimeModule GetManifestModule()
+ {
+ return GetManifestModule(this) ?? GetManifestModuleWorker(this);
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static RuntimeModule GetManifestModuleWorker(RuntimeAssembly assembly)
+ {
+ RuntimeModule? module = null;
+ GetManifestModuleSlow(ObjectHandleOnStack.Create(ref assembly), ObjectHandleOnStack.Create(ref module));
+ return module!;
+ }
+ }
+
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern RuntimeModule GetManifestModule(RuntimeAssembly assembly);
+ private static extern RuntimeModule? GetManifestModule(RuntimeAssembly assembly);
+
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyHandle_GetManifestModuleSlow")]
+ private static partial void GetManifestModuleSlow(ObjectHandleOnStack assembly, ObjectHandleOnStack module);
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern int GetToken(RuntimeAssembly assembly);
@@ -713,7 +727,7 @@ public sealed override Type[] GetForwardedTypes()
List types = new List();
List exceptions = new List();
- MetadataImport scope = GetManifestModule(GetNativeHandle()).MetadataImport;
+ MetadataImport scope = GetManifestModule().MetadataImport;
scope.Enum(MetadataTokenType.ExportedType, 0, out MetadataEnumResult enumResult);
RuntimeAssembly runtimeAssembly = this;
QCallAssembly pAssembly = new QCallAssembly(ref runtimeAssembly);
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs
index a610a5cbe3eab..2ac866f246fce 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs
@@ -82,7 +82,7 @@ internal static IList GetCustomAttributesInternal(RuntimeAs
// No pseudo attributes for RuntimeAssembly
- return GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
+ return GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target));
}
internal static IList GetCustomAttributesInternal(RuntimeParameterInfo target)
@@ -1227,7 +1227,7 @@ internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
Debug.Assert(caType is not null);
// No pseudo attributes for RuntimeAssembly
- return IsCustomAttributeDefined((assembly.ManifestModule as RuntimeModule)!, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType);
+ return IsCustomAttributeDefined((assembly.ManifestModule as RuntimeModule)!, RuntimeAssembly.GetToken(assembly), caType);
}
internal static bool IsDefined(RuntimeModule module, RuntimeType caType)
@@ -1388,7 +1388,7 @@ internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeTy
// No pseudo attributes for RuntimeAssembly
- int assemblyToken = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
+ int assemblyToken = RuntimeAssembly.GetToken(assembly);
return GetCustomAttributes((assembly.ManifestModule as RuntimeModule)!, assemblyToken, 0, caType);
}
diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
index 3d230536519ce..d78cc1ea86bc1 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
@@ -306,11 +306,43 @@ internal RuntimeType GetRuntimeType()
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern CorElementType GetCorElementType(RuntimeType type);
+ internal static RuntimeAssembly GetAssembly(RuntimeType type)
+ {
+ return GetAssemblyIfExists(type) ?? GetAssemblyWorker(type);
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static RuntimeAssembly GetAssemblyWorker(RuntimeType type)
+ {
+ RuntimeAssembly? assembly = null;
+ GetAssemblySlow(ObjectHandleOnStack.Create(ref type), ObjectHandleOnStack.Create(ref assembly));
+ return assembly!;
+ }
+ }
+
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern RuntimeAssembly GetAssembly(RuntimeType type);
+ private static extern RuntimeAssembly? GetAssemblyIfExists(RuntimeType type);
+
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetAssemblySlow")]
+ private static partial void GetAssemblySlow(ObjectHandleOnStack type, ObjectHandleOnStack assembly);
+
+ internal static RuntimeModule GetModule(RuntimeType type)
+ {
+ return GetModuleIfExists(type) ?? GetModuleWorker(type);
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static RuntimeModule GetModuleWorker(RuntimeType type)
+ {
+ RuntimeModule? module = null;
+ GetModuleSlow(ObjectHandleOnStack.Create(ref type), ObjectHandleOnStack.Create(ref module));
+ return module!;
+ }
+ }
[MethodImpl(MethodImplOptions.InternalCall)]
- internal static extern RuntimeModule GetModule(RuntimeType type);
+ private static extern RuntimeModule? GetModuleIfExists(RuntimeType type);
+
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetModuleSlow")]
+ private static partial void GetModuleSlow(ObjectHandleOnStack type, ObjectHandleOnStack module);
public ModuleHandle GetModuleHandle()
{
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.cs b/src/coreclr/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.cs
index 8fe80e7286858..25fc6ff09ad2a 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.cs
@@ -31,7 +31,7 @@ public bool WaitCore(int timeoutMs)
return waitResult == WaitHandle.WaitSuccess;
}
- [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_CorWaitOnePrioritizedNative")]
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_WaitOnePrioritized")]
private static partial int WaitNative(SafeWaitHandle handle, int timeoutMs);
private void ReleaseCore(int count)
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
index d7d83ba51ac0c..486e5a505abeb 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
@@ -58,6 +58,9 @@ public sealed partial class Thread
// but those types of changes may race with the reset anyway, so this field doesn't need to be synchronized.
private bool _mayNeedResetForThreadPool;
+ // Set in unmanaged and read in managed code.
+ private bool _isDead;
+
private Thread() { }
public int ManagedThreadId
@@ -74,7 +77,7 @@ internal ThreadHandle GetNativeHandle()
// This should never happen under normal circumstances.
if (thread == IntPtr.Zero)
{
- throw new ArgumentException(null, SR.Argument_InvalidHandle);
+ throw new ThreadStateException(SR.Argument_InvalidHandle);
}
return new ThreadHandle(thread);
@@ -211,13 +214,25 @@ public extern bool IsThreadPoolThread
internal set;
}
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_SetPriority")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static partial void SetPriority(ObjectHandleOnStack thread, int priority);
+
/// Returns the priority of the thread.
public ThreadPriority Priority
{
- get => (ThreadPriority)GetPriorityNative();
+ get
+ {
+ if (_isDead)
+ {
+ throw new ThreadStateException(SR.ThreadState_Dead_Priority);
+ }
+ return (ThreadPriority)_priority;
+ }
set
{
- SetPriorityNative((int)value);
+ Thread _this = this;
+ SetPriority(ObjectHandleOnStack.Create(ref _this), (int)value);
if (value != ThreadPriority.Normal)
{
_mayNeedResetForThreadPool = true;
@@ -225,12 +240,6 @@ public ThreadPriority Priority
}
}
- [MethodImpl(MethodImplOptions.InternalCall)]
- private extern int GetPriorityNative();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- private extern void SetPriorityNative(int priority);
-
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_GetCurrentOSThreadId")]
private static partial ulong GetCurrentOSThreadId();
@@ -243,21 +252,31 @@ public ThreadPriority Priority
[MethodImpl(MethodImplOptions.InternalCall)]
private extern int GetThreadStateNative();
- public ApartmentState GetApartmentState() =>
-#if FEATURE_COMINTEROP_APARTMENT_SUPPORT
- (ApartmentState)GetApartmentStateNative();
-#else // !FEATURE_COMINTEROP_APARTMENT_SUPPORT
- ApartmentState.Unknown;
-#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
-
///
/// An unstarted thread can be marked to indicate that it will host a
/// single-threaded or multi-threaded apartment.
///
#if FEATURE_COMINTEROP_APARTMENT_SUPPORT
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_GetApartmentState")]
+ private static partial int GetApartmentState(ObjectHandleOnStack t);
+
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_SetApartmentState")]
+ private static partial int SetApartmentState(ObjectHandleOnStack t, int state);
+
+ public ApartmentState GetApartmentState()
+ {
+ Thread _this = this;
+ return (ApartmentState)GetApartmentState(ObjectHandleOnStack.Create(ref _this));
+ }
+
private bool SetApartmentStateUnchecked(ApartmentState state, bool throwOnError)
{
- ApartmentState retState = (ApartmentState)SetApartmentStateNative((int)state);
+ ApartmentState retState;
+ lock (this) // This lock is only needed when the this is not the current thread.
+ {
+ Thread _this = this;
+ retState = (ApartmentState)SetApartmentState(ObjectHandleOnStack.Create(ref _this), (int)state);
+ }
// Special case where we pass in Unknown and get back MTA.
// Once we CoUninitialize the thread, the OS will still
@@ -282,12 +301,9 @@ private bool SetApartmentStateUnchecked(ApartmentState state, bool throwOnError)
return true;
}
- [MethodImpl(MethodImplOptions.InternalCall)]
- internal extern int GetApartmentStateNative();
-
- [MethodImpl(MethodImplOptions.InternalCall)]
- internal extern int SetApartmentStateNative(int state);
#else // FEATURE_COMINTEROP_APARTMENT_SUPPORT
+ public ApartmentState GetApartmentState() => ApartmentState.Unknown;
+
private static bool SetApartmentStateUnchecked(ApartmentState state, bool throwOnError)
{
if (state != ApartmentState.Unknown)
@@ -331,6 +347,10 @@ public void Interrupt()
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_Interrupt")]
private static partial void Interrupt(ThreadHandle t);
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_Join")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static partial bool Join(ObjectHandleOnStack thread, int millisecondsTimeout);
+
///
/// Waits for the thread to die or for timeout milliseconds to elapse.
///
@@ -338,11 +358,20 @@ public void Interrupt()
/// Returns true if the thread died, or false if the wait timed out. If
/// -1 is given as the parameter, no timeout will occur.
///
- /// if timeout < -1 (Timeout.Infinite)
+ /// if timeout < -1 (Timeout.Infinite)
/// if the thread is interrupted while waiting
/// if the thread has not been started yet
- [MethodImpl(MethodImplOptions.InternalCall)]
- public extern bool Join(int millisecondsTimeout);
+ public bool Join(int millisecondsTimeout)
+ {
+ // Validate the timeout
+ if (millisecondsTimeout < 0 && millisecondsTimeout != Timeout.Infinite)
+ {
+ throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
+ }
+
+ Thread _this = this;
+ return Join(ObjectHandleOnStack.Create(ref _this), millisecondsTimeout);
+ }
///
/// Max value to be passed into for optimal delaying. This value is normalized to be
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Threading/WaitHandle.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Threading/WaitHandle.CoreCLR.cs
index f1bfe33e8c8bc..a9fc4d8b2a045 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Threading/WaitHandle.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Threading/WaitHandle.CoreCLR.cs
@@ -8,23 +8,18 @@ namespace System.Threading
{
public abstract partial class WaitHandle
{
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern int WaitOneCore(IntPtr waitHandle, int millisecondsTimeout, bool useTrivialWaits);
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_WaitOneCore")]
+ private static partial int WaitOneCore(IntPtr waitHandle, int millisecondsTimeout, [MarshalAs(UnmanagedType.Bool)] bool useTrivialWaits);
private static unsafe int WaitMultipleIgnoringSyncContextCore(ReadOnlySpan waitHandles, bool waitAll, int millisecondsTimeout)
- {
- fixed (IntPtr* pWaitHandles = &MemoryMarshal.GetReference(waitHandles))
- {
- return WaitMultipleIgnoringSyncContext(pWaitHandles, waitHandles.Length, waitAll, millisecondsTimeout);
- }
- }
+ => WaitMultipleIgnoringSyncContext(waitHandles, waitHandles.Length, waitAll, millisecondsTimeout);
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern unsafe int WaitMultipleIgnoringSyncContext(IntPtr* waitHandles, int numHandles, bool waitAll, int millisecondsTimeout);
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_WaitMultipleIgnoringSyncContext")]
+ private static partial int WaitMultipleIgnoringSyncContext(ReadOnlySpan waitHandles, int numHandles, [MarshalAs(UnmanagedType.Bool)] bool waitAll, int millisecondsTimeout);
private static int SignalAndWaitCore(IntPtr waitHandleToSignal, IntPtr waitHandleToWaitOn, int millisecondsTimeout)
{
- int ret = SignalAndWaitNative(waitHandleToSignal, waitHandleToWaitOn, millisecondsTimeout);
+ int ret = SignalAndWait(waitHandleToSignal, waitHandleToWaitOn, millisecondsTimeout);
if (ret == Interop.Errors.ERROR_TOO_MANY_POSTS)
{
@@ -34,7 +29,7 @@ private static int SignalAndWaitCore(IntPtr waitHandleToSignal, IntPtr waitHandl
return ret;
}
- [MethodImpl(MethodImplOptions.InternalCall)]
- private static extern int SignalAndWaitNative(IntPtr waitHandleToSignal, IntPtr waitHandleToWaitOn, int millisecondsTimeout);
+ [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_SignalAndWait")]
+ private static partial int SignalAndWait(IntPtr waitHandleToSignal, IntPtr waitHandleToWaitOn, int millisecondsTimeout);
}
}
diff --git a/src/coreclr/debug/daccess/dacdbiimpl.cpp b/src/coreclr/debug/daccess/dacdbiimpl.cpp
index be5ee49e10b69..6309533648bb2 100644
--- a/src/coreclr/debug/daccess/dacdbiimpl.cpp
+++ b/src/coreclr/debug/daccess/dacdbiimpl.cpp
@@ -3672,7 +3672,7 @@ HRESULT DacDbiInterfaceImpl::GetLoaderHeapMemoryRanges(DacDbiArrayListGetLoaderAllocator();
+ PTR_LoaderAllocator pGlobalAllocator = SystemDomain::GetGlobalLoaderAllocator();
_ASSERTE(pGlobalAllocator);
EnumerateMemRangesForLoaderAllocator(pGlobalAllocator, &memoryRanges);
diff --git a/src/coreclr/debug/daccess/enummem.cpp b/src/coreclr/debug/daccess/enummem.cpp
index be3c1123ea416..7840bb29070cd 100644
--- a/src/coreclr/debug/daccess/enummem.cpp
+++ b/src/coreclr/debug/daccess/enummem.cpp
@@ -743,7 +743,7 @@ HRESULT ClrDataAccess::EnumMemDumpAppDomainInfo(CLRDataEnumMemoryFlags flags)
if (flags == CLRDATA_ENUM_MEM_HEAP2)
{
- SystemDomain::System()->GetLoaderAllocator()->EnumMemoryRegions(flags);
+ SystemDomain::GetGlobalLoaderAllocator()->EnumMemoryRegions(flags);
}
AppDomain* appDomain = AppDomain::GetCurrentDomain();
diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp
index bbd2b96c9ba37..2be13b91e98aa 100644
--- a/src/coreclr/debug/daccess/request.cpp
+++ b/src/coreclr/debug/daccess/request.cpp
@@ -2838,7 +2838,7 @@ ClrDataAccess::GetAppDomainData(CLRDATA_ADDRESS addr, struct DacpAppDomainData *
ZeroMemory(appdomainData, sizeof(DacpAppDomainData));
appdomainData->AppDomainPtr = PTR_CDADDR(pBaseDomain);
- PTR_LoaderAllocator pLoaderAllocator = pBaseDomain->GetLoaderAllocator();
+ PTR_LoaderAllocator pLoaderAllocator = SystemDomain::GetGlobalLoaderAllocator();
appdomainData->pHighFrequencyHeap = HOST_CDADDR(pLoaderAllocator->GetHighFrequencyHeap());
appdomainData->pLowFrequencyHeap = HOST_CDADDR(pLoaderAllocator->GetLowFrequencyHeap());
appdomainData->pStubHeap = HOST_CDADDR(pLoaderAllocator->GetStubHeap());
@@ -4065,8 +4065,7 @@ ClrDataAccess::TraverseVirtCallStubHeap(CLRDATA_ADDRESS pAppDomain, VCSHeapType
SOSDacEnter();
- BaseDomain* pBaseDomain = PTR_BaseDomain(TO_TADDR(pAppDomain));
- VirtualCallStubManager *pVcsMgr = pBaseDomain->GetLoaderAllocator()->GetVirtualCallStubManager();
+ VirtualCallStubManager *pVcsMgr = SystemDomain::GetGlobalLoaderAllocator()->GetVirtualCallStubManager();
if (!pVcsMgr)
{
hr = E_POINTER;
@@ -4111,8 +4110,8 @@ HRESULT ClrDataAccess::GetDomainLoaderAllocator(CLRDATA_ADDRESS domainAddress, C
SOSDacEnter();
- PTR_BaseDomain pDomain = PTR_BaseDomain(TO_TADDR(domainAddress));
- *pLoaderAllocator = pDomain != nullptr ? HOST_CDADDR(pDomain->GetLoaderAllocator()) : 0;
+ // The one and only app domain uses the global loader allocator
+ *pLoaderAllocator = HOST_CDADDR(SystemDomain::GetGlobalLoaderAllocator());
SOSDacLeave();
return hr;
diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp
index 20cfda9282651..58eb8614b2f59 100644
--- a/src/coreclr/gc/gc.cpp
+++ b/src/coreclr/gc/gc.cpp
@@ -14787,7 +14787,7 @@ gc_heap::wait_for_gc_done(int32_t timeOut)
while (gc_heap::gc_started)
{
#ifdef MULTIPLE_HEAPS
- wait_heap = GCHeap::GetHeap(heap_select::select_heap(NULL))->pGenGCHeap;
+ wait_heap = g_heaps[heap_select::select_heap(NULL)];
dprintf(2, ("waiting for the gc_done_event on heap %d", wait_heap->heap_number));
#endif // MULTIPLE_HEAPS
diff --git a/src/coreclr/gc/handletablescan.cpp b/src/coreclr/gc/handletablescan.cpp
index e5b27da8e621d..276e865518b23 100644
--- a/src/coreclr/gc/handletablescan.cpp
+++ b/src/coreclr/gc/handletablescan.cpp
@@ -1427,7 +1427,14 @@ PTR_TableSegment CALLBACK StandardSegmentIterator(PTR_HandleTable pTable, PTR_Ta
#ifndef DACCESS_COMPILE
// re-sort the block chains if necessary
if (pNextSegment && pNextSegment->fResortChains)
+ {
+ // Since this operation can rewrite segment state, it needs to synchronize with any racing
+ // threads that might be concurrently allocating null handle table slots while running in
+ // preemptive mode (which happens, e.g., during Thread construction when a native thread
+ // first enters the runtime).
+ CrstHolder ch(&pTable->Lock);
SegmentResortChains(pNextSegment);
+ }
#endif
// return the segment we found
diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp
index 7f7f3ec1d5463..6f3bb7a52fa33 100644
--- a/src/coreclr/gc/objecthandle.cpp
+++ b/src/coreclr/gc/objecthandle.cpp
@@ -1105,7 +1105,7 @@ void Ref_TraceNormalRoots(uint32_t condemned, uint32_t maxgen, ScanContext* sc,
// promote objects pointed to by strong handles
// during ephemeral GCs we also want to promote the ones pointed to by sizedref handles.
- uint32_t types[2] = {
+ uint32_t types[] = {
HNDTYPE_STRONG,
#ifdef FEATURE_SIZED_REF_HANDLES
HNDTYPE_SIZEDREF
diff --git a/src/coreclr/hosts/corerun/corerun.hpp b/src/coreclr/hosts/corerun/corerun.hpp
index 5ce0f0b285238..0adcdce234814 100644
--- a/src/coreclr/hosts/corerun/corerun.hpp
+++ b/src/coreclr/hosts/corerun/corerun.hpp
@@ -455,7 +455,7 @@ namespace pal
#else // !__APPLE__
// Use procfs to detect if there is a tracer process.
// See https://www.kernel.org/doc/html/latest/filesystems/proc.html
- char status[2048] = { 0 };
+ char status[2048];
int fd = ::open("/proc/self/status", O_RDONLY);
if (fd == -1)
{
@@ -471,6 +471,8 @@ namespace pal
{
// We have data. At this point we can likely make a strong decision.
const char tracer_pid_name[] = "TracerPid:";
+ // null terminate status
+ status[bytes_read] = '\0';
const char* tracer_pid_ptr = ::strstr(status, tracer_pid_name);
if (tracer_pid_ptr == nullptr)
return debugger_state_t::not_attached;
diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h
index 566d1ecb769a4..bf57e9ea28073 100644
--- a/src/coreclr/inc/corinfo.h
+++ b/src/coreclr/inc/corinfo.h
@@ -930,7 +930,6 @@ struct PatchpointInfo;
// Cookie types consumed by the code generator (these are opaque values
// not inspected by the code generator):
-typedef struct CORINFO_ASSEMBLY_STRUCT_* CORINFO_ASSEMBLY_HANDLE;
typedef struct CORINFO_MODULE_STRUCT_* CORINFO_MODULE_HANDLE;
typedef struct CORINFO_DEPENDENCY_STRUCT_* CORINFO_DEPENDENCY_HANDLE;
typedef struct CORINFO_CLASS_STRUCT_* CORINFO_CLASS_HANDLE;
@@ -2321,18 +2320,9 @@ class ICorStaticInfo
CORINFO_CLASS_HANDLE cls
) = 0;
- virtual CORINFO_MODULE_HANDLE getClassModule (
- CORINFO_CLASS_HANDLE cls
- ) = 0;
-
- // Returns the assembly that contains the module "mod".
- virtual CORINFO_ASSEMBLY_HANDLE getModuleAssembly (
- CORINFO_MODULE_HANDLE mod
- ) = 0;
-
- // Returns the name of the assembly "assem".
- virtual const char* getAssemblyName (
- CORINFO_ASSEMBLY_HANDLE assem
+ // Returns the assembly name of the class "cls", or nullptr if there is none.
+ virtual const char* getClassAssemblyName (
+ CORINFO_CLASS_HANDLE cls
) = 0;
// Allocate and delete process-lifetime objects. Should only be
diff --git a/src/coreclr/inc/eventtracebase.h b/src/coreclr/inc/eventtracebase.h
index 316104f649a1d..38868fe528f79 100644
--- a/src/coreclr/inc/eventtracebase.h
+++ b/src/coreclr/inc/eventtracebase.h
@@ -689,7 +689,6 @@ class Module;
class Assembly;
class MethodDesc;
class MethodTable;
-class BaseDomain;
class AppDomain;
class SString;
class CrawlFrame;
@@ -750,12 +749,11 @@ namespace ETW
#ifdef FEATURE_EVENT_TRACE
static VOID SendThreadRundownEvent();
static VOID SendGCRundownEvent();
- static VOID IterateDomain(BaseDomain *pDomain, DWORD enumerationOptions);
- static VOID IterateAppDomain(AppDomain * pAppDomain, DWORD enumerationOptions);
+ static VOID IterateAppDomain(DWORD enumerationOptions);
static VOID IterateCollectibleLoaderAllocator(AssemblyLoaderAllocator *pLoaderAllocator, DWORD enumerationOptions);
static VOID IterateAssembly(Assembly *pAssembly, DWORD enumerationOptions);
static VOID IterateModule(Module *pModule, DWORD enumerationOptions);
- static VOID EnumerationHelper(Module *moduleFilter, BaseDomain *domainFilter, DWORD enumerationOptions);
+ static VOID EnumerationHelper(Module *moduleFilter, DWORD enumerationOptions);
static DWORD GetEnumerationOptionsFromRuntimeKeywords();
public:
typedef union _EnumerationStructs
@@ -839,7 +837,7 @@ namespace ETW
static VOID SendModuleEvent(Module *pModule, DWORD dwEventOptions, BOOL bFireDomainModuleEvents=FALSE);
static ULONG SendModuleRange(_In_ Module *pModule, _In_ DWORD dwEventOptions);
static VOID SendAssemblyEvent(Assembly *pAssembly, DWORD dwEventOptions);
- static VOID SendDomainEvent(BaseDomain *pBaseDomain, DWORD dwEventOptions, LPCWSTR wszFriendlyName=NULL);
+ static VOID SendDomainEvent(DWORD dwEventOptions, LPCWSTR wszFriendlyName=NULL);
public:
typedef union _LoaderStructs
{
@@ -877,23 +875,23 @@ namespace ETW
}LoaderStructs;
- static VOID DomainLoadReal(BaseDomain *pDomain, _In_opt_ LPWSTR wszFriendlyName=NULL);
+ static VOID DomainLoadReal(_In_opt_ LPWSTR wszFriendlyName=NULL);
- static VOID DomainLoad(BaseDomain *pDomain, _In_opt_ LPWSTR wszFriendlyName = NULL)
+ static VOID DomainLoad(_In_opt_ LPWSTR wszFriendlyName = NULL)
{
if (ETW_PROVIDER_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER))
{
- DomainLoadReal(pDomain, wszFriendlyName);
+ DomainLoadReal(wszFriendlyName);
}
}
- static VOID DomainUnload(AppDomain *pDomain);
+ static VOID DomainUnload();
static VOID CollectibleLoaderAllocatorUnload(AssemblyLoaderAllocator *pLoaderAllocator);
static VOID ModuleLoad(Module *pModule, LONG liReportedSharedModule);
#else
public:
- static VOID DomainLoad(BaseDomain *pDomain, _In_opt_ LPWSTR wszFriendlyName=NULL) {};
- static VOID DomainUnload(AppDomain *pDomain) {};
+ static VOID DomainLoad(_In_opt_ LPWSTR wszFriendlyName=NULL) {};
+ static VOID DomainUnload() {};
static VOID CollectibleLoaderAllocatorUnload(AssemblyLoaderAllocator *pLoaderAllocator) {};
static VOID ModuleLoad(Module *pModule, LONG liReportedSharedModule) {};
#endif // FEATURE_EVENT_TRACE
@@ -904,7 +902,7 @@ namespace ETW
{
friend class ETW::EnumerationLog;
#ifdef FEATURE_EVENT_TRACE
- static VOID SendEventsForJitMethods(BaseDomain *pDomainFilter, LoaderAllocator *pLoaderAllocatorFilter, DWORD dwEventOptions);
+ static VOID SendEventsForJitMethods(BOOL getCodeVersionIds, LoaderAllocator *pLoaderAllocatorFilter, DWORD dwEventOptions);
static VOID SendEventsForJitMethodsHelper(
LoaderAllocator *pLoaderAllocatorFilter,
DWORD dwEventOptions,
diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h
index bbaf43a6ee0ce..ffc4659cb9fb8 100644
--- a/src/coreclr/inc/icorjitinfoimpl_generated.h
+++ b/src/coreclr/inc/icorjitinfoimpl_generated.h
@@ -193,15 +193,9 @@ bool isValueClass(
uint32_t getClassAttribs(
CORINFO_CLASS_HANDLE cls) override;
-CORINFO_MODULE_HANDLE getClassModule(
+const char* getClassAssemblyName(
CORINFO_CLASS_HANDLE cls) override;
-CORINFO_ASSEMBLY_HANDLE getModuleAssembly(
- CORINFO_MODULE_HANDLE mod) override;
-
-const char* getAssemblyName(
- CORINFO_ASSEMBLY_HANDLE assem) override;
-
void* LongLifetimeMalloc(
size_t sz) override;
diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h
index 6aef89b2afd76..bce13e8aabcc3 100644
--- a/src/coreclr/inc/jiteeversionguid.h
+++ b/src/coreclr/inc/jiteeversionguid.h
@@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED
-constexpr GUID JITEEVersionIdentifier = { /* 7f7fd340-4779-455a-8046-628f3cd8c3c7 */
- 0x7f7fd340,
- 0x4779,
- 0x455a,
- {0x80, 0x46, 0x62, 0x8f, 0x3c, 0xd8, 0xc3, 0xc7}
+constexpr GUID JITEEVersionIdentifier = { /* b75a5475-ff22-4078-9551-2024ce03d383 */
+ 0xb75a5475,
+ 0xff22,
+ 0x4078,
+ {0x95, 0x51, 0x20, 0x24, 0xce, 0x03, 0xd3, 0x83}
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/coreclr/jit/ICorJitInfo_names_generated.h b/src/coreclr/jit/ICorJitInfo_names_generated.h
index 2d3865018d1de..15665a14b69ba 100644
--- a/src/coreclr/jit/ICorJitInfo_names_generated.h
+++ b/src/coreclr/jit/ICorJitInfo_names_generated.h
@@ -45,9 +45,7 @@ DEF_CLR_API(getTypeInstantiationArgument)
DEF_CLR_API(printClassName)
DEF_CLR_API(isValueClass)
DEF_CLR_API(getClassAttribs)
-DEF_CLR_API(getClassModule)
-DEF_CLR_API(getModuleAssembly)
-DEF_CLR_API(getAssemblyName)
+DEF_CLR_API(getClassAssemblyName)
DEF_CLR_API(LongLifetimeMalloc)
DEF_CLR_API(LongLifetimeFree)
DEF_CLR_API(getIsClassInitedFlagAddress)
diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
index ff3270192dc5f..f45110fe0caba 100644
--- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
+++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
@@ -416,30 +416,12 @@ uint32_t WrapICorJitInfo::getClassAttribs(
return temp;
}
-CORINFO_MODULE_HANDLE WrapICorJitInfo::getClassModule(
+const char* WrapICorJitInfo::getClassAssemblyName(
CORINFO_CLASS_HANDLE cls)
{
- API_ENTER(getClassModule);
- CORINFO_MODULE_HANDLE temp = wrapHnd->getClassModule(cls);
- API_LEAVE(getClassModule);
- return temp;
-}
-
-CORINFO_ASSEMBLY_HANDLE WrapICorJitInfo::getModuleAssembly(
- CORINFO_MODULE_HANDLE mod)
-{
- API_ENTER(getModuleAssembly);
- CORINFO_ASSEMBLY_HANDLE temp = wrapHnd->getModuleAssembly(mod);
- API_LEAVE(getModuleAssembly);
- return temp;
-}
-
-const char* WrapICorJitInfo::getAssemblyName(
- CORINFO_ASSEMBLY_HANDLE assem)
-{
- API_ENTER(getAssemblyName);
- const char* temp = wrapHnd->getAssemblyName(assem);
- API_LEAVE(getAssemblyName);
+ API_ENTER(getClassAssemblyName);
+ const char* temp = wrapHnd->getClassAssemblyName(cls);
+ API_LEAVE(getClassAssemblyName);
return temp;
}
diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp
index 3f28580aba68a..971d9ea575910 100644
--- a/src/coreclr/jit/compiler.cpp
+++ b/src/coreclr/jit/compiler.cpp
@@ -2586,8 +2586,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
// We have an exclusion list. See if this method is in an assembly that is on the list.
// Note that we check this for every method, since we might inline across modules, and
// if the inlinee module is on the list, we don't want to use the altjit for it.
- const char* methodAssemblyName = info.compCompHnd->getAssemblyName(
- info.compCompHnd->getModuleAssembly(info.compCompHnd->getClassModule(info.compClassHnd)));
+ const char* methodAssemblyName = eeGetClassAssemblyName(info.compClassHnd);
if (s_pAltJitExcludeAssembliesList->IsInList(methodAssemblyName))
{
opts.altJit = false;
@@ -2614,8 +2613,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
bool assemblyInIncludeList = true; // assume we'll dump, if there's not an include list (or it's empty).
if (s_pJitDisasmIncludeAssembliesList != nullptr && !s_pJitDisasmIncludeAssembliesList->IsEmpty())
{
- const char* assemblyName = info.compCompHnd->getAssemblyName(
- info.compCompHnd->getModuleAssembly(info.compCompHnd->getClassModule(info.compClassHnd)));
+ const char* assemblyName = eeGetClassAssemblyName(info.compClassHnd);
if (!s_pJitDisasmIncludeAssembliesList->IsInList(assemblyName))
{
// We have a list, and the current assembly is not in it, so we won't dump.
@@ -6335,39 +6333,29 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
#ifdef DEBUG
if (JitConfig.EnableExtraSuperPmiQueries())
{
- // This call to getClassModule/getModuleAssembly/getAssemblyName fails in crossgen2 due to these
- // APIs being unimplemented. So disable this extra info for pre-jit mode. See
- // https://github.com/dotnet/runtime/issues/48888.
- //
- // Ditto for some of the class name queries for generic params.
- //
- if (!compileFlags->IsSet(JitFlags::JIT_FLAG_PREJIT))
- {
- // Get the assembly name, to aid finding any particular SuperPMI method context function
- (void)info.compCompHnd->getAssemblyName(
- info.compCompHnd->getModuleAssembly(info.compCompHnd->getClassModule(info.compClassHnd)));
+ // Get the assembly name, to aid finding any particular SuperPMI method context function
+ (void)eeGetClassAssemblyName(info.compClassHnd);
- // Fetch class names for the method's generic parameters.
- //
- CORINFO_SIG_INFO sig;
- info.compCompHnd->getMethodSig(info.compMethodHnd, &sig, nullptr);
+ // Fetch class names for the method's generic parameters.
+ //
+ CORINFO_SIG_INFO sig;
+ info.compCompHnd->getMethodSig(info.compMethodHnd, &sig, nullptr);
- const unsigned classInst = sig.sigInst.classInstCount;
- if (classInst > 0)
+ const unsigned classInst = sig.sigInst.classInstCount;
+ if (classInst > 0)
+ {
+ for (unsigned i = 0; i < classInst; i++)
{
- for (unsigned i = 0; i < classInst; i++)
- {
- eeGetClassName(sig.sigInst.classInst[i]);
- }
+ eeGetClassName(sig.sigInst.classInst[i]);
}
+ }
- const unsigned methodInst = sig.sigInst.methInstCount;
- if (methodInst > 0)
+ const unsigned methodInst = sig.sigInst.methInstCount;
+ if (methodInst > 0)
+ {
+ for (unsigned i = 0; i < methodInst; i++)
{
- for (unsigned i = 0; i < methodInst; i++)
- {
- eeGetClassName(sig.sigInst.methInst[i]);
- }
+ eeGetClassName(sig.sigInst.methInst[i]);
}
}
}
@@ -9221,8 +9209,7 @@ void JitTimer::PrintCsvMethodStats(Compiler* comp)
}
else
{
- const char* methodAssemblyName = comp->info.compCompHnd->getAssemblyName(
- comp->info.compCompHnd->getModuleAssembly(comp->info.compCompHnd->getClassModule(comp->info.compClassHnd)));
+ const char* methodAssemblyName = comp->eeGetClassAssemblyName(comp->info.compClassHnd);
fprintf(s_csvFile, "\"%s\",", methodAssemblyName);
}
fprintf(s_csvFile, "%u,", comp->info.compILCodeSize);
diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h
index 2febde4d7365d..a23a650a805f2 100644
--- a/src/coreclr/jit/compiler.h
+++ b/src/coreclr/jit/compiler.h
@@ -5316,6 +5316,8 @@ class Compiler
unsigned xcptnIndex,
bool putInTryRegion);
+ BasicBlock* fgNewBBatTryRegionEnd(BBKinds jumpKind, unsigned tryIndex);
+
void fgInsertBBbefore(BasicBlock* insertBeforeBlk, BasicBlock* newBlk);
void fgInsertBBafter(BasicBlock* insertAfterBlk, BasicBlock* newBlk);
void fgUnlinkBlock(BasicBlock* block);
@@ -7064,8 +7066,6 @@ class Compiler
void optCompactLoops();
void optCompactLoop(FlowGraphNaturalLoop* loop);
- BasicBlock* optFindLoopCompactionInsertionPoint(FlowGraphNaturalLoop* loop, BasicBlock* top);
- BasicBlock* optTryAdvanceLoopCompactionInsertionPoint(FlowGraphNaturalLoop* loop, BasicBlock* insertionPoint, BasicBlock* top, BasicBlock* bottom);
bool optCreatePreheader(FlowGraphNaturalLoop* loop);
void optSetWeightForPreheaderOrExit(FlowGraphNaturalLoop* loop, BasicBlock* block);
@@ -8337,6 +8337,8 @@ class Compiler
void eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle);
const char* eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd);
+ const char* eeGetClassAssemblyName(CORINFO_CLASS_HANDLE clsHnd);
+
#if defined(DEBUG)
unsigned eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd);
#endif
diff --git a/src/coreclr/jit/eeinterface.cpp b/src/coreclr/jit/eeinterface.cpp
index fb07912ebf7d9..7ac73a22d27e0 100644
--- a/src/coreclr/jit/eeinterface.cpp
+++ b/src/coreclr/jit/eeinterface.cpp
@@ -596,6 +596,27 @@ const char* Compiler::eeGetShortClassName(CORINFO_CLASS_HANDLE clsHnd)
return printer.GetBuffer();
}
+//------------------------------------------------------------------------
+// eeGetClassAssemblyName:
+// Get the assembly name of a type.
+// If missing information (in SPMI), then return a placeholder string.
+//
+// Parameters:
+// clsHnd - the handle of the class
+//
+// Return value:
+// The name string.
+//
+const char* Compiler::eeGetClassAssemblyName(CORINFO_CLASS_HANDLE clsHnd)
+{
+ const char* assemblyName = "";
+ eeRunFunctorWithSPMIErrorTrap([&]() {
+ assemblyName = info.compCompHnd->getClassAssemblyName(clsHnd);
+ });
+
+ return assemblyName != nullptr ? assemblyName : "";
+}
+
void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDLE handle)
{
const size_t maxStrSize = 64;
diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp
index f1f716d6de420..33ac26acfd106 100644
--- a/src/coreclr/jit/emit.cpp
+++ b/src/coreclr/jit/emit.cpp
@@ -6773,12 +6773,10 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
#endif
#if defined(TARGET_XARCH) || defined(TARGET_ARM64)
- // For x64/x86/arm64, align methods that are "optimizations enabled" to 32 byte boundaries if
- // they are larger than 16 bytes and contain a loop.
+ // For x64/x86/arm64, align methods that contain a loop to 32 byte boundaries if
+ // they are larger than 16 bytes and loop alignment is enabled.
//
- if (emitComp->opts.OptimizationEnabled() &&
- (!emitComp->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) || comp->IsTargetAbi(CORINFO_NATIVEAOT_ABI)) &&
- (emitTotalHotCodeSize > 16) && emitComp->fgHasLoops)
+ if (codeGen->ShouldAlignLoops() && (emitTotalHotCodeSize > 16) && emitComp->fgHasLoops)
{
codeAlignment = 32;
}
diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp
index 71cafb0d5f488..500d827ab29ca 100644
--- a/src/coreclr/jit/emitxarch.cpp
+++ b/src/coreclr/jit/emitxarch.cpp
@@ -2789,7 +2789,14 @@ bool emitter::emitInsCanOnlyWriteSSE2OrAVXReg(instrDesc* id)
// These SSE instructions write to a general purpose integer register.
return false;
}
-
+ case INS_kmovb_gpr:
+ case INS_kmovw_gpr:
+ case INS_kmovd_gpr:
+ case INS_kmovq_gpr:
+ {
+ // These kmov writes to a general purpose integer register
+ return !isGeneralRegister(id->idReg1());
+ }
default:
{
return true;
diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp
index f8e7ead56b323..774e456f5e761 100644
--- a/src/coreclr/jit/fgbasic.cpp
+++ b/src/coreclr/jit/fgbasic.cpp
@@ -6723,6 +6723,39 @@ BasicBlock* Compiler::fgNewBBinRegionWorker(BBKinds jumpKind,
return newBlk;
}
+//-----------------------------------------------------------------------------
+// fgNewBBatTryRegionEnd: Creates and inserts a new block at the end of the specified
+// try region, updating the try end pointers in the EH table as necessary.
+//
+// Arguments:
+// jumpKind - The jump kind of the new block
+// tryIndex - The index of the try region to insert the new block in
+//
+// Returns:
+// The new block
+//
+BasicBlock* Compiler::fgNewBBatTryRegionEnd(BBKinds jumpKind, unsigned tryIndex)
+{
+ BasicBlock* const oldTryLast = ehGetDsc(tryIndex)->ebdTryLast;
+ BasicBlock* const newBlock = fgNewBBafter(jumpKind, oldTryLast, /* extendRegion */ false);
+ newBlock->setTryIndex(tryIndex);
+ newBlock->clearHndIndex();
+
+ // Update this try region's (and all parent try regions') last block pointer
+ //
+ for (unsigned XTnum = tryIndex; XTnum < compHndBBtabCount; XTnum++)
+ {
+ EHblkDsc* const HBtab = ehGetDsc(XTnum);
+ if (HBtab->ebdTryLast == oldTryLast)
+ {
+ assert((XTnum == tryIndex) || (ehGetDsc(tryIndex)->ebdEnclosingTryIndex != EHblkDsc::NO_ENCLOSING_INDEX));
+ fgSetTryEnd(HBtab, newBlock);
+ }
+ }
+
+ return newBlock;
+}
+
//------------------------------------------------------------------------
// fgUseThrowHelperBlocks: Determinate does compiler use throw helper blocks.
//
diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp
index c60bff8c10202..e021613381de5 100644
--- a/src/coreclr/jit/gentree.cpp
+++ b/src/coreclr/jit/gentree.cpp
@@ -20824,6 +20824,16 @@ GenTree* Compiler::gtNewSimdBinOpNode(
if (op2->IsCnsIntOrI())
{
op2->AsIntCon()->gtIconVal &= shiftCountMask;
+#ifdef TARGET_ARM64
+ // On ARM64, ShiftRight* intrinsics cannot encode a shift value of zero,
+ // so use the generic Shift* fallback intrinsic.
+ // GenTreeHWIntrinsic::GetHWIntrinsicIdForBinOp will see that the immediate node is not const,
+ // and return the correct fallback intrinsic.
+ if ((op != GT_LSH) && (op2->AsIntCon()->IconValue() == 0))
+ {
+ op2 = gtNewZeroConNode(type);
+ }
+#endif // TARGET_ARM64
}
else
{
diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp
index bd5027cd4e02d..d2a4bb4d2caf1 100644
--- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp
+++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp
@@ -434,18 +434,8 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
for (helper.EmitBegin(); !helper.Done(); helper.EmitCaseEnd())
{
const int shiftAmount = helper.ImmValue();
-
- if (shiftAmount == 0)
- {
- // TODO: Use emitIns_Mov instead.
- // We do not use it currently because it will still elide the 'mov'
- // even if 'canSkip' is false. We cannot elide the 'mov' here.
- GetEmitter()->emitIns_R_R_R(INS_mov, emitTypeSize(node), targetReg, reg, reg);
- }
- else
- {
- GetEmitter()->emitIns_R_R_I(ins, emitSize, targetReg, reg, shiftAmount, opt);
- }
+ assert((shiftAmount != 0) || (intrin.category == HW_Category_ShiftLeftByImmediate));
+ GetEmitter()->emitIns_R_R_I(ins, emitSize, targetReg, reg, shiftAmount, opt);
}
};
diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp
index f8bc800241491..d92895a9d4980 100644
--- a/src/coreclr/jit/lower.cpp
+++ b/src/coreclr/jit/lower.cpp
@@ -8962,12 +8962,22 @@ void Lowering::LowerStoreIndirCoalescing(GenTreeIndir* ind)
assert(prevData.IsStore());
assert(currData.IsStore());
- // For now, only constants are supported for data.
+ // For now, only non-relocatable constants are supported for data.
if (!prevData.value->OperIsConst() || !currData.value->OperIsConst())
{
return;
}
+ if (prevData.value->IsCnsIntOrI() && prevData.value->AsIntCon()->ImmedValNeedsReloc(comp))
+ {
+ return;
+ }
+
+ if (currData.value->IsCnsIntOrI() && currData.value->AsIntCon()->ImmedValNeedsReloc(comp))
+ {
+ return;
+ }
+
// Otherwise, the difference between two offsets has to match the size of the type.
// We don't support overlapping stores.
if (abs(prevData.offset - currData.offset) != (int)genTypeSize(prevData.targetType))
diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp
index 1a9d2bc466407..f9880026eab26 100644
--- a/src/coreclr/jit/optimizer.cpp
+++ b/src/coreclr/jit/optimizer.cpp
@@ -2828,7 +2828,7 @@ void Compiler::optCompactLoop(FlowGraphNaturalLoop* loop)
if (insertionPoint == nullptr)
{
- insertionPoint = optFindLoopCompactionInsertionPoint(loop, top);
+ insertionPoint = loop->GetLexicallyBottomMostBlock();
}
BasicBlock* previous = cur->Prev();
@@ -2842,8 +2842,6 @@ void Compiler::optCompactLoop(FlowGraphNaturalLoop* loop)
}
// Now physically move the blocks.
- BasicBlock* moveBefore = insertionPoint->Next();
-
fgUnlinkRange(cur, lastNonLoopBlock);
fgMoveBlocksAfter(cur, lastNonLoopBlock, insertionPoint);
ehUpdateLastBlocks(insertionPoint, lastNonLoopBlock);
@@ -2855,137 +2853,6 @@ void Compiler::optCompactLoop(FlowGraphNaturalLoop* loop)
}
}
-//-----------------------------------------------------------------------------
-// optFindLoopCompactionInsertionPoint: Find a good insertion point at which to
-// move blocks from the lexical range of "loop" that is not part of the loop.
-//
-// Parameters:
-// loop - The loop
-// top - Lexical top block of the loop.
-//
-// Returns:
-// Non-null insertion point.
-//
-BasicBlock* Compiler::optFindLoopCompactionInsertionPoint(FlowGraphNaturalLoop* loop, BasicBlock* top)
-{
- // Find an insertion point for blocks we're going to move. Move them down
- // out of the loop, and if possible find a spot that won't break up fall-through.
- BasicBlock* bottom = loop->GetLexicallyBottomMostBlock();
- BasicBlock* insertionPoint = bottom;
- while (!insertionPoint->IsLast())
- {
- switch (insertionPoint->GetKind())
- {
- case BBJ_ALWAYS:
- if (!insertionPoint->JumpsToNext())
- {
- // Found a branch that isn't to the next block, so we won't split up any fall-through.
- return insertionPoint;
- }
- break;
-
- case BBJ_COND:
- if (!insertionPoint->FalseTargetIs(insertionPoint->Next()))
- {
- // Found a conditional branch that doesn't have a false branch to the next block,
- // so we won't split up any fall-through.
- return insertionPoint;
- }
- break;
-
- case BBJ_CALLFINALLY:
- if (!insertionPoint->isBBCallFinallyPair())
- {
- // Found a retless BBJ_CALLFINALLY block, so we won't split up any fall-through.
- return insertionPoint;
- }
- break;
-
- default:
- // No fall-through to split up.
- return insertionPoint;
- }
-
- // Keep looking for a better insertion point if we can.
- BasicBlock* newInsertionPoint = optTryAdvanceLoopCompactionInsertionPoint(loop, insertionPoint, top, bottom);
- if (newInsertionPoint == nullptr)
- {
- // Ran out of candidate insertion points, so just split up the fall-through.
- break;
- }
-
- insertionPoint = newInsertionPoint;
- }
-
- return insertionPoint;
-}
-
-//-----------------------------------------------------------------------------
-// optTryAdvanceLoopCompactionInsertionPoint: Advance the insertion point to
-// avoid having to insert new blocks due to fallthrough.
-//
-// Parameters:
-// loop - The loop
-// insertionPoint - Current insertion point
-// top - Lexical top block of the loop.
-// bottom - Lexical bottom block of the loop.
-//
-// Returns:
-// New insertion point.
-//
-BasicBlock* Compiler::optTryAdvanceLoopCompactionInsertionPoint(FlowGraphNaturalLoop* loop,
- BasicBlock* insertionPoint,
- BasicBlock* top,
- BasicBlock* bottom)
-{
- BasicBlock* newInsertionPoint = insertionPoint->Next();
-
- if (!BasicBlock::sameEHRegion(insertionPoint, newInsertionPoint))
- {
- // Don't cross an EH region boundary.
- return nullptr;
- }
-
- // TODO-Quirk: Compatibility with old compaction
- if (newInsertionPoint->KindIs(BBJ_ALWAYS, BBJ_COND))
- {
- BasicBlock* dest =
- newInsertionPoint->KindIs(BBJ_ALWAYS) ? newInsertionPoint->GetTarget() : newInsertionPoint->GetTrueTarget();
- if ((dest->bbNum >= top->bbNum) && (dest->bbNum <= bottom->bbNum) && !loop->ContainsBlock(dest))
- {
- return nullptr;
- }
- }
-
- // TODO-Quirk: Compatibility with old compaction
- for (BasicBlock* const predBlock : newInsertionPoint->PredBlocks())
- {
- if ((predBlock->bbNum >= top->bbNum) && (predBlock->bbNum <= bottom->bbNum) && !loop->ContainsBlock(predBlock))
- {
- // Don't make this forward edge a backwards edge.
- return nullptr;
- }
- }
-
- // Compaction runs on outer loops before inner loops. That means all
- // unlexical blocks here are part of an ancestor loop (or trivial
- // BBJ_ALWAYS exit blocks). To avoid breaking lexicality of ancestor loops
- // we avoid moving any block past the bottom of an ancestor loop.
- for (FlowGraphNaturalLoop* ancestor = loop->GetParent(); ancestor != nullptr; ancestor = ancestor->GetParent())
- {
- if (newInsertionPoint == ancestor->GetLexicallyBottomMostBlock())
- {
- return nullptr;
- }
- }
-
- // Advancing the insertion point is ok, except that we can't split up any call finally
- // pair, so if we've got such a pair recurse to see if we can move past the whole thing.
- return newInsertionPoint->isBBCallFinallyPair()
- ? optTryAdvanceLoopCompactionInsertionPoint(loop, newInsertionPoint, top, bottom)
- : newInsertionPoint;
-}
-
//-----------------------------------------------------------------------------
// optCreatePreheader: Create (or find) a preheader for a natural loop.
//
@@ -3024,16 +2891,10 @@ bool Compiler::optCreatePreheader(FlowGraphNaturalLoop* loop)
}
}
- BasicBlock* insertBefore = loop->GetLexicallyTopMostBlock();
- if (!BasicBlock::sameEHRegion(insertBefore, header))
- {
- insertBefore = header;
- }
-
- BasicBlock* preheader = fgNewBBbefore(BBJ_ALWAYS, insertBefore, false);
+ BasicBlock* preheader = fgNewBBbefore(BBJ_ALWAYS, header, false);
preheader->SetFlags(BBF_INTERNAL);
fgSetEHRegionForNewPreheaderOrExit(preheader);
- preheader->bbCodeOffs = insertBefore->bbCodeOffs;
+ preheader->bbCodeOffs = header->bbCodeOffs;
JITDUMP("Created new preheader " FMT_BB " for " FMT_LP "\n", preheader->bbNum, loop->GetIndex());
@@ -3136,21 +2997,11 @@ bool Compiler::optCanonicalizeExit(FlowGraphNaturalLoop* loop, BasicBlock* exit)
{
// Branches to a BBJ_CALLFINALLY _must_ come from inside its associated
// try region, and when we have callfinally thunks the BBJ_CALLFINALLY
- // is outside it. First try to see if the lexically bottom most block
- // is part of the try; if so, inserting after that is a good choice.
+ // is outside it. Thus, insert newExit at the end of the finally's
+ // try region.
BasicBlock* finallyBlock = exit->GetTarget();
assert(finallyBlock->hasHndIndex());
- BasicBlock* bottom = loop->GetLexicallyBottomMostBlock();
- if (bottom->hasTryIndex() && (bottom->getTryIndex() == finallyBlock->getHndIndex()) && !bottom->hasHndIndex())
- {
- newExit = fgNewBBafter(BBJ_ALWAYS, bottom, true);
- }
- else
- {
- // Otherwise just do the heavy-handed thing and insert it anywhere in the right region.
- newExit = fgNewBBinRegion(BBJ_ALWAYS, finallyBlock->bbHndIndex, 0, nullptr, /* putInFilter */ false,
- /* runRarely */ false, /* insertAtEnd */ true);
- }
+ newExit = fgNewBBatTryRegionEnd(BBJ_ALWAYS, finallyBlock->getHndIndex());
}
else
{
diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
index 987bbc6508f13..d766ded60142e 100644
--- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
+++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
@@ -2092,12 +2092,17 @@ private uint getClassAttribsInternal(TypeDesc type)
return (uint)result;
}
- private CORINFO_MODULE_STRUCT_* getClassModule(CORINFO_CLASS_STRUCT_* cls)
- { throw new NotImplementedException("getClassModule"); }
- private CORINFO_ASSEMBLY_STRUCT_* getModuleAssembly(CORINFO_MODULE_STRUCT_* mod)
- { throw new NotImplementedException("getModuleAssembly"); }
- private byte* getAssemblyName(CORINFO_ASSEMBLY_STRUCT_* assem)
- { throw new NotImplementedException("getAssemblyName"); }
+ private byte* getClassAssemblyName(CORINFO_CLASS_STRUCT_* cls)
+ {
+ TypeDesc type = HandleToObject(cls);
+
+ if (type is MetadataType mdType)
+ {
+ return (byte*)GetPin(StringToUTF8(mdType.Module.Assembly.GetName().Name));
+ }
+
+ return null;
+ }
#pragma warning disable CA1822 // Mark members as static
private void* LongLifetimeMalloc(UIntPtr sz)
diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs
index 9213d42aba327..26291e015b428 100644
--- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs
+++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs
@@ -614,42 +614,12 @@ private static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, COR
}
[UnmanagedCallersOnly]
- private static CORINFO_MODULE_STRUCT_* _getClassModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls)
+ private static byte* _getClassAssemblyName(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls)
{
var _this = GetThis(thisHandle);
try
{
- return _this.getClassModule(cls);
- }
- catch (Exception ex)
- {
- *ppException = _this.AllocException(ex);
- return default;
- }
- }
-
- [UnmanagedCallersOnly]
- private static CORINFO_ASSEMBLY_STRUCT_* _getModuleAssembly(IntPtr thisHandle, IntPtr* ppException, CORINFO_MODULE_STRUCT_* mod)
- {
- var _this = GetThis(thisHandle);
- try
- {
- return _this.getModuleAssembly(mod);
- }
- catch (Exception ex)
- {
- *ppException = _this.AllocException(ex);
- return default;
- }
- }
-
- [UnmanagedCallersOnly]
- private static byte* _getAssemblyName(IntPtr thisHandle, IntPtr* ppException, CORINFO_ASSEMBLY_STRUCT_* assem)
- {
- var _this = GetThis(thisHandle);
- try
- {
- return _this.getAssemblyName(assem);
+ return _this.getClassAssemblyName(cls);
}
catch (Exception ex)
{
@@ -2623,7 +2593,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_
private static IntPtr GetUnmanagedCallbacks()
{
- void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 177);
+ void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 175);
callbacks[0] = (delegate* unmanaged)&_isIntrinsic;
callbacks[1] = (delegate* unmanaged)&_notifyMethodInfoUsage;
@@ -2666,142 +2636,140 @@ private static IntPtr GetUnmanagedCallbacks()
callbacks[38] = (delegate* unmanaged)&_printClassName;
callbacks[39] = (delegate* unmanaged)&_isValueClass;
callbacks[40] = (delegate* unmanaged)&_getClassAttribs;
- callbacks[41] = (delegate* unmanaged)&_getClassModule;
- callbacks[42] = (delegate* unmanaged)&_getModuleAssembly;
- callbacks[43] = (delegate* unmanaged)&_getAssemblyName;
- callbacks[44] = (delegate* unmanaged)&_LongLifetimeMalloc;
- callbacks[45] = (delegate* unmanaged)&_LongLifetimeFree;
- callbacks[46] = (delegate* unmanaged)&_getIsClassInitedFlagAddress;
- callbacks[47] = (delegate* unmanaged)&_getClassThreadStaticDynamicInfo;
- callbacks[48] = (delegate* unmanaged)&_getClassStaticDynamicInfo;
- callbacks[49] = (delegate* unmanaged)&_getStaticBaseAddress;
- callbacks[50] = (delegate* unmanaged)&_getClassSize;
- callbacks[51] = (delegate* unmanaged)&_getHeapClassSize;
- callbacks[52] = (delegate* unmanaged)&_canAllocateOnStack;
- callbacks[53] = (delegate* unmanaged)&_getClassAlignmentRequirement;
- callbacks[54] = (delegate* unmanaged)&_getClassGClayout;
- callbacks[55] = (delegate* unmanaged)&_getClassNumInstanceFields;
- callbacks[56] = (delegate* unmanaged)&_getFieldInClass;
- callbacks[57] = (delegate* unmanaged)&_getTypeLayout;
- callbacks[58] = (delegate* unmanaged)&_checkMethodModifier;
- callbacks[59] = (delegate* unmanaged)&_getNewHelper;
- callbacks[60] = (delegate* unmanaged)&_getNewArrHelper;
- callbacks[61] = (delegate* unmanaged)&_getCastingHelper;
- callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper;
- callbacks[63] = (delegate* unmanaged)&_getTypeForBox;
- callbacks[64] = (delegate* unmanaged)&_getTypeForBoxOnStack;
- callbacks[65] = (delegate* unmanaged)&_getBoxHelper;
- callbacks[66] = (delegate* unmanaged)&_getUnBoxHelper;
- callbacks[67] = (delegate* unmanaged)&_getRuntimeTypePointer;
- callbacks[68] = (delegate* unmanaged)&_isObjectImmutable;
- callbacks[69] = (delegate* unmanaged)&_getStringChar;
- callbacks[70] = (delegate* unmanaged)&_getObjectType;
- callbacks[71] = (delegate* unmanaged)&_getReadyToRunHelper;
- callbacks[72] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper;
- callbacks[73] = (delegate* unmanaged)&_initClass;
- callbacks[74] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun;
- callbacks[75] = (delegate* unmanaged)&_getBuiltinClass;
- callbacks[76] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass;
- callbacks[77] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass;
- callbacks[78] = (delegate* unmanaged)&_canCast;
- callbacks[79] = (delegate* unmanaged)&_compareTypesForCast;
- callbacks[80] = (delegate* unmanaged)&_compareTypesForEquality;
- callbacks[81] = (delegate* unmanaged)&_isMoreSpecificType;
- callbacks[82] = (delegate* unmanaged)&_isExactType;
- callbacks[83] = (delegate* unmanaged)&_isGenericType;
- callbacks[84] = (delegate* unmanaged)&_isNullableType;
- callbacks[85] = (delegate* unmanaged)&_isEnum;
- callbacks[86] = (delegate* unmanaged)&_getParentType;
- callbacks[87] = (delegate* unmanaged)&_getChildType;
- callbacks[88] = (delegate* unmanaged)&_isSDArray;
- callbacks[89] = (delegate* unmanaged)&_getArrayRank;
- callbacks[90] = (delegate* unmanaged)&_getArrayIntrinsicID;
- callbacks[91] = (delegate* unmanaged)&_getArrayInitializationData;
- callbacks[92] = (delegate* unmanaged)&_canAccessClass;
- callbacks[93] = (delegate* unmanaged)&_printFieldName;
- callbacks[94] = (delegate* unmanaged)&_getFieldClass;
- callbacks[95] = (delegate* unmanaged)&_getFieldType;
- callbacks[96] = (delegate* unmanaged)&_getFieldOffset;
- callbacks[97] = (delegate* unmanaged)&_getFieldInfo;
- callbacks[98] = (delegate* unmanaged)&_getThreadLocalFieldInfo;
- callbacks[99] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo;
- callbacks[100] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT;
- callbacks[101] = (delegate* unmanaged)&_isFieldStatic;
- callbacks[102] = (delegate* unmanaged)&_getArrayOrStringLength;
- callbacks[103] = (delegate* unmanaged)&_getBoundaries;
- callbacks[104] = (delegate* unmanaged)&_setBoundaries;
- callbacks[105] = (delegate* unmanaged)&_getVars;
- callbacks[106] = (delegate* unmanaged)&_setVars;
- callbacks[107] = (delegate* unmanaged)&_reportRichMappings;
- callbacks[108] = (delegate* unmanaged)&_reportMetadata;
- callbacks[109] = (delegate* unmanaged)&_allocateArray;
- callbacks[110] = (delegate* unmanaged)&_freeArray;
- callbacks[111] = (delegate* unmanaged)&_getArgNext;
- callbacks[112] = (delegate* unmanaged)&_getArgType;
- callbacks[113] = (delegate* unmanaged)&_getExactClasses;
- callbacks[114] = (delegate* unmanaged)&_getArgClass;
- callbacks[115] = (delegate* unmanaged)&_getHFAType;
- callbacks[116] = (delegate* unmanaged)&_runWithErrorTrap;
- callbacks[117] = (delegate* unmanaged)&_runWithSPMIErrorTrap;
- callbacks[118] = (delegate* unmanaged)&_getEEInfo;
- callbacks[119] = (delegate* unmanaged)&_getJitTimeLogFilename;
- callbacks[120] = (delegate* unmanaged)&_getMethodDefFromMethod;
- callbacks[121] = (delegate* unmanaged)&_printMethodName;
- callbacks[122] = (delegate* unmanaged)&_getMethodNameFromMetadata;
- callbacks[123] = (delegate* unmanaged)&_getMethodHash;
- callbacks[124] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor;
- callbacks[125] = (delegate* unmanaged)&_getSwiftLowering;
- callbacks[126] = (delegate* unmanaged)&_getFpStructLowering;
- callbacks[127] = (delegate* unmanaged)&_getThreadTLSIndex;
- callbacks[128] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal;
- callbacks[129] = (delegate* unmanaged)&_getHelperFtn;
- callbacks[130] = (delegate* unmanaged)&_getFunctionEntryPoint;
- callbacks[131] = (delegate* unmanaged)&_getFunctionFixedEntryPoint;
- callbacks[132] = (delegate* unmanaged)&_getMethodSync;
- callbacks[133] = (delegate* unmanaged)&_getLazyStringLiteralHelper;
- callbacks[134] = (delegate* unmanaged)&_embedModuleHandle;
- callbacks[135] = (delegate* unmanaged)&_embedClassHandle;
- callbacks[136] = (delegate* unmanaged)&_embedMethodHandle;
- callbacks[137] = (delegate* unmanaged)&_embedFieldHandle;
- callbacks[138] = (delegate* unmanaged)&_embedGenericHandle;
- callbacks[139] = (delegate* unmanaged)&_getLocationOfThisType;
- callbacks[140] = (delegate* unmanaged)&_getAddressOfPInvokeTarget;
- callbacks[141] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig;
- callbacks[142] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig;
- callbacks[143] = (delegate* unmanaged)&_getJustMyCodeHandle;
- callbacks[144] = (delegate* unmanaged)&_GetProfilingHandle;
- callbacks[145] = (delegate* unmanaged)&_getCallInfo;
- callbacks[146] = (delegate* unmanaged)&_getStaticFieldContent;
- callbacks[147] = (delegate* unmanaged)&_getObjectContent;
- callbacks[148] = (delegate* unmanaged)&_getStaticFieldCurrentClass;
- callbacks[149] = (delegate* unmanaged)&_getVarArgsHandle;
- callbacks[150] = (delegate* unmanaged)&_canGetVarArgsHandle;
- callbacks[151] = (delegate* unmanaged)&_constructStringLiteral;
- callbacks[152] = (delegate* unmanaged)&_emptyStringLiteral;
- callbacks[153] = (delegate* unmanaged)&_getFieldThreadLocalStoreID;
- callbacks[154] = (delegate* unmanaged)&_GetDelegateCtor;
- callbacks[155] = (delegate* unmanaged)&_MethodCompileComplete;
- callbacks[156] = (delegate* unmanaged)&_getTailCallHelpers;
- callbacks[157] = (delegate* unmanaged)&_convertPInvokeCalliToCall;
- callbacks[158] = (delegate* unmanaged)&_notifyInstructionSetUsage;
- callbacks[159] = (delegate* unmanaged)&_updateEntryPointForTailCall;
- callbacks[160] = (delegate* unmanaged)&_allocMem;
- callbacks[161] = (delegate* unmanaged)&_reserveUnwindInfo;
- callbacks[162] = (delegate* unmanaged)&_allocUnwindInfo;
- callbacks[163] = (delegate* unmanaged)&_allocGCInfo;
- callbacks[164] = (delegate* unmanaged)&_setEHcount;
- callbacks[165] = (delegate* unmanaged)&_setEHinfo;
- callbacks[166] = (delegate* unmanaged)&_logMsg;
- callbacks[167] = (delegate* unmanaged)&_doAssert;
- callbacks[168] = (delegate* unmanaged)&_reportFatalError;
- callbacks[169] = (delegate* unmanaged)&_getPgoInstrumentationResults;
- callbacks[170] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema;
- callbacks[171] = (delegate* unmanaged)&_recordCallSite;
- callbacks[172] = (delegate* unmanaged)&_recordRelocation;
- callbacks[173] = (delegate* unmanaged)&_getRelocTypeHint;
- callbacks[174] = (delegate* unmanaged)&_getExpectedTargetArchitecture;
- callbacks[175] = (delegate* unmanaged)&_getJitFlags;
- callbacks[176] = (delegate* unmanaged)&_getSpecialCopyHelper;
+ callbacks[41] = (delegate* unmanaged)&_getClassAssemblyName;
+ callbacks[42] = (delegate* unmanaged)&_LongLifetimeMalloc;
+ callbacks[43] = (delegate* unmanaged)&_LongLifetimeFree;
+ callbacks[44] = (delegate* unmanaged)&_getIsClassInitedFlagAddress;
+ callbacks[45] = (delegate* unmanaged)&_getClassThreadStaticDynamicInfo;
+ callbacks[46] = (delegate* unmanaged)&_getClassStaticDynamicInfo;
+ callbacks[47] = (delegate* unmanaged)&_getStaticBaseAddress;
+ callbacks[48] = (delegate* unmanaged)&_getClassSize;
+ callbacks[49] = (delegate* unmanaged)&_getHeapClassSize;
+ callbacks[50] = (delegate* unmanaged)&_canAllocateOnStack;
+ callbacks[51] = (delegate* unmanaged)&_getClassAlignmentRequirement;
+ callbacks[52] = (delegate* unmanaged)&_getClassGClayout;
+ callbacks[53] = (delegate* unmanaged)&_getClassNumInstanceFields;
+ callbacks[54] = (delegate* unmanaged)&_getFieldInClass;
+ callbacks[55] = (delegate* unmanaged)&_getTypeLayout;
+ callbacks[56] = (delegate* unmanaged)&_checkMethodModifier;
+ callbacks[57] = (delegate* unmanaged)&_getNewHelper;
+ callbacks[58] = (delegate* unmanaged)&_getNewArrHelper;
+ callbacks[59] = (delegate* unmanaged)&_getCastingHelper;
+ callbacks[60] = (delegate* unmanaged)&_getSharedCCtorHelper;
+ callbacks[61] = (delegate* unmanaged)&_getTypeForBox;
+ callbacks[62] = (delegate* unmanaged)&_getTypeForBoxOnStack;
+ callbacks[63] = (delegate* unmanaged)&_getBoxHelper;
+ callbacks[64] = (delegate* unmanaged)&_getUnBoxHelper;
+ callbacks[65] = (delegate* unmanaged)&_getRuntimeTypePointer;
+ callbacks[66] = (delegate* unmanaged)&_isObjectImmutable;
+ callbacks[67] = (delegate* unmanaged)&_getStringChar;
+ callbacks[68] = (delegate* unmanaged)&_getObjectType;
+ callbacks[69] = (delegate* unmanaged)&_getReadyToRunHelper;
+ callbacks[70] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper;
+ callbacks[71] = (delegate* unmanaged)&_initClass;
+ callbacks[72] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun;
+ callbacks[73] = (delegate* unmanaged)&_getBuiltinClass;
+ callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass;
+ callbacks[75] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass;
+ callbacks[76] = (delegate* unmanaged)&_canCast;
+ callbacks[77] = (delegate* unmanaged)&_compareTypesForCast;
+ callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality;
+ callbacks[79] = (delegate* unmanaged)&_isMoreSpecificType;
+ callbacks[80] = (delegate* unmanaged)&_isExactType;
+ callbacks[81] = (delegate* unmanaged)&_isGenericType;
+ callbacks[82] = (delegate* unmanaged)&_isNullableType;
+ callbacks[83] = (delegate* unmanaged)&_isEnum;
+ callbacks[84] = (delegate* unmanaged)&_getParentType;
+ callbacks[85] = (delegate* unmanaged)&_getChildType;
+ callbacks[86] = (delegate* unmanaged)&_isSDArray;
+ callbacks[87] = (delegate* unmanaged)&_getArrayRank;
+ callbacks[88] = (delegate* unmanaged)&_getArrayIntrinsicID;
+ callbacks[89] = (delegate* unmanaged)&_getArrayInitializationData;
+ callbacks[90] = (delegate* unmanaged)&_canAccessClass;
+ callbacks[91] = (delegate* unmanaged)&_printFieldName;
+ callbacks[92] = (delegate* unmanaged)&_getFieldClass;
+ callbacks[93] = (delegate* unmanaged)&_getFieldType;
+ callbacks[94] = (delegate* unmanaged)&_getFieldOffset;
+ callbacks[95] = (delegate* unmanaged)&_getFieldInfo;
+ callbacks[96] = (delegate* unmanaged)&_getThreadLocalFieldInfo;
+ callbacks[97] = (delegate* unmanaged)&_getThreadLocalStaticBlocksInfo;
+ callbacks[98] = (delegate* unmanaged)&_getThreadLocalStaticInfo_NativeAOT;
+ callbacks[99] = (delegate* unmanaged)&_isFieldStatic;
+ callbacks[100] = (delegate* unmanaged)&_getArrayOrStringLength;
+ callbacks[101] = (delegate* unmanaged)&_getBoundaries;
+ callbacks[102] = (delegate* unmanaged)&_setBoundaries;
+ callbacks[103] = (delegate* unmanaged)&_getVars;
+ callbacks[104] = (delegate* unmanaged)&_setVars;
+ callbacks[105] = (delegate* unmanaged)&_reportRichMappings;
+ callbacks[106] = (delegate* unmanaged)&_reportMetadata;
+ callbacks[107] = (delegate* unmanaged)&_allocateArray;
+ callbacks[108] = (delegate* unmanaged)&_freeArray;
+ callbacks[109] = (delegate* unmanaged)&_getArgNext;
+ callbacks[110] = (delegate* unmanaged)&_getArgType;
+ callbacks[111] = (delegate* unmanaged)&_getExactClasses;
+ callbacks[112] = (delegate* unmanaged)&_getArgClass;
+ callbacks[113] = (delegate* unmanaged)&_getHFAType;
+ callbacks[114] = (delegate* unmanaged)&_runWithErrorTrap;
+ callbacks[115] = (delegate* unmanaged)&_runWithSPMIErrorTrap;
+ callbacks[116] = (delegate* unmanaged)&_getEEInfo;
+ callbacks[117] = (delegate* unmanaged)&_getJitTimeLogFilename;
+ callbacks[118] = (delegate* unmanaged)&_getMethodDefFromMethod;
+ callbacks[119] = (delegate* unmanaged)&_printMethodName;
+ callbacks[120] = (delegate* unmanaged)&_getMethodNameFromMetadata;
+ callbacks[121] = (delegate* unmanaged)&_getMethodHash;
+ callbacks[122] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor;
+ callbacks[123] = (delegate* unmanaged)&_getSwiftLowering;
+ callbacks[124] = (delegate* unmanaged)&_getFpStructLowering;
+ callbacks[125] = (delegate* unmanaged)&_getThreadTLSIndex;
+ callbacks[126] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal;
+ callbacks[127] = (delegate* unmanaged)&_getHelperFtn;
+ callbacks[128] = (delegate* unmanaged)&_getFunctionEntryPoint;
+ callbacks[129] = (delegate* unmanaged)&_getFunctionFixedEntryPoint;
+ callbacks[130] = (delegate* unmanaged)&_getMethodSync;
+ callbacks[131] = (delegate* unmanaged)&_getLazyStringLiteralHelper;
+ callbacks[132] = (delegate* unmanaged