Skip to content

Commit

Permalink
8219555: compiler/jvmci/compilerToVM/IsMatureTest.java fails with Une…
Browse files Browse the repository at this point in the history
…xpected isMature state for multiple times invoked method: expected false to equal true

Reviewed-by: kvn
  • Loading branch information
Igor Veresov committed Mar 8, 2021
1 parent bf9b74d commit 1f9ed90
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 46 deletions.
24 changes: 12 additions & 12 deletions src/hotspot/share/compiler/compilationPolicy.cpp
Expand Up @@ -86,15 +86,15 @@ bool CompilationPolicy::must_be_compiled(const methodHandle& m, int comp_level)
(UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods
}

void CompilationPolicy::compile_if_required(const methodHandle& selected_method, TRAPS) {
if (must_be_compiled(selected_method)) {
void CompilationPolicy::compile_if_required(const methodHandle& m, TRAPS) {
if (must_be_compiled(m)) {
// This path is unusual, mostly used by the '-Xcomp' stress test mode.

if (!THREAD->can_call_java() || THREAD->is_Compiler_thread()) {
// don't force compilation, resolve was on behalf of compiler
return;
}
if (selected_method->method_holder()->is_not_initialized()) {
if (m->method_holder()->is_not_initialized()) {
// 'is_not_initialized' means not only '!is_initialized', but also that
// initialization has not been started yet ('!being_initialized')
// Do not force compilation of methods in uninitialized classes.
Expand All @@ -104,9 +104,11 @@ void CompilationPolicy::compile_if_required(const methodHandle& selected_method,
// even before classes are initialized.
return;
}
CompileBroker::compile_method(selected_method, InvocationEntryBci,
CompilationPolicy::initial_compile_level(selected_method),
methodHandle(), 0, CompileTask::Reason_MustBeCompiled, THREAD);
CompLevel level = initial_compile_level(m);
if (PrintTieredEvents) {
print_event(COMPILE, m(), m(), InvocationEntryBci, level);
}
CompileBroker::compile_method(m, InvocationEntryBci, level, methodHandle(), 0, CompileTask::Reason_MustBeCompiled, THREAD);
}
}

Expand Down Expand Up @@ -337,7 +339,7 @@ double CompilationPolicy::threshold_scale(CompLevel level, int feedback_k) {
return 1;
}

void CompilationPolicy::print_counters(const char* prefix, Method* m) {
void CompilationPolicy::print_counters(const char* prefix, const Method* m) {
int invocation_count = m->invocation_count();
int backedge_count = m->backedge_count();
MethodData* mdh = m->method_data();
Expand All @@ -358,8 +360,7 @@ void CompilationPolicy::print_counters(const char* prefix, Method* m) {
}

// Print an event.
void CompilationPolicy::print_event(EventType type, Method* m, Method* im,
int bci, CompLevel level) {
void CompilationPolicy::print_event(EventType type, const Method* m, const Method* im, int bci, CompLevel level) {
bool inlinee_event = m != im;

ttyLocker tty_lock;
Expand Down Expand Up @@ -674,9 +675,8 @@ CompileTask* CompilationPolicy::select_task(CompileQueue* compile_queue) {

methodHandle max_method_h(Thread::current(), max_method);

if (max_task != NULL && max_task->comp_level() == CompLevel_full_profile &&
TieredStopAtLevel > CompLevel_full_profile &&
max_method != NULL && is_method_profiled(max_method_h)) {
if (max_task != NULL && max_task->comp_level() == CompLevel_full_profile && TieredStopAtLevel > CompLevel_full_profile &&
max_method != NULL && is_method_profiled(max_method_h) && !Arguments::is_compiler_only()) {
max_task->set_comp_level(CompLevel_limited_profile);

if (CompileBroker::compilation_is_complete(max_method_h, max_task->osr_bci(), CompLevel_limited_profile)) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/compiler/compilationPolicy.hpp
Expand Up @@ -184,7 +184,7 @@ class CompilationPolicy : AllStatic {
// loop_event checks if a method should be OSR compiled at a different
// level.
static CompLevel loop_event(const methodHandle& method, CompLevel cur_level, Thread* thread);
static void print_counters(const char* prefix, Method* m);
static void print_counters(const char* prefix, const Method* m);
// Has a method been long around?
// We don't remove old methods from the compile queue even if they have
// very low activity (see select_task()).
Expand Down Expand Up @@ -216,7 +216,7 @@ class CompilationPolicy : AllStatic {
static void set_c2_count(int x) { _c2_count = x; }

enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT };
static void print_event(EventType type, Method* m, Method* im, int bci, CompLevel level);
static void print_event(EventType type, const Method* m, const Method* im, int bci, CompLevel level);
// Check if the method can be compiled, change level if necessary
static void compile(const methodHandle& mh, int bci, CompLevel level, TRAPS);
// Simple methods are as good being compiled with C1 as C2.
Expand Down
15 changes: 11 additions & 4 deletions src/hotspot/share/compiler/compilerDefinitions.cpp
Expand Up @@ -305,12 +305,19 @@ void CompilerConfig::set_compilation_policy_flags() {
8 * CodeCache::page_size() <= ReservedCodeCacheSize) {
FLAG_SET_ERGO(SegmentedCodeCache, true);
}
if (Arguments::is_compiler_only()) { // -Xcomp
// Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
// We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
// compile a level 4 (C2) and then continue executing it.
if (FLAG_IS_DEFAULT(Tier3InvokeNotifyFreqLog)) {
FLAG_SET_CMDLINE(Tier3InvokeNotifyFreqLog, 0);
}
if (FLAG_IS_DEFAULT(Tier4InvocationThreshold)) {
FLAG_SET_CMDLINE(Tier4InvocationThreshold, 0);
}
}
}

if (!UseInterpreter) { // -Xcomp
Tier3InvokeNotifyFreqLog = 0;
Tier4InvocationThreshold = 0;
}

if (CompileThresholdScaling < 0) {
vm_exit_during_initialization("Negative value specified for CompileThresholdScaling", NULL);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/method.cpp
Expand Up @@ -1971,7 +1971,7 @@ void Method::clear_all_breakpoints() {

#endif // INCLUDE_JVMTI

int Method::invocation_count() {
int Method::invocation_count() const {
MethodCounters* mcs = method_counters();
MethodData* mdo = method_data();
if (((mcs != NULL) ? mcs->invocation_counter()->carry() : false) ||
Expand All @@ -1983,7 +1983,7 @@ int Method::invocation_count() {
}
}

int Method::backedge_count() {
int Method::backedge_count() const {
MethodCounters* mcs = method_counters();
MethodData* mdo = method_data();
if (((mcs != NULL) ? mcs->backedge_counter()->carry() : false) ||
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/method.hpp
Expand Up @@ -423,8 +423,8 @@ class Method : public Metadata {
}
}

int invocation_count();
int backedge_count();
int invocation_count() const;
int backedge_count() const;

bool was_executed_more_than(int n);
bool was_never_executed() { return !was_executed_more_than(0); }
Expand Down
17 changes: 0 additions & 17 deletions src/hotspot/share/runtime/arguments.cpp
Expand Up @@ -85,8 +85,6 @@ bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
bool Arguments::_UseOnStackReplacement = UseOnStackReplacement;
bool Arguments::_BackgroundCompilation = BackgroundCompilation;
bool Arguments::_ClipInlining = ClipInlining;
intx Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog;
intx Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold;
size_t Arguments::_default_SharedBaseAddress = SharedBaseAddress;

bool Arguments::_enable_preview = false;
Expand Down Expand Up @@ -1458,12 +1456,6 @@ void Arguments::set_mode_flags(Mode mode) {
AlwaysCompileLoopMethods = Arguments::_AlwaysCompileLoopMethods;
UseOnStackReplacement = Arguments::_UseOnStackReplacement;
BackgroundCompilation = Arguments::_BackgroundCompilation;
if (FLAG_IS_DEFAULT(Tier3InvokeNotifyFreqLog)) {
Tier3InvokeNotifyFreqLog = Arguments::_Tier3InvokeNotifyFreqLog;
}
if (FLAG_IS_DEFAULT(Tier4InvocationThreshold)) {
Tier4InvocationThreshold = Arguments::_Tier4InvocationThreshold;
}

// Change from defaults based on mode
switch (mode) {
Expand All @@ -1483,13 +1475,6 @@ void Arguments::set_mode_flags(Mode mode) {
UseInterpreter = false;
BackgroundCompilation = false;
ClipInlining = false;
// Be much more aggressive in tiered mode with -Xcomp and exercise C2 more.
// We will first compile a level 3 version (C1 with full profiling), then do one invocation of it and
// compile a level 4 (C2) and then continue executing it.
if (CompilerConfig::is_c2_or_jvmci_compiler_enabled()) {
Tier3InvokeNotifyFreqLog = 0;
Tier4InvocationThreshold = 0;
}
break;
}
}
Expand Down Expand Up @@ -2136,8 +2121,6 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
Arguments::_UseOnStackReplacement = UseOnStackReplacement;
Arguments::_ClipInlining = ClipInlining;
Arguments::_BackgroundCompilation = BackgroundCompilation;
Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog;
Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold;

// Remember the default value of SharedBaseAddress.
Arguments::_default_SharedBaseAddress = SharedBaseAddress;
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/runtime/arguments.hpp
Expand Up @@ -354,8 +354,6 @@ class Arguments : AllStatic {
static bool _UseOnStackReplacement;
static bool _BackgroundCompilation;
static bool _ClipInlining;
static intx _Tier3InvokeNotifyFreqLog;
static intx _Tier4InvocationThreshold;

// GC ergonomics
static void set_conservative_max_heap_alignment();
Expand Down Expand Up @@ -617,8 +615,10 @@ class Arguments : AllStatic {
static bool init_shared_archive_paths() NOT_CDS_RETURN_(false);

// Operation modi
static Mode mode() { return _mode; }
static bool is_interpreter_only() { return mode() == _int; }
static Mode mode() { return _mode; }
static bool is_interpreter_only() { return mode() == _int; }
static bool is_compiler_only() { return mode() == _comp; }


// preview features
static void set_enable_preview() { _enable_preview = true; }
Expand Down
2 changes: 0 additions & 2 deletions test/hotspot/jtreg/ProblemList-Xcomp.txt
Expand Up @@ -28,5 +28,3 @@
#############################################################################

vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all
compiler/jvmci/compilerToVM/IsMatureTest.java 8219555 generic-all
compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java 8219555 generic-all
Expand Up @@ -29,7 +29,7 @@
* java.management
*
* @comment the test can't be run w/ TieredStopAtLevel < 4
* @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4)
* @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) & vm.compMode != "Xcomp"
*
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
Expand Down

1 comment on commit 1f9ed90

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.