Wed, 27 Aug 2014 08:19:12 -0400
8046598: Scalable Native memory tracking development
Summary: Enhance scalability of native memory tracking
Reviewed-by: coleenp, ctornqvi, gtriantafill
roland@6214 | 1 | /* |
roland@6214 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
roland@6214 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
roland@6214 | 4 | * |
roland@6214 | 5 | * This code is free software; you can redistribute it and/or modify it |
roland@6214 | 6 | * under the terms of the GNU General Public License version 2 only, as |
roland@6214 | 7 | * published by the Free Software Foundation. |
roland@6214 | 8 | * |
roland@6214 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
roland@6214 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
roland@6214 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
roland@6214 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
roland@6214 | 13 | * accompanied this code). |
roland@6214 | 14 | * |
roland@6214 | 15 | * You should have received a copy of the GNU General Public License version |
roland@6214 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
roland@6214 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
roland@6214 | 18 | * |
roland@6214 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
roland@6214 | 20 | * or visit www.oracle.com if you need additional information or have any |
roland@6214 | 21 | * questions. |
roland@6214 | 22 | */ |
roland@6214 | 23 | |
roland@6214 | 24 | /* |
roland@6214 | 25 | * @test |
roland@6214 | 26 | * @bug 8027571 |
roland@6214 | 27 | * @summary meet of TopPTR exact array with constant array is not symmetric |
roland@6384 | 28 | * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -XX:-BackgroundCompilation TestMeetTopArrayExactConstantArray |
roland@6214 | 29 | * |
roland@6214 | 30 | */ |
roland@6214 | 31 | |
roland@6214 | 32 | public class TestMeetTopArrayExactConstantArray { |
roland@6214 | 33 | |
roland@6214 | 34 | static class A { |
roland@6214 | 35 | } |
roland@6214 | 36 | |
roland@6214 | 37 | static class B { |
roland@6214 | 38 | } |
roland@6214 | 39 | |
roland@6214 | 40 | static class C extends A { |
roland@6214 | 41 | } |
roland@6214 | 42 | |
roland@6214 | 43 | static class D extends C { |
roland@6214 | 44 | } |
roland@6214 | 45 | |
roland@6214 | 46 | final static B[] b = new B[10]; |
roland@6214 | 47 | |
roland@6214 | 48 | static void m0(Object[] o) { |
roland@6214 | 49 | if (o.getClass() == Object[].class) { |
roland@6214 | 50 | } |
roland@6214 | 51 | } |
roland@6214 | 52 | |
roland@6214 | 53 | static void m1(Object[] o, boolean cond) { |
roland@6214 | 54 | if (cond) { |
roland@6214 | 55 | o = b; |
roland@6214 | 56 | } |
roland@6214 | 57 | m0(o); |
roland@6214 | 58 | } |
roland@6214 | 59 | |
roland@6214 | 60 | static void m2(Object[] o, boolean cond1, boolean cond2) { |
roland@6214 | 61 | if (cond1) { |
roland@6214 | 62 | m1(o, cond2); |
roland@6214 | 63 | } |
roland@6214 | 64 | } |
roland@6214 | 65 | |
roland@6214 | 66 | static void m3(C[] o, boolean cond1, boolean cond2, boolean cond3) { |
roland@6214 | 67 | if (cond1) { |
roland@6214 | 68 | m2(o, cond2, cond3); |
roland@6214 | 69 | } |
roland@6214 | 70 | } |
roland@6214 | 71 | |
roland@6214 | 72 | static public void main(String[] args) { |
roland@6214 | 73 | A[] a = new A[10]; |
roland@6214 | 74 | D[] d = new D[10]; |
roland@6214 | 75 | Object[] o = new Object[10]; |
roland@6214 | 76 | for (int i = 0; i < 5000; i++) { |
roland@6214 | 77 | // record in profiling that the if in m0 succeeds |
roland@6214 | 78 | m0(o); |
roland@6214 | 79 | // record some profiling for m2 and m1 |
roland@6214 | 80 | m2(a, true, (i%2) == 0); |
roland@6214 | 81 | // record some profiling for m3 and conflicting profile for m2 |
roland@6214 | 82 | m3(d, true, false, (i%2) == 0); |
roland@6214 | 83 | } |
roland@6214 | 84 | |
roland@6214 | 85 | // get m3 compiled. The if in m0 will be optimized because of argument profiling in m3 |
roland@6214 | 86 | C[] c = new C[10]; |
roland@6214 | 87 | for (int i = 0; i < 20000; i++) { |
roland@6214 | 88 | m3(c, true, false, (i%2) == 0); |
roland@6214 | 89 | } |
roland@6214 | 90 | // make m3 not entrant and the if in m0 fail |
roland@6214 | 91 | m3(c, true, true, false); |
roland@6214 | 92 | m3(c, true, true, false); |
roland@6214 | 93 | m3(c, true, true, false); |
roland@6214 | 94 | m3(c, true, true, false); |
roland@6214 | 95 | |
roland@6214 | 96 | // make m3 recompile, this time with if the not optimized |
roland@6214 | 97 | // on entry to m3, argument o is of type C[], profiled C[] |
roland@6214 | 98 | // on entry to m1, argument o is of type C[], speculative C[] exact, profiled A[]. Speculative becomes AnyNull |
roland@6214 | 99 | // after the if in m1, speculative type of o becomes constant from final field b |
roland@6214 | 100 | // the true if branch in m0 does a join between the type of o of speculative type constant from final field b and exact klass Object[] |
roland@6214 | 101 | for (int i = 0; i < 20000; i++) { |
roland@6214 | 102 | m3(c, true, false, (i%2) == 0); |
roland@6214 | 103 | } |
roland@6214 | 104 | |
roland@6214 | 105 | System.out.println("TEST PASSED"); |
roland@6214 | 106 | } |
roland@6214 | 107 | } |