test/compiler/8009761/Test8009761.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
8021775 Cdiff test/compiler/8009761/Test8009761.java
test/compiler/8009761/Test8009761.java
Print this page
*** 19,41 ****
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8009761
* @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
! * @run main/othervm -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
! *
*/
-
public class Test8009761 {
! static class UnloadedClass {
! volatile int i;
! }
static Object m1(boolean deopt) {
// When running interpreted, on sparc, the caller's stack is
// extended for the locals and the caller's frame is restored
// on return.
--- 19,49 ----
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+ import com.sun.management.HotSpotDiagnosticMXBean;
+ import com.sun.management.VMOption;
+ import sun.hotspot.WhiteBox;
+ import sun.management.ManagementFactoryHelper;
+
+ import java.lang.reflect.Method;
+
/*
* @test
* @bug 8009761
+ * @library /testlibrary /testlibrary/whitebox
* @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
! * @build Test8009761
! * @run main ClassFileInstaller sun.hotspot.WhiteBox
! * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
*/
public class Test8009761 {
! private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
! private static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
! private static Method m3 = null;
static Object m1(boolean deopt) {
// When running interpreted, on sparc, the caller's stack is
// extended for the locals and the caller's frame is restored
// on return.
*** 140,152 ****
ll488, ll489, ll490, ll491, ll492, ll493, ll494, ll495, ll496, ll497,
ll498, ll499, ll500, ll501, ll502, ll503, ll504, ll505, ll506, ll507,
ll508, ll509, ll510, ll511;
if (deopt) {
! UnloadedClass res = new UnloadedClass(); // sufficient to force deopt with c2 but not c1
! res.i = 0; // forces deopt with c1
! return res;
}
return null;
}
static int count = 0;
--- 148,162 ----
ll488, ll489, ll490, ll491, ll492, ll493, ll494, ll495, ll496, ll497,
ll498, ll499, ll500, ll501, ll502, ll503, ll504, ll505, ll506, ll507,
ll508, ll509, ll510, ll511;
if (deopt) {
! // Force deoptimization of m3
! WHITE_BOX.deoptimizeMethod(m3);
! if(WHITE_BOX.isMethodCompiled(m3)) {
! throw new RuntimeException(m3 + " not deoptimized");
! }
}
return null;
}
static int count = 0;
*** 223,255 ****
}
return o;
}
static public void main(String[] args) {
int c1;
// Call m2 from m3 recursively until stack overflow. Count the number of recursive calls.
try {
m3(true, false);
} catch(StackOverflowError soe) {
}
c1 = count;
// Force the compilation of m3() that will inline m1()
! for (int i = 0; i < 20000; i++) {
! m3(false, false);
}
count = 0;
// Force deoptimization of m3() in m1(), then return from m1()
// to m3(), call recursively m2(). If deoptimization correctly
// built the interpreter stack for m3()/m1() then we should be
// able to call m2() recursively as many times as before.
try {
m3(false, true);
} catch(StackOverflowError soe) {
}
! if (c1 != count) {
System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count);
System.exit(97);
} else {
System.out.println("PASSED " + c1);
}
}
}
--- 233,297 ----
}
return o;
}
static public void main(String[] args) {
+ // Make sure background compilation is disabled
+ if (backgroundCompilationEnabled()) {
+ throw new RuntimeException("Background compilation enabled");
+ }
+
+ try {
+ // Get Method object for m3
+ m3 = Test8009761.class.getDeclaredMethod("m3", boolean.class, boolean.class);
+ } catch (NoSuchMethodException | SecurityException ex) {
+ throw new RuntimeException("Failed to retrieve method m3");
+ }
+
int c1;
// Call m2 from m3 recursively until stack overflow. Count the number of recursive calls.
try {
m3(true, false);
} catch(StackOverflowError soe) {
}
c1 = count;
+
// Force the compilation of m3() that will inline m1()
! WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION);
! // Because background compilation is disabled, method should now be compiled
! if(!WHITE_BOX.isMethodCompiled(m3)) {
! throw new RuntimeException(m3 + " not compiled");
}
+
count = 0;
// Force deoptimization of m3() in m1(), then return from m1()
// to m3(), call recursively m2(). If deoptimization correctly
// built the interpreter stack for m3()/m1() then we should be
// able to call m2() recursively as many times as before.
try {
m3(false, true);
} catch(StackOverflowError soe) {
}
! // Allow number of recursive calls to vary by 1
! if ((c1 < (count - 1)) || (c1 > (count + 1))) {
System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count);
System.exit(97);
} else {
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());
+ }
}
test/compiler/8009761/Test8009761.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File