hotspot/test/compiler/codegen/8011901/Test8011901.java
author chegar
Tue, 22 Mar 2016 15:26:07 +0000
changeset 36694 182a5e7a519e
parent 29678 dd2f3932c21e
child 36851 03e2f4d0a421
permissions -rw-r--r--
Merge
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
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27699
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
17035
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.
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 27699
diff changeset
    28
 * @modules java.base/sun.misc
17035
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation Test8011901
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
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    33
import java.lang.reflect.*;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    34
import sun.misc.*;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    35
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    36
public class Test8011901 {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    37
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    38
    private long ctl;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    39
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    40
    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
    41
    private static final long CTL;
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    42
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    43
    static {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    44
        try {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    45
            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
    46
            unsafe.setAccessible(true);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    47
            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
    48
            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
    49
        } catch (Exception e) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    50
            throw new Error(e);
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
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    54
    public static void main(String[] args) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    55
        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
    56
            new Test8011901().makeTest();
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    57
        }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    58
        System.out.println("Test Passed");
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
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    61
    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
    62
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    63
    public void makeTest() {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    64
        U.getAndAddLong(this, CTL, EXPECTED);
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    65
        if (ctl != EXPECTED) {
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    66
            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
    67
        }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    68
    }
6bc3ba037e8a 8011901: Unsafe.getAndAddLong(obj, off, delta) does not work properly with long deltas
roland
parents:
diff changeset
    69
}