1 /* 2 * Copyright (c) 2009, 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 6891750 28 * @summary deopt blob kills values in O5 29 * @run main compiler.runtime.cr6891750.Test6891750 30 */ 31 32 package compiler.runtime.cr6891750; 33 34 abstract class Base6891750 extends Thread { 35 abstract public long m(); 36 } 37 class Other6891750 extends Base6891750 { 38 public long m() { 39 return 0; 40 } 41 } 42 43 public class Test6891750 extends Base6891750 { 44 Base6891750 d; 45 volatile long value = 9; 46 47 static int limit = 400000; 48 49 Test6891750() { 50 d = this; 51 52 } 53 public long m() { 54 return value; 55 } 56 57 public long test(boolean doit) { 58 if (doit) { 59 long total0 = 0; 60 long total1 = 0; 61 long total2 = 0; 62 long total3 = 0; 63 long total4 = 0; 64 long total5 = 0; 65 long total6 = 0; 66 long total7 = 0; 67 long total8 = 0; 68 long total9 = 0; 69 for (int i = 0; i < limit; i++) { 70 total0 += d.m(); 71 total1 += d.m(); 72 total2 += d.m(); 73 total3 += d.m(); 74 total4 += d.m(); 75 total5 += d.m(); 76 total6 += d.m(); 77 total7 += d.m(); 78 total8 += d.m(); 79 total9 += d.m(); 80 } 81 return total0 + total1 + total2 + total3 + total4 + total5 + total6 + total7 + total8 + total9; 82 } 83 return 0; 84 } 85 86 public void run() { 87 long result = test(true); 88 for (int i = 0; i < 300; i++) { 89 long result2 = test(true); 90 if (result != result2) { 91 throw new InternalError(result + " != " + result2); 92 } 93 } 94 } 95 96 public static void main(String[] args) throws Exception { 97 Test6891750 Test6891750 = new Test6891750(); 98 // warm it up 99 for (int i = 0; i < 200000; i++) { 100 Test6891750.test(false); 101 } 102 // set in off running 103 Test6891750.start(); 104 Thread.sleep(2000); 105 106 // Load a class to invalidate CHA 107 new Other6891750(); 108 } 109 }