Wed, 28 Aug 2013 19:25:18 -0400
8023900: [TESTBUG] Initial compact profile test groups need adjusting
Reviewed-by: dcubed, mchung, hseigel
twisti@5486 | 1 | /* |
twisti@5486 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
twisti@5486 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
twisti@5486 | 4 | * |
twisti@5486 | 5 | * This code is free software; you can redistribute it and/or modify it |
twisti@5486 | 6 | * under the terms of the GNU General Public License version 2 only, as |
twisti@5486 | 7 | * published by the Free Software Foundation. |
twisti@5486 | 8 | * |
twisti@5486 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
twisti@5486 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
twisti@5486 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
twisti@5486 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
twisti@5486 | 13 | * accompanied this code). |
twisti@5486 | 14 | * |
twisti@5486 | 15 | * You should have received a copy of the GNU General Public License version |
twisti@5486 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
twisti@5486 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
twisti@5486 | 18 | * |
twisti@5486 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
twisti@5486 | 20 | * or visit www.oracle.com if you need additional information or have any |
twisti@5486 | 21 | * questions. |
twisti@5486 | 22 | */ |
twisti@5486 | 23 | |
twisti@5486 | 24 | /* |
twisti@5486 | 25 | * @test |
twisti@5486 | 26 | * @bug 8016474 |
twisti@5486 | 27 | * @summary The bug only happens with C1 and G1 using a different ObjectAlignmentInBytes than KlassAlignmentInBytes (which is 8) |
twisti@5490 | 28 | * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 GetUnsafeObjectG1PreBarrier |
twisti@5486 | 29 | */ |
twisti@5486 | 30 | |
twisti@5486 | 31 | import java.lang.reflect.Field; |
twisti@5486 | 32 | |
twisti@5486 | 33 | import sun.misc.Unsafe; |
twisti@5486 | 34 | |
twisti@5486 | 35 | public class GetUnsafeObjectG1PreBarrier { |
twisti@5486 | 36 | private static final Unsafe unsafe; |
twisti@5486 | 37 | private static final int N = 100_000; |
twisti@5486 | 38 | |
twisti@5486 | 39 | static { |
twisti@5486 | 40 | try { |
twisti@5486 | 41 | Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); |
twisti@5486 | 42 | theUnsafe.setAccessible(true); |
twisti@5486 | 43 | unsafe = (Unsafe) theUnsafe.get(null); |
twisti@5486 | 44 | } catch (NoSuchFieldException | IllegalAccessException e) { |
twisti@5486 | 45 | throw new IllegalStateException(e); |
twisti@5486 | 46 | } |
twisti@5486 | 47 | } |
twisti@5486 | 48 | |
twisti@5486 | 49 | public Object a; |
twisti@5486 | 50 | |
twisti@5486 | 51 | public static void main(String[] args) throws Throwable { |
twisti@5486 | 52 | new GetUnsafeObjectG1PreBarrier(); |
twisti@5486 | 53 | } |
twisti@5486 | 54 | |
twisti@5486 | 55 | public GetUnsafeObjectG1PreBarrier() throws Throwable { |
twisti@5486 | 56 | doit(); |
twisti@5486 | 57 | } |
twisti@5486 | 58 | |
twisti@5486 | 59 | private void doit() throws Throwable { |
twisti@5486 | 60 | Field field = GetUnsafeObjectG1PreBarrier.class.getField("a"); |
twisti@5486 | 61 | long fieldOffset = unsafe.objectFieldOffset(field); |
twisti@5486 | 62 | |
twisti@5486 | 63 | for (int i = 0; i < N; i++) { |
twisti@5486 | 64 | readField(this, fieldOffset); |
twisti@5486 | 65 | } |
twisti@5486 | 66 | } |
twisti@5486 | 67 | |
twisti@5486 | 68 | private void readField(Object o, long fieldOffset) { |
twisti@5486 | 69 | unsafe.getObject(o, fieldOffset); |
twisti@5486 | 70 | } |
twisti@5486 | 71 | } |