test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReadConfigurationTest.java
author kvn
Wed, 01 May 2019 12:31:29 -0700
changeset 54669 ad45b3802d4e
parent 47216 71c04702a3d5
child 55206 2fe2063fe567
permissions -rw-r--r--
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library Reviewed-by: dnsimon, never, stefank, rehn, neliasso, dholmes, kbarrett, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     1
/*
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     4
 *
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     8
 *
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    13
 * accompanied this code).
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    14
 *
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    18
 *
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    21
 * questions.
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    22
 */
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    23
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    24
/*
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    25
 * @test
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    26
 * @bug 8136421
42607
acd91f1875d4 8170227: use vm.jvmci property in compiler/jvmci tests
iignatyev
parents: 40878
diff changeset
    27
 * @requires vm.jvmci
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    28
 * @library / /test/lib
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    29
 * @library ../common/patches
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    30
 * @modules java.base/jdk.internal.misc
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 43962
diff changeset
    31
 * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 43962
diff changeset
    32
 * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    33
 * @build compiler.jvmci.compilerToVM.ReadConfigurationTest
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    34
 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
44836
45196b7066e3 8177845: Need a mechanism to load Graal
dnsimon
parents: 43972
diff changeset
    35
 *                   -Djvmci.Compiler=null
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    36
 *                   compiler.jvmci.compilerToVM.ReadConfigurationTest
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    37
 */
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    38
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    39
package compiler.jvmci.compilerToVM;
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    40
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    41
import jdk.test.lib.Asserts;
43962
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    42
import jdk.vm.ci.hotspot.VMField;
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    43
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    44
import jdk.vm.ci.hotspot.HotSpotVMConfigAccess;
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    45
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    46
import jdk.vm.ci.hotspot.VMIntrinsicMethod;
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    47
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    48
public class ReadConfigurationTest {
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    49
    public static void main(String args[]) {
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    50
        new ReadConfigurationTest().runTest();
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    51
    }
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    52
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    53
    private void runTest() {
43962
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    54
        HotSpotVMConfigStore store = HotSpotJVMCIRuntime.runtime().getConfigStore();
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    55
        TestHotSpotVMConfig config = new TestHotSpotVMConfig(store);
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    56
        Asserts.assertNE(config.codeCacheHighBound, 0L, "Got null address");
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    57
        Asserts.assertNE(config.stubRoutineJintArrayCopy, 0L, "Got null address");
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    58
43962
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    59
        for (VMField field : store.getFields().values()) {
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    60
                Object value = field.value;
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    61
                if (value != null) {
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    62
                    Asserts.assertTrue(value instanceof Long || value instanceof Boolean,
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    63
                        "Got unexpected value type for VM field " + field.name + ": " + value.getClass());
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    64
                }
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    65
        }
8d1c5fdcdf76 8174957: [JVMCI] jaotc is broken in Xcomp mode
dnsimon
parents: 42607
diff changeset
    66
40878
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    67
        for (VMIntrinsicMethod m : config.getStore().getIntrinsics()) {
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    68
            Asserts.assertNotNull(m);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    69
            Asserts.assertNotNull(m.declaringClass);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    70
            Asserts.assertFalse(m.declaringClass.contains("."),
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    71
                "declaringClass should be in class file format: " + m.declaringClass);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    72
            Asserts.assertNotNull(m.name);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    73
            Asserts.assertNotNull(m.descriptor);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    74
            Asserts.assertTrue(m.id > 0);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    75
        }
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    76
    }
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    77
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    78
    private static class TestHotSpotVMConfig extends HotSpotVMConfigAccess {
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    79
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    80
        private TestHotSpotVMConfig(HotSpotVMConfigStore store) {
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    81
            super(store);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    82
        }
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    83
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    84
        final long codeCacheHighBound = getFieldValue("CodeCache::_high_bound", Long.class);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    85
        final long stubRoutineJintArrayCopy = getFieldValue("StubRoutines::_jint_arraycopy", Long.class);
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    86
    }
5d87104b10d5 8164358: [JVMCI] expose Hotspot intrinsics and HotSpotIntrinsicCandidate info to JVMCI
dnsimon
parents:
diff changeset
    87
}