Fix generic non-virtual method call in Ready-to-Run images
authorJohnChen0 <jochen@microsoft.com>
Thu, 26 May 2016 22:07:00 +0000 (15:07 -0700)
committerJohn Chen <jochen@microsoft.com>
Fri, 27 May 2016 05:28:27 +0000 (22:28 -0700)
commit8de59413d0a388ac178ed7c425fab375a7070fdb
tree68c2217eff15a68fe493c1c4eb862a1ce5c8e40c
parent98fba37e938a7984942499a657e2c8fe7acca287
Fix generic non-virtual method call in Ready-to-Run images

Issue dotnet/coreclr#5201 revealed a bug in the Ready-to-Run implementation.
This bug can cause the runtime to dispatch a method call to the
wrong target when all the following conditions are met:
* A shared generic method in a Ready-to-Run module calls a method
  in a shared generic class.
* The target is a non-virtual instance method, but is called through
  callvirt instruction (as C# compiler normally does).
* The target is in a different module.
* The target method is defined in a base class, while the actual
  object instance is of a derived class.

This commit fixes this bug by changing a virtual call to a regular
call when the target is non-virtual.

Commit migrated from https://github.com/dotnet/coreclr/commit/4fd217d564b743f995426de7bd642166e0a84849
src/coreclr/src/vm/genericdict.cpp
src/coreclr/src/vm/jitinterface.cpp
src/coreclr/tests/src/readytorun/main.cs
src/coreclr/tests/src/readytorun/test.cs