55 }
56 return dest;
57 }
58
59 static Object m2_src(Object src) {
60 return src;
61 }
62
63 public static int[] m2(Object src) {
64 if (src == null) return null;
65 src = m2_src(src);
66 int[] dest = new int[10];
67 try {
68 System.arraycopy(src, 0, dest, 0, 10);
69 } catch (ArrayStoreException npe) {
70 }
71 return dest;
72 }
73
74 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
75
76 static boolean deoptimize(Method method, Object src_obj) throws Exception {
77 for (int i = 0; i < 10; i++) {
78 method.invoke(null, src_obj);
79 if (!WHITE_BOX.isMethodCompiled(method)) {
80 return true;
81 }
82 }
83 return false;
84 }
85
86 static public void main(String[] args) throws Exception {
87 if (Platform.isServer()) {
88 int[] src = new int[10];
89 Object src_obj = new Object();
90 Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class);
91 Method method_m2 = TestArrayCopyNoInitDeopt.class.getMethod("m2", Object.class);
92
93 // Warm up
94 for (int i = 0; i < 20000; i++) {
95 m1(src);
96 }
97
98 // And make sure m1 is compiled by C2
99 WHITE_BOX.enqueueMethodForCompilation(method_m1, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
100
101 if (!WHITE_BOX.isMethodCompiled(method_m1)) {
102 throw new RuntimeException("m1 not compiled");
103 }
104
105 // should deoptimize for type check
106 if (!deoptimize(method_m1, src_obj)) {
107 throw new RuntimeException("m1 not deoptimized");
|
55 }
56 return dest;
57 }
58
59 static Object m2_src(Object src) {
60 return src;
61 }
62
63 public static int[] m2(Object src) {
64 if (src == null) return null;
65 src = m2_src(src);
66 int[] dest = new int[10];
67 try {
68 System.arraycopy(src, 0, dest, 0, 10);
69 } catch (ArrayStoreException npe) {
70 }
71 return dest;
72 }
73
74 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
75 private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue();
76
77 static boolean deoptimize(Method method, Object src_obj) throws Exception {
78 for (int i = 0; i < 10; i++) {
79 method.invoke(null, src_obj);
80 if (!WHITE_BOX.isMethodCompiled(method)) {
81 return true;
82 }
83 }
84 return false;
85 }
86
87 static public void main(String[] args) throws Exception {
88 // Only execute if C2 is available
89 if (Platform.isServer() &&
90 TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) {
91 int[] src = new int[10];
92 Object src_obj = new Object();
93 Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class);
94 Method method_m2 = TestArrayCopyNoInitDeopt.class.getMethod("m2", Object.class);
95
96 // Warm up
97 for (int i = 0; i < 20000; i++) {
98 m1(src);
99 }
100
101 // And make sure m1 is compiled by C2
102 WHITE_BOX.enqueueMethodForCompilation(method_m1, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION);
103
104 if (!WHITE_BOX.isMethodCompiled(method_m1)) {
105 throw new RuntimeException("m1 not compiled");
106 }
107
108 // should deoptimize for type check
109 if (!deoptimize(method_m1, src_obj)) {
110 throw new RuntimeException("m1 not deoptimized");
|