author | kvn |
Fri, 07 Jun 2019 13:57:08 -0700 | |
changeset 55295 | 14283f280695 |
parent 55206 | 2fe2063fe567 |
permissions | -rw-r--r-- |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
1 |
/* |
55206 | 2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
4 |
* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
8 |
* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
13 |
* accompanied this code). |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
14 |
* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
18 |
* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
21 |
* questions. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
22 |
*/ |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
23 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
24 |
/* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
25 |
* @test |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
26 |
* @bug 8138708 |
42607
acd91f1875d4
8170227: use vm.jvmci property in compiler/jvmci tests
iignatyev
parents:
41705
diff
changeset
|
27 |
* @requires vm.jvmci |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
28 |
* @library /test/lib / |
36508 | 29 |
* @library ../common/patches |
52427
3c6aa484536c
8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents:
47216
diff
changeset
|
30 |
* @modules java.base/jdk.internal.access |
3c6aa484536c
8211122: Reduce the number of internal classes made accessible to jdk.unsupported
mchung
parents:
47216
diff
changeset
|
31 |
* java.base/jdk.internal.misc |
37301
a936b4e01afb
8137058: Clear out all non-Critical APIs from sun.reflect
chegar
parents:
36508
diff
changeset
|
32 |
* java.base/jdk.internal.reflect |
36508 | 33 |
* java.base/jdk.internal.org.objectweb.asm |
34 |
* java.base/jdk.internal.org.objectweb.asm.tree |
|
43972 | 35 |
* jdk.internal.vm.ci/jdk.vm.ci.hotspot |
36 |
* jdk.internal.vm.ci/jdk.vm.ci.meta |
|
37 |
* jdk.internal.vm.ci/jdk.vm.ci.runtime |
|
40053
b3617982544e
8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents:
39450
diff
changeset
|
38 |
* |
43972 | 39 |
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox |
40053
b3617982544e
8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents:
39450
diff
changeset
|
40 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
b3617982544e
8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents:
39450
diff
changeset
|
41 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
42 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
43 |
* -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI |
55206 | 44 |
* -XX:-UseJVMCICompiler |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
45 |
* compiler.jvmci.compilerToVM.ResolveFieldInPoolTest |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
46 |
*/ |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
47 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
48 |
package compiler.jvmci.compilerToVM; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
49 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
50 |
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
51 |
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
52 |
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; |
40059 | 53 |
import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; |
54 |
import jdk.internal.misc.Unsafe; |
|
55 |
import jdk.internal.org.objectweb.asm.Opcodes; |
|
56 |
import jdk.test.lib.Asserts; |
|
57 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
58 |
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; |
|
59 |
import jdk.vm.ci.meta.ConstantPool; |
|
60 |
||
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
61 |
import java.lang.reflect.Field; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
62 |
import java.util.HashMap; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
63 |
import java.util.Map; |
40059 | 64 |
|
65 |
import static compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes.CONSTANT_FIELDREF; |
|
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
66 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
67 |
/** |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
68 |
* Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveFieldInPool} method |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
69 |
*/ |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
70 |
public class ResolveFieldInPoolTest { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
71 |
|
41092
c388d897472d
8165889: Remove jdk.test.lib.unsafe.UnsafeHelper
gtriantafill
parents:
40855
diff
changeset
|
72 |
private static final Unsafe UNSAFE = Unsafe.getUnsafe(); |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
73 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
74 |
public static void main(String[] args) throws Exception { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
75 |
Map<ConstantTypes, Validator> typeTests = new HashMap<>(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
76 |
typeTests.put(CONSTANT_FIELDREF, ResolveFieldInPoolTest::validate); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
77 |
ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
78 |
testCase.test(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
79 |
// The next "Class.forName" and repeating "testCase.test()" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
80 |
// are here for the following reason. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
81 |
// The first test run is without dummy class initialization, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
82 |
// which means no constant pool cache exists. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
83 |
// The second run is with initialized class (with constant pool cache available). |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
84 |
// Some CompilerToVM methods require different input |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
85 |
// depending on whether CP cache exists or not. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
86 |
for (DummyClasses dummy : DummyClasses.values()) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
87 |
Class.forName(dummy.klass.getName()); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
88 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
89 |
testCase.test(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
90 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
91 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
92 |
private static void validate(ConstantPool constantPoolCTVM, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
93 |
ConstantTypes cpType, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
94 |
DummyClasses dummyClass, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
95 |
int cpi) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
96 |
TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
97 |
if (entry == null) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
98 |
return; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
99 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
100 |
int index = cpi; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
101 |
String cached = ""; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
102 |
int cpci = dummyClass.getCPCacheIndex(cpi); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
103 |
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
104 |
index = cpci; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
105 |
cached = "cached "; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
106 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
107 |
for (int j = 0; j < entry.opcodes.length; j++) { |
43939 | 108 |
int[] info = new int[3]; |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
109 |
HotSpotResolvedObjectType fieldToVerify |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
110 |
= CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
111 |
index, |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38152
diff
changeset
|
112 |
entry.methods == null ? null : entry.methods[j], |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
113 |
entry.opcodes[j], |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
114 |
info); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
115 |
String msg = String.format("Object returned by resolveFieldInPool method" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
116 |
+ " for %sindex %d should not be null", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
117 |
cached, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
118 |
index); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
119 |
Asserts.assertNotNull(fieldToVerify, msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
120 |
String classNameToRefer = entry.klass; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
121 |
String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
122 |
if (!fieldToVerifyKlassToString.contains(classNameToRefer)) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
123 |
msg = String.format("String representation \"%s\" of the object" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
124 |
+ " returned by resolveFieldInPool method" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
125 |
+ " for index %d does not contain a field's class name," |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
126 |
+ " should contain %s", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
127 |
fieldToVerifyKlassToString, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
128 |
index, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
129 |
classNameToRefer); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
130 |
throw new AssertionError(msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
131 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
132 |
msg = String.format("Access flags returned by resolveFieldInPool" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
133 |
+ " method are wrong for the field %s.%s" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
134 |
+ " at %sindex %d", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
135 |
entry.klass, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
136 |
entry.name, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
137 |
cached, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
138 |
index); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
139 |
Asserts.assertEQ(info[0], entry.accFlags, msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
140 |
if (cpci == -1) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
141 |
return; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
142 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
143 |
Class classOfTheField = null; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
144 |
Field fieldToRefer = null; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
145 |
try { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
146 |
classOfTheField = Class.forName(classNameToRefer.replaceAll("/", "\\.")); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
147 |
fieldToRefer = classOfTheField.getDeclaredField(entry.name); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
148 |
fieldToRefer.setAccessible(true); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
149 |
} catch (Exception ex) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
150 |
throw new Error("Unexpected exception", ex); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
151 |
} |
43939 | 152 |
int offsetToRefer; |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
153 |
if ((entry.accFlags & Opcodes.ACC_STATIC) != 0) { |
43939 | 154 |
offsetToRefer = (int) UNSAFE.staticFieldOffset(fieldToRefer); |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
155 |
} else { |
43939 | 156 |
offsetToRefer = (int) UNSAFE.objectFieldOffset(fieldToRefer); |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
157 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
158 |
msg = String.format("Field offset returned by resolveFieldInPool" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
159 |
+ " method is wrong for the field %s.%s" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
160 |
+ " at %sindex %d", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
161 |
entry.klass, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
162 |
entry.name, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
163 |
cached, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
164 |
index); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
165 |
Asserts.assertEQ(info[1], offsetToRefer, msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
166 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
167 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
168 |
} |