Use resolver to get IL header and size (dotnet/coreclr#7924)
authorMukul Sabharwal <muks@microsoft.com>
Tue, 1 Nov 2016 13:28:58 +0000 (14:28 +0100)
committerJan Kotas <jkotas@microsoft.com>
Tue, 1 Nov 2016 13:28:58 +0000 (06:28 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/18915473b567619700bd44dd64d4bb22184889e1

src/coreclr/src/vm/prestub.cpp

index f75ef14..2077f16 100644 (file)
@@ -424,26 +424,30 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS fla
             {
                 BEGIN_PIN_PROFILER(CORProfilerTrackJITInfo());
 
+#ifdef FEATURE_MULTICOREJIT
                 // Multicore JIT should be disabled when CORProfilerTrackJITInfo is on
                 // But there could be corner case in which profiler is attached when multicore background thread is calling MakeJitWorker
                 // Disable this block when calling from multicore JIT background thread
-                if (!IsNoMetadata()
-#ifdef FEATURE_MULTICOREJIT
-
-                    && (! fBackgroundThread)
+                if (!fBackgroundThread)
 #endif
-                    )
-                {
-                    g_profControlBlock.pProfInterface->JITCompilationStarted((FunctionID) this, TRUE);
-                    // The profiler may have changed the code on the callback.  Need to
-                    // pick up the new code.  Note that you have to be fully trusted in
-                    // this mode and the code will not be verified.
-                    COR_ILMETHOD *pilHeader = GetILHeader(TRUE);
-                    new (ILHeader) COR_ILMETHOD_DECODER(pilHeader, GetMDImport(), NULL);
-                }
-                else
                 {
-                    g_profControlBlock.pProfInterface->DynamicMethodJITCompilationStarted((FunctionID) this, TRUE, (LPCBYTE)ILHeader, ILHeader->GetSize());
+                    if (!IsNoMetadata())
+                    {
+                        g_profControlBlock.pProfInterface->JITCompilationStarted((FunctionID) this, TRUE);
+                        // The profiler may have changed the code on the callback.  Need to
+                        // pick up the new code.  Note that you have to be fully trusted in
+                        // this mode and the code will not be verified.
+                        COR_ILMETHOD *pilHeader = GetILHeader(TRUE);
+                        new (ILHeader) COR_ILMETHOD_DECODER(pilHeader, GetMDImport(), NULL);
+                    }
+                    else
+                    {
+                        unsigned int ilSize, unused;
+                        CorInfoOptions corOptions;
+                        LPCBYTE ilHeaderPointer = this->AsDynamicMethodDesc()->GetResolver()->GetCodeInfo(&ilSize, &unused, &corOptions, &unused);
+
+                        g_profControlBlock.pProfInterface->DynamicMethodJITCompilationStarted((FunctionID) this, TRUE, ilHeaderPointer, ilSize);
+                    }
                 }
                 END_PIN_PROFILER();
             }