-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Reduce stack frame size of CheckConstraints #43094
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ | |
| using Xunit; | ||
| using Microsoft.CodeAnalysis.Test.Utilities; | ||
| using Microsoft.CodeAnalysis.CSharp.Test.Utilities; | ||
| using Microsoft.CodeAnalysis.CSharp.Symbols; | ||
| using Microsoft.CodeAnalysis.PooledObjects; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Emit | ||
| { | ||
|
|
@@ -267,5 +269,48 @@ static void Main() | |
| }); | ||
| } | ||
| } | ||
|
|
||
| [WorkItem(42361, "https://github.com/dotnet/roslyn/issues/42361")] | ||
| [ConditionalFact(typeof(WindowsOnly))] | ||
| public void Constraints() | ||
| { | ||
| int n = (ExecutionConditionUtil.Architecture, ExecutionConditionUtil.Configuration) switch | ||
| { | ||
| (ExecutionArchitecture.x86, ExecutionConfiguration.Debug) => 420, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change fixing a regression in our ability to handle complex constraint graphs? Or improving our ability past where it has historically been?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change improves the ability to handle complex constraint graphs, although 15.9 uses less stack space still. In reply to: 405771709 [](ancestors = 405771709) |
||
| (ExecutionArchitecture.x86, ExecutionConfiguration.Release) => 1100, | ||
| (ExecutionArchitecture.x64, ExecutionConfiguration.Debug) => 200, | ||
| (ExecutionArchitecture.x64, ExecutionConfiguration.Release) => 520, | ||
| _ => throw new Exception($"Unexpected configuration {ExecutionConditionUtil.Architecture} {ExecutionConditionUtil.Configuration}") | ||
| }; | ||
|
|
||
| RunTest(n, runTest); | ||
|
|
||
| static void runTest(int n) | ||
| { | ||
| // class C0<T> where T : C1<T> { } | ||
| // class C1<T> where T : C2<T> { } | ||
| // ... | ||
| // class CN<T> where T : C0<T> { } | ||
| var sourceBuilder = new StringBuilder(); | ||
| var diagnosticsBuilder = ArrayBuilder<DiagnosticDescription>.GetInstance(); | ||
| for (int i = 0; i <= n; i++) | ||
| { | ||
| int next = (i == n) ? 0 : i + 1; | ||
| sourceBuilder.AppendLine($"class C{i}<T> where T : C{next}<T> {{ }}"); | ||
| diagnosticsBuilder.Add(Diagnostic(ErrorCode.ERR_GenericConstraintNotSatisfiedRefType, "T").WithArguments($"C{i}<T>", $"C{next}<T>", "T", "T")); | ||
| } | ||
| var source = sourceBuilder.ToString(); | ||
| var diagnostics = diagnosticsBuilder.ToArrayAndFree(); | ||
|
|
||
| RunInThread(() => | ||
| { | ||
| var comp = CreateCompilation(source); | ||
| var type = comp.GetMember<NamedTypeSymbol>("C0"); | ||
| var typeParameter = type.TypeParameters[0]; | ||
| Assert.True(typeParameter.IsReferenceType); | ||
| comp.VerifyDiagnostics(diagnostics); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.