Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8269342: CICrashAt=1 does not always catch first Java method
Reviewed-by: kvn, thartmann
  • Loading branch information
dean-long committed Jul 26, 2021
1 parent 8785737 commit fcc7d59
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/hotspot/share/compiler/compileBroker.cpp
Expand Up @@ -140,6 +140,7 @@ CompileLog** CompileBroker::_compiler2_logs = NULL;
// These counters are used to assign an unique ID to each compilation.
volatile jint CompileBroker::_compilation_id = 0;
volatile jint CompileBroker::_osr_compilation_id = 0;
volatile jint CompileBroker::_native_compilation_id = 0;

// Performance counters
PerfCounter* CompileBroker::_perf_total_compilation = NULL;
Expand Down Expand Up @@ -1588,7 +1589,7 @@ int CompileBroker::assign_compile_id(const methodHandle& method, int osr_bci) {
assert(!is_osr, "can't be osr");
// Adapters, native wrappers and method handle intrinsics
// should be generated always.
return Atomic::add(&_compilation_id, 1);
return Atomic::add(CICountNative ? &_native_compilation_id : &_compilation_id, 1);
} else if (CICountOSR && is_osr) {
id = Atomic::add(&_osr_compilation_id, 1);
if (CIStartOSR <= id && id < CIStopOSR) {
Expand Down Expand Up @@ -2474,6 +2475,8 @@ void CompileBroker::update_compile_perf_data(CompilerThread* thread, const metho
int last_compile_type = normal_compile;
if (CICountOSR && is_osr) {
last_compile_type = osr_compile;
} else if (CICountNative && method->is_native()) {
last_compile_type = native_compile;
}

CompilerCounters* counters = thread->counters();
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/compiler/compileBroker.hpp
Expand Up @@ -174,6 +174,7 @@ class CompileBroker: AllStatic {
// These counters are used for assigning id's to each compilation
static volatile jint _compilation_id;
static volatile jint _osr_compilation_id;
static volatile jint _native_compilation_id;

static CompileQueue* _c2_compile_queue;
static CompileQueue* _c1_compile_queue;
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/compiler/compiler_globals.hpp
Expand Up @@ -72,6 +72,10 @@
develop(bool, CICountOSR, false, \
"use a separate counter when assigning ids to osr compilations") \
\
develop(bool, CICountNative, false, \
"use a separate counter when assigning ids to native " \
"compilations") \
\
develop(bool, CICompileNatives, true, \
"compile native methods if supported by the compiler") \
\
Expand Down
13 changes: 10 additions & 3 deletions test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java
Expand Up @@ -68,17 +68,24 @@ public abstract class CiReplayBase {
"-XX:CompilerThreadStackSize=512", "-XX:ParallelGCThreads=1", "-XX:CICompilerCount=2",
"-XX:-BackgroundCompilation", "-XX:CompileCommand=inline,java.io.PrintStream::*",
"-XX:+IgnoreUnrecognizedVMOptions", "-XX:TypeProfileLevel=222", // extra profile data as a stress test
"-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError",
"-XX:+PreferInterpreterNativeStubs", REPLAY_FILE_OPTION};
"-XX:+CICountNative", "-XX:CICrashAt=1", "-XX:+DumpReplayDataOnError",
REPLAY_FILE_OPTION};
private static final String[] REPLAY_OPTIONS = new String[]{DISABLE_COREDUMP_ON_CRASH,
"-XX:+IgnoreUnrecognizedVMOptions", "-XX:TypeProfileLevel=222",
"-XX:+ReplayCompiles", REPLAY_FILE_OPTION};
protected final Optional<Boolean> runServer;
private static int dummy;

static interface Lambda {
int value();
}

public static class TestMain {
public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
// explicitly trigger native compilation
Lambda start = () -> 0;

for (int i = start.value(); i < 20_000; i++) {
test(i);
}
}
Expand Down

1 comment on commit fcc7d59

@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.