annotate test/compiler/stringopts/TestOptimizeStringConcat.java @ 24225:a2dbb6fcc923

Added tag jvmci-0.33 for changeset 3aed4cb813f4
author Doug Simon <doug.simon@oracle.com>
date Fri, 18 Aug 2017 22:47:33 +0200
parents 007ed0fcee27
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22812
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
1 /*
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
2 * Copyright 2015 SAP AG. All Rights Reserved.
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
4 *
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
7 * published by the Free Software Foundation.
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
8 *
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
13 * accompanied this code).
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
14 *
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
18 *
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
21 * questions.
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
22 */
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
23
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
24 /*
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
25 * @test
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
26 * @bug 8068909
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
27 * @key regression
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
28 * @summary test that string optimizations produce code, that doesn't lead to a crash.
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
29 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestOptimizeStringConcat
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
30 * @author axel.siebenborn@sap.com
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
31 */
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
32 public class TestOptimizeStringConcat {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
33
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
34 static boolean checkArgumentSyntax(String value, String allowedchars, String notallowedchars, String logmsg) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
35 String rc = null;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
36
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
37 int maxchar = 99999;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
38 int minchar = 1;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
39 if ((allowedchars != null && notallowedchars != null) || minchar > maxchar) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
40 rc = "internal error";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
41 } else {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
42 if (value == null) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
43 rc = "the value null is not allowed, it is missing";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
44 } else if (value != null && minchar > 0 && value.trim().equals("")) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
45 rc = "the value must not be empty";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
46 } else if (value != null) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
47 if (value.length() < minchar || value.length() > maxchar) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
48 if (rc == null) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
49 rc = "the value length must be between +minchar+ and +maxchar";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
50 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
51 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
52 char[] _value = value.toCharArray();
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
53 boolean dotfound = false;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
54 int i = 1;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
55 if (_value[i] == '.' && !dotfound) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
56 dotfound = true;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
57 } else if (allowedchars != null && allowedchars.indexOf(_value[i]) == -1) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
58 if (rc == null) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
59 rc = "the value contains an illegal character: '" + _value[i] + "', only following characters are allowed: '+allowedchars+'";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
60 } else {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
61 rc += " / the value contains an illegal character: '" + _value[i] + "', only following characters are allowed: '+allowedchars+'";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
62 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
63 } else if (notallowedchars != null && notallowedchars.indexOf(_value[i]) != -1) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
64 if (rc == null) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
65 rc = "the value contains an illegal character: '" + _value[i] + "', following characters are not allowed '+notallowedchars+'";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
66 } else {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
67 rc += " / the value contains an illegal character: '" + _value[i] + "', following characters are not allowed '+notallowedchars+'";
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
68 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
69 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
70 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
71 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
72
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
73 if (rc != null) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
74 System.out.println(logmsg + " ==> " + rc);
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
75 return false;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
76 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
77 return true;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
78 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
79
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
80 public static void main(String[] args) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
81 boolean failed = false;
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
82 for (int i = 0; i < 10000; i++) {
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
83 failed |= !checkArgumentSyntax("theName", null, "\"<&", "Error consistencyCheck: name in component definition");
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
84 failed |= !checkArgumentSyntax(null, null, "\"<&", "Error consistencyCheck: name in component definition");
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
85 failed |= !checkArgumentSyntax("42", "0123456789.", null, "Error consistencyCheck: counter in component definition");
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
86 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
87 System.out.println(failed);
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
88 }
007ed0fcee27 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
asiebenborn
parents:
diff changeset
89 }