Wed, 21 May 2014 10:56:41 -0700
Added tag jdk8u20-b15 for changeset 8c785f9bde6f
kvn@1688 | 1 | /* |
trims@1907 | 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
kvn@1688 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
kvn@1688 | 4 | * |
kvn@1688 | 5 | * This code is free software; you can redistribute it and/or modify it |
kvn@1688 | 6 | * under the terms of the GNU General Public License version 2 only, as |
kvn@1688 | 7 | * published by the Free Software Foundation. |
kvn@1688 | 8 | * |
kvn@1688 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
kvn@1688 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
kvn@1688 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
kvn@1688 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
kvn@1688 | 13 | * accompanied this code). |
kvn@1688 | 14 | * |
kvn@1688 | 15 | * You should have received a copy of the GNU General Public License version |
kvn@1688 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
kvn@1688 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
kvn@1688 | 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. |
kvn@1688 | 22 | * |
kvn@1688 | 23 | */ |
kvn@1688 | 24 | |
kvn@1688 | 25 | /** |
kvn@1688 | 26 | * @test |
kvn@1688 | 27 | * @bug 6910605 |
kvn@1688 | 28 | * @summary C2: NullPointerException/ClassCaseException is thrown when C2 with DeoptimizeALot is used |
kvn@1688 | 29 | * |
kvn@1688 | 30 | * @run main/othervm -Xmx64m -XX:+IgnoreUnrecognizedVMOptions -XX:+DeoptimizeALot -XX:+DoEscapeAnalysis -Xbatch -XX:InlineSmallCode=2000 Test |
kvn@1688 | 31 | * |
kvn@1688 | 32 | */ |
kvn@1688 | 33 | |
kvn@1688 | 34 | /* |
kvn@1688 | 35 | * Added InlineSmallCode=2000 to guaranty inlining of StringBuilder::append() to allow scalar replace StringBuilder object. |
kvn@1688 | 36 | * |
kvn@1688 | 37 | * original test: gc/gctests/StringGC |
kvn@1688 | 38 | */ |
kvn@1688 | 39 | |
kvn@1688 | 40 | public class Test { |
kvn@1688 | 41 | private final String toAdd = "0123456789abcdef"; |
kvn@1688 | 42 | private int maxLength; |
kvn@1688 | 43 | private static final int numberOfThreads = 8; |
kvn@1688 | 44 | |
kvn@1688 | 45 | private class StringAdder extends Thread { |
kvn@1688 | 46 | private String s; |
kvn@1688 | 47 | |
kvn@1688 | 48 | public void test() { |
kvn@1688 | 49 | s = s + toAdd; |
kvn@1688 | 50 | } |
kvn@1688 | 51 | public void run() { |
kvn@1688 | 52 | do { |
kvn@1688 | 53 | test(); |
kvn@1688 | 54 | } while (s.length() < maxLength); |
kvn@1688 | 55 | } |
kvn@1688 | 56 | } |
kvn@1688 | 57 | |
kvn@1688 | 58 | public void test() throws InterruptedException { |
kvn@1688 | 59 | maxLength = toAdd.length() * 15000/ numberOfThreads; |
kvn@1688 | 60 | StringAdder[] sa = new StringAdder[numberOfThreads]; |
kvn@1688 | 61 | for (int i = 0; i < numberOfThreads; i++) { |
kvn@1688 | 62 | sa[i] = new StringAdder(); |
kvn@1688 | 63 | sa[i].start(); |
kvn@1688 | 64 | } |
kvn@1688 | 65 | for (int i = 0; i < numberOfThreads; i++) { |
kvn@1688 | 66 | sa[i].join(); |
kvn@1688 | 67 | } |
kvn@1688 | 68 | } |
kvn@1688 | 69 | |
kvn@1688 | 70 | public static void main(String[] args) throws InterruptedException { |
kvn@1688 | 71 | Test t = new Test(); |
kvn@1688 | 72 | t.test(); |
kvn@1688 | 73 | } |
kvn@1688 | 74 | } |