Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java @ 15193:96bb07a5d667
Spit up and move GraalInternalError.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Thu, 17 Apr 2014 15:18:41 +0200 |
parents | db4254246f9a |
children | affef8631cf4 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
2 * Copyright (c) 2011, 2013, 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 */ |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
23 package com.oracle.graal.hotspot.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12431
diff
changeset
|
25 import static com.oracle.graal.graph.UnsafeAccess.*; |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
26 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
27 |
14093 | 28 import java.lang.invoke.*; |
29 | |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5278
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
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
|
31 import com.oracle.graal.bytecode.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
32 import com.oracle.graal.compiler.common.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.hotspot.*; |
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 */ |
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
|
38 public class HotSpotConstantPool extends CompilerObject implements ConstantPool { |
5278
74dfa6f86879
removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
39 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
40 private static final long serialVersionUID = -5443206401485234850L; |
5278
74dfa6f86879
removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
41 |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
42 /** |
14529 | 43 * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and |
44 * internal ones. | |
45 */ | |
46 private enum JVM_CONSTANT { | |
47 // @formatter:off | |
48 Utf8(config().jvmConstantUtf8), | |
49 Integer(config().jvmConstantInteger), | |
50 Long(config().jvmConstantLong), | |
51 Float(config().jvmConstantFloat), | |
52 Double(config().jvmConstantDouble), | |
53 Class(config().jvmConstantClass), | |
54 UnresolvedClass(config().jvmConstantUnresolvedClass), | |
55 UnresolvedClassInError(config().jvmConstantUnresolvedClassInError), | |
56 String(config().jvmConstantString), | |
57 Fieldref(config().jvmConstantFieldref), | |
58 MethodRef(config().jvmConstantMethodref), | |
59 InterfaceMethodref(config().jvmConstantInterfaceMethodref), | |
60 NameAndType(config().jvmConstantNameAndType), | |
61 MethodHandle(config().jvmConstantMethodHandle), | |
62 MethodHandleInError(config().jvmConstantMethodHandleInError), | |
63 MethodType(config().jvmConstantMethodType), | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
64 MethodTypeInError(config().jvmConstantMethodTypeInError), |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
65 InvokeDynamic(config().jvmConstantInvokeDynamic); |
14529 | 66 // @formatter:on |
67 | |
68 private final int value; | |
69 | |
70 private JVM_CONSTANT(int value) { | |
71 this.value = value; | |
72 } | |
73 | |
74 private static HotSpotVMConfig config() { | |
75 return runtime().getConfig(); | |
76 } | |
77 | |
78 public static JVM_CONSTANT getEnum(int value) { | |
79 for (JVM_CONSTANT e : values()) { | |
80 if (e.value == value) { | |
81 return e; | |
82 } | |
83 } | |
84 throw GraalInternalError.shouldNotReachHere("unknown enum value " + value); | |
85 } | |
86 } | |
87 | |
88 /** | |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
89 * Reference to the C++ ConstantPool object. |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
90 */ |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
91 private final long metaspaceConstantPool; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
93 public HotSpotConstantPool(long metaspaceConstantPool) { |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
94 this.metaspaceConstantPool = metaspaceConstantPool; |
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
|
95 } |
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
|
96 |
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
|
97 /** |
14093 | 98 * Gets the holder for this constant pool as {@link HotSpotResolvedObjectType}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
99 * |
14093 | 100 * @return holder for this constant pool |
101 */ | |
14117
2b2f0022900f
removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents:
14093
diff
changeset
|
102 private HotSpotResolvedObjectType getHolder() { |
14093 | 103 final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolHolderOffset); |
104 return (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); | |
105 } | |
106 | |
107 /** | |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
108 * 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
|
109 * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
110 * |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
111 * @param rawIndex index from the bytecode |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
112 * @param opcode bytecode to convert the index for |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
113 * @return constant pool index |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
114 */ |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
115 private static int toConstantPoolIndex(int rawIndex, int opcode) { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
116 int index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
117 if (opcode == Bytecodes.INVOKEDYNAMIC) { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
118 index = rawIndex; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
119 // See: ConstantPool::is_invokedynamic_index |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
120 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
|
121 } else { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
122 assert opcode == Bytecodes.GETFIELD || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTSTATIC || opcode == Bytecodes.INVOKEINTERFACE || |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
123 opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + Bytecodes.nameOf(opcode); |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
124 index = rawIndex + runtime().getConfig().constantPoolCpCacheIndexTag; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
125 } |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
126 return index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
127 } |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
128 |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
129 /** |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
130 * 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
|
131 * |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
132 * See {@code ConstantPool::decode_cpcache_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
133 * |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
134 * @param index constant pool cache index |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
135 * @return decoded index |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
136 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
137 private static int decodeConstantPoolCacheIndex(int index) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
138 if (isInvokedynamicIndex(index)) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
139 return decodeInvokedynamicIndex(index); |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
140 } else { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
141 return index - runtime().getConfig().constantPoolCpCacheIndexTag; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
142 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
143 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
144 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
145 /** |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
146 * See {@code ConstantPool::is_invokedynamic_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
147 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
148 private static boolean isInvokedynamicIndex(int index) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
149 return index < 0; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
150 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
151 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
152 /** |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
153 * See {@code ConstantPool::decode_invokedynamic_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
154 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
155 private static int decodeInvokedynamicIndex(int i) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
156 assert isInvokedynamicIndex(i) : i; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
157 return ~i; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
158 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
159 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
160 /** |
14093 | 161 * 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
|
162 * |
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
|
163 * @param index constant pool index |
14093 | 164 * @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
|
165 */ |
14529 | 166 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
|
167 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
|
168 HotSpotVMConfig config = runtime().getConfig(); |
14529 | 169 final long metaspaceConstantPoolTags = unsafe.getAddress(metaspaceConstantPool + config.constantPoolTagsOffset); |
170 final int tag = unsafe.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); | |
171 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
|
172 } |
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
|
173 |
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
|
174 /** |
14093 | 175 * 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
|
176 * |
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
|
177 * @param index constant pool index |
14093 | 178 * @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
|
179 */ |
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
|
180 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
|
181 assertBounds(index); |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
182 return unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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
|
183 } |
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
|
184 |
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
|
185 /** |
14093 | 186 * 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
|
187 * |
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
|
188 * @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
|
189 * @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
|
190 */ |
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
|
191 private int getIntAt(int index) { |
14529 | 192 assertTag(index, JVM_CONSTANT.Integer); |
193 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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
|
194 } |
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
|
195 |
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
|
196 /** |
14093 | 197 * 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
|
198 * |
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
|
199 * @param index constant pool index |
14093 | 200 * @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
|
201 */ |
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
|
202 private long getLongAt(int index) { |
14529 | 203 assertTag(index, JVM_CONSTANT.Long); |
204 return unsafe.getLong(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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
|
205 } |
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
|
206 |
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
|
207 /** |
14093 | 208 * 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
|
209 * |
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
|
210 * @param index constant pool index |
14093 | 211 * @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
|
212 */ |
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
|
213 private float getFloatAt(int index) { |
14529 | 214 assertTag(index, JVM_CONSTANT.Float); |
215 return unsafe.getFloat(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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
|
216 } |
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
|
217 |
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
|
218 /** |
14093 | 219 * 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
|
220 * |
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
|
221 * @param index constant pool index |
14093 | 222 * @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
|
223 */ |
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
|
224 private double getDoubleAt(int index) { |
14529 | 225 assertTag(index, JVM_CONSTANT.Double); |
226 return unsafe.getDouble(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().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
|
227 } |
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
|
228 |
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
|
229 /** |
14093 | 230 * 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
|
231 * |
14093 | 232 * @param index constant pool index |
233 * @return {@code JVM_CONSTANT_NameAndType} constant pool entry | |
234 */ | |
235 private int getNameAndTypeAt(int index) { | |
14529 | 236 assertTag(index, JVM_CONSTANT.NameAndType); |
237 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); | |
14093 | 238 } |
239 | |
240 /** | |
241 * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index | |
242 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
243 * |
14093 | 244 * @param index constant pool index |
245 * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry | |
246 */ | |
247 private int getNameAndTypeRefIndexAt(int index) { | |
248 return runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(metaspaceConstantPool, index); | |
249 } | |
250 | |
251 /** | |
252 * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index | |
253 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
254 * |
14093 | 255 * @param index constant pool index |
256 * @return name as {@link String} | |
257 */ | |
258 private String getNameRefAt(int index) { | |
259 final long name = runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index); | |
260 HotSpotSymbol symbol = new HotSpotSymbol(name); | |
261 return symbol.asString(); | |
262 } | |
263 | |
264 /** | |
265 * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at | |
266 * index {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
267 * |
14093 | 268 * @param index constant pool index |
269 * @return name reference index | |
270 */ | |
271 private int getNameRefIndexAt(int index) { | |
272 final int refIndex = getNameAndTypeAt(index); | |
273 // name ref index is in the low 16-bits. | |
274 return refIndex & 0xFFFF; | |
275 } | |
276 | |
277 /** | |
278 * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index | |
279 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
280 * |
14093 | 281 * @param index constant pool index |
282 * @return signature as {@link String} | |
283 */ | |
284 private String getSignatureRefAt(int index) { | |
285 final long name = runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index); | |
286 HotSpotSymbol symbol = new HotSpotSymbol(name); | |
287 return symbol.asString(); | |
288 } | |
289 | |
290 /** | |
291 * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry | |
292 * at index {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
293 * |
14093 | 294 * @param index constant pool index |
295 * @return signature reference index | |
296 */ | |
297 private int getSignatureRefIndexAt(int index) { | |
298 final int refIndex = getNameAndTypeAt(index); | |
299 // signature ref index is in the high 16-bits. | |
300 return refIndex >>> 16; | |
301 } | |
302 | |
303 /** | |
304 * Gets the klass reference index 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
|
305 * |
14093 | 306 * @param index constant pool index |
307 * @return klass reference index | |
308 */ | |
309 private int getKlassRefIndexAt(int index) { | |
310 return runtime().getCompilerToVM().lookupKlassRefIndexInPool(metaspaceConstantPool, index); | |
311 } | |
312 | |
313 /** | |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
314 * 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
|
315 * {@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
|
316 * |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
317 * @param index constant pool index |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
318 * @return klass reference index |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
319 */ |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
320 private int getUncachedKlassRefIndexAt(int index) { |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
321 assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
322 final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
323 // klass ref index is in the low 16-bits. |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
324 return refIndex & 0xFFFF; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
325 } |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
326 |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
327 /** |
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
|
328 * 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
|
329 * |
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
|
330 * @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
|
331 */ |
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
|
332 private void assertBounds(int index) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13259
diff
changeset
|
333 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
|
334 } |
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
|
335 |
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
|
336 /** |
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
|
337 * 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
|
338 * |
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
|
339 * @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
|
340 * @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
|
341 */ |
14529 | 342 private void assertTag(int index, JVM_CONSTANT tag) { |
343 assert getTagAt(index) == tag : "constant pool tag at index " + index + " is " + getTagAt(index) + " but expected " + 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
|
344 } |
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
|
345 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 @Override |
9108 | 347 public int length() { |
14529 | 348 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolLengthOffset); |
9108 | 349 } |
350 | |
351 @Override | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 public Object lookupConstant(int cpi) { |
7002
74f0207b82f5
fixed bug in bytecode reconstitution
Doug Simon <doug.simon@oracle.com>
parents:
6588
diff
changeset
|
353 assert cpi != 0; |
14529 | 354 final JVM_CONSTANT tag = getTagAt(cpi); |
355 switch (tag) { | |
356 case Integer: | |
357 return Constant.forInt(getIntAt(cpi)); | |
358 case Long: | |
359 return Constant.forLong(getLongAt(cpi)); | |
360 case Float: | |
361 return Constant.forFloat(getFloatAt(cpi)); | |
362 case Double: | |
363 return Constant.forDouble(getDoubleAt(cpi)); | |
364 case Class: | |
365 case UnresolvedClass: | |
366 case UnresolvedClassInError: | |
367 final int opcode = -1; // opcode is not used | |
368 return lookupType(cpi, opcode); | |
369 case String: | |
370 Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi); | |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
371 return HotSpotObjectConstant.forObject(string); |
14529 | 372 case MethodHandle: |
373 case MethodHandleInError: | |
374 case MethodType: | |
375 case MethodTypeInError: | |
376 Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi); | |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
377 return HotSpotObjectConstant.forObject(obj); |
14529 | 378 default: |
379 throw GraalInternalError.shouldNotReachHere("unknown constant pool tag " + 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
|
380 } |
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
|
381 } |
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
|
382 |
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
|
383 @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
|
384 public String lookupUtf8(int cpi) { |
14529 | 385 assertTag(cpi, JVM_CONSTANT.Utf8); |
386 final long metaspaceSymbol = getEntryAt(cpi); | |
387 HotSpotSymbol symbol = new HotSpotSymbol(metaspaceSymbol); | |
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
|
388 return symbol.asString(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 @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
|
392 public Signature lookupSignature(int cpi) { |
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
|
393 return new HotSpotSignature(lookupUtf8(cpi)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
394 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
395 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
396 @Override |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
397 public Constant 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
|
398 assert Bytecodes.isInvoke(opcode); |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
399 final int index = toConstantPoolIndex(cpi, opcode); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
400 Object result = runtime().getCompilerToVM().lookupAppendixInPool(metaspaceConstantPool, index); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
401 if (result == null) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
402 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
403 } else { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
404 return HotSpotObjectConstant.forObject(result); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
405 } |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
406 } |
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
407 |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
408 /** |
14093 | 409 * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending |
410 * on the {@link HotSpotVMConfig#compilerToVMKlassTag tag}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
411 * |
14093 | 412 * @param metaspacePointer either a metaspace Klass or a metaspace Symbol |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
413 */ |
14093 | 414 private static JavaType getJavaType(final long metaspacePointer) { |
415 HotSpotVMConfig config = runtime().getConfig(); | |
416 if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) { | |
417 final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag; | |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
418 String name = new HotSpotSymbol(metaspaceSymbol).asString(); |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
419 return HotSpotUnresolvedJavaType.create(name); |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
420 } else { |
14093 | 421 assert (metaspacePointer & config.compilerToVMKlassTag) == 0; |
422 return HotSpotResolvedObjectType.fromMetaspaceKlass(metaspacePointer); | |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
423 } |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
424 } |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
425 |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
426 @Override |
6588
b89b5038ad7e
removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
427 public JavaMethod lookupMethod(int cpi, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
428 final int index = toConstantPoolIndex(cpi, opcode); |
14093 | 429 final long metaspaceMethod = runtime().getCompilerToVM().lookupMethodInPool(metaspaceConstantPool, index, (byte) opcode); |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
430 if (metaspaceMethod != 0L) { |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
431 return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
432 } else { |
14093 | 433 // Get the method's name and signature. |
434 String name = getNameRefAt(index); | |
435 String signature = getSignatureRefAt(index); | |
436 if (opcode == Bytecodes.INVOKEDYNAMIC) { | |
437 JavaType holder = HotSpotResolvedJavaType.fromClass(MethodHandle.class); | |
438 return new HotSpotMethodUnresolved(name, signature, holder); | |
439 } else { | |
440 final int klassIndex = getKlassRefIndexAt(index); | |
441 final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, klassIndex); | |
442 JavaType holder = getJavaType(metaspacePointer); | |
443 return new HotSpotMethodUnresolved(name, signature, holder); | |
444 } | |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
445 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 @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
|
449 public JavaType lookupType(int cpi, int opcode) { |
14093 | 450 final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi); |
451 return getJavaType(metaspacePointer); | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
453 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 @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
|
455 public JavaField lookupField(int cpi, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
456 final int index = toConstantPoolIndex(cpi, opcode); |
14093 | 457 final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index); |
458 final int nameIndex = getNameRefIndexAt(nameAndTypeIndex); | |
459 String name = lookupUtf8(nameIndex); | |
460 final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); | |
461 String typeName = lookupUtf8(typeIndex); | |
14117
2b2f0022900f
removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents:
14093
diff
changeset
|
462 JavaType type = runtime().lookupType(typeName, getHolder(), false); |
14093 | 463 |
464 final int holderIndex = getKlassRefIndexAt(index); | |
465 JavaType holder = lookupType(holderIndex, opcode); | |
466 | |
467 if (holder instanceof HotSpotResolvedObjectType) { | |
468 long[] info = new long[2]; | |
469 long metaspaceKlass; | |
470 try { | |
471 metaspaceKlass = runtime().getCompilerToVM().resolveField(metaspaceConstantPool, index, (byte) opcode, info); | |
472 } catch (Throwable t) { | |
473 /* | |
474 * If there was an exception resolving the field we give up and return an unresolved | |
475 * field. | |
476 */ | |
477 return new HotSpotUnresolvedField(holder, name, type); | |
478 } | |
479 HotSpotResolvedObjectType resolvedHolder = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); | |
480 final int flags = (int) info[0]; | |
481 final long offset = info[1]; | |
482 return resolvedHolder.createField(name, type, offset, flags); | |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
483 } else { |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
484 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
|
485 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
487 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 @Override |
6588
b89b5038ad7e
removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
489 public void loadReferencedType(int cpi, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
490 int index; |
14093 | 491 switch (opcode) { |
492 case Bytecodes.CHECKCAST: | |
493 case Bytecodes.INSTANCEOF: | |
494 case Bytecodes.NEW: | |
495 case Bytecodes.ANEWARRAY: | |
496 case Bytecodes.MULTIANEWARRAY: | |
497 case Bytecodes.LDC: | |
498 case Bytecodes.LDC_W: | |
499 case Bytecodes.LDC2_W: | |
500 index = cpi; | |
501 break; | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
502 case Bytecodes.INVOKEDYNAMIC: |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
503 // invokedynamic instructions point to a constant pool cache entry. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
504 index = decodeConstantPoolCacheIndex(cpi); |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
505 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
506 break; |
14093 | 507 default: |
508 index = toConstantPoolIndex(cpi, opcode); | |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
509 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
510 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
511 |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
512 JVM_CONSTANT tag = getTagAt(index); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
513 switch (tag) { |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
514 case Fieldref: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
515 case MethodRef: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
516 case InterfaceMethodref: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
517 index = getUncachedKlassRefIndexAt(index); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
518 tag = getTagAt(index); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
519 assert tag == JVM_CONSTANT.Class || tag == JVM_CONSTANT.UnresolvedClass || tag == JVM_CONSTANT.UnresolvedClassInError : tag; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
520 break; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
521 default: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
522 // nothing |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
523 break; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
524 } |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
525 |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
526 switch (tag) { |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
527 case Class: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
528 case UnresolvedClass: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
529 case UnresolvedClassInError: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
530 final long metaspaceKlass = runtime().getCompilerToVM().constantPoolKlassAt(metaspaceConstantPool, index); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
531 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
532 Class<?> klass = type.mirror(); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
533 if (!klass.isPrimitive() && !klass.isArray()) { |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
534 unsafe.ensureClassInitialized(klass); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
535 } |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
536 break; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
537 default: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
538 // nothing |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
539 break; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
540 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 } |