Skip to content

Commit

Permalink
Merge branch 'main' into dev/jela/log-profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Sep 9, 2024
2 parents 61337f5 + d2c7db0 commit dc0ad26
Show file tree
Hide file tree
Showing 143 changed files with 2,223 additions and 1,905 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
"version": "9.0.0-prerelease.24452.1",
"version": "10.0.0-prerelease.24459.1",
"commands": [
"xharness"
]
Expand Down
12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,17 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>7cb32e193a55a95c74fc3bd56501b951b48b700f</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="9.0.0-prerelease.24452.1">
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="10.0.0-prerelease.24459.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>c2215b88cdac5390888de3e6ad301c113f40ed6c</Sha>
<Sha>df9b6509e6b3976d158e46c23d72d6acd9f0d326</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="9.0.0-prerelease.24452.1">
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="10.0.0-prerelease.24459.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>c2215b88cdac5390888de3e6ad301c113f40ed6c</Sha>
<Sha>df9b6509e6b3976d158e46c23d72d6acd9f0d326</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="9.0.0-prerelease.24452.1">
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="10.0.0-prerelease.24459.1">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>c2215b88cdac5390888de3e6ad301c113f40ed6c</Sha>
<Sha>df9b6509e6b3976d158e46c23d72d6acd9f0d326</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.PackageTesting" Version="9.0.0-beta.24423.2">
<Uri>https://github.com/dotnet/arcade</Uri>
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@
<!-- Testing -->
<MicrosoftNETCoreCoreDisToolsVersion>1.4.0</MicrosoftNETCoreCoreDisToolsVersion>
<MicrosoftNETTestSdkVersion>17.4.0-preview-20220707-01</MicrosoftNETTestSdkVersion>
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>9.0.0-prerelease.24452.1</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>9.0.0-prerelease.24452.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>9.0.0-prerelease.24452.1</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>10.0.0-prerelease.24459.1</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>10.0.0-prerelease.24459.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>10.0.0-prerelease.24459.1</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>9.0.0-alpha.0.24419.1</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
<NUnitVersion>3.12.0</NUnitVersion>
<NUnit3TestAdapterVersion>4.5.0</NUnit3TestAdapterVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}:
Expand Down
35 changes: 34 additions & 1 deletion eng/pipelines/coreclr/runtime-nativeaot-outerloop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
29 changes: 20 additions & 9 deletions src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -791,16 +791,25 @@ public static unsafe T[] AllocateUninitializedArray<T>(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<T[]>(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!;
}
}

/// <summary>
Expand All @@ -818,7 +827,9 @@ public static T[] AllocateArray<T>(int length, bool pinned = false) // T[] rathe
flags = GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
}

return Unsafe.As<T[]>(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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -263,7 +261,7 @@ public override Type[] GetExportedTypes()
public override IEnumerable<TypeInfo> DefinedTypes
{
[RequiresUnreferencedCode("Types might be removed")]
get => GetManifestModule(GetNativeHandle()).GetDefinedTypes();
get => GetManifestModule().GetDefinedTypes();
}

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyNative_GetIsCollectible")]
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -713,7 +727,7 @@ public sealed override Type[] GetForwardedTypes()
List<Type> types = new List<Type>();
List<Exception> exceptions = new List<Exception>();

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal static IList<CustomAttributeData> 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<CustomAttributeData> GetCustomAttributesInternal(RuntimeParameterInfo target)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down
36 changes: 34 additions & 2 deletions src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit dc0ad26

Please sign in to comment.