hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java
author dnsimon
Mon, 11 Jul 2016 19:15:21 +0000
changeset 40055 34d785a46283
parent 40053 b3617982544e
child 40059 c2304140ed64
permissions -rw-r--r--
8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler Reviewed-by: kvn, twisti, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
/*
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    25
 * @test
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
 * @bug 8136421
39291
a4efe145313d 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 38152
diff changeset
    27
 * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    28
 * @library / /testlibrary
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    29
 * @library ../common/patches
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 37285
diff changeset
    30
 * @modules java.base/jdk.internal.misc
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    31
 * @modules java.base/jdk.internal.org.objectweb.asm
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    32
 *          java.base/jdk.internal.org.objectweb.asm.tree
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    33
 *          jdk.vm.ci/jdk.vm.ci.hotspot
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    34
 *          jdk.vm.ci/jdk.vm.ci.code
40055
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    35
 *          jdk.vm.ci/jdk.vm.ci.code.site
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    36
 *          jdk.vm.ci/jdk.vm.ci.meta
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    37
 *          jdk.vm.ci/jdk.vm.ci.runtime
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    38
 *
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35823
diff changeset
    39
 * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    40
 * @build compiler.jvmci.common.JVMCIHelpers
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
 *     compiler.jvmci.events.JvmciNotifyInstallEventTest
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    42
 * @run driver jdk.test.lib.FileInstaller ../common/services/ ./META-INF/services/
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    43
 * @run driver jdk.test.lib.FileInstaller ./JvmciNotifyInstallEventTest.config
40055
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    44
 *     ./META-INF/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    45
 * @run driver ClassFileInstaller
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    46
 *      compiler.jvmci.common.JVMCIHelpers$EmptyHotspotCompiler
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    47
 *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilerFactory
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    48
 *      compiler.jvmci.common.JVMCIHelpers$EmptyCompilationRequestResult
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    49
 *       compiler.jvmci.common.JVMCIHelpers$EmptyVMEventListener
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    50
 *      compiler.jvmci.events.JvmciNotifyInstallEventTest
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    51
 *      compiler.jvmci.common.CTVMUtilities
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    52
 *      compiler.jvmci.common.testcases.SimpleClass
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    53
 *      jdk.test.lib.Asserts
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 40034
diff changeset
    54
 *      jdk.test.lib.Utils
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    55
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
40055
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    56
 *     -Xbootclasspath/a:. -Xmixed
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    57
 *     -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    58
 *     -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=false
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    59
 *     compiler.jvmci.events.JvmciNotifyInstallEventTest
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    60
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
 *     -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
 *     -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    63
 *     -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=false
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    64
 *     compiler.jvmci.events.JvmciNotifyInstallEventTest
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    65
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    66
 *     -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    67
 *     -XX:+UseJVMCICompiler -XX:-BootstrapJVMCI -XX:JVMCINMethodSizeLimit=0
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    68
 *     -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=false
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    69
 *     compiler.jvmci.events.JvmciNotifyInstallEventTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    70
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:-EnableJVMCI
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    71
 *     -Djvmci.compiler=EmptyCompiler -Xbootclasspath/a:. -Xmixed
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    72
 *     -Dcompiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit=true
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    73
 *     compiler.jvmci.events.JvmciNotifyInstallEventTest
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    74
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    75
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    76
package compiler.jvmci.events;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    77
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    78
import compiler.jvmci.common.CTVMUtilities;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    79
import compiler.jvmci.common.testcases.SimpleClass;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    80
import jdk.test.lib.Asserts;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    81
import java.lang.reflect.Method;
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    82
import jdk.test.lib.Utils;
40055
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    83
import jdk.vm.ci.hotspot.services.HotSpotVMEventListener;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    84
import jdk.vm.ci.code.CompiledCode;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    85
import jdk.vm.ci.code.InstalledCode;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    86
import jdk.vm.ci.code.site.DataPatch;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    87
import jdk.vm.ci.code.site.Site;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    88
import jdk.vm.ci.meta.Assumptions.Assumption;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    89
import jdk.vm.ci.meta.ResolvedJavaMethod;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    90
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    91
import jdk.vm.ci.hotspot.HotSpotCompiledCode;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
    92
import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    93
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
    94
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
40055
34d785a46283 8160730: [JVMCI] compiler selection should work without -Djvmci.Compiler
dnsimon
parents: 40053
diff changeset
    96
public class JvmciNotifyInstallEventTest extends HotSpotVMEventListener {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
    private static final String METHOD_NAME = "testMethod";
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    98
    private static final boolean FAIL_ON_INIT = !Boolean.getBoolean(
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
    99
            "compiler.jvmci.events.JvmciNotifyInstallEventTest.failoninit");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   100
    private static volatile int gotInstallNotification = 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   101
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   102
    public static void main(String args[]) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   103
        new JvmciNotifyInstallEventTest().runTest();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   104
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   105
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   106
    private void runTest() {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   107
        if (gotInstallNotification != 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   108
            throw new Error("Got install notification before test actions");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   109
        }
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   110
        HotSpotCodeCacheProvider codeCache;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
        try {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   112
            codeCache = (HotSpotCodeCacheProvider) HotSpotJVMCIRuntime.runtime()
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   113
                    .getHostJVMCIBackend().getCodeCache();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   114
        } catch (InternalError ie) {
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   115
            if (FAIL_ON_INIT) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   116
                throw new AssertionError(
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   117
                        "Got unexpected InternalError trying to get code cache",
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   118
                        ie);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   119
            }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   120
            // passed
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   121
            return;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   122
        }
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   123
        Asserts.assertTrue(FAIL_ON_INIT,
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   124
                    "Haven't caught InternalError in negative case");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   125
        Method testMethod;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   126
        try {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   127
            testMethod = SimpleClass.class.getDeclaredMethod(METHOD_NAME);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   128
        } catch (NoSuchMethodException e) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   129
            throw new Error("TEST BUG: Can't find " + METHOD_NAME, e);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   130
        }
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33160
diff changeset
   131
        HotSpotResolvedJavaMethod method = CTVMUtilities
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   132
                .getResolvedMethod(SimpleClass.class, testMethod);
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   133
        HotSpotCompiledCode compiledCode = new HotSpotCompiledCode(METHOD_NAME,
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   134
                new byte[0], 0, new Site[0], new Assumption[0],
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   135
                new ResolvedJavaMethod[]{method}, new Comment[0], new byte[0],
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   136
                16, new DataPatch[0], false, 0, null);
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   137
        codeCache.installCode(method, compiledCode, /* installedCode = */ null,
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   138
                /* speculationLog = */ null, /* isDefault = */ false);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   139
        Asserts.assertEQ(gotInstallNotification, 1,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   140
                "Got unexpected event count after 1st install attempt");
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   141
        // since "empty" compilation result is ok, a second attempt should be ok
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   142
        codeCache.installCode(method, compiledCode, /* installedCode = */ null,
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   143
                /* speculationLog = */ null, /* isDefault = */ false);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   144
        Asserts.assertEQ(gotInstallNotification, 2,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   145
                "Got unexpected event count after 2nd install attempt");
37285
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   146
        // and an incorrect cases
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   147
        Utils.runAndCheckException(() -> {
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   148
            codeCache.installCode(method, null, null, null, true);
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   149
        }, NullPointerException.class);
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   150
        Asserts.assertEQ(gotInstallNotification, 2,
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   151
                "Got unexpected event count after 3rd install attempt");
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   152
        Utils.runAndCheckException(() -> {
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   153
            codeCache.installCode(null, null, null, null, true);
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   154
        }, NullPointerException.class);
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   155
        Asserts.assertEQ(gotInstallNotification, 2,
0473a5a36212 8138798: improve tests for HotSpotVMEventListener::notifyInstall
dpochepk
parents: 36508
diff changeset
   156
                "Got unexpected event count after 4th install attempt");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   157
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   158
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   159
    @Override
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   160
    public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider,
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35148
diff changeset
   161
            InstalledCode installedCode, CompiledCode compiledCode) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   162
        gotInstallNotification++;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   163
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   164
}