hotspot/test/compiler/intrinsics/string/TestStringConstruction.java
author vdeshpande
Fri, 26 Aug 2016 12:20:09 -0700
changeset 41362 e09e871860a7
parent 40059 c2304140ed64
permissions -rw-r--r--
8154122: Intrinsify fused mac operations Summary: added FMA intrinsics on x86 Reviewed-by: kvn, aph, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34499
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     1
/*
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     4
 *
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     8
 *
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    13
 * accompanied this code).
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    14
 *
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    18
 *
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    21
 * questions.
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    22
 */
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    23
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    24
/*
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    25
 * @test
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    26
 * @bug 8142303
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    27
 * @summary Tests handling of invalid array indices in C2 intrinsic if explicit range check in Java code is not inlined.
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    28
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    29
 * @run main/othervm
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    30
 *      -XX:CompileCommand=inline,java.lang.String::*
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    31
 *      -XX:CompileCommand=inline,java.lang.StringUTF16::*
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    32
 *      -XX:CompileCommand=exclude,java.lang.String::checkBoundsOffCount
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    33
 *      compiler.intrinsics.string.TestStringConstruction
34499
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    34
 */
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    35
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    36
package compiler.intrinsics.string;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 34499
diff changeset
    37
34499
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    38
public class TestStringConstruction {
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    39
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    40
    public static void main(String[] args) {
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    41
        char[] chars = new char[42];
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    42
        for (int i = 0; i < 10_000; ++i) {
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    43
            test(chars);
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    44
        }
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    45
    }
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    46
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    47
    private static String test(char[] chars) {
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    48
        try {
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    49
            // The constructor calls String::checkBoundsOffCount(-1, 42) to perform
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    50
            // range checks on offset and count. If this method is not inlined, C2
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    51
            // does not know about the explicit range checks and does not cut off the
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    52
            // dead code. As a result, -1 is fed as offset into the StringUTF16.compress
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    53
            // intrinsic which is replaced by TOP and causes a failure in the matcher.
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    54
            return new String(chars, -1 , 42);
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    55
        } catch (Exception e) {
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    56
            return "";
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    57
        }
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    58
    }
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    59
}
343abbc06572 8142303: C2 compilation fails with "bad AD file"
thartmann
parents:
diff changeset
    60