Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java @ 22455:7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 24 Aug 2015 11:06:40 +0200 |
parents | 76af33d4d504 |
children | a0e5714d5436 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
22054 | 23 package jdk.internal.jvmci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22054 | 25 import static jdk.internal.jvmci.common.UnsafeAccess.*; |
26 import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; | |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
27 |
14093 | 28 import java.lang.invoke.*; |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
29 import java.util.*; |
14093 | 30 |
22054 | 31 import jdk.internal.jvmci.common.*; |
32 import jdk.internal.jvmci.meta.*; | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
33 import jdk.internal.jvmci.options.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 /** |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5554
diff
changeset
|
36 * Implementation of {@link ConstantPool} for HotSpot. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 */ |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
38 public final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { |
5278
74dfa6f86879
removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
39 |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
40 public static class Options { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
41 // @formatter:off |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
42 @Option(help = "Use Java code to access the constant pool cache and resolved references array", type = OptionType.Expert) |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
43 public static final OptionValue<Boolean> UseConstantPoolCacheJavaCode = new OptionValue<>(false); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
44 // @formatter:on |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
45 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
46 |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
47 /** |
21720
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
48 * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
49 */ |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21720
diff
changeset
|
50 public static class Bytecodes { |
21720
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
51 public static final int LDC = 18; // 0x12 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
52 public static final int LDC_W = 19; // 0x13 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
53 public static final int LDC2_W = 20; // 0x14 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
54 public static final int GETSTATIC = 178; // 0xB2 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
55 public static final int PUTSTATIC = 179; // 0xB3 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
56 public static final int GETFIELD = 180; // 0xB4 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
57 public static final int PUTFIELD = 181; // 0xB5 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
58 public static final int INVOKEVIRTUAL = 182; // 0xB6 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
59 public static final int INVOKESPECIAL = 183; // 0xB7 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
60 public static final int INVOKESTATIC = 184; // 0xB8 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
61 public static final int INVOKEINTERFACE = 185; // 0xB9 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
62 public static final int INVOKEDYNAMIC = 186; // 0xBA |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
63 public static final int NEW = 187; // 0xBB |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
64 public static final int NEWARRAY = 188; // 0xBC |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
65 public static final int ANEWARRAY = 189; // 0xBD |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
66 public static final int CHECKCAST = 192; // 0xC0 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
67 public static final int INSTANCEOF = 193; // 0xC1 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
68 public static final int MULTIANEWARRAY = 197; // 0xC5 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
69 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
70 static boolean isInvoke(int opcode) { |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
71 switch (opcode) { |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
72 case INVOKEVIRTUAL: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
73 case INVOKESPECIAL: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
74 case INVOKESTATIC: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
75 case INVOKEINTERFACE: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
76 case INVOKEDYNAMIC: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
77 return true; |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
78 default: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
79 return false; |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
80 } |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
81 } |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
82 |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
83 /** |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
84 * See: {@code Rewriter::maybe_rewrite_invokehandle}. |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
85 */ |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
86 static boolean isInvokeHandleAlias(int opcode) { |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
87 switch (opcode) { |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
88 case INVOKEVIRTUAL: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
89 case INVOKESPECIAL: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
90 return true; |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
91 default: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
92 return false; |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
93 } |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
94 } |
21720
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
95 } |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
96 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
97 /** |
14529 | 98 * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and |
99 * internal ones. | |
100 */ | |
101 private enum JVM_CONSTANT { | |
102 // @formatter:off | |
103 Utf8(config().jvmConstantUtf8), | |
104 Integer(config().jvmConstantInteger), | |
105 Long(config().jvmConstantLong), | |
106 Float(config().jvmConstantFloat), | |
107 Double(config().jvmConstantDouble), | |
108 Class(config().jvmConstantClass), | |
109 UnresolvedClass(config().jvmConstantUnresolvedClass), | |
110 UnresolvedClassInError(config().jvmConstantUnresolvedClassInError), | |
111 String(config().jvmConstantString), | |
112 Fieldref(config().jvmConstantFieldref), | |
113 MethodRef(config().jvmConstantMethodref), | |
114 InterfaceMethodref(config().jvmConstantInterfaceMethodref), | |
115 NameAndType(config().jvmConstantNameAndType), | |
116 MethodHandle(config().jvmConstantMethodHandle), | |
117 MethodHandleInError(config().jvmConstantMethodHandleInError), | |
118 MethodType(config().jvmConstantMethodType), | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
119 MethodTypeInError(config().jvmConstantMethodTypeInError), |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
120 InvokeDynamic(config().jvmConstantInvokeDynamic); |
14529 | 121 // @formatter:on |
122 | |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
123 private final int tag; |
14529 | 124 |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
125 private static final int ExternalMax = config().jvmConstantExternalMax; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
126 private static final int InternalMin = config().jvmConstantInternalMin; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
127 private static final int InternalMax = config().jvmConstantInternalMax; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
128 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
129 private JVM_CONSTANT(int tag) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
130 this.tag = tag; |
14529 | 131 } |
132 | |
133 private static HotSpotVMConfig config() { | |
134 return runtime().getConfig(); | |
135 } | |
136 | |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
137 /** |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
138 * Maps JVM_CONSTANT tags to {@link JVM_CONSTANT} values. Using a separate class for lazy |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
139 * initialization. |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
140 */ |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
141 static class TagValueMap { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
142 private static final JVM_CONSTANT[] table = new JVM_CONSTANT[ExternalMax + 1 + (InternalMax - InternalMin) + 1]; |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
143 |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
144 static { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
145 assert InternalMin > ExternalMax; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
146 for (JVM_CONSTANT e : values()) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
147 table[indexOf(e.tag)] = e; |
14529 | 148 } |
149 } | |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
150 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
151 private static int indexOf(int tag) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
152 if (tag >= InternalMin) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
153 return tag - InternalMin + ExternalMax + 1; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
154 } else { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
155 assert tag <= ExternalMax; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
156 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
157 return tag; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
158 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
159 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
160 static JVM_CONSTANT get(int tag) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
161 JVM_CONSTANT res = table[indexOf(tag)]; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
162 if (res != null) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
163 return res; |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
164 } |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
165 throw new JVMCIError("Unknown JVM_CONSTANT tag %s", tag); |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
166 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
167 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
168 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
169 public static JVM_CONSTANT getEnum(int tag) { |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
170 return TagValueMap.get(tag); |
14529 | 171 } |
172 } | |
173 | |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
174 private static class LookupTypeCacheElement { |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
175 int lastCpi = Integer.MIN_VALUE; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
176 JavaType javaType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
177 |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
178 public LookupTypeCacheElement(int lastCpi, JavaType javaType) { |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
179 super(); |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
180 this.lastCpi = lastCpi; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
181 this.javaType = javaType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
182 } |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
183 } |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
184 |
14529 | 185 /** |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
186 * Reference to the C++ ConstantPool object. |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
187 */ |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
188 private final long metaspaceConstantPool; |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
189 private volatile LookupTypeCacheElement lastLookupType; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
191 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
192 * The constant pool cache of this constant pool. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
193 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
194 private final Cache cache; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
195 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
196 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
197 * Represents a {@code ConstantPoolCache}. The cache needs to be lazy since the constant pool |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
198 * cache is created when the methods of this class are rewritten and rewriting happens when the |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
199 * class is linked. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
200 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
201 private final class Cache { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
202 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
203 private long address; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
204 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
205 public Cache() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
206 // Maybe the constant pool cache already exists... |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
207 queryAddress(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
208 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
209 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
210 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
211 * Queries the current value of {@code ConstantPool::_cache} if the current address is null. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
212 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
213 private void queryAddress() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
214 if (address == 0) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
215 address = unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolCacheOffset); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
216 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
217 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
218 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
219 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
220 * Returns whether a constant pool cache for this constant pool exists. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
221 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
222 * @return true if it exists, false otherwise |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
223 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
224 public boolean exists() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
225 queryAddress(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
226 return address != 0; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
227 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
228 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
229 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
230 * Represents a {@code ConstantPoolCacheEntry}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
231 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
232 private final class Entry { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
233 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
234 private final long address; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
235 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
236 public Entry(final long address) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
237 this.address = address; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
238 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
239 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
240 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
241 * {@code ConstantPoolCacheEntry::_indices} is volatile of type {@code intx}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
242 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
243 * @return value of field {@code _indices} |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
244 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
245 private long getIndices() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
246 assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
247 return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryIndicesOffset); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
248 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
249 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
250 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
251 * {@code ConstantPoolCacheEntry::_f1} is volatile of type {@code Metadata*}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
252 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
253 * @return value of field {@code _f1} |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
254 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
255 private long getF1() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
256 assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
257 return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryF1Offset); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
258 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
259 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
260 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
261 * {@code ConstantPoolCacheEntry::_f2} is volatile of type {@code intx}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
262 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
263 * @return value of field {@code _f2} |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
264 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
265 private long getF2() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
266 assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
267 return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryF2Offset); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
268 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
269 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
270 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
271 * {@code ConstantPoolCacheEntry::_flags} is volatile of type {@code intx}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
272 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
273 * @return flag bits |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
274 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
275 private long flags() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
276 assert runtime().getHostJVMCIBackend().getTarget().wordSize == 8 : "port to non-64-bit platform"; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
277 return unsafe.getLongVolatile(null, address + runtime().getConfig().constantPoolCacheEntryFlagsOffset); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
278 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
279 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
280 private boolean isF1Null() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
281 final long f1 = getF1(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
282 return f1 == 0; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
283 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
284 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
285 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
286 * Returns the constant pool index for this entry. See |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
287 * {@code ConstantPoolCacheEntry::constant_pool_index()} |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
288 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
289 * @return the constant pool index for this entry |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
290 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
291 public int getConstantPoolIndex() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
292 return ((int) getIndices()) & runtime().getConfig().constantPoolCacheEntryCpIndexMask; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
293 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
294 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
295 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
296 * See {@code ConstantPoolCache::has_appendix()}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
297 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
298 * @return true if there is an appendix, false otherwise |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
299 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
300 private boolean hasAppendix() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
301 return (!isF1Null()) && (flags() & (1 << runtime().getConfig().constantPoolCacheEntryHasAppendixShift)) != 0; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
302 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
303 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
304 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
305 * See {@code ConstantPoolCache::appendix_if_resolved()}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
306 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
307 public Object getAppendixIfResolved() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
308 if (!hasAppendix()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
309 return null; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
310 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
311 final int index = ((int) getF2()) + runtime().getConfig().constantPoolCacheEntryIndyResolvedReferencesAppendixOffset; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
312 return resolvedReferences.getArray()[index]; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
313 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
314 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
315 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
316 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
317 * Get the constant pool cache entry at index {@code index}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
318 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
319 * @param index index of entry to return |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
320 * @return constant pool cache entry at given index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
321 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
322 public Entry getEntryAt(int index) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
323 queryAddress(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
324 assert exists(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
325 HotSpotVMConfig config = runtime().getConfig(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
326 return new Entry(address + config.constantPoolCacheSize + config.constantPoolCacheEntrySize * index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
327 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
328 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
329 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
330 * Maps the constant pool cache index back to a constant pool index. See |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
331 * {@code ConstantPool::remap_instruction_operand_from_cache}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
332 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
333 * @param index the constant pool cache index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
334 * @return constant pool index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
335 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
336 public int constantPoolCacheIndexToConstantPoolIndex(int index) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
337 final int cacheIndex = index - runtime().getConfig().constantPoolCpCacheIndexTag; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
338 return getEntryAt(cacheIndex).getConstantPoolIndex(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
339 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
340 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
341 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
342 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
343 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
344 * Resolved references of this constant pool. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
345 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
346 private final ResolvedReferences resolvedReferences = new ResolvedReferences(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
347 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
348 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
349 * Hide the resolved references array in a private class so it cannot be accessed directly. The |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
350 * reason is the resolved references array is created when the constant pool cache is created. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
351 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
352 * @see Cache |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
353 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
354 private final class ResolvedReferences { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
355 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
356 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
357 * Pointer to the {@code ConstantPool::_resolved_references} array. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
358 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
359 private Object[] resolvedReferences; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
360 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
361 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
362 * Map of constant pool indexes to {@code ConstantPool::_resolved_references} indexes. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
363 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
364 private final HashMap<Integer, Integer> referenceMap = new HashMap<>(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
365 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
366 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
367 * Returns the {@code ConstantPool::_resolved_references} array for this constant pool. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
368 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
369 * @return resolved references array if exists, null otherwise |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
370 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
371 public Object[] getArray() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
372 if (resolvedReferences == null) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
373 final long handle = unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolResolvedReferencesOffset); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
374 if (handle != 0) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
375 resolvedReferences = (Object[]) runtime().getCompilerToVM().readUncompressedOop(handle + runtime().getConfig().handleHandleOffset); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
376 fillReferenceMap(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
377 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
378 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
379 return resolvedReferences; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
380 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
381 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
382 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
383 * Fills the {@link #referenceMap} with all the values from |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
384 * {@code ConstantPool::_reference_map} for faster lookup. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
385 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
386 private void fillReferenceMap() { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
387 // It is possible there is a resolved references array but no reference map. |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
388 final long address = unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolReferenceMapOffset); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
389 if (address != 0) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
390 final int length = unsafe.getInt(null, address + runtime().getConfig().arrayU1LengthOffset); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
391 for (int i = 0; i < length; i++) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
392 final int value = unsafe.getShort(address + runtime().getConfig().arrayU2DataOffset + i * Short.BYTES); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
393 referenceMap.put(value, i); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
394 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
395 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
396 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
397 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
398 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
399 * See {@code ConstantPool::cp_to_object_index}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
400 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
401 * @param cpi constant pool index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
402 * @return resolved references array index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
403 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
404 public int constantPoolIndexToResolvedReferencesIndex(int cpi) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
405 final Integer index = referenceMap.get(cpi); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
406 // We might not find the index for jsr292 call. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
407 return (index == null) ? -1 : index; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
408 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
409 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
410 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
411 |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
412 /** |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
413 * Gets the JVMCI mirror from a HotSpot constant pool.The VM is responsible for ensuring that |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
414 * the ConstantPool is kept alive for the duration of this call and the |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
415 * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
416 * |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
417 * Called from the VM. |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
418 * |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
419 * @param metaspaceConstantPool a metaspace ConstantPool object |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
420 * @return the {@link HotSpotConstantPool} corresponding to {@code metaspaceConstantPool} |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
421 */ |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
422 @SuppressWarnings("unused") |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
423 private static HotSpotConstantPool fromMetaspace(long metaspaceConstantPool) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
424 return new HotSpotConstantPool(metaspaceConstantPool); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
425 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
426 |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
427 private HotSpotConstantPool(long metaspaceConstantPool) { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
428 this.metaspaceConstantPool = metaspaceConstantPool; |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
429 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
430 // Cache constructor needs metaspaceConstantPool. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
431 cache = new Cache(); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
432 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
433 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
434 /** |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
435 * Gets the holder for this constant pool as {@link HotSpotResolvedObjectTypeImpl}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
436 * |
14093 | 437 * @return holder for this constant pool |
438 */ | |
14117
2b2f0022900f
removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents:
14093
diff
changeset
|
439 private HotSpotResolvedObjectType getHolder() { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
440 return runtime().getCompilerToVM().getResolvedJavaType(this, runtime().getConfig().constantPoolHolderOffset, false); |
14093 | 441 } |
442 | |
443 /** | |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
444 * Converts a raw index from the bytecodes to a constant pool index by adding a |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
445 * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
446 * |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
447 * @param rawIndex index from the bytecode |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
448 * @param opcode bytecode to convert the index for |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
449 * @return constant pool index |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
450 */ |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
451 private static int rawIndexToConstantPoolIndex(int rawIndex, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
452 int index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
453 if (opcode == Bytecodes.INVOKEDYNAMIC) { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
454 index = rawIndex; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
455 // See: ConstantPool::is_invokedynamic_index |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
456 assert index < 0 : "not an invokedynamic constant pool index " + index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
457 } else { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
458 assert opcode == Bytecodes.GETFIELD || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTSTATIC || opcode == Bytecodes.INVOKEINTERFACE || |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
459 opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + opcode; |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
460 index = rawIndex + runtime().getConfig().constantPoolCpCacheIndexTag; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
461 } |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
462 return index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
463 } |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
464 |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
465 /** |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
466 * Decode a constant pool cache index to a constant pool index. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
467 * |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
468 * See {@code ConstantPool::decode_cpcache_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
469 * |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
470 * @param index constant pool cache index |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
471 * @return decoded index |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
472 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
473 private static int decodeConstantPoolCacheIndex(int index) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
474 if (isInvokedynamicIndex(index)) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
475 return decodeInvokedynamicIndex(index); |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
476 } else { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
477 return index - runtime().getConfig().constantPoolCpCacheIndexTag; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
478 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
479 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
480 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
481 /** |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
482 * See {@code ConstantPool::is_invokedynamic_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
483 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
484 private static boolean isInvokedynamicIndex(int index) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
485 return index < 0; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
486 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
487 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
488 /** |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
489 * See {@code ConstantPool::decode_invokedynamic_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
490 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
491 private static int decodeInvokedynamicIndex(int i) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
492 assert isInvokedynamicIndex(i) : i; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
493 return ~i; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
494 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
495 |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
496 public long getMetaspaceConstantPool() { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
497 return metaspaceConstantPool; |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
498 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
499 |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
500 public long getMetaspacePointer() { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
501 return getMetaspaceConstantPool(); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
502 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
503 |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
504 /** |
14093 | 505 * Gets the constant pool tag at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
506 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
507 * @param index constant pool index |
14093 | 508 * @return constant pool tag |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
509 */ |
14529 | 510 private JVM_CONSTANT getTagAt(int index) { |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
511 assertBounds(index); |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
512 HotSpotVMConfig config = runtime().getConfig(); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
513 final long metaspaceConstantPoolTags = unsafe.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); |
14529 | 514 final int tag = unsafe.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); |
17394
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
515 if (tag == 0) { |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
516 return null; |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
517 } |
14529 | 518 return JVM_CONSTANT.getEnum(tag); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
519 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
520 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
521 /** |
14093 | 522 * Gets the constant pool entry at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
523 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
524 * @param index constant pool index |
14093 | 525 * @return constant pool entry |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
526 */ |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
527 private long getEntryAt(int index) { |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
528 assertBounds(index); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
529 return unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
530 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
531 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
532 /** |
14093 | 533 * Gets the integer constant pool entry at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
534 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
535 * @param index constant pool index |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
536 * @return integer constant pool entry at index |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
537 */ |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
538 private int getIntAt(int index) { |
14529 | 539 assertTag(index, JVM_CONSTANT.Integer); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
540 return unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
541 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
542 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
543 /** |
14093 | 544 * Gets the long constant pool entry at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
545 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
546 * @param index constant pool index |
14093 | 547 * @return long constant pool entry |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
548 */ |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
549 private long getLongAt(int index) { |
14529 | 550 assertTag(index, JVM_CONSTANT.Long); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
551 return unsafe.getLong(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
552 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
553 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
554 /** |
14093 | 555 * Gets the float constant pool entry at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
556 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
557 * @param index constant pool index |
14093 | 558 * @return float constant pool entry |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
559 */ |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
560 private float getFloatAt(int index) { |
14529 | 561 assertTag(index, JVM_CONSTANT.Float); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
562 return unsafe.getFloat(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
563 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
564 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
565 /** |
14093 | 566 * Gets the double constant pool entry at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
567 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
568 * @param index constant pool index |
14093 | 569 * @return float constant pool entry |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
570 */ |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
571 private double getDoubleAt(int index) { |
14529 | 572 assertTag(index, JVM_CONSTANT.Double); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
573 return unsafe.getDouble(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
574 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
575 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
576 /** |
14093 | 577 * Gets the {@code JVM_CONSTANT_NameAndType} constant pool entry at index {@code index}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
578 * |
14093 | 579 * @param index constant pool index |
580 * @return {@code JVM_CONSTANT_NameAndType} constant pool entry | |
581 */ | |
582 private int getNameAndTypeAt(int index) { | |
14529 | 583 assertTag(index, JVM_CONSTANT.NameAndType); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
584 return unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
14093 | 585 } |
586 | |
587 /** | |
588 * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index | |
589 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
590 * |
14093 | 591 * @param index constant pool index |
592 * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry | |
593 */ | |
594 private int getNameAndTypeRefIndexAt(int index) { | |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
595 return runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(this, index); |
14093 | 596 } |
597 | |
598 /** | |
599 * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index | |
600 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
601 * |
14093 | 602 * @param index constant pool index |
603 * @return name as {@link String} | |
604 */ | |
605 private String getNameRefAt(int index) { | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
606 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
607 final int nameRefIndex = getNameRefIndexAt(getNameAndTypeRefIndexAt(index)); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
608 return new HotSpotSymbol(getEntryAt(nameRefIndex)).asString(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
609 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
610 return runtime().getCompilerToVM().lookupNameRefInPool(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
611 } |
14093 | 612 } |
613 | |
614 /** | |
615 * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at | |
616 * index {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
617 * |
14093 | 618 * @param index constant pool index |
619 * @return name reference index | |
620 */ | |
621 private int getNameRefIndexAt(int index) { | |
622 final int refIndex = getNameAndTypeAt(index); | |
623 // name ref index is in the low 16-bits. | |
624 return refIndex & 0xFFFF; | |
625 } | |
626 | |
627 /** | |
628 * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index | |
629 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
630 * |
14093 | 631 * @param index constant pool index |
632 * @return signature as {@link String} | |
633 */ | |
634 private String getSignatureRefAt(int index) { | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
635 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
636 final int signatureRefIndex = getSignatureRefIndexAt(getNameAndTypeRefIndexAt(index)); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
637 return new HotSpotSymbol(getEntryAt(signatureRefIndex)).asString(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
638 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
639 return runtime().getCompilerToVM().lookupSignatureRefInPool(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
640 } |
14093 | 641 } |
642 | |
643 /** | |
644 * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry | |
645 * at index {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
646 * |
14093 | 647 * @param index constant pool index |
648 * @return signature reference index | |
649 */ | |
650 private int getSignatureRefIndexAt(int index) { | |
651 final int refIndex = getNameAndTypeAt(index); | |
652 // signature ref index is in the high 16-bits. | |
653 return refIndex >>> 16; | |
654 } | |
655 | |
656 /** | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
657 * Gets the klass reference index constant pool entry at index {@code index}. See |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
658 * {@code ConstantPool::klass_ref_index_at}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
659 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
660 * @param index constant pool index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
661 * @param cached whether to go through the constant pool cache |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
662 * @return klass reference index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
663 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
664 private int getKlassRefIndexAt(int index, boolean cached) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
665 int cpi = index; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
666 if (cached && cache.exists()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
667 // change byte-ordering and go via cache |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
668 cpi = cache.constantPoolCacheIndexToConstantPoolIndex(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
669 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
670 assertTagIsFieldOrMethod(cpi); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
671 final int refIndex = unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + cpi * runtime().getHostJVMCIBackend().getTarget().wordSize); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
672 // klass ref index is in the low 16-bits. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
673 return refIndex & 0xFFFF; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
674 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
675 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
676 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
677 * Gets the klass reference index constant pool entry at index {@code index}. See |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
678 * {@code ConstantPool::klass_ref_index_at}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
679 * |
14093 | 680 * @param index constant pool index |
681 * @return klass reference index | |
682 */ | |
683 private int getKlassRefIndexAt(int index) { | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
684 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
685 return getKlassRefIndexAt(index, true); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
686 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
687 return runtime().getCompilerToVM().lookupKlassRefIndexInPool(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
688 } |
14093 | 689 } |
690 | |
691 /** | |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
692 * Gets the uncached klass reference index constant pool entry at index {@code index}. See: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
693 * {@code ConstantPool::uncached_klass_ref_index_at}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
694 * |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
695 * @param index constant pool index |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
696 * @return klass reference index |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
697 */ |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
698 private int getUncachedKlassRefIndexAt(int index) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
699 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
700 return getKlassRefIndexAt(index, false); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
701 } else { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
702 assertTagIsFieldOrMethod(index); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
703 final int refIndex = unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
704 // klass ref index is in the low 16-bits. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
705 return refIndex & 0xFFFF; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
706 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
707 } |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
708 |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
709 /** |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
710 * Asserts that the constant pool index {@code index} is in the bounds of the constant pool. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
711 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
712 * @param index constant pool index |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
713 */ |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
714 private void assertBounds(int index) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13259
diff
changeset
|
715 assert 0 <= index && index < length() : "index " + index + " not between 0 and " + length(); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
716 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
717 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
718 /** |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
719 * Asserts that the constant pool tag at index {@code index} is equal to {@code tag}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
720 * |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
721 * @param index constant pool index |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
722 * @param tag expected tag |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
723 */ |
14529 | 724 private void assertTag(int index, JVM_CONSTANT tag) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
725 final JVM_CONSTANT tagAt = getTagAt(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
726 assert tagAt == tag : "constant pool tag at index " + index + " is " + tagAt + " but expected " + tag; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
727 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
728 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
729 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
730 * Asserts that the constant pool tag at index {@code index} is a {@link JVM_CONSTANT#Fieldref}, |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
731 * or a {@link JVM_CONSTANT#MethodRef}, or a {@link JVM_CONSTANT#InterfaceMethodref}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
732 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
733 * @param index constant pool index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
734 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
735 private void assertTagIsFieldOrMethod(int index) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
736 final JVM_CONSTANT tagAt = getTagAt(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
737 assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt; |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
738 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
739 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
740 @Override |
9108 | 741 public int length() { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
742 return unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolLengthOffset); |
9108 | 743 } |
744 | |
745 @Override | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 public Object lookupConstant(int cpi) { |
7002
74f0207b82f5
fixed bug in bytecode reconstitution
Doug Simon <doug.simon@oracle.com>
parents:
6588
diff
changeset
|
747 assert cpi != 0; |
14529 | 748 final JVM_CONSTANT tag = getTagAt(cpi); |
749 switch (tag) { | |
750 case Integer: | |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
751 return JavaConstant.forInt(getIntAt(cpi)); |
14529 | 752 case Long: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
753 return JavaConstant.forLong(getLongAt(cpi)); |
14529 | 754 case Float: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
755 return JavaConstant.forFloat(getFloatAt(cpi)); |
14529 | 756 case Double: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
757 return JavaConstant.forDouble(getDoubleAt(cpi)); |
14529 | 758 case Class: |
759 case UnresolvedClass: | |
760 case UnresolvedClassInError: | |
761 final int opcode = -1; // opcode is not used | |
762 return lookupType(cpi, opcode); | |
763 case String: | |
22272
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
764 /* |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
765 * Normally, we would expect a String here, but anonymous classes can have |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
766 * "pseudo strings" (arbitrary live objects) patched into a String entry. Such |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
767 * entries do not have a symbol in the constant pool slot. |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
768 */ |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
769 Object string; |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
770 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
771 // See: ConstantPool::resolve_constant_at_impl |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
772 /* |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
773 * Note: Call getArray() before constantPoolIndexToResolvedReferencesIndex() |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
774 * because it fills the map if the array exists. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
775 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
776 Object[] localResolvedReferences = resolvedReferences.getArray(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
777 final int index = resolvedReferences.constantPoolIndexToResolvedReferencesIndex(cpi); |
22272
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
778 assert index >= 0; |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
779 // See: ConstantPool::string_at_impl |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
780 string = localResolvedReferences[index]; |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
781 if (string != null) { |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
782 assert string instanceof String || getEntryAt(index) == 0L; |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
783 return HotSpotObjectConstantImpl.forObject(string); |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
784 } else { |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
785 final long metaspaceSymbol = getEntryAt(cpi); |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
786 if (metaspaceSymbol != 0L) { |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
787 HotSpotSymbol symbol = new HotSpotSymbol(metaspaceSymbol); |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
788 string = symbol.asString().intern(); |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
789 // See: ConstantPool::string_at_put |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
790 localResolvedReferences[index] = string; |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
791 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
792 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
793 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
794 string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
795 } |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
796 return HotSpotObjectConstantImpl.forObject(string); |
14529 | 797 case MethodHandle: |
798 case MethodHandleInError: | |
799 case MethodType: | |
800 case MethodTypeInError: | |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
801 Object obj = runtime().getCompilerToVM().resolveConstantInPool(this, cpi); |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
802 return HotSpotObjectConstantImpl.forObject(obj); |
14529 | 803 default: |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
804 throw new JVMCIError("Unknown constant pool tag %s", tag); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
805 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
806 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
807 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
808 @Override |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
809 public String lookupUtf8(int cpi) { |
14529 | 810 assertTag(cpi, JVM_CONSTANT.Utf8); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
811 String s; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
812 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
813 HotSpotSymbol symbol = new HotSpotSymbol(getEntryAt(cpi)); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
814 s = symbol.asString(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
815 // It shouldn't but just in case something went wrong... |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
816 if (s == null) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
817 throw JVMCIError.shouldNotReachHere("malformed UTF-8 string in constant pool"); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
818 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
819 } else { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
820 s = runtime().getCompilerToVM().getSymbol(getEntryAt(cpi)); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
821 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
822 return s; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
823 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
826 public Signature lookupSignature(int cpi) { |
18540
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
827 return new HotSpotSignature(runtime(), lookupUtf8(cpi)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
831 public JavaConstant lookupAppendix(int cpi, int opcode) { |
9011
23762f2438b6
support for compiling LambdaForm invocations (invokevirtual instructions that were rewritten to invokehandle instructions)
Doug Simon <doug.simon@oracle.com>
parents:
8945
diff
changeset
|
832 assert Bytecodes.isInvoke(opcode); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
833 final int index = rawIndexToConstantPoolIndex(cpi, opcode); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
834 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
835 Object appendix = null; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
836 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
837 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
838 if (!cache.exists()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
839 // Nothing to load yet. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
840 return null; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
841 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
842 final int cacheIndex = decodeConstantPoolCacheIndex(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
843 Cache.Entry entry = cache.getEntryAt(cacheIndex); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
844 appendix = entry.getAppendixIfResolved(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
845 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
846 appendix = runtime().getCompilerToVM().lookupAppendixInPool(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
847 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
848 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
849 if (appendix == null) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
850 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
851 } else { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
852 return HotSpotObjectConstantImpl.forObject(appendix); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
853 } |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
854 } |
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
855 |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
856 /** |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
857 * Gets a {@link JavaType} corresponding a given resolved or unresolved type. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
858 * |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
859 * @param type either a ResolvedJavaType or a String naming a unresolved type. |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
860 */ |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
861 private static JavaType getJavaType(final Object type) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
862 if (type instanceof String) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
863 String name = (String) type; |
18540
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
864 return HotSpotUnresolvedJavaType.create(runtime(), "L" + name + ";"); |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
865 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
866 return (JavaType) type; |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
867 } |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
868 } |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
869 |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
870 @Override |
6588
b89b5038ad7e
removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
871 public JavaMethod lookupMethod(int cpi, int opcode) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
872 final int index = rawIndexToConstantPoolIndex(cpi, opcode); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
873 final HotSpotResolvedJavaMethod method = runtime().getCompilerToVM().lookupMethodInPool(this, index, (byte) opcode); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
874 if (method != null) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
875 return method; |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
876 } else { |
14093 | 877 // Get the method's name and signature. |
878 String name = getNameRefAt(index); | |
18540
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
879 HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureRefAt(index)); |
14093 | 880 if (opcode == Bytecodes.INVOKEDYNAMIC) { |
18540
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
881 HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); |
14093 | 882 return new HotSpotMethodUnresolved(name, signature, holder); |
883 } else { | |
884 final int klassIndex = getKlassRefIndexAt(index); | |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
885 final Object type = runtime().getCompilerToVM().lookupKlassInPool(this, klassIndex); |
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
886 JavaType holder = getJavaType(type); |
14093 | 887 return new HotSpotMethodUnresolved(name, signature, holder); |
888 } | |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
889 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
891 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
892 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
893 public JavaType lookupType(int cpi, int opcode) { |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
894 final LookupTypeCacheElement elem = this.lastLookupType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
895 if (elem != null && elem.lastCpi == cpi) { |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
896 return elem.javaType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
897 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
898 final Object type = runtime().getCompilerToVM().lookupKlassInPool(this, cpi); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
899 JavaType result = getJavaType(type); |
21431
90c55b9ad309
only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21411
diff
changeset
|
900 if (result instanceof ResolvedJavaType) { |
90c55b9ad309
only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21411
diff
changeset
|
901 this.lastLookupType = new LookupTypeCacheElement(cpi, result); |
90c55b9ad309
only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21411
diff
changeset
|
902 } |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
903 return result; |
19377
2ff3a30501da
Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
904 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
905 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
906 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
907 @Override |
5541
b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
908 public JavaField lookupField(int cpi, int opcode) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
909 final int index = rawIndexToConstantPoolIndex(cpi, opcode); |
14093 | 910 final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index); |
911 final int nameIndex = getNameRefIndexAt(nameAndTypeIndex); | |
912 String name = lookupUtf8(nameIndex); | |
913 final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); | |
914 String typeName = lookupUtf8(typeIndex); | |
14117
2b2f0022900f
removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents:
14093
diff
changeset
|
915 JavaType type = runtime().lookupType(typeName, getHolder(), false); |
14093 | 916 |
917 final int holderIndex = getKlassRefIndexAt(index); | |
918 JavaType holder = lookupType(holderIndex, opcode); | |
919 | |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
920 if (holder instanceof HotSpotResolvedObjectTypeImpl) { |
14093 | 921 long[] info = new long[2]; |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
922 HotSpotResolvedObjectTypeImpl resolvedHolder; |
14093 | 923 try { |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
924 resolvedHolder = runtime().getCompilerToVM().resolveFieldInPool(this, index, (byte) opcode, info); |
14093 | 925 } catch (Throwable t) { |
926 /* | |
927 * If there was an exception resolving the field we give up and return an unresolved | |
928 * field. | |
929 */ | |
930 return new HotSpotUnresolvedField(holder, name, type); | |
931 } | |
932 final int flags = (int) info[0]; | |
933 final long offset = info[1]; | |
19377
2ff3a30501da
Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
934 HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags); |
2ff3a30501da
Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
935 return result; |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
936 } else { |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
937 return new HotSpotUnresolvedField(holder, name, type); |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
938 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
939 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
940 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
941 @Override |
6588
b89b5038ad7e
removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
942 public void loadReferencedType(int cpi, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
943 int index; |
14093 | 944 switch (opcode) { |
945 case Bytecodes.CHECKCAST: | |
946 case Bytecodes.INSTANCEOF: | |
947 case Bytecodes.NEW: | |
948 case Bytecodes.ANEWARRAY: | |
949 case Bytecodes.MULTIANEWARRAY: | |
950 case Bytecodes.LDC: | |
951 case Bytecodes.LDC_W: | |
952 case Bytecodes.LDC2_W: | |
953 index = cpi; | |
954 break; | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
955 case Bytecodes.INVOKEDYNAMIC: { |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
956 // invokedynamic instructions point to a constant pool cache entry. |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
957 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
958 // index = decodeConstantPoolCacheIndex(cpi) + |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
959 // runtime().getConfig().constantPoolCpCacheIndexTag; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
960 // index = cache.constantPoolCacheIndexToConstantPoolIndex(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
961 final int cacheIndex = cpi; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
962 index = cache.getEntryAt(decodeInvokedynamicIndex(cacheIndex)).getConstantPoolIndex(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
963 // JVMCIError.guarantee(index == x, index + " != " + x); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
964 } else { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
965 index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag; |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
966 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
967 } |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
968 break; |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
969 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
970 case Bytecodes.GETSTATIC: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
971 case Bytecodes.PUTSTATIC: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
972 case Bytecodes.GETFIELD: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
973 case Bytecodes.PUTFIELD: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
974 case Bytecodes.INVOKEVIRTUAL: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
975 case Bytecodes.INVOKESPECIAL: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
976 case Bytecodes.INVOKESTATIC: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
977 case Bytecodes.INVOKEINTERFACE: { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
978 // invoke and field instructions point to a constant pool cache entry. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
979 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
980 // index = rawIndexToConstantPoolIndex(cpi, opcode); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
981 // index = cache.constantPoolCacheIndexToConstantPoolIndex(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
982 final int cacheIndex = cpi; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
983 index = cache.getEntryAt(cacheIndex).getConstantPoolIndex(); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
984 // JVMCIError.guarantee(index == x, index + " != " + x); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
985 } else { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
986 index = rawIndexToConstantPoolIndex(cpi, opcode); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
987 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
988 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
989 break; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
990 } |
14093 | 991 default: |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
992 throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
993 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
994 |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
995 final JVM_CONSTANT tag = getTagAt(index); |
17394
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
996 if (tag == null) { |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
997 assert getTagAt(index - 1) == JVM_CONSTANT.Double || getTagAt(index - 1) == JVM_CONSTANT.Long; |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
998 return; |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
999 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1000 switch (tag) { |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
1001 case MethodRef: |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1002 case Fieldref: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1003 case InterfaceMethodref: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1004 index = getUncachedKlassRefIndexAt(index); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1005 // Read the tag only once because it could change between multiple reads. |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1006 final JVM_CONSTANT klassTag = getTagAt(index); |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1007 assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17394
diff
changeset
|
1008 // fall through |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1009 case Class: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1010 case UnresolvedClass: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1011 case UnresolvedClassInError: |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
1012 final HotSpotResolvedObjectTypeImpl type = runtime().getCompilerToVM().resolveTypeInPool(this, index); |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1013 Class<?> klass = type.mirror(); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1014 if (!klass.isPrimitive() && !klass.isArray()) { |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1015 unsafe.ensureClassInitialized(klass); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1016 } |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1017 switch (tag) { |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1018 case MethodRef: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1019 if (Bytecodes.isInvokeHandleAlias(opcode)) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1020 final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1021 if (isInvokeHandle(methodRefCacheIndex, type)) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
1022 runtime().getCompilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1023 } |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1024 } |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
1025 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1026 break; |
15205
affef8631cf4
Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
1027 case InvokeDynamic: |
17394
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1028 if (isInvokedynamicIndex(cpi)) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
1029 runtime().getCompilerToVM().resolveInvokeDynamicInPool(this, cpi); |
15255
cf6aedb39215
Prevent using loadReferencedType with LDC when the constant pool index refers to InvokeDynamic entry but isn't an invokedynamic index.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15205
diff
changeset
|
1030 } |
15205
affef8631cf4
Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
1031 break; |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1032 default: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1033 // nothing |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1034 break; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
1035 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1036 } |
17394
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1037 |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1038 private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1039 int index; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1040 if (Options.UseConstantPoolCacheJavaCode.getValue()) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1041 index = cache.constantPoolCacheIndexToConstantPoolIndex(methodRefCacheIndex); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1042 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
1043 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1044 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
1045 assertTag(index, JVM_CONSTANT.MethodRef); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
1046 return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameRefAt(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
1047 } |
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
1048 |
17394
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1049 @Override |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1050 public String toString() { |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1051 HotSpotResolvedObjectType holder = getHolder(); |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1052 return "HotSpotConstantPool<" + holder.toJavaName() + ">"; |
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
1053 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1054 } |