Wed, 28 Aug 2013 19:25:18 -0400
8023900: [TESTBUG] Initial compact profile test groups need adjusting
Reviewed-by: dcubed, mchung, hseigel
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | */ |
aoqi@0 | 23 | |
aoqi@0 | 24 | /* |
aoqi@0 | 25 | * @test |
aoqi@0 | 26 | * @bug 8010927 |
aoqi@0 | 27 | * @summary Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy |
aoqi@0 | 28 | * @library /testlibrary/whitebox /testlibrary |
aoqi@0 | 29 | * @build Test8010927 |
aoqi@0 | 30 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
aoqi@0 | 31 | * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -Xmx64m -XX:NewSize=20971520 -XX:MaxNewSize=32m -XX:-UseTLAB -XX:-UseParNewGC -XX:-UseAdaptiveSizePolicy Test8010927 |
aoqi@0 | 32 | */ |
aoqi@0 | 33 | |
aoqi@0 | 34 | import sun.hotspot.WhiteBox; |
aoqi@0 | 35 | import java.lang.reflect.Field; |
aoqi@0 | 36 | import sun.misc.Unsafe; |
aoqi@0 | 37 | |
aoqi@0 | 38 | /** |
aoqi@0 | 39 | * The test creates uncommitted space between oldgen and young gen |
aoqi@0 | 40 | * by specifying MaxNewSize bigger than NewSize. |
aoqi@0 | 41 | * NewSize = 20971520 = (512*4K) * 10 for 4k pages |
aoqi@0 | 42 | * Then it tries to execute arraycopy() with elements type check |
aoqi@0 | 43 | * to the array at the end of survive space near unused space. |
aoqi@0 | 44 | */ |
aoqi@0 | 45 | |
aoqi@0 | 46 | public class Test8010927 { |
aoqi@0 | 47 | |
aoqi@0 | 48 | private static final Unsafe U; |
aoqi@0 | 49 | |
aoqi@0 | 50 | static { |
aoqi@0 | 51 | try { |
aoqi@0 | 52 | Field unsafe = Unsafe.class.getDeclaredField("theUnsafe"); |
aoqi@0 | 53 | unsafe.setAccessible(true); |
aoqi@0 | 54 | U = (Unsafe) unsafe.get(null); |
aoqi@0 | 55 | } catch (Exception e) { |
aoqi@0 | 56 | throw new Error(e); |
aoqi@0 | 57 | } |
aoqi@0 | 58 | } |
aoqi@0 | 59 | |
aoqi@0 | 60 | public static Object[] o; |
aoqi@0 | 61 | |
aoqi@0 | 62 | public static final boolean debug = Boolean.getBoolean("debug"); |
aoqi@0 | 63 | |
aoqi@0 | 64 | // 2 different obect arrays but same element types |
aoqi@0 | 65 | static Test8010927[] masterA; |
aoqi@0 | 66 | static Object[] masterB; |
aoqi@0 | 67 | static final Test8010927 elem = new Test8010927(); |
aoqi@0 | 68 | static final WhiteBox wb = WhiteBox.getWhiteBox(); |
aoqi@0 | 69 | |
aoqi@0 | 70 | static final int obj_header_size = U.ARRAY_OBJECT_BASE_OFFSET; |
aoqi@0 | 71 | static final int heap_oop_size = wb.getHeapOopSize(); |
aoqi@0 | 72 | static final int card_size = 512; |
aoqi@0 | 73 | static final int one_card = (card_size - obj_header_size)/heap_oop_size; |
aoqi@0 | 74 | |
aoqi@0 | 75 | static final int surv_size = 2112 * 1024; |
aoqi@0 | 76 | |
aoqi@0 | 77 | // The size is big to not fit into survive space. |
aoqi@0 | 78 | static final Object[] cache = new Object[(surv_size / card_size)]; |
aoqi@0 | 79 | |
aoqi@0 | 80 | public static void main(String[] args) { |
aoqi@0 | 81 | masterA = new Test8010927[one_card]; |
aoqi@0 | 82 | masterB = new Object[one_card]; |
aoqi@0 | 83 | for (int i = 0; i < one_card; ++i) { |
aoqi@0 | 84 | masterA[i] = elem; |
aoqi@0 | 85 | masterB[i] = elem; |
aoqi@0 | 86 | } |
aoqi@0 | 87 | |
aoqi@0 | 88 | // Move cache[] to the old gen. |
aoqi@0 | 89 | long low_limit = wb.getObjectAddress(cache); |
aoqi@0 | 90 | System.gc(); |
aoqi@0 | 91 | // Move 'cache' to oldgen. |
aoqi@0 | 92 | long upper_limit = wb.getObjectAddress(cache); |
aoqi@0 | 93 | if ((low_limit - upper_limit) > 0) { // substaction works with unsigned values |
aoqi@0 | 94 | // OldGen is placed before youngger for ParallelOldGC. |
aoqi@0 | 95 | upper_limit = low_limit + 21000000l; // +20971520 |
aoqi@0 | 96 | } |
aoqi@0 | 97 | // Each A[one_card] size is 512 bytes, |
aoqi@0 | 98 | // it will take about 40000 allocations to trigger GC. |
aoqi@0 | 99 | // cache[] has 8192 elements so GC should happen |
aoqi@0 | 100 | // each 5th iteration. |
aoqi@0 | 101 | for(long l = 0; l < 20; l++) { |
aoqi@0 | 102 | fill_heap(); |
aoqi@0 | 103 | if (debug) { |
aoqi@0 | 104 | System.out.println("test oop_disjoint_arraycopy"); |
aoqi@0 | 105 | } |
aoqi@0 | 106 | testA_arraycopy(); |
aoqi@0 | 107 | if (debug) { |
aoqi@0 | 108 | System.out.println("test checkcast_arraycopy"); |
aoqi@0 | 109 | } |
aoqi@0 | 110 | testB_arraycopy(); |
aoqi@0 | 111 | // Execute arraycopy to the topmost array in young gen |
aoqi@0 | 112 | if (debug) { |
aoqi@0 | 113 | int top_index = get_top_address(low_limit, upper_limit); |
aoqi@0 | 114 | if (top_index >= 0) { |
aoqi@0 | 115 | long addr = wb.getObjectAddress(cache[top_index]); |
aoqi@0 | 116 | System.out.println("top_addr: 0x" + Long.toHexString(addr) + ", 0x" + Long.toHexString(addr + 512)); |
aoqi@0 | 117 | } |
aoqi@0 | 118 | } |
aoqi@0 | 119 | } |
aoqi@0 | 120 | } |
aoqi@0 | 121 | static void fill_heap() { |
aoqi@0 | 122 | for (int i = 0; i < cache.length; ++i) { |
aoqi@0 | 123 | o = new Test8010927[one_card]; |
aoqi@0 | 124 | System.arraycopy(masterA, 0, o, 0, masterA.length); |
aoqi@0 | 125 | cache[i] = o; |
aoqi@0 | 126 | } |
aoqi@0 | 127 | for (long j = 0; j < 256; ++j) { |
aoqi@0 | 128 | o = new Long[10000]; // to trigger GC |
aoqi@0 | 129 | } |
aoqi@0 | 130 | } |
aoqi@0 | 131 | static void testA_arraycopy() { |
aoqi@0 | 132 | for (int i = 0; i < cache.length; ++i) { |
aoqi@0 | 133 | System.arraycopy(masterA, 0, cache[i], 0, masterA.length); |
aoqi@0 | 134 | } |
aoqi@0 | 135 | } |
aoqi@0 | 136 | static void testB_arraycopy() { |
aoqi@0 | 137 | for (int i = 0; i < cache.length; ++i) { |
aoqi@0 | 138 | System.arraycopy(masterB, 0, cache[i], 0, masterB.length); |
aoqi@0 | 139 | } |
aoqi@0 | 140 | } |
aoqi@0 | 141 | static int get_top_address(long min, long max) { |
aoqi@0 | 142 | int index = -1; |
aoqi@0 | 143 | long addr = min; |
aoqi@0 | 144 | for (int i = 0; i < cache.length; ++i) { |
aoqi@0 | 145 | long test = wb.getObjectAddress(cache[i]); |
aoqi@0 | 146 | if (((test - addr) > 0) && ((max - test) > 0)) { // substaction works with unsigned values |
aoqi@0 | 147 | addr = test; |
aoqi@0 | 148 | index = i; |
aoqi@0 | 149 | } |
aoqi@0 | 150 | } |
aoqi@0 | 151 | return index; |
aoqi@0 | 152 | } |
aoqi@0 | 153 | } |