23
24 import com.sun.management.HotSpotDiagnosticMXBean;
25 import com.sun.management.VMOption;
26 import sun.hotspot.WhiteBox;
27 import sun.management.ManagementFactoryHelper;
28
29 import java.lang.reflect.Method;
30
31 /*
32 * @test
33 * @bug 8009761
34 * @library /testlibrary /testlibrary/whitebox
35 * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
36 * @build Test8009761
37 * @run main ClassFileInstaller sun.hotspot.WhiteBox
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
39 */
40 public class Test8009761 {
41
42 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
43 private static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
44 private static Method m3 = null;
45
46 static Object m1(boolean deopt) {
47 // When running interpreted, on sparc, the caller's stack is
48 // extended for the locals and the caller's frame is restored
49 // on return.
50 long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
51 l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
52 l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
53 l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
54 l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
55 l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
56 l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
57 l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
58 l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
59 l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
60 l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
61 l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
62 l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
239 if (backgroundCompilationEnabled()) {
240 throw new RuntimeException("Background compilation enabled");
241 }
242
243 try {
244 // Get Method object for m3
245 m3 = Test8009761.class.getDeclaredMethod("m3", boolean.class, boolean.class);
246 } catch (NoSuchMethodException | SecurityException ex) {
247 throw new RuntimeException("Failed to retrieve method m3");
248 }
249
250 int c1;
251 // Call m2 from m3 recursively until stack overflow. Count the number of recursive calls.
252 try {
253 m3(true, false);
254 } catch(StackOverflowError soe) {
255 }
256 c1 = count;
257
258 // Force the compilation of m3() that will inline m1()
259 WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION);
260 // Because background compilation is disabled, method should now be compiled
261 if(!WHITE_BOX.isMethodCompiled(m3)) {
262 throw new RuntimeException(m3 + " not compiled");
263 }
264
265 count = 0;
266 // Force deoptimization of m3() in m1(), then return from m1()
267 // to m3(), call recursively m2(). If deoptimization correctly
268 // built the interpreter stack for m3()/m1() then we should be
269 // able to call m2() recursively as many times as before.
270 try {
271 m3(false, true);
272 } catch(StackOverflowError soe) {
273 }
274 // Allow number of recursive calls to vary by 1
275 if ((c1 < (count - 1)) || (c1 > (count + 1))) {
276 throw new RuntimeException("Failed: init recursive calls: " + c1 + ". After deopt " + count);
277 } else {
278 System.out.println("PASSED " + c1);
279 }
|
23
24 import com.sun.management.HotSpotDiagnosticMXBean;
25 import com.sun.management.VMOption;
26 import sun.hotspot.WhiteBox;
27 import sun.management.ManagementFactoryHelper;
28
29 import java.lang.reflect.Method;
30
31 /*
32 * @test
33 * @bug 8009761
34 * @library /testlibrary /testlibrary/whitebox
35 * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
36 * @build Test8009761
37 * @run main ClassFileInstaller sun.hotspot.WhiteBox
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
39 */
40 public class Test8009761 {
41
42 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
43 private static int COMP_LEVEL_SIMPLE = 1;
44 private static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
45 private static Method m3 = null;
46
47 static Object m1(boolean deopt) {
48 // When running interpreted, on sparc, the caller's stack is
49 // extended for the locals and the caller's frame is restored
50 // on return.
51 long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
52 l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
53 l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
54 l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
55 l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
56 l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
57 l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
58 l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
59 l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
60 l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
61 l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
62 l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
63 l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
240 if (backgroundCompilationEnabled()) {
241 throw new RuntimeException("Background compilation enabled");
242 }
243
244 try {
245 // Get Method object for m3
246 m3 = Test8009761.class.getDeclaredMethod("m3", boolean.class, boolean.class);
247 } catch (NoSuchMethodException | SecurityException ex) {
248 throw new RuntimeException("Failed to retrieve method m3");
249 }
250
251 int c1;
252 // Call m2 from m3 recursively until stack overflow. Count the number of recursive calls.
253 try {
254 m3(true, false);
255 } catch(StackOverflowError soe) {
256 }
257 c1 = count;
258
259 // Force the compilation of m3() that will inline m1()
260 if(!WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION)) {
261 // C2 compiler not available, compile with C1
262 WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_SIMPLE);
263 }
264
265 // Because background compilation is disabled, method should now be compiled
266 if(!WHITE_BOX.isMethodCompiled(m3)) {
267 throw new RuntimeException(m3 + " not compiled");
268 }
269
270 count = 0;
271 // Force deoptimization of m3() in m1(), then return from m1()
272 // to m3(), call recursively m2(). If deoptimization correctly
273 // built the interpreter stack for m3()/m1() then we should be
274 // able to call m2() recursively as many times as before.
275 try {
276 m3(false, true);
277 } catch(StackOverflowError soe) {
278 }
279 // Allow number of recursive calls to vary by 1
280 if ((c1 < (count - 1)) || (c1 > (count + 1))) {
281 throw new RuntimeException("Failed: init recursive calls: " + c1 + ". After deopt " + count);
282 } else {
283 System.out.println("PASSED " + c1);
284 }
|