author | kvn |
Wed, 01 May 2019 12:31:29 -0700 (2019-05-01) | |
changeset 54669 | ad45b3802d4e |
parent 50858 | 2d3e99a72541 |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33160 | 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 |
package compiler.jvmci.compilerToVM; |
|
25 |
||
40059 | 26 |
import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; |
27 |
import jdk.internal.reflect.ConstantPool; |
|
28 |
import jdk.internal.reflect.ConstantPool.Tag; |
|
50858 | 29 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
33632 | 30 |
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
31 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
32 |
import sun.hotspot.WhiteBox; |
40059 | 33 |
|
34 |
import java.util.HashMap; |
|
35 |
import java.util.Map; |
|
36 |
||
37 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_CLASS; |
|
38 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_DOUBLE; |
|
39 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; |
|
40 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FLOAT; |
|
41 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTEGER; |
|
42 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INTERFACEMETHODREF; |
|
43 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVALID; |
|
44 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_INVOKEDYNAMIC; |
|
45 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_LONG; |
|
46 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODHANDLE; |
|
47 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODREF; |
|
48 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_METHODTYPE; |
|
49 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_NAMEANDTYPE; |
|
50 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_STRING; |
|
51 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_UTF8; |
|
33160 | 52 |
|
53 |
/** |
|
54 |
* Common class for jdk.vm.ci.hotspot.CompilerToVM constant pool tests |
|
55 |
*/ |
|
56 |
public class ConstantPoolTestCase { |
|
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
57 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
58 |
private static final Map<Tag, ConstantTypes> TAG_TO_TYPE_MAP; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
59 |
static { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
60 |
TAG_TO_TYPE_MAP = new HashMap<>(); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
61 |
TAG_TO_TYPE_MAP.put(Tag.CLASS, CONSTANT_CLASS); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
62 |
TAG_TO_TYPE_MAP.put(Tag.FIELDREF, CONSTANT_FIELDREF); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
63 |
TAG_TO_TYPE_MAP.put(Tag.METHODREF, CONSTANT_METHODREF); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
64 |
TAG_TO_TYPE_MAP.put(Tag.INTERFACEMETHODREF, CONSTANT_INTERFACEMETHODREF); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
65 |
TAG_TO_TYPE_MAP.put(Tag.STRING, CONSTANT_STRING); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
66 |
TAG_TO_TYPE_MAP.put(Tag.INTEGER, CONSTANT_INTEGER); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
67 |
TAG_TO_TYPE_MAP.put(Tag.FLOAT, CONSTANT_FLOAT); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
68 |
TAG_TO_TYPE_MAP.put(Tag.LONG, CONSTANT_LONG); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
69 |
TAG_TO_TYPE_MAP.put(Tag.DOUBLE, CONSTANT_DOUBLE); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
70 |
TAG_TO_TYPE_MAP.put(Tag.NAMEANDTYPE, CONSTANT_NAMEANDTYPE); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
71 |
TAG_TO_TYPE_MAP.put(Tag.UTF8, CONSTANT_UTF8); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
72 |
TAG_TO_TYPE_MAP.put(Tag.METHODHANDLE, CONSTANT_METHODHANDLE); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
73 |
TAG_TO_TYPE_MAP.put(Tag.METHODTYPE, CONSTANT_METHODTYPE); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
74 |
TAG_TO_TYPE_MAP.put(Tag.INVOKEDYNAMIC, CONSTANT_INVOKEDYNAMIC); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
75 |
TAG_TO_TYPE_MAP.put(Tag.INVALID, CONSTANT_INVALID); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
76 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
77 |
private static final WhiteBox WB = WhiteBox.getWhiteBox(); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
78 |
private final Map<ConstantTypes, Validator> typeTests; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
79 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
80 |
public static enum ConstantTypes { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
81 |
CONSTANT_CLASS { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
82 |
@Override |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
83 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
84 |
ConstantPool constantPoolSS = dummyClass.constantPoolSS; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
85 |
checkIndex(constantPoolSS, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
86 |
Class<?> klass = constantPoolSS.getClassAt(index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
87 |
String klassName = klass.getName(); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
88 |
TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
89 |
for (TestedCPEntry entry : testedEntries) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
90 |
if (entry.klass.replaceAll("/", "\\.").equals(klassName)) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
91 |
return entry; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
92 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
93 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
94 |
return null; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
95 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
96 |
}, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
97 |
CONSTANT_FIELDREF { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
98 |
@Override |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
99 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
100 |
return this.getTestedCPEntryForMethodAndField(dummyClass, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
101 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
102 |
}, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
103 |
CONSTANT_METHODREF { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
104 |
@Override |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
105 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
106 |
return this.getTestedCPEntryForMethodAndField(dummyClass, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
107 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
108 |
}, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
109 |
CONSTANT_INTERFACEMETHODREF { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
110 |
@Override |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
111 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
112 |
return this.getTestedCPEntryForMethodAndField(dummyClass, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
113 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
114 |
}, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
115 |
CONSTANT_STRING { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
116 |
@Override |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
117 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
118 |
ConstantPool constantPoolSS = dummyClass.constantPoolSS; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
119 |
checkIndex(constantPoolSS, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
120 |
String value = constantPoolSS.getStringAt(index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
121 |
TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
122 |
for (TestedCPEntry entry : testedEntries) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
123 |
if (entry.name.equals(value)) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
124 |
return entry; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
125 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
126 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
127 |
return null; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
128 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
129 |
}, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
130 |
CONSTANT_INTEGER, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
131 |
CONSTANT_FLOAT, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
132 |
CONSTANT_LONG, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
133 |
CONSTANT_DOUBLE, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
134 |
CONSTANT_NAMEANDTYPE, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
135 |
CONSTANT_UTF8, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
136 |
CONSTANT_METHODHANDLE, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
137 |
CONSTANT_METHODTYPE, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
138 |
CONSTANT_INVOKEDYNAMIC { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
139 |
@Override |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
140 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
141 |
ConstantPool constantPoolSS = dummyClass.constantPoolSS; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
142 |
checkIndex(constantPoolSS, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
143 |
int nameAndTypeIndex = constantPoolSS.getNameAndTypeRefIndexAt(index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
144 |
String[] info = constantPoolSS.getNameAndTypeRefInfoAt(nameAndTypeIndex); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
145 |
TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
146 |
for (TestedCPEntry entry : testedEntries) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
147 |
if (info[0].equals(entry.name) && info[1].equals(entry.type)) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
148 |
return entry; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
149 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
150 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
151 |
return null; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
152 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
153 |
}, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
154 |
CONSTANT_INVALID; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
155 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
156 |
public TestedCPEntry getTestedCPEntry(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
157 |
return null; // returning null by default |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
158 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
159 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
160 |
public TestedCPEntry[] getAllCPEntriesForType(DummyClasses dummyClass) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
161 |
TestedCPEntry[] toReturn = dummyClass.testedCP.get(this); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
162 |
if (toReturn == null) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
163 |
return new TestedCPEntry[0]; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
164 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
165 |
return dummyClass.testedCP.get(this); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
166 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
167 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
168 |
protected TestedCPEntry getTestedCPEntryForMethodAndField(DummyClasses dummyClass, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
169 |
ConstantPool constantPoolSS = dummyClass.constantPoolSS; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
170 |
checkIndex(constantPoolSS, index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
171 |
String[] info = constantPoolSS.getMemberRefInfoAt(index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
172 |
TestedCPEntry[] testedEntries = dummyClass.testedCP.get(this); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
173 |
for (TestedCPEntry entry : testedEntries) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
174 |
if (info[0].equals(entry.klass) && info[1].equals(entry.name) && info[2].equals(entry.type)) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
175 |
return entry; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
176 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
177 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
178 |
return null; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
179 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
180 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
181 |
protected void checkIndex(ConstantPool constantPoolSS, int index) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
182 |
ConstantPool.Tag tag = constantPoolSS.getTagAt(index); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
183 |
ConstantTypes type = mapTagToCPType(tag); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
184 |
if (!this.equals(type)) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
185 |
String msg = String.format("TESTBUG: CP tag should be a %s, but is %s", |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
186 |
this.name(), |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
187 |
type.name()); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
188 |
throw new Error(msg); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
189 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
190 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
191 |
} |
33160 | 192 |
|
193 |
public static interface Validator { |
|
33632 | 194 |
void validate(jdk.vm.ci.meta.ConstantPool constantPoolCTVM, |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
195 |
ConstantTypes cpType, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
196 |
DummyClasses dummyClass, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
197 |
int index); |
33160 | 198 |
} |
199 |
||
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
200 |
public static class TestedCPEntry { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
201 |
public final String klass; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
202 |
public final String name; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
203 |
public final String type; |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
204 |
public final ResolvedJavaMethod[] methods; |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
205 |
public final byte[] opcodes; |
43939 | 206 |
public final int accFlags; |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
207 |
|
43939 | 208 |
public TestedCPEntry(String klass, String name, String type, byte[] opcodes, int accFlags) { |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
209 |
this(klass, name, type, null, opcodes, accFlags); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
210 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
211 |
|
43939 | 212 |
public TestedCPEntry(String klass, String name, String type, ResolvedJavaMethod[] methods, byte[] opcodes, int accFlags) { |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
213 |
this.klass = klass; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
214 |
this.name = name; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
215 |
this.type = type; |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
216 |
if (methods != null) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
217 |
this.methods = new ResolvedJavaMethod[methods.length]; |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
218 |
System.arraycopy(methods, 0, this.methods, 0, methods.length); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
219 |
} else { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
220 |
this.methods = null; |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
37301
diff
changeset
|
221 |
} |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
222 |
if (opcodes != null) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
223 |
this.opcodes = new byte[opcodes.length]; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
224 |
System.arraycopy(opcodes, 0, this.opcodes, 0, opcodes.length); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
225 |
} else { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
226 |
this.opcodes = null; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
227 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
228 |
this.accFlags = accFlags; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
229 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
230 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
231 |
public TestedCPEntry(String klass, String name, String type, byte[] opcodes) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
232 |
this(klass, name, type, opcodes, 0); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
233 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
234 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
235 |
public TestedCPEntry(String klass, String name, String type) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
236 |
this(klass, name, type, null, 0); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
237 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
238 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
239 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
240 |
public static ConstantTypes mapTagToCPType(Tag tag) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
241 |
return TAG_TO_TYPE_MAP.get(tag); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
242 |
} |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
243 |
|
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
244 |
public ConstantPoolTestCase(Map<ConstantTypes, Validator> typeTests) { |
33160 | 245 |
this.typeTests = new HashMap<>(); |
246 |
this.typeTests.putAll(typeTests); |
|
247 |
} |
|
248 |
||
249 |
public void test() { |
|
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
250 |
for (DummyClasses dummyClass : DummyClasses.values()) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
251 |
boolean isCPCached = WB.getConstantPoolCacheLength(dummyClass.klass) > -1; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
252 |
System.out.printf("Testing dummy %s with constant pool cached = %b%n", |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
253 |
dummyClass.klass, |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
254 |
isCPCached); |
50858 | 255 |
HotSpotResolvedObjectType holder = CompilerToVMHelper.fromObjectClass(dummyClass.klass); |
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
256 |
jdk.vm.ci.meta.ConstantPool constantPoolCTVM = holder.getConstantPool(); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
257 |
ConstantPool constantPoolSS = dummyClass.constantPoolSS; |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
258 |
for (int i = 0; i < constantPoolSS.getSize(); i++) { |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
259 |
Tag tag = constantPoolSS.getTagAt(i); |
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
260 |
ConstantTypes cpType = mapTagToCPType(tag); |
33160 | 261 |
if (!typeTests.keySet().contains(cpType)) { |
262 |
continue; |
|
263 |
} |
|
36305
55c7fe59d6d7
8141618: Change JVMCI compilerToVM constant pool tests to support CP cache
kshefov
parents:
33632
diff
changeset
|
264 |
typeTests.get(cpType).validate(constantPoolCTVM, cpType, dummyClass, i); |
33160 | 265 |
} |
266 |
} |
|
267 |
} |
|
268 |
} |