Optimize type casts (#14420)
authorAndy Ayers <andya@microsoft.com>
Fri, 13 Oct 2017 22:55:06 +0000 (15:55 -0700)
committerGitHub <noreply@github.com>
Fri, 13 Oct 2017 22:55:06 +0000 (15:55 -0700)
commit98181d40c00134704992fa0ef034fcd2e014e383
treed995cc30f56f4599bfedb726a401820c53e7523b
parent70ed53a06d0f1a3e9532f4c3be1b35e7a3a94afa
Optimize type casts (#14420)

JIT: optimize type casts

Implement the jit interface compareTypesForEquality method
to handle casts from known types to known types, and from
shared types to certain interface types.

Call this method in the jit for castclass and isinst, using
`gtGetClassHandle` to obtain the from type. Optimize sucessful
casts and unsuccessful isinsts when the from type is known
exactly.

Undo part of the type-equality based optimization/workaround
in the AsyncMethodBuilder code that was introduced in #14178
in favor of interface checks. There is more here that can
be done here before this issue is entirely closed and I will
look at this subsequently.

This optimization allows the jit to remove boxes that are
used solely to feed type casts, and so closes #12877.
src/jit/compiler.h
src/jit/importer.cpp
src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
src/vm/jitinterface.cpp
tests/src/jit/opt/Casts/shared.cs [new file with mode: 0644]
tests/src/jit/opt/Casts/shared.csproj [new file with mode: 0644]
tests/src/jit/opt/Casts/tests.cs [new file with mode: 0644]
tests/src/jit/opt/Casts/tests.csproj [new file with mode: 0644]