Skip to content

Commit

Permalink
8048003: test/compiler/8009761/Test8009761.java failed with: java.lan…
Browse files Browse the repository at this point in the history
…g.RuntimeException: static java.lang.Object Test8009761.m3(boolean,boolean) not compiled

Compile m3 with C1 if C2 is not available.

Backport-of: b4d4c8a3922f6563013d4e997e149bd0198222d2
  • Loading branch information
zzambers committed Oct 22, 2024
1 parent 42c6c17 commit 432d962
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions hotspot/test/compiler/8009761/Test8009761.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
* questions.
*/

import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
import sun.hotspot.WhiteBox;
import sun.management.ManagementFactoryHelper;

import java.lang.reflect.Method;

/*
Expand All @@ -41,6 +37,7 @@
public class Test8009761 {

private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
private static int COMP_LEVEL_SIMPLE = 1;
private static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
private static Method m3 = null;

Expand Down Expand Up @@ -237,7 +234,7 @@ static Object m3(boolean overflow_stack, boolean deopt) {

static public void main(String[] args) {
// Make sure background compilation is disabled
if (backgroundCompilationEnabled()) {
if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
throw new RuntimeException("Background compilation enabled");
}

Expand All @@ -257,7 +254,11 @@ static public void main(String[] args) {
c1 = count;

// Force the compilation of m3() that will inline m1()
WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION);
if(!WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION)) {
// C2 compiler not available, compile with C1
WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_SIMPLE);
}

// Because background compilation is disabled, method should now be compiled
if(!WHITE_BOX.isMethodCompiled(m3)) {
throw new RuntimeException(m3 + " not compiled");
Expand All @@ -279,19 +280,4 @@ static public void main(String[] args) {
System.out.println("PASSED " + c1);
}
}

/**
* Checks if background compilation (-XX:+BackgroundCompilation) is enabled.
* @return True if background compilation is enabled, false otherwise
*/
private static boolean backgroundCompilationEnabled() {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
VMOption backgroundCompilation;
try {
backgroundCompilation = diagnostic.getVMOption("BackgroundCompilation");
} catch (IllegalArgumentException e) {
return false;
}
return Boolean.valueOf(backgroundCompilation.getValue());
}
}

1 comment on commit 432d962

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