-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 EH filters for generic catch(T) blocks #72721
Conversation
…ntime-1 into nativeaot-eh-generic-exception
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr jitstressregs, runtime-coreclr gcstress0x3-gcstress0xc, runtime-coreclr crossgen2 |
Azure Pipelines successfully started running 5 pipeline(s). |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs
Outdated
Show resolved
Hide resolved
9d9e2ea
to
54763a7
Compare
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr jitstressregs, runtime-coreclr gcstress0x3-gcstress0xc, runtime-coreclr crossgen2, runtime-extra-platforms |
Azure Pipelines successfully started running 6 pipeline(s). |
src/tests/JIT/Generics/Exceptions/GenericCatchInterfaceProgram.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
…r.cs Co-authored-by: Jan Kotas <jkotas@microsoft.com>
} | ||
else | ||
{ | ||
runtimeLookup = getTokenHandleTree(&resolvedToken, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious if this is measurable for something like Assert.Throws<T>
given that it is using the slow runtime lookup here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out Xunit's Assert.Throws doesn't use generic "catch" blocks.
Also, this PR actually improves perf 😮:
static void Main(string[] args) =>
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
[Benchmark]
public void Test()
{
Throws<DivideByZeroException>(() =>
{
int b = 0;
int x = 100 / b;
});
}
static void Throws<T>(Action action) where T : Exception
{
try { action(); }
catch (T) { return; }
throw new Exception();
}
by 5%
@dotnet/jit-contrib @AndyAyersMS PTAL jit side |
src/coreclr/jit/jiteh.cpp
Outdated
lvaTable[tempNum].lvType = TYP_REF; | ||
GenTree* argAsg = gtNewTempAssign(tempNum, arg); | ||
arg = gtNewLclvNode(tempNum, TYP_REF); | ||
filterBb->bbStkTempsIn = tempNum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit -- you don't need to set this.
filterBb->bbStkTempsIn = tempNum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm.. I think I had to actually, let me see if CI is happy then
Co-authored-by: Andy Ayers <andya@microsoft.com>
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr jitstressregs, runtime-coreclr gcstress0x3-gcstress0xc, runtime-coreclr crossgen2 |
Azure Pipelines successfully started running 5 pipeline(s). |
Closes #67806
Closes #70400
This PR emits single-block EH filters in front of catch clauses which require runtime lookup for Exception objects
Adds generic exceptions support for NativeAOT