From 1464a16032e6f4cc16601662eb5d34fbcc9bca21 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Tue, 6 Feb 2018 11:07:08 -0800 Subject: [PATCH] JIT: recognize we have exact type for this in constructors In constructors the exact type of `this` is known. Tracking this helps the jit devirtualize calls made from chaining constructors. Related discussion in #16198. --- src/jit/lclvars.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp index bf9a1f9a18f9..1b387999da2f 100644 --- a/src/jit/lclvars.cpp +++ b/src/jit/lclvars.cpp @@ -412,8 +412,9 @@ void Compiler::lvaInitThisPtr(InitVarDscInfo* varDscInfo) } else { - varDsc->lvType = TYP_REF; - lvaSetClass(varDscInfo->varNum, info.compClassHnd); + const bool isExact = (info.compFlags & CORINFO_FLG_CONSTRUCTOR) != 0; + varDsc->lvType = TYP_REF; + lvaSetClass(varDscInfo->varNum, info.compClassHnd, isExact); } if (tiVerificationNeeded)