From 6c67eb9a245559622c6477b5feb01fcdbd814050 Mon Sep 17 00:00:00 2001
Date: Tue, 26 May 2026 15:35:28 +0800
Subject: JProfilecache: remove redundant assert
src/hotspot/cpu/aarch64/aarch64.ad | 4 +++-
.../share/jprofilecache/jitProfileCache.cpp | 1 -
.../jprofilecache/jitProfileCacheUtils.cpp | 5 +++++
src/hotspot/share/opto/compile.cpp | 17 +++++++++++++++++
src/hotspot/share/opto/compile.hpp | 3 +++
src/hotspot/share/opto/parse1.cpp | 4 +++-
6 files changed, 31 insertions(+), 3 deletions(-)
@@ -1777,7 +1777,9 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
__ nop();
if (C->clinit_barrier_on_entry()) {
- assert(!C->method()->holder()->is_not_initialized(), "initialization should have been started");
+ assert(!C->method()->holder()->is_not_initialized() ||
+ C->is_linked_jprofile_conservative_compilation(),
+ "initialization should have been started or be a linked JProfileCache conservative C2 compile");
Label L_skip_barrier;
@@ -84,7 +84,6 @@ JitProfileCache::JitProfileCacheState JitProfileCache::init_for_recording() {
}
JitProfileCache::JitProfileCacheState JitProfileCache::init_for_profilecache() {
- assert(!JProfilingCacheRecording && JProfilingCacheCompileAdvance, "JitProfileCache JVM option verify failure");
if (CompilationProfileCacheExclude != nullptr) {
_excluding_matcher = new SymbolRegexMatcher<mtClass>(CompilationProfileCacheExclude);
}
@@ -27,6 +27,7 @@
#include "compiler/compilationPolicy.hpp"
#include "compiler/compileBroker.hpp"
#include "jprofilecache/jitProfileCacheUtils.hpp"
+#include "logging/log.hpp"
Symbol* JitProfileCacheUtils::get_class_loader_name(ClassLoaderData* cld) {
Handle class_loader(Thread::current(), cld->class_loader());
@@ -75,6 +76,10 @@ Symbol* JitProfileCacheUtils::remove_meaningless_suffix(Symbol* s) {
bool JitProfileCacheUtils::commit_compilation(methodHandle m, int comp_level, int bci, TRAPS) {
comp_level = MIN3(comp_level, JProfilingCacheMaxTierLimit, (int) TieredStopAtLevel);
+ if (CompileBroker::compiler(comp_level) == nullptr) {
+ log_info(jprofilecache)("[JitProfileCache] skip compilation at level %d: compiler is unavailable", comp_level);
+ return false;
+ }
if (CompilationPolicy::can_be_compiled(m, comp_level)) {
CompileBroker::compile_method(m, bci, comp_level,
methodHandle(), 1,
@@ -4204,6 +4204,23 @@ void Compile::set_allowed_deopt_reasons() {
}
}
+#ifdef ASSERT
+bool Compile::is_linked_jprofile_conservative_compilation() const {
+#ifdef AARCH64
+ CompileTask* task = env() != nullptr ? env()->task() : nullptr;
+ return task != nullptr &&
+ task->is_jprofilecache_compilation() &&
+ JProfilingCacheCompileAdvance &&
+ !ProfileCacheAggressiveInit &&
+ method() != nullptr &&
+ method()->holder()->is_instance_klass() &&
+ method()->holder()->is_linked();
+#else
+ return false;
+#endif
+}
+#endif
+
bool Compile::needs_clinit_barrier(ciMethod* method, ciMethod* accessing_method) {
return method->is_static() && needs_clinit_barrier(method->holder(), accessing_method);
}
@@ -639,6 +639,9 @@ class Compile : public Phase {
void set_max_node_limit(uint n) { _max_node_limit = n; }
bool clinit_barrier_on_entry() { return _clinit_barrier_on_entry; }
void set_clinit_barrier_on_entry(bool z) { _clinit_barrier_on_entry = z; }
+#ifdef ASSERT
+ bool is_linked_jprofile_conservative_compilation() const;
+#endif
bool has_monitors() const { return _has_monitors; }
void set_has_monitors(bool v) { _has_monitors = v; }
@@ -2185,7 +2185,9 @@ void Parse::clinit_deopt() {
assert(C->has_method(), "only for normal compilations");
assert(depth() == 1, "only for main compiled method");
assert(is_normal_parse(), "no barrier needed on osr entry");
- assert(!method()->holder()->is_not_initialized(), "initialization should have been started");
+ assert(!method()->holder()->is_not_initialized() ||
+ C->is_linked_jprofile_conservative_compilation(),
+ "initialization should have been started or be a linked JProfileCache conservative C2 compile");
set_parse_bci(0);
--
2.17.1