Skip to content

Commit 166b880

Browse files
committed
Squashed commit of the following:
commit 7ae87de Author: Larry Ewing <[email protected]> Date: Mon Sep 9 22:11:12 2024 -0500 [wasm] more cases when looking up unmanaged delegates (dotnet#107113) Make the association between the wasm_native_to_interp_ftndescs generation and the lookup from unmanaged more robust so that we don't see problems like dotnet#107212 where the same slot was being reused for multiple methods with different signatures. To do this we change the Key(s) we use and fix the string escaping it relies on, and attempt to lookup by token first. Next , we rewrite the C code generation to make it easier to read and modify and mitigate some potentially negative memory side effects of that we introduce a gratuitous custom text writer that understands the idea of concatenated strings and use that where possible when building the output. Next, we change the import code generation to use binary rather than linear search for both the module and symbol. And finally, we update the ICall table generation to use the extensions. part of dotnet#104391 and dotnet#107212 commit 1808129 Author: Elinor Fung <[email protected]> Date: Mon Sep 9 20:03:34 2024 -0700 Remove FCThrowRes from AssemblyNative::IsDynamic (dotnet#107574) commit 5cb6a06 Author: Aman Khalid <[email protected]> Date: Tue Sep 10 02:38:23 2024 +0000 JIT: Add simple late layout pass (dotnet#107483) commit c762b75 Author: Martin Costello <[email protected]> Date: Tue Sep 10 03:15:53 2024 +0100 Add [DebuggerDisplay] to CancellationTokenSource (dotnet#105764) * Add [DebuggerDisplay] to CancellationTokenSource Add `[DebuggerDisplay]` to `CancellationTokenSource` to show whether cancelled or disposed. Relates to dotnet#105698. * Update src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs --------- Co-authored-by: Stephen Toub <[email protected]> commit b77b71e Author: Katelyn Gadd <[email protected]> Date: Mon Sep 9 17:40:14 2024 -0700 [wasm] Clean up some FIXMEs in the jiterpreter (dotnet#107562) * Cleanup some fixmes in the jiterpreter * Flow through size of the var in MINT_LDLOCA_S so jiterpreter can do accurate invalidation commit c21d90e Author: Pavel Savara <[email protected]> Date: Tue Sep 10 02:40:00 2024 +0200 [WASI] improve single-threaded threadpool (dotnet#107395) * fix dotnet#104803 * PollWasiEventLoopUntilResolvedVoid * more * wip * CPU-bound work to do * fix exit * Update src/mono/sample/wasi/http-p2/Program.cs Co-authored-by: Larry Ewing <[email protected]> * feedback --------- Co-authored-by: Larry Ewing <[email protected]> commit 61de5df Author: Elinor Fung <[email protected]> Date: Mon Sep 9 17:14:07 2024 -0700 Make DAC and ProfToEEInterfaceImpl stop using BaseDomain (dotnet#107570) `BaseDomain` should no longer be needed now that we only have one `AppDomain` and the `SystemDomain` can be treated as separate. This makes the DAC and ProfToEEInterfaceImpl use `AppDomain` directly and check against `SystemDomain::System()` to determine if a pointer is the system domain. commit 76dbb27 Author: Stephen Toub <[email protected]> Date: Mon Sep 9 19:59:54 2024 -0400 Use SearchValues in Uri.CheckForUnicodeOrEscapedUnreserved (dotnet#107357) commit 149d4bb Author: Miha Zupan <[email protected]> Date: Mon Sep 9 16:54:00 2024 -0700 Extend the list of recognized SearchValues<char> field names in Regex (dotnet#107402) commit e591fbf Author: Kunal Pathak <[email protected]> Date: Mon Sep 9 16:38:42 2024 -0700 Arm: Fix the base register used for restoring register from stack (dotnet#107564) * Use correct baseReg for vstr, similar to vldr * add test cases * Mark internal test methods private commit 51c350c Author: Elinor Fung <[email protected]> Date: Mon Sep 9 16:35:02 2024 -0700 Make missing framework error message list other architectures that were found (dotnet#107156) When erroring on a missing framework, check if there are versions of the framework for other architectures and list them for the user. commit 2ed43b6 Author: Alan Hayward <[email protected]> Date: Mon Sep 9 23:53:45 2024 +0100 ARM64-SVE: Allow op inside conditionalselect to be non HWintrinsic (dotnet#107180) * ARM64-SVE: Allow op inside conditionselect to be non HWintrinsic * Add Sve.IsSupported check to test commit ac4b7c6 Author: Kunal Pathak <[email protected]> Date: Mon Sep 9 15:52:00 2024 -0700 Arm: Consider the fact that targetReg can be second half during resolution (dotnet#107493) * Arm: Consider the fact that targetReg can be second half during resolution * add test case * Make sure we only handle float registers * fix test case's public methods commit 18eedbe Author: Aaron Robinson <[email protected]> Date: Mon Sep 9 14:02:51 2024 -0700 Convert Thread FCalls to QCalls (dotnet#107495) * Convert Thread.IsAlive property * Convert Thread.GetCurrentThread() * Convert Thread.ThreadState property * Convert Thread.Initialize() commit d45ccfd Author: Michal Strehovský <[email protected]> Date: Tue Sep 10 05:28:57 2024 +0900 Fix reflection-calling `Set` method on arrays (dotnet#107529) The test added in dotnet#106787 found an issue in the implementation of reflection calls to array `Set` methods. We used to throw the wrong exception type. There were probably other corner case bugs (like what exception is thrown when both element type is wrong and index is out of range and when/how value coercion should happen). This should fix that. commit c534080 Author: Tom McDonald <[email protected]> Date: Mon Sep 9 15:21:41 2024 -0400 Avoid using OpenThread for out of process SetThreadContext debugging (dotnet#107511) * Avoid using OpenThread in out of process thread context scenarios * Add comments * Update src/coreclr/debug/di/process.cpp Co-authored-by: mikelle-rogers <[email protected]> * Update src/coreclr/debug/di/process.cpp Co-authored-by: mikelle-rogers <[email protected]> * Update src/coreclr/debug/di/process.cpp Co-authored-by: Noah Falk <[email protected]> --------- Co-authored-by: mikelle-rogers <[email protected]> Co-authored-by: Noah Falk <[email protected]> commit d2c7db0 Author: Tanner Gooding <[email protected]> Date: Mon Sep 9 11:06:45 2024 -0700 Disable TensorExtensionsTwoSpanInFloatOut due to dotnet#107254 (dotnet#107555) commit b7b91cb Author: Aaron Robinson <[email protected]> Date: Mon Sep 9 09:08:31 2024 -0700 Convert some handle APIs to QCalls (dotnet#107513) Convert RuntimeTypeHandle.GetAssembly() Convert RuntimeTypeHandle.GetModule() Convert RuntimeAssembly.GetManifestModule() commit 600f6bd Author: David Wrighton <[email protected]> Date: Mon Sep 9 09:04:51 2024 -0700 Fix thread static cleanup paths (dotnet#107438) * Fix thread static cleanup paths - Do not destroy GC handles while holding the spin lock - Free the pLoaderHandle array when the thread is terminated * When using a ThreadStatics stress test on collectible assemblies, a few more issues were found - Fix issue where the LoaderAllocator's SegmentedHandleIndex wasn't being freed - Fix issue where the logic to re-use TLSIndex values wasn't working properly commit fe7a52d Author: Linus Hamlin <[email protected]> Date: Mon Sep 9 17:57:31 2024 +0200 Remove ActiveIssue for solved issues in Vector tests (dotnet#107127) commit 0c33c6f Author: Elinor Fung <[email protected]> Date: Mon Sep 9 08:21:16 2024 -0700 Fix module being set as tenured too early (dotnet#107489) commit 2fb3629 Author: Elinor Fung <[email protected]> Date: Mon Sep 9 08:03:27 2024 -0700 Remove `BaseDomain` use in `LoaderAllocator` and event tracing helpers (dotnet#107481) - Remove `BaseDomain` member on `LoaderAllocator` - Add asserts in functions using `AppDomain` that the loader allocator is collectible and the type is `LAT_Assembly` (so `AssemblyLoaderAllocator` which always had `AppDomain`) - Remove unnecessary `BaseDomain`/`AppDomain` parameters from event tracing helpers - They were always being called with the current app domain commit 62133e0 Author: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon Sep 9 16:56:30 2024 +0200 [main] Update dependencies from dotnet/xharness (dotnet#107291) * Update dependencies from https://github.com/dotnet/xharness build 20240902.2 Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 9.0.0-prerelease.24452.1 -> To Version 9.0.0-prerelease.24452.2 * Update dependencies from https://github.com/dotnet/xharness build 20240903.1 Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 9.0.0-prerelease.24452.2 -> To Version 9.0.0-prerelease.24453.1 * Update dependencies from https://github.com/dotnet/xharness build 20240904.2 Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 9.0.0-prerelease.24453.1 -> To Version 10.0.0-prerelease.24454.2 * Update dependencies from https://github.com/dotnet/xharness build 20240906.1 Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 10.0.0-prerelease.24454.2 -> To Version 10.0.0-prerelease.24456.1 * Update dependencies from https://github.com/dotnet/xharness build 20240909.1 Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 10.0.0-prerelease.24456.1 -> To Version 10.0.0-prerelease.24459.1 --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Ilona Tomkowicz <[email protected]> commit 4c0973e Author: Jeremi Kurdek <[email protected]> Date: Mon Sep 9 17:53:45 2024 +0300 Fix passing assemblies using relative path (dotnet#107536) commit 67e5768 Author: Katelyn Gadd <[email protected]> Date: Mon Sep 9 06:19:10 2024 -0700 [wasm] Implement MINT_NEWARR in jiterpreter (dotnet#107430) commit 176754d Author: Matous Kozak <[email protected]> Date: Mon Sep 9 13:35:01 2024 +0200 [mono][infra] decrease CPU count for fullAOT CI build (dotnet#107531) commit 49bf719 Author: Pavel Savara <[email protected]> Date: Mon Sep 9 12:30:47 2024 +0200 [browser][MT] fix feature detection on webworker (dotnet#107452) commit aa418fc Author: Preeyan Parmar <[email protected]> Date: Sun Sep 8 22:44:27 2024 +0100 Remove unused declarations from clsload.hpp (dotnet#107509) * Remove unused declarations from clsload.hpp * also remove unused ClassLoader::TryEnsureLoaded commit 7d68c7f Author: Steve <[email protected]> Date: Mon Sep 9 06:36:18 2024 +0900 Implement getClassAssemblyName (dotnet#106959) * Add getClassAssemblyName * Handle nullptrs * Remove CORINFO_ASSEMBLY_HANDLE * Address feedbacks Co-authored-by: Jan Kotas <[email protected]> commit 39c84a3 Author: Jan Kotas <[email protected]> Date: Sun Sep 8 11:24:13 2024 -0700 Fix corner-case accounting bug in new codeheap allocation (dotnet#107492) The size of internal CodeHeap structures was not included in codeheap memory reservation. It caused false OOM exception to be thrown when JITed method code size was near 64kB multiple commit 10f6c4c Author: Aaron Robinson <[email protected]> Date: Sun Sep 8 11:02:41 2024 -0700 Convert WaitHandle FCalls to QCalls (dotnet#107488) commit b523ec5 Author: Aman Khalid <[email protected]> Date: Sun Sep 8 14:42:04 2024 +0000 JIT: Simplify block insertion logic during loop canonicalization (dotnet#107371)
1 parent 47d20a0 commit 166b880

File tree

128 files changed

+2064
-1406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+2064
-1406
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
},
1717
"microsoft.dotnet.xharness.cli": {
18-
"version": "9.0.0-prerelease.24452.1",
18+
"version": "10.0.0-prerelease.24459.1",
1919
"commands": [
2020
"xharness"
2121
]

eng/Version.Details.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,17 +316,17 @@
316316
<Uri>https://github.com/dotnet/runtime</Uri>
317317
<Sha>7cb32e193a55a95c74fc3bd56501b951b48b700f</Sha>
318318
</Dependency>
319-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.24452.1">
319+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="10.0.0-prerelease.24459.1">
320320
<Uri>https://github.com/dotnet/xharness</Uri>
321-
<Sha>c2215b88cdac5390888de3e6ad301c113f40ed6c</Sha>
321+
<Sha>df9b6509e6b3976d158e46c23d72d6acd9f0d326</Sha>
322322
</Dependency>
323-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="9.0.0-prerelease.24452.1">
323+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="10.0.0-prerelease.24459.1">
324324
<Uri>https://github.com/dotnet/xharness</Uri>
325-
<Sha>c2215b88cdac5390888de3e6ad301c113f40ed6c</Sha>
325+
<Sha>df9b6509e6b3976d158e46c23d72d6acd9f0d326</Sha>
326326
</Dependency>
327-
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="9.0.0-prerelease.24452.1">
327+
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="10.0.0-prerelease.24459.1">
328328
<Uri>https://github.com/dotnet/xharness</Uri>
329-
<Sha>c2215b88cdac5390888de3e6ad301c113f40ed6c</Sha>
329+
<Sha>df9b6509e6b3976d158e46c23d72d6acd9f0d326</Sha>
330330
</Dependency>
331331
<Dependency Name="Microsoft.DotNet.PackageTesting" Version="9.0.0-beta.24423.2">
332332
<Uri>https://github.com/dotnet/arcade</Uri>

eng/Versions.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@
180180
<!-- Testing -->
181181
<MicrosoftNETCoreCoreDisToolsVersion>1.4.0</MicrosoftNETCoreCoreDisToolsVersion>
182182
<MicrosoftNETTestSdkVersion>17.4.0-preview-20220707-01</MicrosoftNETTestSdkVersion>
183-
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>9.0.0-prerelease.24452.1</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
184-
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.24452.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
185-
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.24452.1</MicrosoftDotNetXHarnessCLIVersion>
183+
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>10.0.0-prerelease.24459.1</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
184+
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>10.0.0-prerelease.24459.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
185+
<MicrosoftDotNetXHarnessCLIVersion>10.0.0-prerelease.24459.1</MicrosoftDotNetXHarnessCLIVersion>
186186
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>9.0.0-alpha.0.24419.1</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
187187
<NUnitVersion>3.12.0</NUnitVersion>
188188
<NUnit3TestAdapterVersion>4.5.0</NUnit3TestAdapterVersion>

eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ steps:
7070
displayName: "AOT compile CoreCLR tests"
7171
target: ${{ coalesce(parameters.llvmAotStepContainer, parameters.container) }}
7272
- ${{ if in(parameters.runtimeVariant, 'llvmfullaot', 'minifullaot') }}:
73-
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(logRootNameArg)MonoAot mono_fullaot ${{ parameters.buildConfig }} ${{ parameters.archType }} /p:RuntimeVariant=${{ parameters.runtimeVariant }} -maxcpucount:2
73+
- script: $(Build.SourcesDirectory)/src/tests/build$(scriptExt) $(logRootNameArg)MonoAot mono_fullaot ${{ parameters.buildConfig }} ${{ parameters.archType }} /p:RuntimeVariant=${{ parameters.runtimeVariant }} -maxcpucount:1
7474
displayName: "AOT compile CoreCLR tests"
7575
target: ${{ coalesce(parameters.llvmAotStepContainer, parameters.container) }}
7676
- ${{ if eq(parameters.archType, 'arm64') }}:

src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public override string? CodeBase
115115
}
116116
}
117117

