25 /**
26 * @test
27 * @bug 8136421
28 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
29 * @library /testlibrary /../../test/lib /
30 * @clean compiler.jvmci.compilerToVM.*
31 * @compile -g DummyInterface.java
32 * @compile -g DummyAbstractClass.java
33 * @compile -g DummyClass.java
34 * @compile ../common/CompilerToVMHelper.java
35 * @run main ClassFileInstaller jdk.vm.ci.hotspot.CompilerToVMHelper
36 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
37 * -Xbootclasspath/a:.
38 * compiler.jvmci.compilerToVM.GetLocalVariableTableTest
39 * @clean compiler.jvmci.compilerToVM.*
40 */
41
42 package compiler.jvmci.compilerToVM;
43
44 import compiler.jvmci.common.CTVMUtilities;
45 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethodImpl;
46 import jdk.vm.ci.hotspot.CompilerToVMHelper;
47 import jdk.test.lib.Asserts;
48
49 import java.lang.reflect.Executable;
50 import java.util.HashMap;
51 import java.util.Map;
52
53 public class GetLocalVariableTableTest {
54
55 public static final int MAIN_LOCALS_COUNT = 0;
56 public static final int INSTANCE_LOCALS_COUNT = 4;
57 public static final int EMPTY_INSTANCE_COUNT = 1;
58 public static final int EMPTY_STATIC_COUNT = 0;
59 public static final int ABSTRACT_INHERIT_LOCALS_COUNT = 2;
60 public static final int DEFAULTFUNC_LOCALS_COUNT = 4;
61
62 public static void main(String[] args) {
63 Map<Executable, Integer> testCases = createTestCases();
64 testCases.forEach(GetLocalVariableTableTest::runSanityTest);
65 }
83 methods.put(aClass.getMethod("dummyFunction"),
84 EMPTY_INSTANCE_COUNT);
85 methods.put(aClass.getMethod("dummyAbstractFunction"),
86 ABSTRACT_INHERIT_LOCALS_COUNT);
87
88 aClass = DummyInterface.class;
89 methods.put(aClass.getMethod("dummyFunction"), EMPTY_STATIC_COUNT);
90 methods.put(aClass.getMethod("dummyDefaultFunction", int.class,
91 int.class), DEFAULTFUNC_LOCALS_COUNT);
92
93 aClass = DummyAbstractClass.class;
94 methods.put(aClass.getMethod("dummyAbstractFunction"), 0);
95 } catch (NoSuchMethodException e) {
96 throw new Error("TEST BUG", e);
97 }
98 return methods;
99 }
100
101 private static void runSanityTest(Executable aMethod,
102 Integer expectedTableLength) {
103 HotSpotResolvedJavaMethodImpl method = CTVMUtilities
104 .getResolvedMethod(aMethod);
105
106 int tblLength = CompilerToVMHelper.getLocalVariableTableLength(method);
107 Asserts.assertEQ(tblLength, expectedTableLength, aMethod + " : incorrect "
108 + "local variable table length.");
109
110 long tblStart = CompilerToVMHelper.getLocalVariableTableStart(method);
111 if (tblLength > 0) {
112 Asserts.assertNE(tblStart, 0L, aMethod + " : local variable table starts"
113 + " at 0 with length " + tblLength);
114 }
115 }
116 }
|
25 /**
26 * @test
27 * @bug 8136421
28 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9") & os.arch != "aarch64"
29 * @library /testlibrary /../../test/lib /
30 * @clean compiler.jvmci.compilerToVM.*
31 * @compile -g DummyInterface.java
32 * @compile -g DummyAbstractClass.java
33 * @compile -g DummyClass.java
34 * @compile ../common/CompilerToVMHelper.java
35 * @run main ClassFileInstaller jdk.vm.ci.hotspot.CompilerToVMHelper
36 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
37 * -Xbootclasspath/a:.
38 * compiler.jvmci.compilerToVM.GetLocalVariableTableTest
39 * @clean compiler.jvmci.compilerToVM.*
40 */
41
42 package compiler.jvmci.compilerToVM;
43
44 import compiler.jvmci.common.CTVMUtilities;
45 import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
46 import jdk.vm.ci.hotspot.CompilerToVMHelper;
47 import jdk.test.lib.Asserts;
48
49 import java.lang.reflect.Executable;
50 import java.util.HashMap;
51 import java.util.Map;
52
53 public class GetLocalVariableTableTest {
54
55 public static final int MAIN_LOCALS_COUNT = 0;
56 public static final int INSTANCE_LOCALS_COUNT = 4;
57 public static final int EMPTY_INSTANCE_COUNT = 1;
58 public static final int EMPTY_STATIC_COUNT = 0;
59 public static final int ABSTRACT_INHERIT_LOCALS_COUNT = 2;
60 public static final int DEFAULTFUNC_LOCALS_COUNT = 4;
61
62 public static void main(String[] args) {
63 Map<Executable, Integer> testCases = createTestCases();
64 testCases.forEach(GetLocalVariableTableTest::runSanityTest);
65 }
83 methods.put(aClass.getMethod("dummyFunction"),
84 EMPTY_INSTANCE_COUNT);
85 methods.put(aClass.getMethod("dummyAbstractFunction"),
86 ABSTRACT_INHERIT_LOCALS_COUNT);
87
88 aClass = DummyInterface.class;
89 methods.put(aClass.getMethod("dummyFunction"), EMPTY_STATIC_COUNT);
90 methods.put(aClass.getMethod("dummyDefaultFunction", int.class,
91 int.class), DEFAULTFUNC_LOCALS_COUNT);
92
93 aClass = DummyAbstractClass.class;
94 methods.put(aClass.getMethod("dummyAbstractFunction"), 0);
95 } catch (NoSuchMethodException e) {
96 throw new Error("TEST BUG", e);
97 }
98 return methods;
99 }
100
101 private static void runSanityTest(Executable aMethod,
102 Integer expectedTableLength) {
103 HotSpotResolvedJavaMethod method = CTVMUtilities
104 .getResolvedMethod(aMethod);
105
106 int tblLength = CompilerToVMHelper.getLocalVariableTableLength(method);
107 Asserts.assertEQ(tblLength, expectedTableLength, aMethod + " : incorrect "
108 + "local variable table length.");
109
110 long tblStart = CompilerToVMHelper.getLocalVariableTableStart(method);
111 if (tblLength > 0) {
112 Asserts.assertNE(tblStart, 0L, aMethod + " : local variable table starts"
113 + " at 0 with length " + tblLength);
114 }
115 }
116 }
|