test/compiler/8009761/Test8009761.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8021775 Sdiff test/compiler/8009761

test/compiler/8009761/Test8009761.java

Print this page




   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 



  24 /*
  25  * @test
  26  * @bug 8009761

  27  * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
  28  * @run main/othervm -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
  29  *

  30  */
  31 
  32 public class Test8009761 {
  33 
  34     static class UnloadedClass {
  35         volatile int i;
  36     }
  37 
  38     static Object m1(boolean deopt) {
  39         // When running interpreted, on sparc, the caller's stack is
  40         // extended for the locals and the caller's frame is restored
  41         // on return.
  42         long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
  43         l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
  44         l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
  45         l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
  46         l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
  47         l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
  48         l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
  49         l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
  50         l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
  51         l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
  52         l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
  53         l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
  54         l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
  55         l148, l149, l150, l151, l152, l153, l154, l155, l156, l157,
  56         l158, l159, l160, l161, l162, l163, l164, l165, l166, l167,


 125         ll338, ll339, ll340, ll341, ll342, ll343, ll344, ll345, ll346, ll347,
 126         ll348, ll349, ll350, ll351, ll352, ll353, ll354, ll355, ll356, ll357,
 127         ll358, ll359, ll360, ll361, ll362, ll363, ll364, ll365, ll366, ll367,
 128         ll368, ll369, ll370, ll371, ll372, ll373, ll374, ll375, ll376, ll377,
 129         ll378, ll379, ll380, ll381, ll382, ll383, ll384, ll385, ll386, ll387,
 130         ll388, ll389, ll390, ll391, ll392, ll393, ll394, ll395, ll396, ll397,
 131         ll398, ll399, ll400, ll401, ll402, ll403, ll404, ll405, ll406, ll407,
 132         ll408, ll409, ll410, ll411, ll412, ll413, ll414, ll415, ll416, ll417,
 133         ll418, ll419, ll420, ll421, ll422, ll423, ll424, ll425, ll426, ll427,
 134         ll428, ll429, ll430, ll431, ll432, ll433, ll434, ll435, ll436, ll437,
 135         ll438, ll439, ll440, ll441, ll442, ll443, ll444, ll445, ll446, ll447,
 136         ll448, ll449, ll450, ll451, ll452, ll453, ll454, ll455, ll456, ll457,
 137         ll458, ll459, ll460, ll461, ll462, ll463, ll464, ll465, ll466, ll467,
 138         ll468, ll469, ll470, ll471, ll472, ll473, ll474, ll475, ll476, ll477,
 139         ll478, ll479, ll480, ll481, ll482, ll483, ll484, ll485, ll486, ll487,
 140         ll488, ll489, ll490, ll491, ll492, ll493, ll494, ll495, ll496, ll497,
 141         ll498, ll499, ll500, ll501, ll502, ll503, ll504, ll505, ll506, ll507,
 142         ll508, ll509, ll510, ll511;
 143 
 144         if (deopt) {
 145             UnloadedClass res = new UnloadedClass(); // sufficient to force deopt with c2 but not c1
 146             res.i = 0; // forces deopt with c1
 147             return res;


 148         }
 149         return null;
 150     }
 151 
 152     static int count = 0;
 153 
 154     static void m2() {
 155         // Will be called recursively until a stack overflow
 156         // exception. Makes sure it has a lot of locals so that it's
 157         // not called a sufficient number of times to trigger
 158         // compilation.
 159 
 160         long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
 161         l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
 162         l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
 163         l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
 164         l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
 165         l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
 166         l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
 167         l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,


 208         l498, l499, l500, l501, l502, l503, l504, l505, l506, l507,
 209         l508, l509, l510, l511;
 210 
 211         count++;
 212         m2();
 213     }
 214 
 215     static Object m3(boolean overflow_stack, boolean deopt) {
 216         if (overflow_stack) {
 217             m2();
 218             return null;
 219         }
 220         Object o = m1(deopt);
 221         if (deopt) {
 222             m2();
 223         }
 224         return o;
 225     }
 226 
 227     static public void main(String[] args) {







 228         int c1;
 229         // Call m2 from m3 recursively until stack overflow. Count the number of recursive calls.
 230         try {
 231             m3(true, false);
 232         } catch(StackOverflowError soe) {
 233         }
 234         c1 = count;

 235         // Force the compilation of m3() that will inline m1()
 236         for (int i = 0; i < 20000; i++) {
 237             m3(false, false);

 238         }

 239         count = 0;
 240         // Force deoptimization of m3() in m1(), then return from m1()
 241         // to m3(), call recursively m2(). If deoptimization correctly
 242         // built the interpreter stack for m3()/m1() then we should be
 243         // able to call m2() recursively as many times as before.
 244         try {
 245             m3(false, true);
 246         } catch(StackOverflowError soe) {
 247         }
 248         if (c1 != count) {
 249             System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count);
 250             System.exit(97);
 251         } else {
 252             System.out.println("PASSED " + c1);
 253         }
 254     }
 255 }


   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import sun.hotspot.WhiteBox;
  25 import java.lang.reflect.Method;
  26 
  27 /*
  28  * @test
  29  * @bug 8009761
  30  * @library /testlibrary /testlibrary/whitebox
  31  * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates
  32  * @build Test8009761
  33  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  34  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
  35  */

  36 public class Test8009761 {
  37     
  38     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
  39     private static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
  40     private static Method m3 = null;
  41 
  42     static Object m1(boolean deopt) {
  43         // When running interpreted, on sparc, the caller's stack is
  44         // extended for the locals and the caller's frame is restored
  45         // on return.
  46         long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
  47         l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
  48         l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
  49         l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
  50         l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
  51         l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
  52         l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
  53         l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
  54         l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
  55         l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
  56         l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
  57         l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
  58         l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
  59         l148, l149, l150, l151, l152, l153, l154, l155, l156, l157,
  60         l158, l159, l160, l161, l162, l163, l164, l165, l166, l167,


 129         ll338, ll339, ll340, ll341, ll342, ll343, ll344, ll345, ll346, ll347,
 130         ll348, ll349, ll350, ll351, ll352, ll353, ll354, ll355, ll356, ll357,
 131         ll358, ll359, ll360, ll361, ll362, ll363, ll364, ll365, ll366, ll367,
 132         ll368, ll369, ll370, ll371, ll372, ll373, ll374, ll375, ll376, ll377,
 133         ll378, ll379, ll380, ll381, ll382, ll383, ll384, ll385, ll386, ll387,
 134         ll388, ll389, ll390, ll391, ll392, ll393, ll394, ll395, ll396, ll397,
 135         ll398, ll399, ll400, ll401, ll402, ll403, ll404, ll405, ll406, ll407,
 136         ll408, ll409, ll410, ll411, ll412, ll413, ll414, ll415, ll416, ll417,
 137         ll418, ll419, ll420, ll421, ll422, ll423, ll424, ll425, ll426, ll427,
 138         ll428, ll429, ll430, ll431, ll432, ll433, ll434, ll435, ll436, ll437,
 139         ll438, ll439, ll440, ll441, ll442, ll443, ll444, ll445, ll446, ll447,
 140         ll448, ll449, ll450, ll451, ll452, ll453, ll454, ll455, ll456, ll457,
 141         ll458, ll459, ll460, ll461, ll462, ll463, ll464, ll465, ll466, ll467,
 142         ll468, ll469, ll470, ll471, ll472, ll473, ll474, ll475, ll476, ll477,
 143         ll478, ll479, ll480, ll481, ll482, ll483, ll484, ll485, ll486, ll487,
 144         ll488, ll489, ll490, ll491, ll492, ll493, ll494, ll495, ll496, ll497,
 145         ll498, ll499, ll500, ll501, ll502, ll503, ll504, ll505, ll506, ll507,
 146         ll508, ll509, ll510, ll511;
 147 
 148         if (deopt) {
 149             // Force deoptimization of m3
 150             WHITE_BOX.deoptimizeMethod(m3);
 151             if(WHITE_BOX.isMethodCompiled(m3)) {
 152                 throw new RuntimeException(m3 + " not deoptimized");
 153             }
 154         }
 155         return null;
 156     }
 157 
 158     static int count = 0;
 159 
 160     static void m2() {
 161         // Will be called recursively until a stack overflow
 162         // exception. Makes sure it has a lot of locals so that it's
 163         // not called a sufficient number of times to trigger
 164         // compilation.
 165 
 166         long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
 167         l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
 168         l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
 169         l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
 170         l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
 171         l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
 172         l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
 173         l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,


 214         l498, l499, l500, l501, l502, l503, l504, l505, l506, l507,
 215         l508, l509, l510, l511;
 216 
 217         count++;
 218         m2();
 219     }
 220 
 221     static Object m3(boolean overflow_stack, boolean deopt) {
 222         if (overflow_stack) {
 223             m2();
 224             return null;
 225         }
 226         Object o = m1(deopt);
 227         if (deopt) {
 228             m2();
 229         }
 230         return o;
 231     }
 232 
 233     static public void main(String[] args) {
 234         try {
 235             // Get Method object for m3
 236             m3 = Test8009761.class.getDeclaredMethod("m3", boolean.class, boolean.class);
 237         } catch (NoSuchMethodException | SecurityException ex) {
 238             throw new RuntimeException("Failed to retrieve method m3");
 239         }
 240         
 241         int c1;
 242         // Call m2 from m3 recursively until stack overflow. Count the number of recursive calls.
 243         try {
 244             m3(true, false);
 245         } catch(StackOverflowError soe) {
 246         }
 247         c1 = count;
 248         
 249         // Force the compilation of m3() that will inline m1()
 250         WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION);
 251         if(!WHITE_BOX.isMethodCompiled(m3)) {
 252             throw new RuntimeException(m3 + " not compiled");
 253         }
 254         
 255         count = 0;
 256         // Force deoptimization of m3() in m1(), then return from m1()
 257         // to m3(), call recursively m2(). If deoptimization correctly
 258         // built the interpreter stack for m3()/m1() then we should be
 259         // able to call m2() recursively as many times as before.
 260         try {
 261             m3(false, true);
 262         } catch(StackOverflowError soe) {
 263         }
 264         if (c1 != count) {
 265             System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count);
 266             System.exit(97);
 267         } else {
 268             System.out.println("PASSED " + c1);
 269         }
 270     }
 271 }
test/compiler/8009761/Test8009761.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File