118-
internal RuntimeAssembly GetNativeHandle() => this;
119-
120118
// If the assembly is copied before it is loaded, the codebase will be set to the
121119
// actual file loaded if copiedName is true. If it is false, then the original code base
122120
// is returned.
@@ -263,7 +261,7 @@ public override Type[] GetExportedTypes()
263261
public override IEnumerable<TypeInfo> DefinedTypes
264262
{
265263
[RequiresUnreferencedCode("Types might be removed")]
266-
get => GetManifestModule(GetNativeHandle()).GetDefinedTypes();
264+
get => GetManifestModule().GetDefinedTypes();
267265
}
268266

269267
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetIsCollectible")]
@@ -324,7 +322,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
324322
public override Module ManifestModule =>
325323
// We don't need to return the "external" ModuleBuilder because
326324
// it is meant to be read-only
327-
GetManifestModule(GetNativeHandle());
325+
GetManifestModule();
328326

329327
public override object[] GetCustomAttributes(bool inherit)
330328
{
@@ -586,9 +584,17 @@ private CultureInfo GetLocale()
586584
}
587585

588586
[MethodImpl(MethodImplOptions.InternalCall)]
589-
private static extern bool FCallIsDynamic(RuntimeAssembly assembly);
587+
private static extern bool GetIsDynamic(IntPtr assembly);
590588

