--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java Sat Feb 20 11:44:14 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestCase.java Sat Feb 20 11:49:02 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,118 +27,214 @@
import java.util.HashMap;
import java.util.Map;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
-import jdk.internal.misc.SharedSecrets;
+import sun.hotspot.WhiteBox;
import sun.reflect.ConstantPool;
+import sun.reflect.ConstantPool.Tag;
+import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses;
+import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.*;
/**
* Common class for jdk.vm.ci.hotspot.CompilerToVM constant pool tests
*/
public class ConstantPoolTestCase {
- private final Map<ConstantPoolTestsHelper.ConstantTypes, Validator> typeTests;
+
+ private static final Map<Tag, ConstantTypes> TAG_TO_TYPE_MAP;
+ static {
+ TAG_TO_TYPE_MAP = new HashMap<>();
+ TAG_TO_TYPE_MAP.put(Tag.CLASS, CONSTANT_CLASS);
+ TAG_TO_TYPE_MAP.put(Tag.FIELDREF, CONSTANT_FIELDREF);
+ TAG_TO_TYPE_MAP.put(Tag.METHODREF, CONSTANT_METHODREF);
+ TAG_TO_TYPE_MAP.put(Tag.INTERFACEMETHODREF, CONSTANT_INTERFACEMETHODREF);
+ TAG_TO_TYPE_MAP.put(Tag.STRING, CONSTANT_STRING);
+ TAG_TO_TYPE_MAP.put(Tag.INTEGER, CONSTANT_INTEGER);
+ TAG_TO_TYPE_MAP.put(Tag.FLOAT, CONSTANT_FLOAT);
+ TAG_TO_TYPE_MAP.put(Tag.LONG, CONSTANT_LONG);
+ TAG_TO_TYPE_MAP.put(Tag.DOUBLE, CONSTANT_DOUBLE);
+ TAG_TO_TYPE_MAP.put(Tag.NAMEANDTYPE, CONSTANT_NAMEANDTYPE);
+ TAG_TO_TYPE_MAP.put(Tag.UTF8, CONSTANT_UTF8);
+ TAG_TO_TYPE_MAP.put(Tag.METHODHANDLE, CONSTANT_METHODHANDLE);
+ TAG_TO_TYPE_MAP.put(Tag.METHODTYPE, CONSTANT_METHODTYPE);
+ TAG_TO_TYPE_MAP.put(Tag.INVOKEDYNAMIC, CONSTANT_INVOKEDYNAMIC);
+ TAG_TO_TYPE_MAP.put(Tag.INVALID, CONSTANT_INVALID);
+ }
+ private static final WhiteBox WB = WhiteBox.getWhiteBox();
+ private final Map<ConstantTypes, Validator> typeTests;
+
+ public static enum ConstantTypes {
+ CONSTANT_CLASS {
+ @Override
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ ConstantPool constantPoolSS = dummyClass.constantPoolSS;
+ checkIndex(constantPoolSS, index);
+ Class<?> klass = constantPoolSS.getClassAt(index);
+ String klassName = klass.getName();
+ TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this);
+ for (TestedCPEntry entry : testedEntries) {
+ if (entry.klass.replaceAll("/", "\\.").equals(klassName)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+ },
+ CONSTANT_FIELDREF {
+ @Override
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ return this.getTestedCPEntryForMethodAndField(dummyClass, index);
+ }
+ },
+ CONSTANT_METHODREF {
+ @Override
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ return this.getTestedCPEntryForMethodAndField(dummyClass, index);
+ }
+ },
+ CONSTANT_INTERFACEMETHODREF {
+ @Override
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ return this.getTestedCPEntryForMethodAndField(dummyClass, index);
+ }
+ },
+ CONSTANT_STRING {
+ @Override
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ ConstantPool constantPoolSS = dummyClass.constantPoolSS;
+ checkIndex(constantPoolSS, index);
+ String value = constantPoolSS.getStringAt(index);
+ TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this);
+ for (TestedCPEntry entry : testedEntries) {
+ if (entry.name.equals(value)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+ },
+ CONSTANT_INTEGER,
+ CONSTANT_FLOAT,
+ CONSTANT_LONG,
+ CONSTANT_DOUBLE,
+ CONSTANT_NAMEANDTYPE,
+ CONSTANT_UTF8,
+ CONSTANT_METHODHANDLE,
+ CONSTANT_METHODTYPE,
+ CONSTANT_INVOKEDYNAMIC {
+ @Override
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ ConstantPool constantPoolSS = dummyClass.constantPoolSS;
+ checkIndex(constantPoolSS, index);
+ int nameAndTypeIndex = constantPoolSS.getNameAndTypeRefIndexAt(index);
+ String[] info = constantPoolSS.getNameAndTypeRefInfoAt(nameAndTypeIndex);
+ TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this);
+ for (TestedCPEntry entry : testedEntries) {
+ if (info[0].equals(entry.name) && info[1].equals(entry.type)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+ },
+ CONSTANT_INVALID;
+
+ public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) {
+ return null; // returning null by default
+ }
+
+ public TestedCPEntry[] getAllCPEntriesForType(DummyClasses dummyClass) {
+ TestedCPEntry[] toReturn = dummyClass.testedCP.get(this);
+ if (toReturn == null) {
+ return new TestedCPEntry[0];
+ }
+ return dummyClass.testedCP.get(this);
+ }
+
+ protected TestedCPEntry getTestedCPEntryForMethodAndField(DummyClasses dummyClass, int index) {
+ ConstantPool constantPoolSS = dummyClass.constantPoolSS;
+ checkIndex(constantPoolSS, index);
+ String[] info = constantPoolSS.getMemberRefInfoAt(index);
+ TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this);
+ for (TestedCPEntry entry : testedEntries) {
+ if (info[0].equals(entry.klass) && info[1].equals(entry.name) && info[2].equals(entry.type)) {
+ return entry;
+ }
+ }
+ return null;
+ }
+
+ protected void checkIndex(ConstantPool constantPoolSS, int index) {
+ ConstantPool.Tag tag = constantPoolSS.getTagAt(index);
+ ConstantTypes type = mapTagToCPType(tag);
+ if (!this.equals(type)) {
+ String msg = String.format("TESTBUG: CP tag should be a %s, but is %s",
+ this.name(),
+ type.name());
+ throw new Error(msg);
+ }
+ }
+ }
public static interface Validator {
void validate(jdk.vm.ci.meta.ConstantPool constantPoolCTVM,
- ConstantPool constantPoolSS,
- ConstantPoolTestsHelper.DummyClasses dummyClass, int index);
+ ConstantTypes cpType,
+ DummyClasses dummyClass,
+ int index);
}
- public ConstantPoolTestCase(Map<ConstantPoolTestsHelper.ConstantTypes,Validator> typeTests) {
+ public static class TestedCPEntry {
+ public final String klass;
+ public final String name;
+ public final String type;
+ public final byte[] opcodes;
+ public final long accFlags;
+
+ public TestedCPEntry(String klass, String name, String type, byte[] opcodes, long accFlags) {
+ this.klass = klass;
+ this.name = name;
+ this.type = type;
+ if (opcodes != null) {
+ this.opcodes = new byte[opcodes.length];
+ System.arraycopy(opcodes, 0, this.opcodes, 0, opcodes.length);
+ } else {
+ this.opcodes = null;
+ }
+ this.accFlags = accFlags;
+ }
+
+ public TestedCPEntry(String klass, String name, String type, byte[] opcodes) {
+ this(klass, name, type, opcodes, 0);
+ }
+
+ public TestedCPEntry(String klass, String name, String type) {
+ this(klass, name, type, null, 0);
+ }
+ }
+
+ public static ConstantTypes mapTagToCPType(Tag tag) {
+ return TAG_TO_TYPE_MAP.get(tag);
+ }
+
+ public ConstantPoolTestCase(Map<ConstantTypes, Validator> typeTests) {
this.typeTests = new HashMap<>();
this.typeTests.putAll(typeTests);
}
- private void messageOnFail(Throwable t,
- ConstantPoolTestsHelper.ConstantTypes cpType,
- ConstantPoolTestsHelper.DummyClasses dummyClass, int index) {
- ConstantPool constantPoolSS = SharedSecrets.getJavaLangAccess().
- getConstantPool(dummyClass.klass);
- String msg = String.format("Test for %s constant pool entry of"
- + " type %s",
- dummyClass.klass, cpType.name());
- switch (cpType) {
- case CONSTANT_CLASS:
- case CONSTANT_STRING:
- case CONSTANT_METHODTYPE:
- String utf8 = constantPoolSS
- .getUTF8At((int) dummyClass.cp.get(index).value);
- msg = String.format("%s (%s) failed with %s", msg, utf8, t);
- break;
- case CONSTANT_INTEGER:
- int intValue = constantPoolSS.getIntAt(index);
- msg = String.format("%s (%d) failed with %s", msg, intValue, t);
- break;
- case CONSTANT_LONG:
- long longValue = constantPoolSS.getLongAt(index);
- msg = String.format("%s (%d) failed with %s", msg, longValue, t);
- break;
- case CONSTANT_FLOAT:
- float floatValue = constantPoolSS.getFloatAt(index);
- msg = String.format("%s (%E) failed with %s", msg, floatValue, t);
- break;
- case CONSTANT_DOUBLE:
- double doubleValue = constantPoolSS.getDoubleAt(index);
- msg = String.format("%s (%E) failed with %s", msg, doubleValue, t);
- break;
- case CONSTANT_UTF8:
- String utf8Value = constantPoolSS.getUTF8At(index);
- msg = String.format("%s (%s) failed with %s", msg, utf8Value, t);
- break;
- case CONSTANT_INVOKEDYNAMIC:
- index = ((int[]) dummyClass.cp.get(index).value)[1];
- case CONSTANT_NAMEANDTYPE:
- String name = constantPoolSS
- .getUTF8At(((int[]) dummyClass.cp.get(index).value)[0]);
- String type = constantPoolSS
- .getUTF8At(((int[]) dummyClass.cp.get(index).value)[1]);
- msg = String.format("%s (%s:%s) failed with %s",
- msg, name, type, t);
- break;
- case CONSTANT_METHODHANDLE:
- index = ((int[]) dummyClass.cp.get(index).value)[1];
- case CONSTANT_METHODREF:
- case CONSTANT_INTERFACEMETHODREF:
- case CONSTANT_FIELDREF:
- int classIndex = ((int[]) dummyClass.cp.get(index).value)[0];
- int nameAndTypeIndex = ((int[]) dummyClass.cp.get(index).value)[1];
- String cName = constantPoolSS
- .getUTF8At((int) dummyClass.cp.get(classIndex).value);
- String mName = constantPoolSS
- .getUTF8At(((int[]) dummyClass.cp.get(nameAndTypeIndex).value)[0]);
- String mType = constantPoolSS
- .getUTF8At(((int[]) dummyClass.cp.get(nameAndTypeIndex).value)[1]);
- msg = String.format("%s (%s.%s:%s) failed with %s ",
- msg, cName, mName, mType, t);
- break;
- default:
- msg = String.format("Test bug: unknown constant type %s ", cpType);
- }
- throw new Error(msg + t.getMessage(), t);
- }
-
public void test() {
- for (ConstantPoolTestsHelper.DummyClasses dummyClass
- : ConstantPoolTestsHelper.DummyClasses.values()) {
- System.out.printf("%nTesting dummy %s%n", dummyClass.klass);
- HotSpotResolvedObjectType holder = HotSpotResolvedObjectType
- .fromObjectClass(dummyClass.klass);
- jdk.vm.ci.meta.ConstantPool constantPoolCTVM
- = holder.getConstantPool();
- ConstantPool constantPoolSS = SharedSecrets.getJavaLangAccess().
- getConstantPool(dummyClass.klass);
- for (Integer i : dummyClass.cp.keySet()) {
- ConstantPoolTestsHelper.ConstantTypes cpType
- = dummyClass.cp.get(i).type;
+ for (DummyClasses dummyClass : DummyClasses.values()) {
+ boolean isCPCached = WB.getConstantPoolCacheLength(dummyClass.klass) > -1;
+ System.out.printf("Testing dummy %s with constant pool cached = %b%n",
+ dummyClass.klass,
+ isCPCached);
+ HotSpotResolvedObjectType holder = HotSpotResolvedObjectType.fromObjectClass(dummyClass.klass);
+ jdk.vm.ci.meta.ConstantPool constantPoolCTVM = holder.getConstantPool();
+ ConstantPool constantPoolSS = dummyClass.constantPoolSS;
+ for (int i = 0; i < constantPoolSS.getSize(); i++) {
+ Tag tag = constantPoolSS.getTagAt(i);
+ ConstantTypes cpType = mapTagToCPType(tag);
if (!typeTests.keySet().contains(cpType)) {
continue;
}
- try {
- typeTests.get(cpType).validate(constantPoolCTVM,
- constantPoolSS, dummyClass, i);
- } catch (Throwable t) {
- messageOnFail(t, cpType, dummyClass, i);
- }
+ typeTests.get(cpType).validate(constantPoolCTVM, cpType, dummyClass, i);
}
}
}
}
-
--- a/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Sat Feb 20 11:44:14 2016 +0300
+++ b/hotspot/test/compiler/jvmci/compilerToVM/ConstantPoolTestsHelper.java Sat Feb 20 11:49:02 2016 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,19 @@
*/
package compiler.jvmci.compilerToVM;
+import compiler.jvmci.common.testcases.MultipleAbstractImplementer;
import compiler.jvmci.common.testcases.MultipleImplementer2;
import compiler.jvmci.common.testcases.MultipleImplementersInterface;
+import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes;
+import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.*;
+import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry;
import java.util.HashMap;
import java.util.Map;
+import jdk.internal.misc.SharedSecrets;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import sun.hotspot.WhiteBox;
+import sun.reflect.ConstantPool;
+import sun.reflect.ConstantPool.Tag;
/**
* Class contains hard-coded constant pool tables for dummy classes used for
@@ -34,104 +43,437 @@
*/
public class ConstantPoolTestsHelper {
- public enum ConstantTypes {
- CONSTANT_CLASS,
- CONSTANT_FIELDREF,
- CONSTANT_METHODREF,
- CONSTANT_INTERFACEMETHODREF,
- CONSTANT_STRING,
- CONSTANT_INTEGER,
- CONSTANT_FLOAT,
- CONSTANT_LONG,
- CONSTANT_DOUBLE,
- CONSTANT_NAMEANDTYPE,
- CONSTANT_UTF8,
- CONSTANT_METHODHANDLE,
- CONSTANT_METHODTYPE,
- CONSTANT_INVOKEDYNAMIC;
- }
+ public static final int NO_CP_CACHE_PRESENT = Integer.MAX_VALUE;
public enum DummyClasses {
DUMMY_CLASS(MultipleImplementer2.class, CP_MAP_FOR_CLASS),
+ DUMMY_ABS_CLASS(MultipleAbstractImplementer.class, CP_MAP_FOR_ABS_CLASS),
DUMMY_INTERFACE(MultipleImplementersInterface.class, CP_MAP_FOR_INTERFACE);
+ private static final WhiteBox WB = WhiteBox.getWhiteBox();
public final Class<?> klass;
- public final Map<Integer, ConstantPoolEntry> cp;
+ public final ConstantPool constantPoolSS;
+ public final Map<ConstantTypes, TestedCPEntry[]> testedCP;
- DummyClasses(Class<?> klass, Map<Integer, ConstantPoolEntry> cp) {
+ DummyClasses(Class<?> klass, Map<ConstantTypes, TestedCPEntry[]> testedCP) {
this.klass = klass;
- this.cp = cp;
+ this.constantPoolSS = SharedSecrets.getJavaLangAccess().getConstantPool(klass);
+ this.testedCP = testedCP;
}
- }
- public static class ConstantPoolEntry {
-
- public final ConstantTypes type;
- public final Object value;
-
- public ConstantPoolEntry(ConstantTypes type, Object value) {
- this.type = type;
- this.value = value;
+ public int getCPCacheIndex(int cpi) {
+ int cacheLength = WB.getConstantPoolCacheLength(this.klass);
+ int indexTag = WB.getConstantPoolCacheIndexTag();
+ for (int cpci = indexTag; cpci < cacheLength + indexTag; cpci++) {
+ if (WB.remapInstructionOperandFromCPCache(this.klass, cpci) == cpi) {
+ if (constantPoolSS.getTagAt(cpi).equals(Tag.INVOKEDYNAMIC)) {
+ return WB.encodeConstantPoolIndyIndex(cpci) + indexTag;
+ }
+ return cpci;
+ }
+ }
+ return NO_CP_CACHE_PRESENT;
}
}
- private static final Map<Integer, ConstantPoolEntry> CP_MAP_FOR_CLASS
- = new HashMap<>();
+ private static final Map<ConstantTypes, TestedCPEntry[]> CP_MAP_FOR_CLASS = new HashMap<>();
static {
- CP_MAP_FOR_CLASS.put(1, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{22, 68}));
- CP_MAP_FOR_CLASS.put(2, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 69));
- CP_MAP_FOR_CLASS.put(3, new ConstantPoolEntry(ConstantTypes.CONSTANT_INTEGER, 2147483647));
- CP_MAP_FOR_CLASS.put(4, new ConstantPoolEntry(ConstantTypes.CONSTANT_FIELDREF, new int[]{35, 70}));
- CP_MAP_FOR_CLASS.put(5, new ConstantPoolEntry(ConstantTypes.CONSTANT_LONG, 9223372036854775807L));
- CP_MAP_FOR_CLASS.put(8, new ConstantPoolEntry(ConstantTypes.CONSTANT_FLOAT, 3.4028235E38F));
- CP_MAP_FOR_CLASS.put(10, new ConstantPoolEntry(ConstantTypes.CONSTANT_DOUBLE, 1.7976931348623157E308D));
- CP_MAP_FOR_CLASS.put(13, new ConstantPoolEntry(ConstantTypes.CONSTANT_STRING, 74));
- CP_MAP_FOR_CLASS.put(22, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 83));
- CP_MAP_FOR_CLASS.put(23, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{22, 84}));
- CP_MAP_FOR_CLASS.put(24, new ConstantPoolEntry(ConstantTypes.CONSTANT_INTERFACEMETHODREF, new int[]{2, 85}));
- CP_MAP_FOR_CLASS.put(26, new ConstantPoolEntry(ConstantTypes.CONSTANT_INVOKEDYNAMIC, new int[]{0, 91}));
- CP_MAP_FOR_CLASS.put(29, new ConstantPoolEntry(ConstantTypes.CONSTANT_FIELDREF, new int[]{35, 94}));
- CP_MAP_FOR_CLASS.put(35, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 100));
- CP_MAP_FOR_CLASS.put(68, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{54, 55}));
- CP_MAP_FOR_CLASS.put(70, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{48, 37}));
- CP_MAP_FOR_CLASS.put(84, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{59, 55}));
- CP_MAP_FOR_CLASS.put(85, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{103, 63}));
- CP_MAP_FOR_CLASS.put(91, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{106, 107}));
- CP_MAP_FOR_CLASS.put(94, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{36, 37}));
- CP_MAP_FOR_CLASS.put(104, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{110, 111}));
- CP_MAP_FOR_CLASS.put(105, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{35, 112}));
- CP_MAP_FOR_CLASS.put(110, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 113));
- CP_MAP_FOR_CLASS.put(111, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{114, 118}));
- CP_MAP_FOR_CLASS.put(112, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{58, 55}));
+ CP_MAP_FOR_CLASS.put(CONSTANT_CLASS,
+ new TestedCPEntry[] {
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2", null, null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2$1", null, null),
+ new TestedCPEntry("java/lang/invoke/MethodHandles$Lookup", null, null),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_FIELDREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "intStaticField",
+ "I",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "longStaticField",
+ "J",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_FINAL | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "floatStaticField",
+ "F",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_VOLATILE | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "doubleStaticField",
+ "D",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "stringStaticField",
+ "Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "objectStaticField",
+ "Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "intField",
+ "I",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_PUBLIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "longField",
+ "J",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_PRIVATE),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "floatField",
+ "F",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_PROTECTED),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "doubleField",
+ "D",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_TRANSIENT),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "objectField",
+ "Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_FINAL),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "stringField",
+ "Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_VOLATILE),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "stringFieldEmpty",
+ "Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ 0L),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_METHODREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/lang/System",
+ "getProperties",
+ "()Ljava/util/Properties;",
+ new byte[] {(byte) Opcodes.INVOKESTATIC}),
+ new TestedCPEntry("java/util/HashMap",
+ "<init>",
+ "()V",
+ new byte[] {(byte) Opcodes.INVOKESPECIAL}),
+ new TestedCPEntry("java/lang/Object",
+ "toString",
+ "()Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.INVOKESPECIAL,
+ (byte) Opcodes.INVOKEVIRTUAL}),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2$1",
+ "<init>",
+ "(Lcompiler/jvmci/common/testcases/MultipleImplementer2;)V",
+ new byte[0]),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1",
+ "run",
+ "()V",
+ new byte[0]),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_INTERFACEMETHODREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/util/Map",
+ "put",
+ "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.INVOKEINTERFACE}),
+ new TestedCPEntry("java/util/Map",
+ "remove",
+ "(Ljava/lang/Object;)Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.INVOKEINTERFACE}),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_STRING,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null, "Message", null),
+ new TestedCPEntry(null, "", null),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_METHODHANDLE,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/lang/invoke/LambdaMetafactory",
+ "metafactory",
+ "(Ljava/lang/invoke/MethodHandles$Lookup;"
+ + "Ljava/lang/String;"
+ + "Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodHandle;"
+ + "Ljava/lang/invoke/MethodType;)"
+ + "Ljava/lang/invoke/CallSite;",
+ null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementer2",
+ "testMethod",
+ "()V"),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_METHODTYPE,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null, null, "()V"),
+ }
+ );
+ CP_MAP_FOR_CLASS.put(CONSTANT_INVOKEDYNAMIC,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null,
+ "run",
+ "(Lcompiler/jvmci/common/testcases/MultipleImplementer2;)"
+ + "Ljava/lang/Runnable;"),
+ }
+ );
}
- private static final Map<Integer, ConstantPoolEntry> CP_MAP_FOR_INTERFACE
+ private static final Map<ConstantTypes, TestedCPEntry[]> CP_MAP_FOR_ABS_CLASS
= new HashMap<>();
static {
- CP_MAP_FOR_INTERFACE.put(1, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 48));
- CP_MAP_FOR_INTERFACE.put(5, new ConstantPoolEntry(ConstantTypes.CONSTANT_INTERFACEMETHODREF, new int[]{13, 52}));
- CP_MAP_FOR_INTERFACE.put(6, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 53));
- CP_MAP_FOR_INTERFACE.put(7, new ConstantPoolEntry(ConstantTypes.CONSTANT_INVOKEDYNAMIC, new int[]{0, 58}));
- CP_MAP_FOR_INTERFACE.put(8, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{6, 59}));
- CP_MAP_FOR_INTERFACE.put(9, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{6, 60}));
- CP_MAP_FOR_INTERFACE.put(12, new ConstantPoolEntry(ConstantTypes.CONSTANT_FIELDREF, new int[]{13, 63}));
- CP_MAP_FOR_INTERFACE.put(13, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 64));
- CP_MAP_FOR_INTERFACE.put(17, new ConstantPoolEntry(ConstantTypes.CONSTANT_INTEGER, 2147483647));
- CP_MAP_FOR_INTERFACE.put(20, new ConstantPoolEntry(ConstantTypes.CONSTANT_LONG, 9223372036854775807l));
- CP_MAP_FOR_INTERFACE.put(24, new ConstantPoolEntry(ConstantTypes.CONSTANT_FLOAT, 3.4028235E38f));
- CP_MAP_FOR_INTERFACE.put(27, new ConstantPoolEntry(ConstantTypes.CONSTANT_DOUBLE, 1.7976931348623157E308d));
- CP_MAP_FOR_INTERFACE.put(31, new ConstantPoolEntry(ConstantTypes.CONSTANT_STRING, 65));
- CP_MAP_FOR_INTERFACE.put(52, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{34, 35}));
- CP_MAP_FOR_INTERFACE.put(55, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODHANDLE, new int[]{6, 67}));
- CP_MAP_FOR_INTERFACE.put(56, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODTYPE, 35));
- CP_MAP_FOR_INTERFACE.put(57, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODHANDLE, new int[]{9, 5}));
- CP_MAP_FOR_INTERFACE.put(58, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{68, 69}));
- CP_MAP_FOR_INTERFACE.put(59, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{70, 71}));
- CP_MAP_FOR_INTERFACE.put(60, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{72, 35}));
- CP_MAP_FOR_INTERFACE.put(63, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{32, 33}));
- CP_MAP_FOR_INTERFACE.put(67, new ConstantPoolEntry(ConstantTypes.CONSTANT_METHODREF, new int[]{73, 74}));
- CP_MAP_FOR_INTERFACE.put(73, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 75));
- CP_MAP_FOR_INTERFACE.put(74, new ConstantPoolEntry(ConstantTypes.CONSTANT_NAMEANDTYPE, new int[]{76, 80}));
- CP_MAP_FOR_INTERFACE.put(77, new ConstantPoolEntry(ConstantTypes.CONSTANT_CLASS, 82));
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_CLASS,
+ new TestedCPEntry[] {
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer", null, null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1", null, null),
+ new TestedCPEntry("java/lang/invoke/MethodHandles$Lookup", null, null),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_FIELDREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "intStaticField",
+ "I",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "longStaticField",
+ "J",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_FINAL | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "floatStaticField",
+ "F",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_VOLATILE | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "doubleStaticField",
+ "D",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "stringStaticField",
+ "Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "objectStaticField",
+ "Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "intField",
+ "I",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_PUBLIC),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "longField",
+ "J",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_PRIVATE),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "floatField",
+ "F",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_PROTECTED),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "doubleField",
+ "D",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_TRANSIENT),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "objectField",
+ "Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_FINAL),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "stringField",
+ "Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ Opcodes.ACC_VOLATILE),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "stringFieldEmpty",
+ "Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.PUTFIELD | (byte) Opcodes.GETFIELD},
+ 0L),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_METHODREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/lang/System",
+ "getProperties",
+ "()Ljava/util/Properties;",
+ new byte[] {(byte) Opcodes.INVOKESTATIC}),
+ new TestedCPEntry("java/util/HashMap",
+ "<init>",
+ "()V",
+ new byte[] {(byte) Opcodes.INVOKESPECIAL}),
+ new TestedCPEntry("java/lang/Object",
+ "toString",
+ "()Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.INVOKESPECIAL,
+ (byte) Opcodes.INVOKEVIRTUAL}),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1",
+ "<init>",
+ "(Lcompiler/jvmci/common/testcases/MultipleAbstractImplementer;)V",
+ new byte[0]),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1",
+ "run",
+ "()V",
+ new byte[0]),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_INTERFACEMETHODREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/util/Map",
+ "put",
+ "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.INVOKEINTERFACE}),
+ new TestedCPEntry("java/util/Map",
+ "remove",
+ "(Ljava/lang/Object;)Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.INVOKEINTERFACE}),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_STRING,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null, "Message", null),
+ new TestedCPEntry(null, "", null),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_METHODHANDLE,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/lang/invoke/LambdaMetafactory",
+ "metafactory",
+ "(Ljava/lang/invoke/MethodHandles$Lookup;"
+ + "Ljava/lang/String;"
+ + "Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodHandle;"
+ + "Ljava/lang/invoke/MethodType;)"
+ + "Ljava/lang/invoke/CallSite;",
+ null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer",
+ "testMethod",
+ "()V"),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_METHODTYPE,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null, null, "()V"),
+ }
+ );
+ CP_MAP_FOR_ABS_CLASS.put(CONSTANT_INVOKEDYNAMIC,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null,
+ "run",
+ "(Lcompiler/jvmci/common/testcases/MultipleAbstractImplementer;)"
+ + "Ljava/lang/Runnable;"),
+ }
+ );
+ }
+
+ private static final Map<ConstantTypes, TestedCPEntry[]> CP_MAP_FOR_INTERFACE
+ = new HashMap<>();
+ static {
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_CLASS,
+ new TestedCPEntry[] {
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface", null, null),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface$1", null, null),
+ new TestedCPEntry("java/lang/Object", null, null),
+ new TestedCPEntry("java/lang/invoke/MethodHandles$Lookup", null, null),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_FIELDREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface",
+ "OBJECT_CONSTANT",
+ "Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.PUTSTATIC, (byte) Opcodes.GETSTATIC},
+ Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_PUBLIC),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/lang/System",
+ "getProperties",
+ "()Ljava/util/Properties;",
+ new byte[] {(byte) Opcodes.INVOKESTATIC}),
+ new TestedCPEntry("java/util/HashMap",
+ "<init>",
+ "()V",
+ new byte[] {(byte) Opcodes.INVOKESPECIAL}),
+ new TestedCPEntry("java/lang/Object",
+ "toString",
+ "()Ljava/lang/String;",
+ new byte[] {(byte) Opcodes.INVOKEVIRTUAL}),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1",
+ "<init>",
+ "(Lcompiler/jvmci/common/testcases/MultipleAbstractImplementer;)V",
+ new byte[0]),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleAbstractImplementer$1",
+ "run",
+ "()V",
+ new byte[0]),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_INTERFACEMETHODREF,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/util/Map",
+ "put",
+ "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.INVOKEINTERFACE}),
+ new TestedCPEntry("java/util/Map",
+ "remove",
+ "(Ljava/lang/Object;)Ljava/lang/Object;",
+ new byte[] {(byte) Opcodes.INVOKEINTERFACE}),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_STRING,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null, "Hello", null),
+ new TestedCPEntry(null, "", null),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODHANDLE,
+ new TestedCPEntry[] {
+ new TestedCPEntry("java/lang/invoke/LambdaMetafactory",
+ "metafactory",
+ "(Ljava/lang/invoke/MethodHandles$Lookup;"
+ + "Ljava/lang/String;Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodType;"
+ + "Ljava/lang/invoke/MethodHandle;"
+ + "Ljava/lang/invoke/MethodType;)"
+ + "Ljava/lang/invoke/CallSite;"),
+ new TestedCPEntry("compiler/jvmci/common/testcases/MultipleImplementersInterface",
+ "defaultMethod",
+ "()V"),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_METHODTYPE,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null, null, "()V"),
+ }
+ );
+ CP_MAP_FOR_INTERFACE.put(CONSTANT_INVOKEDYNAMIC,
+ new TestedCPEntry[] {
+ new TestedCPEntry(null,
+ "run",
+ "(Lcompiler/jvmci/common/testcases/MultipleImplementersInterface;)"
+ + "Ljava/lang/Runnable;"),
+ }
+ );
}
}