hotspot/test/compiler/arraycopy/TestArrayCopyOverflowArguments.java
author thartmann
Thu, 04 Aug 2016 10:34:34 +0200
changeset 40365 3791c1b34e36
parent 40059 c2304140ed64
permissions -rw-r--r--
8136818: Test compiler/arraycopy/TestEliminatedArrayCopyDeopt.java fails with "m1 failed" Summary: Added missing Op_StoreB check to ArrayCopyNode::may_modify_helper(). Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35112
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     1
/*
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     2
 * Copyright (c) 2015 SAP SE. All rights reserved.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     4
 *
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     8
 *
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    13
 * accompanied this code).
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    14
 *
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    18
 *
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    21
 * questions.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    22
 */
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    23
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    24
/*
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    25
 * @test
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    26
 * @summary Test that overflowed integers passed to arraycopy don't do any harm. This might
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    27
 *          be the case on platforms where C-code expects that ints passed to a call
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    28
 *          are properly sign extended to 64 bit (e.g., PPC64, s390x). This can fail
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    29
 *          if slow_arraycopy_C() is commpiled by the C compiler without any imlicit
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    30
 *          casts (as spill stores to the stack that are done with 4-byte instruction).
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    31
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 35112
diff changeset
    32
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 35112
diff changeset
    33
 *                   compiler.arraycopy.TestArrayCopyOverflowArguments
35112
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    34
 */
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    35
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 35112
diff changeset
    36
package compiler.arraycopy;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 35112
diff changeset
    37
35112
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    38
public class TestArrayCopyOverflowArguments {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    39
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    40
    // Without volatile the overflowing computation was moved up and then
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    41
    // spilled to the stack. The 32-bit spill store caused proper rounding.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    42
    static volatile int mod = Integer.MAX_VALUE;
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    43
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    44
    public static int[] m1(Object src) {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    45
        if (src == null) return null;
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    46
        int[] dest = new int[10];
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    47
        try {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    48
            // PPC C calling conventions require that ints are properly expanded
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    49
            // to longs when passed to a function.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    50
            int pos   =  8 + mod + mod; // = 0x1_0000_0006.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    51
            int start =  2 + mod + mod; // = 0x1_0000_0000.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    52
            int len   = 12 + mod + mod; // = 0x1_0000_0010.
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    53
            // This is supposed to call SharedRuntime::slow_arraycopy_C().
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    54
            System.arraycopy(src, pos, dest, 0, 10);
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    55
        } catch (ArrayStoreException npe) {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    56
        }
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    57
        return dest;
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    58
    }
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    59
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    60
    static public void main(String[] args) throws Exception {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    61
        int[] src = new int[20];
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    62
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    63
        for (int i  = 0; i < 20; ++i) {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    64
            src[i] = i * (i-1);
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    65
        }
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    66
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    67
        for (int i = 0; i < 20000; i++) {
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    68
            m1(src);
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    69
        }
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    70
    }
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    71
}
b3c4347bb751 8144466: ppc64: fix argument passing through opto stubs.
goetz
parents:
diff changeset
    72