591-
public override bool IsDynamic => FCallIsDynamic(GetNativeHandle());
589+
public override bool IsDynamic
590+
{
591+
get
592+
{
593+
bool isDynamic = GetIsDynamic(GetUnderlyingNativeHandle());
594+
GC.KeepAlive(this); // We directly pass the native handle above - make sure this object stays alive for the call
595+
return isDynamic;
596+
}
597+
}
592598

593599
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetSimpleName")]
594600
private static partial void GetSimpleName(QCallAssembly assembly, StringHandleOnStack retSimpleName);
@@ -701,8 +707,24 @@ public override Module[] GetLoadedModules(bool getResourceModules)
701707
return GetModulesInternal(false, getResourceModules);
702708
}
703709

710+
private RuntimeModule GetManifestModule()
711+
{
712+
return GetManifestModule(this) ?? GetManifestModuleWorker(this);
713+
714+
[MethodImpl(MethodImplOptions.NoInlining)]
715+
static RuntimeModule GetManifestModuleWorker(RuntimeAssembly assembly)
716+
{
717+
RuntimeModule? module = null;
718+
GetManifestModuleSlow(ObjectHandleOnStack.Create(ref assembly), ObjectHandleOnStack.Create(ref module));
719+
return module!;
720+
}
721+
}
722+
704723
[MethodImpl(MethodImplOptions.InternalCall)]
705-
internal static extern RuntimeModule GetManifestModule(RuntimeAssembly assembly);
724+
private static extern RuntimeModule? GetManifestModule(RuntimeAssembly assembly);
725+
726+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyHandle_GetManifestModuleSlow")]
727+
private static partial void GetManifestModuleSlow(ObjectHandleOnStack assembly, ObjectHandleOnStack module);
706728

