Use getLocationOfThisType instead of embedGenericHandle (#7813)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Thu, 27 Oct 2016 02:57:41 +0000 (19:57 -0700)
committerGitHub <noreply@github.com>
Thu, 27 Oct 2016 02:57:41 +0000 (19:57 -0700)
getLocationOfThisType does way less work and gives the same result (the part we care about).

src/jit/compiler.h
src/jit/importer.cpp

index 0f9618d..2f51c01 100644 (file)
@@ -2912,7 +2912,7 @@ public:
                                unsigned                flags,
                                void*                   compileTimeHandle);
 
-    GenTreePtr getRuntimeContextTree(CORINFO_LOOKUP* pLookup);
+    GenTreePtr getRuntimeContextTree(CORINFO_RUNTIME_LOOKUP_KIND kind);
 
     GenTreePtr impRuntimeLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken,
                                       CORINFO_LOOKUP*         pLookup,
index 61906b2..742d998 100644 (file)
@@ -1872,7 +1872,7 @@ GenTreePtr Compiler::impMethodPointer(CORINFO_RESOLVED_TOKEN* pResolvedToken, CO
 // getRuntimeContextTree: find pointer to context for runtime lookup.
 //
 // Arguments:
-//    pLookup - how to do lookup.
+//    kind - lookup kind.
 //
 // Return Value:
 //    Return GenTree pointer to generic shared context.
@@ -1880,10 +1880,9 @@ GenTreePtr Compiler::impMethodPointer(CORINFO_RESOLVED_TOKEN* pResolvedToken, CO
 // Notes:
 //    Reports about generic context using.
 
-GenTreePtr Compiler::getRuntimeContextTree(CORINFO_LOOKUP* pLookup)
+GenTreePtr Compiler::getRuntimeContextTree(CORINFO_RUNTIME_LOOKUP_KIND kind)
 {
-    GenTreePtr                  ctxTree = nullptr;
-    CORINFO_RUNTIME_LOOKUP_KIND kind    = pLookup->lookupKind.runtimeLookupKind;
+    GenTreePtr ctxTree = nullptr;
 
     // Collectible types requires that for shared generic code, if we use the generic context parameter
     // that we report it. (This is a conservative approach, we could detect some cases particularly when the
@@ -1936,7 +1935,7 @@ GenTreePtr Compiler::impRuntimeLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedTok
     // In other word, it cannot be called by the instance of the Compiler for the inlinee.
     assert(!compIsForInlining());
 
-    GenTreePtr ctxTree = getRuntimeContextTree(pLookup);
+    GenTreePtr ctxTree = getRuntimeContextTree(pLookup->lookupKind.runtimeLookupKind);
 
 #ifdef FEATURE_READYTORUN_COMPILER
     if (opts.IsReadyToRun())
@@ -5794,11 +5793,10 @@ GenTreePtr Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolve
         {
 #ifdef FEATURE_READYTORUN_COMPILER
             noway_assert(opts.IsReadyToRun());
-            CORINFO_GENERICHANDLE_RESULT embedInfo;
-            info.compCompHnd->embedGenericHandle(pResolvedToken, FALSE, &embedInfo);
-            assert(embedInfo.lookup.lookupKind.needsRuntimeLookup);
+            CORINFO_LOOKUP_KIND kind = info.compCompHnd->getLocationOfThisType(info.compMethodHnd);
+            assert(kind.needsRuntimeLookup);
 
-            GenTreePtr      ctxTree = getRuntimeContextTree(&embedInfo.lookup);
+            GenTreePtr      ctxTree = getRuntimeContextTree(kind.runtimeLookupKind);
             GenTreeArgList* args    = gtNewArgList(ctxTree);
 
             unsigned callFlags = 0;