Harden resolveVirtualMethod against invalid types (dotnet/coreclr#9989)
authorAndy Ayers <andya@microsoft.com>
Tue, 7 Mar 2017 03:31:24 +0000 (19:31 -0800)
committerGitHub <noreply@github.com>
Tue, 7 Mar 2017 03:31:24 +0000 (19:31 -0800)
commit04513facbf7d42cdceae5da6e2619440dfeac2ba
tree13986feb86cd122c2ef5f0127789b1f3fe13bf5d
parent496feff71f84d5ee263952e71a5fc8a2b93b5f15
Harden resolveVirtualMethod against invalid types (dotnet/coreclr#9989)

Split resolveVirtualMethod into a wrapper/helper to allow early
returns as failure reasons are discovered.

Before devirtualizing, ensure that the derived class claimed by the jit
is really a subclass of the class that introduces the virtual method.
Fail early if this is not the case.

Also add early out for interface call devirtualization. The jit currently
does not ask for this but asking for it should not trigger an assert.

Closes dotnet/coreclr#9945 (along with dotnet/coreclr#9959).

Commit migrated from https://github.com/dotnet/coreclr/commit/8902cdb044587ec713f25cb2a137b9532b98e7a2
src/coreclr/src/vm/jitinterface.cpp
src/coreclr/tests/src/JIT/opt/Devirtualization/GitHub_9945_2.il [new file with mode: 0644]
src/coreclr/tests/src/JIT/opt/Devirtualization/GitHub_9945_2.ilproj [new file with mode: 0644]