707729
[MethodImpl(MethodImplOptions.InternalCall)]
708730
internal static extern int GetToken(RuntimeAssembly assembly);
@@ -713,7 +735,7 @@ public sealed override Type[] GetForwardedTypes()
713735
List<Type> types = new List<Type>();
714736
List<Exception> exceptions = new List<Exception>();
715737

716-
MetadataImport scope = GetManifestModule(GetNativeHandle()).MetadataImport;
738+
MetadataImport scope = GetManifestModule().MetadataImport;
717739
scope.Enum(MetadataTokenType.ExportedType, 0, out MetadataEnumResult enumResult);
718740
RuntimeAssembly runtimeAssembly = this;
719741
QCallAssembly pAssembly = new QCallAssembly(ref runtimeAssembly);

src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeAs
8282

8383
// No pseudo attributes for RuntimeAssembly
8484

85-
return GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
85+
return GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target));
8686
}
8787

8888
internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target)
@@ -1227,7 +1227,7 @@ internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
12271227
Debug.Assert(caType is not null);
12281228

12291229
// No pseudo attributes for RuntimeAssembly
1230-
return IsCustomAttributeDefined((assembly.ManifestModule as RuntimeModule)!, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType);
1230+
return IsCustomAttributeDefined((assembly.ManifestModule as RuntimeModule)!, RuntimeAssembly.GetToken(assembly), caType);
12311231
}
12321232

