TestUnalignedLoad.java revision 11707:ad7af1afda7a
1/*
2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25/**
26 * @test
27 * @bug 6769124
28 * @summary unaligned load may fail with c1 on 64 bit
29 *
30 * @run main compiler.c1.TestUnalignedLoad
31 */
32
33package compiler.c1;
34
35public class TestUnalignedLoad {
36
37    static long l1v = 0x200000003L;
38    static long l2v = 0x400000005L;
39    static double d1v = Double.MAX_VALUE;
40    static double d2v = Double.MIN_VALUE;
41
42    public static void main(String[] args) {
43        long l1 = l1v;
44        double d1 = d1v;
45        long l2 = l2v;
46        double d2 = d2v;
47
48        // Run long enough to induce an OSR
49        for (int i = 0; i < 10000000; i++) {
50        }
51        boolean error = false;
52
53        if (l1 != l1v) {
54            System.out.println(l1 + " != " + l1v);
55            error = true;
56        }
57        if (l2 != l2v) {
58            System.out.println(l2 + " != " + l2v);
59            error = true;
60        }
61        if (d1 != d1v) {
62            System.out.println(d1 + " != " + d1v);
63            error = true;
64        }
65        if (d2 != d2v) {
66            System.out.println(d2 + " != " + d2v);
67            error = true;
68        }
69        if (error) {
70            throw new InternalError();
71        }
72    }
73}
74