Mon, 28 Jul 2014 15:06:38 -0700
8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn
twisti@1210 | 1 | /* |
trims@1907 | 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
twisti@1210 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
twisti@1210 | 4 | * |
twisti@1210 | 5 | * This code is free software; you can redistribute it and/or modify it |
twisti@1210 | 6 | * under the terms of the GNU General Public License version 2 only, as |
twisti@1210 | 7 | * published by the Free Software Foundation. |
twisti@1210 | 8 | * |
twisti@1210 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
twisti@1210 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
twisti@1210 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
twisti@1210 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
twisti@1210 | 13 | * accompanied this code). |
twisti@1210 | 14 | * |
twisti@1210 | 15 | * You should have received a copy of the GNU General Public License version |
twisti@1210 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
twisti@1210 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
twisti@1210 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
twisti@1210 | 22 | */ |
twisti@1210 | 23 | |
twisti@1210 | 24 | /** |
twisti@1210 | 25 | * @test |
twisti@1210 | 26 | * @bug 6823354 |
twisti@1210 | 27 | * @summary These methods can be instrinsified by using bit scan, bit test, and population count instructions. |
twisti@1210 | 28 | * |
twisti@1210 | 29 | * @run main/othervm -Xcomp -XX:CompileOnly=Test6823354.lzcomp,Test6823354.tzcomp,.dolzcomp,.dotzcomp Test6823354 |
twisti@1210 | 30 | */ |
twisti@1210 | 31 | |
twisti@1210 | 32 | import java.net.URLClassLoader; |
twisti@1210 | 33 | |
twisti@1210 | 34 | public class Test6823354 { |
twisti@1210 | 35 | // Arrays of corner case values. |
twisti@1210 | 36 | static final int[] ia = new int[] { 0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE }; |
twisti@1210 | 37 | static final long[] la = new long[] { 0L, 1L, -1L, Long.MIN_VALUE, Long.MAX_VALUE }; |
twisti@1210 | 38 | |
twisti@1210 | 39 | public static void main(String[] args) throws Exception { |
twisti@1210 | 40 | // Load the classes and the methods. |
twisti@1210 | 41 | Integer.numberOfLeadingZeros(0); |
twisti@1210 | 42 | Integer.numberOfTrailingZeros(0); |
twisti@1210 | 43 | Long.numberOfLeadingZeros(0); |
twisti@1210 | 44 | Long.numberOfTrailingZeros(0); |
twisti@1210 | 45 | |
twisti@1210 | 46 | lz(); |
twisti@1210 | 47 | tz(); |
twisti@1210 | 48 | } |
twisti@1210 | 49 | |
twisti@1210 | 50 | static void lz() throws Exception { |
twisti@1210 | 51 | // int |
twisti@1210 | 52 | |
twisti@1210 | 53 | // Test corner cases. |
twisti@1210 | 54 | for (int i = 0; i < ia.length; i++) { |
twisti@1210 | 55 | int x = ia[i]; |
twisti@1210 | 56 | check(x, lzcomp(x), lzint(x)); |
twisti@1210 | 57 | } |
twisti@1210 | 58 | |
twisti@1210 | 59 | // Test all possible return values. |
twisti@1210 | 60 | for (int i = 0; i < Integer.SIZE; i++) { |
twisti@1210 | 61 | int x = 1 << i; |
twisti@1210 | 62 | check(x, lzcomp(x), lzint(x)); |
twisti@1210 | 63 | } |
twisti@1210 | 64 | |
twisti@1210 | 65 | String classname = "Test6823354$lzconI"; |
twisti@1210 | 66 | |
twisti@1210 | 67 | // Test Ideal optimizations (constant values). |
twisti@1210 | 68 | for (int i = 0; i < ia.length; i++) { |
twisti@1210 | 69 | testclass(classname, ia[i]); |
twisti@1210 | 70 | } |
twisti@1210 | 71 | |
twisti@1210 | 72 | // Test Ideal optimizations (constant values). |
twisti@1210 | 73 | for (int i = 0; i < Integer.SIZE; i++) { |
twisti@1210 | 74 | int x = 1 << i; |
twisti@1210 | 75 | testclass(classname, x); |
twisti@1210 | 76 | } |
twisti@1210 | 77 | |
twisti@1210 | 78 | |
twisti@1210 | 79 | // long |
twisti@1210 | 80 | |
twisti@1210 | 81 | // Test corner cases. |
twisti@1210 | 82 | for (int i = 0; i < ia.length; i++) { |
twisti@1210 | 83 | long x = la[i]; |
twisti@1210 | 84 | check(x, lzcomp(x), lzint(x)); |
twisti@1210 | 85 | } |
twisti@1210 | 86 | |
twisti@1210 | 87 | // Test all possible return values. |
twisti@1210 | 88 | for (int i = 0; i < Long.SIZE; i++) { |
twisti@1210 | 89 | long x = 1L << i; |
twisti@1210 | 90 | check(x, lzcomp(x), lzint(x)); |
twisti@1210 | 91 | } |
twisti@1210 | 92 | |
twisti@1210 | 93 | classname = "Test6823354$lzconL"; |
twisti@1210 | 94 | |
twisti@1210 | 95 | // Test Ideal optimizations (constant values). |
twisti@1210 | 96 | for (int i = 0; i < la.length; i++) { |
twisti@1210 | 97 | testclass(classname, la[i]); |
twisti@1210 | 98 | } |
twisti@1210 | 99 | |
twisti@1210 | 100 | // Test Ideal optimizations (constant values). |
twisti@1210 | 101 | for (int i = 0; i < Long.SIZE; i++) { |
twisti@1210 | 102 | long x = 1L << i; |
twisti@1210 | 103 | testclass(classname, x); |
twisti@1210 | 104 | } |
twisti@1210 | 105 | } |
twisti@1210 | 106 | |
twisti@1210 | 107 | static void tz() throws Exception { |
twisti@1210 | 108 | // int |
twisti@1210 | 109 | |
twisti@1210 | 110 | // Test corner cases. |
twisti@1210 | 111 | for (int i = 0; i < ia.length; i++) { |
twisti@1210 | 112 | int x = ia[i]; |
twisti@1210 | 113 | check(x, tzcomp(x), tzint(x)); |
twisti@1210 | 114 | } |
twisti@1210 | 115 | |
twisti@1210 | 116 | // Test all possible return values. |
twisti@1210 | 117 | for (int i = 0; i < Integer.SIZE; i++) { |
twisti@1210 | 118 | int x = 1 << i; |
twisti@1210 | 119 | check(x, tzcomp(x), tzint(x)); |
twisti@1210 | 120 | } |
twisti@1210 | 121 | |
twisti@1210 | 122 | String classname = "Test6823354$tzconI"; |
twisti@1210 | 123 | |
twisti@1210 | 124 | // Test Ideal optimizations (constant values). |
twisti@1210 | 125 | for (int i = 0; i < ia.length; i++) { |
twisti@1210 | 126 | testclass(classname, ia[i]); |
twisti@1210 | 127 | } |
twisti@1210 | 128 | |
twisti@1210 | 129 | // Test Ideal optimizations (constant values). |
twisti@1210 | 130 | for (int i = 0; i < Integer.SIZE; i++) { |
twisti@1210 | 131 | int x = 1 << i; |
twisti@1210 | 132 | testclass(classname, x); |
twisti@1210 | 133 | } |
twisti@1210 | 134 | |
twisti@1210 | 135 | |
twisti@1210 | 136 | // long |
twisti@1210 | 137 | |
twisti@1210 | 138 | // Test corner cases. |
twisti@1210 | 139 | for (int i = 0; i < la.length; i++) { |
twisti@1210 | 140 | long x = la[i]; |
twisti@1210 | 141 | check(x, tzcomp(x), tzint(x)); |
twisti@1210 | 142 | } |
twisti@1210 | 143 | |
twisti@1210 | 144 | // Test all possible return values. |
twisti@1210 | 145 | for (int i = 0; i < Long.SIZE; i++) { |
twisti@1210 | 146 | long x = 1L << i; |
twisti@1210 | 147 | check(x, tzcomp(x), tzint(x)); |
twisti@1210 | 148 | } |
twisti@1210 | 149 | |
twisti@1210 | 150 | classname = "Test6823354$tzconL"; |
twisti@1210 | 151 | |
twisti@1210 | 152 | // Test Ideal optimizations (constant values). |
twisti@1210 | 153 | for (int i = 0; i < la.length; i++) { |
twisti@1210 | 154 | testclass(classname, la[i]); |
twisti@1210 | 155 | } |
twisti@1210 | 156 | |
twisti@1210 | 157 | // Test Ideal optimizations (constant values). |
twisti@1210 | 158 | for (int i = 0; i < Long.SIZE; i++) { |
twisti@1210 | 159 | long x = 1L << i; |
twisti@1210 | 160 | testclass(classname, x); |
twisti@1210 | 161 | } |
twisti@1210 | 162 | } |
twisti@1210 | 163 | |
twisti@1210 | 164 | static void check(int value, int result, int expected) { |
twisti@1210 | 165 | //System.out.println(value + ": " + result + ", " + expected); |
twisti@1210 | 166 | if (result != expected) |
twisti@1210 | 167 | throw new InternalError(value + " failed: " + result + " != " + expected); |
twisti@1210 | 168 | } |
twisti@1210 | 169 | |
twisti@1210 | 170 | static void check(long value, long result, long expected) { |
twisti@1210 | 171 | //System.out.println(value + ": " + result + ", " + expected); |
twisti@1210 | 172 | if (result != expected) |
twisti@1210 | 173 | throw new InternalError(value + " failed: " + result + " != " + expected); |
twisti@1210 | 174 | } |
twisti@1210 | 175 | |
twisti@1210 | 176 | static int lzint( int i) { return Integer.numberOfLeadingZeros(i); } |
twisti@1210 | 177 | static int lzcomp(int i) { return Integer.numberOfLeadingZeros(i); } |
twisti@1210 | 178 | |
twisti@1210 | 179 | static int lzint( long l) { return Long.numberOfLeadingZeros(l); } |
twisti@1210 | 180 | static int lzcomp(long l) { return Long.numberOfLeadingZeros(l); } |
twisti@1210 | 181 | |
twisti@1210 | 182 | static int tzint( int i) { return Integer.numberOfTrailingZeros(i); } |
twisti@1210 | 183 | static int tzcomp(int i) { return Integer.numberOfTrailingZeros(i); } |
twisti@1210 | 184 | |
twisti@1210 | 185 | static int tzint( long l) { return Long.numberOfTrailingZeros(l); } |
twisti@1210 | 186 | static int tzcomp(long l) { return Long.numberOfTrailingZeros(l); } |
twisti@1210 | 187 | |
twisti@1210 | 188 | static void testclass(String classname, int x) throws Exception { |
twisti@1210 | 189 | System.setProperty("value", "" + x); |
twisti@1210 | 190 | loadandrunclass(classname); |
twisti@1210 | 191 | } |
twisti@1210 | 192 | |
twisti@1210 | 193 | static void testclass(String classname, long x) throws Exception { |
twisti@1210 | 194 | System.setProperty("value", "" + x); |
twisti@1210 | 195 | loadandrunclass(classname); |
twisti@1210 | 196 | } |
twisti@1210 | 197 | |
twisti@1210 | 198 | static void loadandrunclass(String classname) throws Exception { |
twisti@1210 | 199 | Class cl = Class.forName(classname); |
twisti@1210 | 200 | URLClassLoader apploader = (URLClassLoader) cl.getClassLoader(); |
twisti@1210 | 201 | ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent()); |
twisti@1210 | 202 | Class c = loader.loadClass(classname); |
twisti@1210 | 203 | Runnable r = (Runnable) c.newInstance(); |
twisti@1210 | 204 | r.run(); |
twisti@1210 | 205 | } |
twisti@1210 | 206 | |
twisti@1210 | 207 | public static class lzconI implements Runnable { |
twisti@1210 | 208 | static final int VALUE; |
twisti@1210 | 209 | |
twisti@1210 | 210 | static { |
twisti@1210 | 211 | int value = 0; |
twisti@1210 | 212 | try { |
twisti@1210 | 213 | value = Integer.decode(System.getProperty("value")); |
twisti@1210 | 214 | } catch (Throwable e) {} |
twisti@1210 | 215 | VALUE = value; |
twisti@1210 | 216 | } |
twisti@1210 | 217 | |
twisti@1210 | 218 | public void run() { check(VALUE, lzint(VALUE), dolzcomp()); } |
twisti@1210 | 219 | static int dolzcomp() { return lzcomp(VALUE); } |
twisti@1210 | 220 | } |
twisti@1210 | 221 | |
twisti@1210 | 222 | public static class lzconL implements Runnable { |
twisti@1210 | 223 | static final long VALUE; |
twisti@1210 | 224 | |
twisti@1210 | 225 | static { |
twisti@1210 | 226 | long value = 0; |
twisti@1210 | 227 | try { |
twisti@1210 | 228 | value = Long.decode(System.getProperty("value")); |
twisti@1210 | 229 | } catch (Throwable e) {} |
twisti@1210 | 230 | VALUE = value; |
twisti@1210 | 231 | } |
twisti@1210 | 232 | |
twisti@1210 | 233 | public void run() { check(VALUE, lzint(VALUE), dolzcomp()); } |
twisti@1210 | 234 | static int dolzcomp() { return lzcomp(VALUE); } |
twisti@1210 | 235 | } |
twisti@1210 | 236 | |
twisti@1210 | 237 | public static class tzconI implements Runnable { |
twisti@1210 | 238 | static final int VALUE; |
twisti@1210 | 239 | |
twisti@1210 | 240 | static { |
twisti@1210 | 241 | int value = 0; |
twisti@1210 | 242 | try { |
twisti@1210 | 243 | value = Integer.decode(System.getProperty("value")); |
twisti@1210 | 244 | } catch (Throwable e) {} |
twisti@1210 | 245 | VALUE = value; |
twisti@1210 | 246 | } |
twisti@1210 | 247 | |
twisti@1210 | 248 | public void run() { check(VALUE, tzint(VALUE), dotzcomp()); } |
twisti@1210 | 249 | static int dotzcomp() { return tzcomp(VALUE); } |
twisti@1210 | 250 | } |
twisti@1210 | 251 | |
twisti@1210 | 252 | public static class tzconL implements Runnable { |
twisti@1210 | 253 | static final long VALUE; |
twisti@1210 | 254 | |
twisti@1210 | 255 | static { |
twisti@1210 | 256 | long value = 0; |
twisti@1210 | 257 | try { |
twisti@1210 | 258 | value = Long.decode(System.getProperty("value")); |
twisti@1210 | 259 | } catch (Throwable e) {} |
twisti@1210 | 260 | VALUE = value; |
twisti@1210 | 261 | } |
twisti@1210 | 262 | |
twisti@1210 | 263 | public void run() { check(VALUE, tzint(VALUE), dotzcomp()); } |
twisti@1210 | 264 | static int dotzcomp() { return tzcomp(VALUE); } |
twisti@1210 | 265 | } |
twisti@1210 | 266 | } |