12331233
internal static bool IsDefined(RuntimeModule module, RuntimeType caType)
@@ -1388,7 +1388,7 @@ internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeTy
13881388

13891389
// No pseudo attributes for RuntimeAssembly
13901390

1391-
int assemblyToken = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
1391+
int assemblyToken = RuntimeAssembly.GetToken(assembly);
13921392
return GetCustomAttributes((assembly.ManifestModule as RuntimeModule)!, assemblyToken, 0, caType);
13931393
}
13941394

src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,43 @@ internal RuntimeType GetRuntimeType()
306306
[MethodImpl(MethodImplOptions.InternalCall)]
307307
internal static extern CorElementType GetCorElementType(RuntimeType type);
308308

309+
internal static RuntimeAssembly GetAssembly(RuntimeType type)
310+
{
311+
return GetAssemblyIfExists(type) ?? GetAssemblyWorker(type);
312+
313+
[MethodImpl(MethodImplOptions.NoInlining)]
314+
static RuntimeAssembly GetAssemblyWorker(RuntimeType type)
315+
{
316+
RuntimeAssembly? assembly = null;
317+
GetAssemblySlow(ObjectHandleOnStack.Create(ref type), ObjectHandleOnStack.Create(ref assembly));
318+
return assembly!;
319+
}
320+
}
321+
309322
[MethodImpl(MethodImplOptions.InternalCall)]
310-
internal static extern RuntimeAssembly GetAssembly(RuntimeType type);
323+
private static extern RuntimeAssembly? GetAssemblyIfExists(RuntimeType type);
324+
325+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetAssemblySlow")]
326+
private static partial void GetAssemblySlow(ObjectHandleOnStack type, ObjectHandleOnStack assembly);
327+
328+
internal static RuntimeModule GetModule(RuntimeType type)
329+
{
330+
return GetModuleIfExists(type) ?? GetModuleWorker(type);
331+
332+
[MethodImpl(MethodImplOptions.NoInlining)]
333+
static RuntimeModule GetModuleWorker(RuntimeType type)
334+
{
335+
RuntimeModule? module = null;
336+
GetModuleSlow(ObjectHandleOnStack.Create(ref type), ObjectHandleOnStack.Create(ref module));
337+
return module!;
338+
}
339+
}
311340

