Skip to content

Commit

Permalink
Only load initialized class from SCC into iprofiler data
Browse files Browse the repository at this point in the history
Profiled class from last run might not get used in the second run. If
we don't check its initialization status, the profiling data might
be inconsistent with the class hierarchy, resulting in bad inlining
decision or even wrong optimization.

Signed-off-by: Liqun Liu <liqunl@ca.ibm.com>
  • Loading branch information
Liqun Liu committed Dec 8, 2020
1 parent c144b7c commit ba7298e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion runtime/compiler/runtime/IProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3153,7 +3153,13 @@ TR_IPBCDataCallGraph::loadFromPersistentCopy(TR_IPBCDataStorageHeader * storage,
if (comp->fej9()->sharedCache()->isROMClassOffsetInSharedCache(csInfoClazzOffset, &romClass))
ramClass = ((TR_J9VM *)comp->fej9())->matchRAMclassFromROMclass((J9ROMClass *)romClass, comp);

if (ramClass)
// Optimizer and the codegen assume receiver classes of a call from profiling data are initialized,
// otherwise they shouldn't show up in the profile. But classes from iprofiling data from last run
// may be uninitialized in load time, as the program behavior may change in the second run. Thus
// we need to verify that a class is initialized, otherwise optimizer or codegen will make wrong
// transformation based on invalid assumption.
//
if (ramClass && comp->fej9()->isClassInitialized((TR_OpaqueClassBlock*)ramClass))
{
_csInfo.setClazz(i, (uintptr_t)ramClass);
_csInfo._weight[i] = store->_csInfo._weight[i];
Expand Down

0 comments on commit ba7298e

Please sign in to comment.