Mercurial > hg > truffle
comparison test/compiler/5091921/Test6357214.java @ 3345:bad7ecd0b6ed
5091921: Sign flip issues in loop optimizer
Summary: Fix integer overflow problem in the code generated by loop optimizer.
Reviewed-by: never
author | kvn |
---|---|
date | Wed, 04 May 2011 13:12:42 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3344:0139aac70fb5 | 3345:bad7ecd0b6ed |
---|---|
1 /* | |
2 * Copyright (c) 2011, 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 6357214 | |
28 * @summary Hotspot server compiler gets integer comparison wrong | |
29 * | |
30 * @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 Test6357214 | |
31 */ | |
32 | |
33 // The test hangs after few iterations before the fix. So it fails if timeout. | |
34 class MyResult { | |
35 public boolean next() { | |
36 return true; | |
37 } | |
38 | |
39 public String getString(String in) { | |
40 if (in.equals("id")) | |
41 return "idFoo"; | |
42 if (in.equals("contentKey")) | |
43 return "ckFoo"; | |
44 return "Foo"; | |
45 } | |
46 | |
47 public int getInt(String in) { | |
48 if (in.equals("processingComplete")) | |
49 return 0; | |
50 return 1; | |
51 } | |
52 | |
53 public byte[] getBytes(String in) { | |
54 byte[] arr = null; | |
55 if (in.equals("content")) { | |
56 arr = new byte[65536]; | |
57 byte j = 32; | |
58 for (int i=0; i<65536; i++) { | |
59 arr[i] = j; | |
60 if (++j == 127) | |
61 j=32; | |
62 } | |
63 } | |
64 return arr; | |
65 } | |
66 } | |
67 | |
68 public class Test6357214 { | |
69 public static volatile boolean bollocks = true; | |
70 public String create(String context) throws Exception { | |
71 | |
72 // | |
73 // Extract HTTP parameters | |
74 // | |
75 | |
76 boolean showAll = System.getProperty("showAll") != null; | |
77 String eventID = System.getProperty("eventID"); | |
78 String eventContentKey = System.getProperty("cKey"); | |
79 // | |
80 // Build ContentStaging query based on eventID or eventContentKey | |
81 // | |
82 | |
83 String sql = "select id, processingComplete, contentKey, content " | |
84 + "from ContentStaging cs, ContentStagingKey csk " | |
85 + "where cs.eventContentKey = csk.eventContentKey "; | |
86 | |
87 if (eventID != null) { | |
88 sql += "and id = " + eventID; | |
89 } | |
90 else if (eventContentKey != null) { | |
91 sql += "and cs.eventContentKey = '" | |
92 + eventContentKey | |
93 + "' having id = max(id)"; | |
94 } | |
95 else { | |
96 throw new Exception("Need eventID or eventContentKey"); | |
97 } | |
98 | |
99 // | |
100 // This factory builds a static panel, there is no JSP | |
101 // | |
102 | |
103 StringBuffer html = new StringBuffer(); | |
104 | |
105 try { | |
106 | |
107 MyResult result = new MyResult(); | |
108 if (result.next()) { | |
109 | |
110 eventID = result.getString("id"); | |
111 int processingComplete = result.getInt("processingComplete"); | |
112 String contentKey = result.getString("contentKey"); | |
113 byte[] bytes = result.getBytes("content"); | |
114 | |
115 // | |
116 // Print content status and associated controls | |
117 // | |
118 | |
119 html.append("<br/><font class=\"small\">"); | |
120 html.append("Status: "); | |
121 switch (processingComplete) { | |
122 case 0 : | |
123 case 1 : html.append("PENDING"); break; | |
124 case 2 : html.append(contentKey); break; | |
125 case 3 : html.append(eventID); break; | |
126 default : html.append("UNKNONW"); | |
127 } | |
128 html.append("</font><br/>"); | |
129 | |
130 // | |
131 // Print at most 20Kb of content unless "showAll" is set | |
132 // | |
133 | |
134 int limit = showAll ? Integer.MAX_VALUE : 1024 * 20; | |
135 System.out.println(limit); | |
136 html.append("<pre>"); | |
137 for (int i = 0; bytes != null && i < bytes.length; i++) { | |
138 char c = (char) bytes[i]; | |
139 switch (c) { | |
140 case '<' : html.append("<"); break; | |
141 case '>' : html.append(">"); break; | |
142 case '&' : html.append("&"); break; | |
143 default : html.append(c); | |
144 } | |
145 | |
146 if (i > limit) { | |
147 while (bollocks); | |
148 // System.out.println("i is " + i); | |
149 // System.out.println("limit is " + limit); | |
150 html.append("...\n</pre>"); | |
151 html.append(eventID); | |
152 html.append("<pre>"); | |
153 break; | |
154 } | |
155 } | |
156 html.append("</pre>"); | |
157 } | |
158 } | |
159 catch (Exception exception) { | |
160 throw exception; | |
161 } | |
162 finally { | |
163 html.append("Oof!!"); | |
164 } | |
165 String ret = html.toString(); | |
166 System.out.println("Returning string length = "+ ret.length()); | |
167 return ret; | |
168 } | |
169 | |
170 public static void main(String[] args) throws Exception { | |
171 int length=0; | |
172 | |
173 for (int i = 0; i < 100; i++) { | |
174 length = new Test6357214().create("boo").length(); | |
175 System.out.println(length); | |
176 } | |
177 } | |
178 } | |
179 |