312341
[MethodImpl(MethodImplOptions.InternalCall)]
313-
internal static extern RuntimeModule GetModule(RuntimeType type);
342+
private static extern RuntimeModule? GetModuleIfExists(RuntimeType type);
343+
344+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "RuntimeTypeHandle_GetModuleSlow")]
345+
private static partial void GetModuleSlow(ObjectHandleOnStack type, ObjectHandleOnStack module);
314346

315347
public ModuleHandle GetModuleHandle()
316348
{

src/coreclr/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public bool WaitCore(int timeoutMs)
3131
return waitResult == WaitHandle.WaitSuccess;
3232
}
3333

34-
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_CorWaitOnePrioritizedNative")]
34+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_WaitOnePrioritized")]
3535
private static partial int WaitNative(SafeWaitHandle handle, int timeoutMs);
3636

3737
private void ReleaseCore(int count)

src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,24 @@ public static void SpinWait(int iterations)
151151
public static bool Yield() => YieldInternal() != Interop.BOOL.FALSE;
152152

153153
[MethodImpl(MethodImplOptions.NoInlining)]
154-
private static Thread InitializeCurrentThread() => t_currentThread = GetCurrentThreadNative();
154+
private static Thread InitializeCurrentThread()
155+
{
156+
Thread? thread = null;
157+
GetCurrentThread(ObjectHandleOnStack.Create(ref thread));
158+
return t_currentThread = thread!;
159+
}
155160

