hotspot/test/compiler/codegen/8011901/Test8011901.java
author zmajo
Tue, 18 Nov 2014 19:44:45 +0100
changeset 27699 9913b19c0948
parent 17035 hotspot/test/compiler/8011901/Test8011901.java@6bc3ba037e8a
child 29678 dd2f3932c21e
permissions -rw-r--r--
8062854: move compiler jtreg test to corresponding subfolders and use those in TEST.groups Summary: move all test from <bug_id> directories to <functional_dir_name>/<bug_id>; update TEST.groups to execute more tests Reviewed-by: drchase, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17035
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     1
/*
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     4
 *
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     8
 *
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    13
 * accompanied this code).
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    14
 *
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    18
 *
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    21
 * questions.
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    22
 */
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    23
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    24
/*
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    25
 * @test
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    26
 * @bug 8011901
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    27
 * @summary instruct xaddL_no_res shouldn't allow 64 bit constants.
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    28
 * @run main/othervm -XX:-BackgroundCompilation Test8011901
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    29
 *
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    30
 */
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    31
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    32
import java.lang.reflect.*;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    33
import sun.misc.*;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    34
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    35
public class Test8011901 {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    36
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    37
    private long ctl;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    38
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    39
    private static final sun.misc.Unsafe U;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    40
    private static final long CTL;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    41
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    42
    static {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    43
        try {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    44
            Field unsafe = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    45
            unsafe.setAccessible(true);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    46
            U = (sun.misc.Unsafe) unsafe.get(null);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    47
            CTL = U.objectFieldOffset(Test8011901.class.getDeclaredField("ctl"));
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    48
        } catch (Exception e) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    49
            throw new Error(e);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    50
        }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    51
    }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    52
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    53
    public static void main(String[] args) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    54
        for(int c = 0; c < 20000; c++) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    55
            new Test8011901().makeTest();
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    56
        }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    57
        System.out.println("Test Passed");
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    58
    }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    59
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    60
    public static final long EXPECTED = 1L << 42;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    61
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    62
    public void makeTest() {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    63
        U.getAndAddLong(this, CTL, EXPECTED);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    64
        if (ctl != EXPECTED) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    65
            throw new RuntimeException("Test failed. Expected: " + EXPECTED + ", but got = " + ctl);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    66
        }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    67
    }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    68
}