1 /* 2 * Copyright (c) 2016, 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 * @test 26 * @bug 8156034 27 * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") 28 * @library / /testlibrary 29 * @library ../common/patches 30 * @modules java.base/jdk.internal.misc 31 * java.base/jdk.internal.org.objectweb.asm 32 * java.base/jdk.internal.org.objectweb.asm.tree 33 * jdk.vm.ci/jdk.vm.ci.hotspot 34 * jdk.vm.ci/jdk.vm.ci.code 35 * jdk.vm.ci/jdk.vm.ci.meta 36 * jdk.vm.ci/jdk.vm.ci.runtime 37 * 38 * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper 39 * @build compiler.jvmci.common.JVMCIHelpers 40 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 41 * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/ 42 * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyBootstrapFinishedEventTest.config 43 * ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener 44 * @run driver ClassFileInstaller 45 * compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler 46 * compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory 47 * compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult 48 * compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener 49 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 50 * jdk.test.lib.Asserts 51 * jdk.test.lib.Utils 52 * @run main/othervm -XX:+UnlockExperimentalVMOptions 53 * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. 54 * -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI 55 * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=false 56 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 57 * @run main/othervm -XX:+UnlockExperimentalVMOptions 58 * -Djvmci.Compiler=EmptyCompiler -Xbootclasspath/a:. 59 * -XX:+UseJVMCICompiler -XX:+BootstrapJVMCI 60 * -Dcompiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap=true 61 * compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest 62 */ 63 64 package compiler.jvmci.events; 65 66 import jdk.test.lib.Asserts; 67 import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; 68 69 public class JvmciNotifyBootstrapFinishedEventTest extends HotSpotVMEventListener { 70 private static final boolean BOOTSTRAP = Boolean 71 .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap"); 72 private static volatile int gotBoostrapNotification = 0; 73 74 public static void main(String args[]) { 75 if (BOOTSTRAP) { 76 Asserts.assertEQ(gotBoostrapNotification, 1, "Did not receive expected number of bootstrap events"); 77 } else { 78 Asserts.assertEQ(gotBoostrapNotification, 0, "Got unexpected bootstrap event"); 79 } 80 } 81 82 @Override 83 public void notifyBootstrapFinished() { 84 gotBoostrapNotification++; 85 } 86 }