156-
[MethodImpl(MethodImplOptions.InternalCall)]
157-
private static extern Thread GetCurrentThreadNative();
161+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_GetCurrentThread")]
162+
private static partial void GetCurrentThread(ObjectHandleOnStack thread);
158163

159-
[MethodImpl(MethodImplOptions.InternalCall)]
160-
private extern void Initialize();
164+
private void Initialize()
165+
{
166+
Thread _this = this;
167+
Initialize(ObjectHandleOnStack.Create(ref _this));
168+
}
169+
170+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_Initialize")]
171+
private static partial void Initialize(ObjectHandleOnStack thread);
161172

162173
/// <summary>Clean up the thread when it goes away.</summary>
163174
~Thread() => InternalFinalize(); // Delegate to the unmanaged portion.
@@ -175,11 +186,7 @@ partial void ThreadNameChanged(string? value)
175186
private static partial void InformThreadNameChange(ThreadHandle t, string? name, int len);
176187

177188
/// <summary>Returns true if the thread has been started and is not dead.</summary>
178-
public extern bool IsAlive
179-
{
180-
[MethodImpl(MethodImplOptions.InternalCall)]
181-
get;
182-
}
189+
public bool IsAlive => (ThreadState & (ThreadState.Unstarted | ThreadState.Stopped | ThreadState.Aborted)) == 0;
183190

184191
/// <summary>
185192
/// Return whether or not this thread is a background thread. Background
@@ -247,10 +254,19 @@ public ThreadPriority Priority
247254
/// Return the thread state as a consistent set of bits. This is more
248255
/// general then IsAlive or IsBackground.
249256
/// </summary>
250-
public ThreadState ThreadState => (ThreadState)GetThreadStateNative();
257+
public ThreadState ThreadState
258+
{
259+
get
260+
{
261+
var state = (ThreadState)GetThreadState(GetNativeHandle());
262+
GC.KeepAlive(this);
263+
return state;
264+
}
265+
}
251266

252-
[MethodImpl(MethodImplOptions.InternalCall)]
253-
private extern int GetThreadStateNative();
267+
[SuppressGCTransition]
268+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_GetThreadState")]
269+
private static partial int GetThreadState(ThreadHandle t);
254270

255271
/// <summary>
256272
/// An unstarted thread can be marked to indicate that it will host a
@@ -327,6 +343,7 @@ public void DisableComObjectEagerCleanup()
327343
GC.KeepAlive(this);
328344
}
329345

346+
[SuppressGCTransition]
330347
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "ThreadNative_DisableComObjectEagerCleanup")]
331348
private static partial void DisableComObjectEagerCleanup(ThreadHandle t);
332349
#else // !FEATURE_COMINTEROP

