Skip to content

Commit

Permalink
Consider the compileMethod() API in replenishInvocationCount() Assertion
Browse files Browse the repository at this point in the history
Add a flag in the optimization plan for compilations triggered by
the compileMethod API, which can have the invocation count be any
positive integer; replenishInvocationCount will not raise the assertion
failure for unexpected count value.

Based on eclipse-openj9#15472

Signed-off-by: Luke Li <[email protected]>
  • Loading branch information
luke-li-2003 committed Dec 31, 2024
1 parent 775e962 commit 7b249a7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11955,7 +11955,11 @@ TR::CompilationInfo::replenishInvocationCount(J9Method *method, TR::Compilation
}
else
{
TR_ASSERT(false, "Unexpected value for method->extra = %p (method=%p)\n", TR::CompilationInfo::getJ9MethodExtra(method), method);
if (!comp->getOptimizationPlan()->getIsCompileMethodAPI())
{
TR_ASSERT(false, "Unexpected value for method->extra = %p (method=%p)\n",
TR::CompilationInfo::getJ9MethodExtra(method), method);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions runtime/compiler/control/J9CompilationStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ TR_OptimizationPlan *J9::CompilationStrategy::processEvent(TR_MethodEvent *event
plan = self()->processInterpreterSample(event);
*newPlanCreated = true;
break;
case TR_MethodEvent::CompileMethodAPI:
case TR_MethodEvent::InterpreterCounterTripped:
TR_ASSERT(event->_oldStartPC == 0, "oldStartPC should be 0 for an interpreted method");
compInfo->_stats._methodsCompiledOnCount++;
Expand All @@ -115,6 +116,13 @@ TR_OptimizationPlan *J9::CompilationStrategy::processEvent(TR_MethodEvent *event
plan = TR_OptimizationPlan::alloc(hotnessLevel, true, false);
else
plan = TR_OptimizationPlan::alloc(hotnessLevel);

// set a flag to indicate the counter was not tripped
if (event->_eventType == TR_MethodEvent::CompileMethodAPI)
{
plan->setIsCompileMethodAPI(true);
}

*newPlanCreated = true;
// the optimization plan needs to include opt level and if we do profiling
// these may change
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/control/J9CompilationStrategy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class TR_MethodEvent
{
public:
enum { InvalidEvent=0,
CompileMethodAPI,
InterpreterCounterTripped,
InterpretedMethodSample,
JittedMethodSample,
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/control/rossa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ internalCompileClass(J9VMThread * vmThread, J9Class * clazz)
{
bool queued = false;
TR_MethodEvent event;
event._eventType = TR_MethodEvent::InterpreterCounterTripped;
event._eventType = TR_MethodEvent::CompileMethodAPI;
event._j9method = method;
event._oldStartPC = 0;
event._vmThread = vmThread;
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/env/ClassLoaderTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ TR_PersistentClassLoaderTable::associateClassLoaderWithClass(J9VMThread *vmThrea
{
// Since current thread has shared VM access and holds the classTableMutex,
// no other thread can be modifying the table at the same time.
TR_ASSERT(hasSharedVMAccess(vmThread), "Must have shared VM access");
TR_ASSERT((vmThread->publicFlags & J9_PUBLIC_FLAGS_VM_ACCESS), "Must have shared VM access");
TR_ASSERT(TR::MonitorTable::get()->getClassTableMutex()->owned_by_self(), "Must hold classTableMutex");

bool useAOTCache = false;
Expand Down

0 comments on commit 7b249a7

Please sign in to comment.