Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to not generate precise GC info #88811

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions eng/testing/tests.singlefile.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Project>
<PropertyGroup>
<IlcUseConservativeGc>true</IlcUseConservativeGc>

<OutputType>Exe</OutputType>

<BundleDir>$([MSBuild]::NormalizeDirectory('$(OutDir)', 'publish'))</BundleDir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ The .NET Foundation licenses this file to you under the MIT license.
<IlcArg Include="--resilient" />
<IlcArg Include="@(UnmanagedEntryPointsAssembly->'--generateunmanagedentrypoints:%(Identity)')" />

<IlcArg Condition="'$(IlcUseConservativeGc)' == 'true'" Include="--runtimeopt:gcConservative=1" />
<IlcArg Condition="'$(IlcUseConservativeGc)' == 'true'" Include="--noprecisegc" />

<IlcArg Condition="$(IlcDisableReflection) == 'true'" Include="--feature:System.Reflection.IsReflectionExecutionAvailable=false" />

<!-- Configure LINQ expressions - disable Emit everywhere -->
Expand Down
10 changes: 9 additions & 1 deletion src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,15 @@ private void PublishCode()
_methodCodeNode.InitializeColdFrameInfos(_coldFrameInfos);
#endif
_methodCodeNode.InitializeDebugEHClauseInfos(debugEHClauseInfos);
_methodCodeNode.InitializeGCInfo(_gcInfo);

#if !READYTORUN
if ((_compilation._compilationOptions & RyuJitCompilationOptions.NoPreciseGc) == 0
// GC info is necessary to unwind reverse P/invokes and cannot be stripped
|| _methodCodeNode.Method.IsUnmanagedCallersOnly)
#endif
{
_methodCodeNode.InitializeGCInfo(_gcInfo);
}
_methodCodeNode.InitializeEHInfo(ehInfo);

_methodCodeNode.InitializeDebugLocInfos(_debugLocInfos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class CompilationBuilder
protected SecurityMitigationOptions _mitigationOptions;
protected bool _dehydrate;
protected bool _useDwarf5;
protected bool _isPreciseGc = true;

partial void InitializePartial()
{
Expand Down Expand Up @@ -122,6 +123,12 @@ public CompilationBuilder UseDwarf5(bool value)
return this;
}

public CompilationBuilder UseGCStackReporting(bool isPrecise)
{
_isPreciseGc = isPrecise;
return this;
}

protected PreinitializationManager GetPreinitializationManager()
{
if (_preinitializationManager == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,6 @@ public enum RyuJitCompilationOptions
ControlFlowGuardAnnotations = 0x2,
UseDwarf5 = 0x4,
UseResilience = 0x8,
NoPreciseGc = 0x10,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public override ICompilation ToCompilation()
if (_resilient)
options |= RyuJitCompilationOptions.UseResilience;

if (!_isPreciseGc)
options |= RyuJitCompilationOptions.NoPreciseGc;

var factory = new RyuJitNodeFactory(_context, _compilationGroup, _metadataManager, _interopStubManager, _nameMangler, _vtableSliceProvider, _dictionaryLayoutProvider, _inlinedThreadStatics, GetPreinitializationManager());

JitConfigProvider.Initialize(_context.Target, jitFlagBuilder.ToArray(), _ryujitOptions, _jitPath);
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ internal sealed class ILCompilerRootCommand : CliRootCommand
new("--stacktracedata") { Description = "Emit data to support generating stack trace strings at runtime" };
public CliOption<bool> MethodBodyFolding { get; } =
new("--methodbodyfolding") { Description = "Fold identical method bodies" };
public CliOption<bool> NoPreciseGc { get; } =
new("--noprecisegc") { Description = "Do not generate precise stack GC information" };
public CliOption<string[]> InitAssemblies { get; } =
new("--initassembly") { DefaultValueFactory = _ => Array.Empty<string>(), Description = "Assembly(ies) with a library initializer" };
public CliOption<string[]> FeatureSwitches { get; } =
Expand Down Expand Up @@ -202,6 +204,7 @@ public ILCompilerRootCommand(string[] args) : base(".NET Native IL Compiler")
Options.Add(IlDump);
Options.Add(EmitStackTraceData);
Options.Add(MethodBodyFolding);
Options.Add(NoPreciseGc);
Options.Add(InitAssemblies);
Options.Add(FeatureSwitches);
Options.Add(RuntimeOptions);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/tools/aot/ILCompiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ void RunScanner()
.UseInstructionSetSupport(instructionSetSupport)
.UseBackendOptions(Get(_command.CodegenOptions))
.UseMethodBodyFolding(enable: Get(_command.MethodBodyFolding))
.UseGCStackReporting(isPrecise: !Get(_command.NoPreciseGc))
.UseParallelism(parallelism)
.UseMetadataManager(metadataManager)
.UseInteropStubManager(interopStubManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public static IEnumerable<object[]> LookupItems_AllItemsFoundAsExpected_MemberDa

[Theory]
[MemberData(nameof(LookupItems_AllItemsFoundAsExpected_MemberData))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/88628", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
public void LookupItems_AllItemsFoundAsExpected(int size, IEqualityComparer<TKey> comparer, bool specifySameComparer)
{
Dictionary<TKey, TValue> original =
Expand Down
2 changes: 2 additions & 0 deletions src/tests/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@

<!-- We expect trimming to be fully enabled in these tests -->
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>

<IlcUseConservativeGc>true</IlcUseConservativeGc>
</PropertyGroup>
</Project>