src/coreclr/System.Private.CoreLib/src/System/Threading/WaitHandle.CoreCLR.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ namespace System.Threading
88
{
99
public abstract partial class WaitHandle
1010
{
11-
[MethodImpl(MethodImplOptions.InternalCall)]
12-
private static extern int WaitOneCore(IntPtr waitHandle, int millisecondsTimeout, bool useTrivialWaits);
11+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_WaitOneCore")]
12+
private static partial int WaitOneCore(IntPtr waitHandle, int millisecondsTimeout, [MarshalAs(UnmanagedType.Bool)] bool useTrivialWaits);
1313

1414
private static unsafe int WaitMultipleIgnoringSyncContextCore(ReadOnlySpan<IntPtr> waitHandles, bool waitAll, int millisecondsTimeout)
15-
{
16-
fixed (IntPtr* pWaitHandles = &MemoryMarshal.GetReference(waitHandles))
17-
{
18-
return WaitMultipleIgnoringSyncContext(pWaitHandles, waitHandles.Length, waitAll, millisecondsTimeout);
19-
}
20-
}
15+
=> WaitMultipleIgnoringSyncContext(waitHandles, waitHandles.Length, waitAll, millisecondsTimeout);
2116

22-
[MethodImpl(MethodImplOptions.InternalCall)]
23-
private static extern unsafe int WaitMultipleIgnoringSyncContext(IntPtr* waitHandles, int numHandles, bool waitAll, int millisecondsTimeout);
17+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_WaitMultipleIgnoringSyncContext")]
18+
private static partial int WaitMultipleIgnoringSyncContext(ReadOnlySpan<IntPtr> waitHandles, int numHandles, [MarshalAs(UnmanagedType.Bool)] bool waitAll, int millisecondsTimeout);
2419

2520
private static int SignalAndWaitCore(IntPtr waitHandleToSignal, IntPtr waitHandleToWaitOn, int millisecondsTimeout)
2621
{
27-
int ret = SignalAndWaitNative(waitHandleToSignal, waitHandleToWaitOn, millisecondsTimeout);
22+
int ret = SignalAndWait(waitHandleToSignal, waitHandleToWaitOn, millisecondsTimeout);
2823

2924
if (ret == Interop.Errors.ERROR_TOO_MANY_POSTS)
3025
{
@@ -34,7 +29,7 @@ private static int SignalAndWaitCore(IntPtr waitHandleToSignal, IntPtr waitHandl
3429
return ret;
3530
}
3631

37-
[MethodImpl(MethodImplOptions.InternalCall)]
38-
private static extern int SignalAndWaitNative(IntPtr waitHandleToSignal, IntPtr waitHandleToWaitOn, int millisecondsTimeout);
32+
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "WaitHandle_SignalAndWait")]
33+
private static partial int SignalAndWait(IntPtr waitHandleToSignal, IntPtr waitHandleToWaitOn, int millisecondsTimeout);
3934
}
4035
}

src/coreclr/debug/daccess/dacdbiimpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5557,6 +5557,8 @@ CorDebugUserState DacDbiInterfaceImpl::GetPartialUserState(VMPTR_Thread vmThread
55575557
result |= USER_STOPPED;
55585558
}
55595559

5560+
// Don't report Thread::TS_AbortRequested
5561+
55605562
// The interruptible flag is unreliable (see issue 699245)
55615563
// The Debugger_SleepWaitJoin is always accurate when it is present, but it is still
55625564
// just a band-aid fix to cover some of the race conditions interruptible has.

src/coreclr/debug/daccess/dacimpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ class ClrDataAccess
10611061
virtual HRESULT STDMETHODCALLTYPE GetAppDomainData(CLRDATA_ADDRESS addr, struct DacpAppDomainData *data);
10621062
virtual HRESULT STDMETHODCALLTYPE GetAppDomainName(CLRDATA_ADDRESS addr, unsigned int count, _Inout_updates_z_(count) WCHAR *name, unsigned int *pNeeded);
10631063
virtual HRESULT STDMETHODCALLTYPE GetAssemblyList(CLRDATA_ADDRESS appDomain, int count, CLRDATA_ADDRESS values[], int *fetched);
1064-
virtual HRESULT STDMETHODCALLTYPE GetAssemblyData(CLRDATA_ADDRESS baseDomainPtr, CLRDATA_ADDRESS assembly, struct DacpAssemblyData *data);
1064+
virtual HRESULT STDMETHODCALLTYPE GetAssemblyData(CLRDATA_ADDRESS domainPtr, CLRDATA_ADDRESS assembly, struct DacpAssemblyData *data);
10651065
virtual HRESULT STDMETHODCALLTYPE GetAssemblyName(CLRDATA_ADDRESS assembly, unsigned int count, _Inout_updates_z_(count) WCHAR *name, unsigned int *pNeeded);
10661066
virtual HRESULT STDMETHODCALLTYPE GetThreadData(CLRDATA_ADDRESS thread, struct DacpThreadData *data);
10671067
virtual HRESULT STDMETHODCALLTYPE GetThreadFromThinlockID(UINT thinLockId, CLRDATA_ADDRESS *pThread);

0 commit comments

Comments
 (0)