author | gtriantafill |
Wed, 14 Sep 2016 08:17:50 -0400 | |
changeset 41092 | c388d897472d |
parent 40855 | 3c4c913195e3 |
child 41705 | 332239c052cc |
permissions | -rw-r--r-- |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
1 |
/* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
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 |
/* |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
26 |
* @test |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
27 |
* @bug 8138708 |
39291
a4efe145313d
8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents:
38152
diff
changeset
|
28 |
* @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64") |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
29 |
* @library /test/lib / |
36508 | 30 |
* @library ../common/patches |
31 |
* @modules 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 |
|
35 |
* jdk.vm.ci/jdk.vm.ci.hotspot |
|
36 |
* jdk.vm.ci/jdk.vm.ci.meta |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38152
diff
changeset
|
37 |
* jdk.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 |
* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
39 |
* @build jdk.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 |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
44 |
* compiler.jvmci.compilerToVM.ResolveFieldInPoolTest |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
45 |
*/ |
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 |
package compiler.jvmci.compilerToVM; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
48 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
49 |
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.ConstantTypes; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
50 |
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.TestedCPEntry; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
51 |
import compiler.jvmci.compilerToVM.ConstantPoolTestCase.Validator; |
40059 | 52 |
import compiler.jvmci.compilerToVM.ConstantPoolTestsHelper.DummyClasses; |
53 |
import jdk.internal.misc.Unsafe; |
|
54 |
import jdk.internal.org.objectweb.asm.Opcodes; |
|
55 |
import jdk.test.lib.Asserts; |
|
56 |
import jdk.vm.ci.hotspot.CompilerToVMHelper; |
|
57 |
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; |
|
58 |
import jdk.vm.ci.meta.ConstantPool; |
|
59 |
||
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
60 |
import java.lang.reflect.Field; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
61 |
import java.util.HashMap; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
62 |
import java.util.Map; |
40059 | 63 |
|
64 |
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
|
65 |
|
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 |
* 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
|
68 |
*/ |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
69 |
public class ResolveFieldInPoolTest { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
70 |
|
41092
c388d897472d
8165889: Remove jdk.test.lib.unsafe.UnsafeHelper
gtriantafill
parents:
40855
diff
changeset
|
71 |
private static final Unsafe UNSAFE = Unsafe.getUnsafe(); |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
72 |
|
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
73 |
public static void main(String[] args) throws Exception { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
74 |
Map<ConstantTypes, Validator> typeTests = new HashMap<>(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
75 |
typeTests.put(CONSTANT_FIELDREF, ResolveFieldInPoolTest::validate); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
76 |
ConstantPoolTestCase testCase = new ConstantPoolTestCase(typeTests); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
77 |
testCase.test(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
78 |
// The next "Class.forName" and repeating "testCase.test()" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
79 |
// are here for the following reason. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
80 |
// 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
|
81 |
// which means no constant pool cache exists. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
82 |
// 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
|
83 |
// Some CompilerToVM methods require different input |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
84 |
// depending on whether CP cache exists or not. |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
85 |
for (DummyClasses dummy : DummyClasses.values()) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
86 |
Class.forName(dummy.klass.getName()); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
87 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
88 |
testCase.test(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
89 |
} |
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 |
private static void validate(ConstantPool constantPoolCTVM, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
92 |
ConstantTypes cpType, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
93 |
DummyClasses dummyClass, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
94 |
int cpi) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
95 |
TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
96 |
if (entry == null) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
97 |
return; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
98 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
99 |
int index = cpi; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
100 |
String cached = ""; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
101 |
int cpci = dummyClass.getCPCacheIndex(cpi); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
102 |
if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
103 |
index = cpci; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
104 |
cached = "cached "; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
105 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
106 |
for (int j = 0; j < entry.opcodes.length; j++) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
107 |
long[] info = new long[2]; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
108 |
HotSpotResolvedObjectType fieldToVerify |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
109 |
= CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
110 |
index, |
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38152
diff
changeset
|
111 |
entry.methods == null ? null : entry.methods[j], |
36306
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
112 |
entry.opcodes[j], |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
113 |
info); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
114 |
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
|
115 |
+ " for %sindex %d should not be null", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
116 |
cached, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
117 |
index); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
118 |
Asserts.assertNotNull(fieldToVerify, msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
119 |
String classNameToRefer = entry.klass; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
120 |
String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString(); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
121 |
if (!fieldToVerifyKlassToString.contains(classNameToRefer)) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
122 |
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
|
123 |
+ " returned by resolveFieldInPool method" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
124 |
+ " 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
|
125 |
+ " should contain %s", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
126 |
fieldToVerifyKlassToString, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
127 |
index, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
128 |
classNameToRefer); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
129 |
throw new AssertionError(msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
130 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
131 |
msg = String.format("Access flags returned by resolveFieldInPool" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
132 |
+ " method are wrong for the field %s.%s" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
133 |
+ " at %sindex %d", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
134 |
entry.klass, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
135 |
entry.name, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
136 |
cached, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
137 |
index); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
138 |
Asserts.assertEQ(info[0], entry.accFlags, msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
139 |
if (cpci == -1) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
140 |
return; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
141 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
142 |
Class classOfTheField = null; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
143 |
Field fieldToRefer = null; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
144 |
try { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
145 |
classOfTheField = Class.forName(classNameToRefer.replaceAll("/", "\\.")); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
146 |
fieldToRefer = classOfTheField.getDeclaredField(entry.name); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
147 |
fieldToRefer.setAccessible(true); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
148 |
} catch (Exception ex) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
149 |
throw new Error("Unexpected exception", ex); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
150 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
151 |
long offsetToRefer; |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
152 |
if ((entry.accFlags & Opcodes.ACC_STATIC) != 0) { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
153 |
offsetToRefer = UNSAFE.staticFieldOffset(fieldToRefer); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
154 |
} else { |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
155 |
offsetToRefer = UNSAFE.objectFieldOffset(fieldToRefer); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
156 |
} |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
157 |
msg = String.format("Field offset returned by resolveFieldInPool" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
158 |
+ " method is wrong for the field %s.%s" |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
159 |
+ " at %sindex %d", |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
160 |
entry.klass, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
161 |
entry.name, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
162 |
cached, |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
163 |
index); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
164 |
Asserts.assertEQ(info[1], offsetToRefer, msg); |
9b8ba80e9327
8141619: Develop new tests for JVMCI compilerToVM class' CP related methods
kshefov
parents:
diff
changeset
|
165 |
} |
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 |
} |