summaryrefslogtreecommitdiff
path: root/src/vm/ceeload.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vm/ceeload.cpp')
-rw-r--r--src/vm/ceeload.cpp79
1 files changed, 65 insertions, 14 deletions
diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp
index 61d8ae207f..1979d694cb 100644
--- a/src/vm/ceeload.cpp
+++ b/src/vm/ceeload.cpp
@@ -437,6 +437,55 @@ Module::Module(Assembly *pAssembly, mdFile moduleRef, PEFile *file)
file->AddRef();
}
+void Module::InitializeForProfiling()
+{
+ CONTRACTL
+ {
+ INSTANCE_CHECK;
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ PRECONDITION(HasNativeOrReadyToRunImage());
+ }
+ CONTRACTL_END;
+
+ COUNT_T cbProfileList = 0;
+
+ m_nativeImageProfiling = FALSE;
+
+ if (HasNativeImage())
+ {
+ PEImageLayout * pNativeImage = GetNativeImage();
+ CORCOMPILE_VERSION_INFO * pNativeVersionInfo = pNativeImage->GetNativeVersionInfoMaybeNull();
+ if ((pNativeVersionInfo != NULL) && (pNativeVersionInfo->wConfigFlags & CORCOMPILE_CONFIG_INSTRUMENTATION))
+ {
+ m_nativeImageProfiling = GetAssembly()->IsInstrumented();
+ }
+
+ // Link the module to the profile data list if available.
+ m_methodProfileList = pNativeImage->GetNativeProfileDataList(&cbProfileList);
+ }
+ else // ReadyToRun image
+ {
+ // We already setup the m_methodProfileList in the ReadyToRunInfo constructor
+ if (m_methodProfileList != nullptr)
+ {
+ ReadyToRunInfo * pInfo = GetReadyToRunInfo();
+ PEImageLayout * pImage = pInfo->GetImage();
+
+ // Enable profiling if the ZapBBInstr value says to
+ m_nativeImageProfiling = GetAssembly()->IsInstrumented();
+ }
+ }
+
+#ifdef FEATURE_LAZY_COW_PAGES
+ // When running a IBC tuning image to gather profile data
+ // we increment the block counts contained in this area.
+ //
+ if (cbProfileList)
+ EnsureWritablePages(m_methodProfileList, cbProfileList);
+#endif
+}
#ifdef FEATURE_PREJIT
@@ -461,20 +510,6 @@ void Module::InitializeNativeImage(AllocMemTracker* pamTracker)
ExecutionManager::AddNativeImageRange(dac_cast<TADDR>(pNativeImage->GetBase()), pNativeImage->GetVirtualSize(), this);
- CORCOMPILE_VERSION_INFO * pNativeVersionInfo = pNativeImage->GetNativeVersionInfoMaybeNull();
- if ((pNativeVersionInfo != NULL) && (pNativeVersionInfo->wConfigFlags & CORCOMPILE_CONFIG_INSTRUMENTATION))
- {
- m_nativeImageProfiling = GetAssembly()->IsInstrumented();
- }
-
- // Link the module to the profile data list if available.
- COUNT_T cbProfileList;
- m_methodProfileList = pNativeImage->GetNativeProfileDataList(&cbProfileList);
-#ifdef FEATURE_LAZY_COW_PAGES
- if (cbProfileList)
- EnsureWritablePages(m_methodProfileList, cbProfileList);
-#endif
-
#ifndef CROSSGEN_COMPILE
LoadTokenTables();
LoadHelperTable();
@@ -652,9 +687,15 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
#ifdef FEATURE_PREJIT
// Set up native image
if (HasNativeImage())
+ {
InitializeNativeImage(pamTracker);
+ }
#endif // FEATURE_PREJIT
+ if (HasNativeOrReadyToRunImage())
+ {
+ InitializeForProfiling();
+ }
#ifdef FEATURE_NATIVE_IMAGE_GENERATION
if (g_CorCompileVerboseLevel)
@@ -4279,6 +4320,16 @@ BOOL Module::IsVisibleToDebugger()
return TRUE;
}
+BOOL Module::HasNativeOrReadyToRunImage()
+{
+#ifdef FEATURE_READYTORUN
+ if (IsReadyToRun())
+ return TRUE;
+#endif
+
+ return HasNativeImage();
+}
+
PEImageLayout * Module::GetNativeOrReadyToRunImage()
{
LIMITED_METHOD_CONTRACT;