From ed8ab5793008d3a87d5518458565a30e8d9a0414 Mon Sep 17 00:00:00 2001 From: Brian Sullivan Date: Thu, 30 Mar 2017 18:16:58 -0700 Subject: Added DisableInlining flag to the ProfileData. Extended CompileStatus to have both COMPILE_HOT_EXCLUDED and COMPILE_COLD_EXCLUDED. Fixes the IsNull implementation Fixes getBBProfileData to handle the case where pos can now be zero --- src/inc/corbbtprof.h | 1 + src/zap/zapimage.cpp | 40 ++++++++++++++++++++-------------------- src/zap/zapimage.h | 38 ++++++++++++++++++++++++++++++++------ src/zap/zapinfo.cpp | 11 +++++++++-- 4 files changed, 62 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/inc/corbbtprof.h b/src/inc/corbbtprof.h index ba00984e5e..5aa7782544 100644 --- a/src/inc/corbbtprof.h +++ b/src/inc/corbbtprof.h @@ -178,6 +178,7 @@ enum MethodProfilingDataFlags WriteMethodPrecode = 12, // 0x01000 ExcludeHotMethodCode = 13, // 0x02000 // Hot method should be excluded from the ReadyToRun image ExcludeColdMethodCode = 14, // 0x04000 // Cold method should be excluded from the ReadyToRun image + DisableInlining = 15, // 0x08000 // Disable inlining of this method in optimized AOT native code }; enum GeneralProfilingDataFlags diff --git a/src/zap/zapimage.cpp b/src/zap/zapimage.cpp index 2e3aacecc0..cb69ba9f96 100644 --- a/src/zap/zapimage.cpp +++ b/src/zap/zapimage.cpp @@ -1089,14 +1089,14 @@ HANDLE ZapImage::SaveImage(LPCWSTR wszOutputFileName, CORCOMPILE_NGEN_SIGNATURE OutputTables(); - // Create a empty export table. This makes tools like symchk not think - // that native images are resoure-only DLLs. It is important to NOT - // be a resource-only DLL because those DLL's PDBS are not put up on the - // symbol server and we want NEN PDBS to be placed there. - ZapPEExports* exports = new(GetHeap()) ZapPEExports(wszOutputFileName); - m_pDebugSection->Place(exports); - SetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXPORT, exports); - + // Create a empty export table. This makes tools like symchk not think + // that native images are resoure-only DLLs. It is important to NOT + // be a resource-only DLL because those DLL's PDBS are not put up on the + // symbol server and we want NEN PDBS to be placed there. + ZapPEExports* exports = new(GetHeap()) ZapPEExports(wszOutputFileName); + m_pDebugSection->Place(exports); + SetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXPORT, exports); + ComputeRVAs(); if (!IsReadyToRunCompilation()) @@ -1610,7 +1610,7 @@ void ZapImage::ProfileDisableInlining() // Hot methods can be marked to be excluded from the AOT native image. // We also need to disable inlining of such methods. // - if ((methodProfilingDataFlags & (1 << ExcludeHotMethodCode)) != 0) + if ((methodProfilingDataFlags & (1 << DisableInlining)) != 0) { // Disable the inlining of this method // @@ -1685,7 +1685,7 @@ void ZapImage::CompileHotRegion() } } - // Update the 'flags' saved in the profileDataHashTable hash table. + // Update the 'flags' and 'compileResult' saved in the profileDataHashTable hash table. // hashBBUpdateFlagsAndCompileResult(token, methodProfilingDataFlags, compileResult); } @@ -2100,8 +2100,8 @@ ZapImage::CompileStatus ZapImage::TryCompileMethodWorker(CORINFO_METHOD_HANDLE h // if ((methodProfilingDataFlags & (1 << ExcludeHotMethodCode)) != 0) { - // returning COMPILE_EXCLUDED excludes this method from the AOT native image - return COMPILE_EXCLUDED; + // returning COMPILE_HOT_EXCLUDED excludes this method from the AOT native image + return COMPILE_HOT_EXCLUDED; } // Cold methods can be marked to be excluded from the AOT native image. @@ -2110,8 +2110,8 @@ ZapImage::CompileStatus ZapImage::TryCompileMethodWorker(CORINFO_METHOD_HANDLE h // if ((methodProfilingDataFlags & (1 << ExcludeColdMethodCode)) != 0) { - // returning COMPILE_EXCLUDED excludes this method from the AOT native image - return COMPILE_EXCLUDED; + // returning COMPILE_COLD_EXCLUDED excludes this method from the AOT native image + return COMPILE_COLD_EXCLUDED; } // If the code was never executed based on the profile data @@ -2131,19 +2131,19 @@ ZapImage::CompileStatus ZapImage::TryCompileMethodWorker(CORINFO_METHOD_HANDLE h // if (m_zapper->m_pOpt->m_fPartialNGen) { - // returning COMPILE_EXCLUDED excludes this method from the AOT native image - return COMPILE_EXCLUDED; + // returning COMPILE_COLD_EXCLUDED excludes this method from the AOT native image + return COMPILE_COLD_EXCLUDED; } // Retrieve any information that we have about a previous compilation attempt of this method const ProfileDataHashEntry* pEntry = profileDataHashTable.LookupPtr(md); if (pEntry != nullptr) - { - if (pEntry->status == COMPILE_EXCLUDED) + { + if ((pEntry->status == COMPILE_HOT_EXCLUDED) || (pEntry->status == COMPILE_COLD_EXCLUDED)) { - // returning COMPILE_EXCLUDED excludes this method from the AOT native image - return COMPILE_EXCLUDED; + // returning COMPILE_HOT_EXCLUDED excludes this method from the AOT native image + return pEntry->status; } } } diff --git a/src/zap/zapimage.h b/src/zap/zapimage.h index ba4bbc5cfc..f0bcbcb033 100644 --- a/src/zap/zapimage.h +++ b/src/zap/zapimage.h @@ -338,10 +338,20 @@ private: public: enum CompileStatus { - LOOKUP_FAILED = -2, COMPILE_FAILED = -1, // Failure - NOT_COMPILED = 0, COMPILE_EXCLUDED = 1, // Info - COMPILE_SUCCEED = 10, ALREADY_COMPILED = 11 - }; // Success + // Failure status values are negative + LOOKUP_FAILED = -2, + COMPILE_FAILED = -1, + + // Info status values are [0..9] + NOT_COMPILED = 0, + COMPILE_EXCLUDED = 1, + COMPILE_HOT_EXCLUDED = 2, + COMPILE_COLD_EXCLUDED = 3, + + // Successful status values are 10 or greater + COMPILE_SUCCEED = 10, + ALREADY_COMPILED = 11 + }; private: // A hash table entry that contains the profile infomation and the CompileStatus for a given method @@ -376,8 +386,24 @@ private: return (count_t)k; } - static const element_t Null() { LIMITED_METHOD_CONTRACT; ProfileDataHashEntry e; e.pos = 0; e.size = 0; e.md = 0; return e; } // Assuming method profile data cannot start from position 0. - static bool IsNull(const element_t &e) { LIMITED_METHOD_CONTRACT; return e.pos == 0; } + static const element_t Null() + { + LIMITED_METHOD_CONTRACT; + ProfileDataHashEntry e; + e.md = 0; + e.size = 0; + e.pos = 0; + e.flags = 0; + e.status = NOT_COMPILED; + return e; + } + + static bool IsNull(const element_t &e) + { + LIMITED_METHOD_CONTRACT; + // returns true if both md and pos are zero + return (e.md == 0) && (e.pos == 0); + } }; typedef SHash ProfileDataHashTable; diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp index 9713ce57ea..af0c41c4e4 100644 --- a/src/zap/zapinfo.cpp +++ b/src/zap/zapinfo.cpp @@ -1009,12 +1009,19 @@ HRESULT ZapInfo::getBBProfileData ( } // The md must match. - _ASSERTE(foundEntry->md == md); + _ASSERTE(foundEntry->md == md); + if (foundEntry->pos == 0) + { + // We might not have profile data and instead only have CompileStatus and flags + assert(foundEntry->size == 0); + return E_FAIL; + } + + // // // We found the md. Let's retrieve the profile data. // - _ASSERTE(foundEntry->pos > 0); // The target position cannot be 0. _ASSERTE(foundEntry->size >= sizeof(CORBBTPROF_METHOD_HEADER)); // The size must at least this ProfileReader profileReader(DataSection_MethodBlockCounts->pData, DataSection_MethodBlockCounts->dataSize); -- cgit v1.2.3