annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java @ 21536:7fed589ff982

remove documentation about extended bytecodes
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 11:06:22 +0200
parents de0cf192779c
children c1e2fdb5fea3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
21529
de0cf192779c removed more dependencies from JVMCI classes to non-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 */
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
23 package com.oracle.graal.hotspot.jvmci;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
15291
471e28b8f03b Move UnsafeAccess to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15255
diff changeset
25 import static com.oracle.graal.compiler.common.UnsafeAccess.*;
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
26 import static com.oracle.graal.hotspot.jvmci.HotSpotJVMCIRuntime.*;
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 9108
diff changeset
27
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
28 import java.lang.invoke.*;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
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.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 /**
5775
2c088af17e59 Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5554
diff changeset
35 * Implementation of {@link ConstantPool} for HotSpot.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 */
21411
082417ac43e4 removed com.oracle.graal.hotspot.server and uses of Serializable it depended upon (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21252
diff changeset
37 public class HotSpotConstantPool implements ConstantPool, HotSpotProxified {
5278
74dfa6f86879 removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
38
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
39 /**
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
40 * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
41 * internal ones.
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
42 */
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
43 private enum JVM_CONSTANT {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
44 // @formatter:off
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
45 Utf8(config().jvmConstantUtf8),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
46 Integer(config().jvmConstantInteger),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
47 Long(config().jvmConstantLong),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
48 Float(config().jvmConstantFloat),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
49 Double(config().jvmConstantDouble),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
50 Class(config().jvmConstantClass),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
51 UnresolvedClass(config().jvmConstantUnresolvedClass),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
52 UnresolvedClassInError(config().jvmConstantUnresolvedClassInError),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
53 String(config().jvmConstantString),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
54 Fieldref(config().jvmConstantFieldref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
55 MethodRef(config().jvmConstantMethodref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
56 InterfaceMethodref(config().jvmConstantInterfaceMethodref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
57 NameAndType(config().jvmConstantNameAndType),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
58 MethodHandle(config().jvmConstantMethodHandle),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
59 MethodHandleInError(config().jvmConstantMethodHandleInError),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
60 MethodType(config().jvmConstantMethodType),
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
61 MethodTypeInError(config().jvmConstantMethodTypeInError),
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
62 InvokeDynamic(config().jvmConstantInvokeDynamic);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
63 // @formatter:on
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
64
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
65 private final int tag;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
66
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
67 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
68 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
69 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
70
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
71 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
72 this.tag = tag;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
73 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
74
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
75 private static HotSpotVMConfig config() {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
76 return runtime().getConfig();
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
77 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
78
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
79 /**
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
80 * 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
81 * 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
82 */
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
83 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
84 private static final JVM_CONSTANT[] table = new JVM_CONSTANT[ExternalMax + 1 + (InternalMax - InternalMin) + 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
85 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
86 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
87 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
88 table[indexOf(e.tag)] = e;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
89 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
90 }
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
91
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
92 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
93 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
94 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
95 } 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
96 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
97 }
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
98 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
99 }
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
100
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
101 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
102 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
103 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
104 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
105 }
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
106 throw GraalInternalError.shouldNotReachHere("unknown JVM_CONSTANT tag " + 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
107 }
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
108 }
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
109
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
110 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
111 return TagValueMap.get(tag);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
112 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
113 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
114
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
115 private static class LookupTypeCacheElement {
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
116 int lastCpi = Integer.MIN_VALUE;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
117 JavaType javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
118
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
119 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
120 super();
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
121 this.lastCpi = lastCpi;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
122 this.javaType = javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
123 }
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
124 }
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
125
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
126 /**
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
127 * Reference to the C++ ConstantPool object.
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
128 */
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
129 private final long metaspaceConstantPool;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
130 private final Object[] cache;
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
131 private volatile LookupTypeCacheElement lastLookupType;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
133 public HotSpotConstantPool(long metaspaceConstantPool) {
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
134 this.metaspaceConstantPool = metaspaceConstantPool;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
135 cache = new Object[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
136 }
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
137
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
138 /**
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
139 * 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
140 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
141 * @return holder for this constant pool
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
142 */
14117
2b2f0022900f removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents: 14093
diff changeset
143 private HotSpotResolvedObjectType getHolder() {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
144 final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolHolderOffset);
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
145 return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
146 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
147
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
148 /**
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
149 * 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
150 * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
151 *
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
152 * @param rawIndex index from the bytecode
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
153 * @param opcode bytecode to convert the index for
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
154 * @return constant pool index
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
155 */
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
156 private static int toConstantPoolIndex(int rawIndex, int opcode) {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
157 int index;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
158 if (opcode == Bytecodes.INVOKEDYNAMIC) {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
159 index = rawIndex;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
160 // See: ConstantPool::is_invokedynamic_index
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
161 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
162 } else {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
163 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
164 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
165 index = rawIndex + runtime().getConfig().constantPoolCpCacheIndexTag;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
166 }
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
167 return index;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
168 }
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
169
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
170 /**
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
171 * 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
172 *
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
173 * See {@code ConstantPool::decode_cpcache_index}.
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
174 *
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
175 * @param index constant pool cache index
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
176 * @return decoded index
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
177 */
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
178 private static int decodeConstantPoolCacheIndex(int index) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
179 if (isInvokedynamicIndex(index)) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
180 return decodeInvokedynamicIndex(index);
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
181 } else {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
182 return index - runtime().getConfig().constantPoolCpCacheIndexTag;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
183 }
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
184 }
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
185
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
186 /**
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
187 * See {@code ConstantPool::is_invokedynamic_index}.
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
188 */
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
189 private static boolean isInvokedynamicIndex(int index) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
190 return index < 0;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
191 }
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
192
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
193 /**
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
194 * See {@code ConstantPool::decode_invokedynamic_index}.
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
195 */
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
196 private static int decodeInvokedynamicIndex(int i) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
197 assert isInvokedynamicIndex(i) : i;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
198 return ~i;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
199 }
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
200
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
201 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
202 * 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
203 *
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
204 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
205 * @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
206 */
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
207 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
208 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
209 HotSpotVMConfig config = runtime().getConfig();
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
210 final long metaspaceConstantPoolTags = unsafe.getAddress(metaspaceConstantPool + config.constantPoolTagsOffset);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
211 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
212 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
213 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
214 }
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
215 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
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
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
219 * 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
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
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
222 * @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
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 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
225 assertBounds(index);
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
226 return unsafe.getAddress(metaspaceConstantPool + 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
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
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
230 * 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
231 *
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
232 * @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
233 * @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
234 */
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
235 private int getIntAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
236 assertTag(index, JVM_CONSTANT.Integer);
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
237 return unsafe.getInt(metaspaceConstantPool + 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
238 }
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
239
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
240 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
241 * 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
242 *
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
243 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
244 * @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
245 */
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
246 private long getLongAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
247 assertTag(index, JVM_CONSTANT.Long);
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
248 return unsafe.getLong(metaspaceConstantPool + 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
249 }
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
250
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
251 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
252 * 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
253 *
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
254 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
255 * @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
256 */
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
257 private float getFloatAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
258 assertTag(index, JVM_CONSTANT.Float);
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
259 return unsafe.getFloat(metaspaceConstantPool + 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
260 }
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
261
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
262 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
263 * 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
264 *
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
265 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
266 * @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
267 */
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
268 private double getDoubleAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
269 assertTag(index, JVM_CONSTANT.Double);
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
270 return unsafe.getDouble(metaspaceConstantPool + 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
271 }
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
272
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
273 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
274 * 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
275 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
276 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
277 * @return {@code JVM_CONSTANT_NameAndType} constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
278 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
279 private int getNameAndTypeAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
280 assertTag(index, JVM_CONSTANT.NameAndType);
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
281 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
282 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
283
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
284 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
285 * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
286 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
287 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
288 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
289 * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
290 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
291 private int getNameAndTypeRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
292 return runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(metaspaceConstantPool, index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
293 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
294
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
295 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
296 * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
297 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
298 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
299 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
300 * @return name as {@link String}
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
301 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
302 private String getNameRefAt(int index) {
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
303 return runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
304 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
305
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
306 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
307 * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
308 * index {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
309 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
310 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
311 * @return name reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
312 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
313 private int getNameRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
314 final int refIndex = getNameAndTypeAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
315 // name ref index is in the low 16-bits.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
316 return refIndex & 0xFFFF;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
317 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
318
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
319 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
320 * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
321 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
322 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
323 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
324 * @return signature as {@link String}
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
325 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
326 private String getSignatureRefAt(int index) {
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
327 return runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
328 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
329
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
330 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
331 * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
332 * at index {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
333 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
334 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
335 * @return signature reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
336 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
337 private int getSignatureRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
338 final int refIndex = getNameAndTypeAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
339 // signature ref index is in the high 16-bits.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
340 return refIndex >>> 16;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
341 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
342
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
343 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
344 * 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
345 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
346 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
347 * @return klass reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
348 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
349 private int getKlassRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
350 return runtime().getCompilerToVM().lookupKlassRefIndexInPool(metaspaceConstantPool, index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
351 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
352
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
353 /**
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
354 * 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
355 * {@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
356 *
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
357 * @param index constant pool index
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
358 * @return klass reference index
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
359 */
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
360 private int getUncachedKlassRefIndexAt(int index) {
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
361 assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref;
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
362 final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
363 // klass ref index is in the low 16-bits.
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
364 return refIndex & 0xFFFF;
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
365 }
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
366
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
367 /**
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
368 * 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
369 *
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
370 * @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
371 */
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
372 private void assertBounds(int index) {
13261
0ffe9e4bb364 don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents: 13259
diff changeset
373 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
374 }
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
375
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
376 /**
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
377 * 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
378 *
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
379 * @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
380 * @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
381 */
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
382 private void assertTag(int index, JVM_CONSTANT tag) {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
383 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
384 }
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
385
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 @Override
9108
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
387 public int length() {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
388 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolLengthOffset);
9108
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
389 }
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
390
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
391 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 public Object lookupConstant(int cpi) {
7002
74f0207b82f5 fixed bug in bytecode reconstitution
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
393 assert cpi != 0;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
394 final JVM_CONSTANT tag = getTagAt(cpi);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
395 switch (tag) {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
396 case Integer:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
397 return JavaConstant.forInt(getIntAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
398 case Long:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
399 return JavaConstant.forLong(getLongAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
400 case Float:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
401 return JavaConstant.forFloat(getFloatAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
402 case Double:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
403 return JavaConstant.forDouble(getDoubleAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
404 case Class:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
405 case UnresolvedClass:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
406 case UnresolvedClassInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
407 final int opcode = -1; // opcode is not used
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
408 return lookupType(cpi, opcode);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
409 case String:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
410 Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi);
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
411 return HotSpotObjectConstantImpl.forObject(string);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
412 case MethodHandle:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
413 case MethodHandleInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
414 case MethodType:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
415 case MethodTypeInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
416 Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi);
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
417 return HotSpotObjectConstantImpl.forObject(obj);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
418 default:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
419 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
420 }
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
421 }
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
422
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
423 @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
424 public String lookupUtf8(int cpi) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
425 assertTag(cpi, JVM_CONSTANT.Utf8);
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
426 return runtime().getCompilerToVM().getSymbol(getEntryAt(cpi));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 @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
430 public Signature lookupSignature(int cpi) {
18542
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
431 return new HotSpotSignature(runtime(), lookupUtf8(cpi));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
435 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
436 assert Bytecodes.isInvoke(opcode);
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
437 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
438 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
439 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
440 return null;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14979
diff changeset
441 } else {
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
442 return HotSpotObjectConstantImpl.forObject(result);
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14979
diff changeset
443 }
8945
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
444 }
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
445
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
446 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
447 * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
448 * 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
449 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
450 * @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
451 */
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
452 private static JavaType getJavaType(final long metaspacePointer) {
21529
de0cf192779c removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21431
diff changeset
453 HotSpotJVMCIRuntime runtime = runtime();
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
454 HotSpotVMConfig config = runtime.getConfig();
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
455 if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
456 final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag;
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
457 String name = runtime.getCompilerToVM().getSymbol(metaspaceSymbol);
18542
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
458 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
459 } else {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
460 assert (metaspacePointer & config.compilerToVMKlassTag) == 0;
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
461 return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspacePointer);
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
462 }
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
463 }
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
464
8945
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
465 @Override
6588
b89b5038ad7e removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
466 public JavaMethod lookupMethod(int cpi, int opcode) {
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
467 if (opcode != Bytecodes.INVOKEDYNAMIC) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
468 Object result = cache[cpi];
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
469 if (result != null) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
470 return (ResolvedJavaMethod) result;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
471 }
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
472 }
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
473 final int index = toConstantPoolIndex(cpi, opcode);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
474 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
475 if (metaspaceMethod != 0L) {
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
476 HotSpotResolvedJavaMethod result = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod);
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
477 if (opcode != Bytecodes.INVOKEDYNAMIC) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
478 cache[cpi] = result;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
479 }
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
480 return result;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
481 } else {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
482 // Get the method's name and signature.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
483 String name = getNameRefAt(index);
18542
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
484 HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureRefAt(index));
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
485 if (opcode == Bytecodes.INVOKEDYNAMIC) {
18542
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
486 HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
487 return new HotSpotMethodUnresolved(name, signature, holder);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
488 } else {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
489 final int klassIndex = getKlassRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
490 final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, klassIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
491 JavaType holder = getJavaType(metaspacePointer);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
492 return new HotSpotMethodUnresolved(name, signature, holder);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
493 }
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
494 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 @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
498 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
499 final LookupTypeCacheElement elem = this.lastLookupType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
500 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
501 return elem.javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
502 } else {
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
503 final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, cpi);
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
504 JavaType result = getJavaType(metaspacePointer);
21431
90c55b9ad309 only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents: 21411
diff changeset
505 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
506 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
507 }
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
508 return result;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
509 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
511
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 @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
513 public JavaField lookupField(int cpi, int opcode) {
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
514 Object resolvedJavaField = cache[cpi];
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
515 if (resolvedJavaField != null) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
516 return (ResolvedJavaField) resolvedJavaField;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
517 }
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
518 final int index = toConstantPoolIndex(cpi, opcode);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
519 final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
520 final int nameIndex = getNameRefIndexAt(nameAndTypeIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
521 String name = lookupUtf8(nameIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
522 final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
523 String typeName = lookupUtf8(typeIndex);
14117
2b2f0022900f removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents: 14093
diff changeset
524 JavaType type = runtime().lookupType(typeName, getHolder(), false);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
525
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
526 final int holderIndex = getKlassRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
527 JavaType holder = lookupType(holderIndex, opcode);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
528
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
529 if (holder instanceof HotSpotResolvedObjectTypeImpl) {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
530 long[] info = new long[2];
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
531 long metaspaceKlass;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
532 try {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
533 metaspaceKlass = runtime().getCompilerToVM().resolveField(metaspaceConstantPool, index, (byte) opcode, info);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
534 } catch (Throwable t) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
535 /*
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
536 * If there was an exception resolving the field we give up and return an unresolved
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
537 * field.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
538 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
539 return new HotSpotUnresolvedField(holder, name, type);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
540 }
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
541 HotSpotResolvedObjectTypeImpl resolvedHolder = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
542 final int flags = (int) info[0];
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
543 final long offset = info[1];
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
544 HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags);
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
545 if (type instanceof ResolvedJavaType) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
546 cache[cpi] = result;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
547 }
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
548 return result;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
549 } else {
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
550 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
551 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
554 @Override
6588
b89b5038ad7e removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
555 public void loadReferencedType(int cpi, int opcode) {
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
556 int index;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
557 switch (opcode) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
558 case Bytecodes.CHECKCAST:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
559 case Bytecodes.INSTANCEOF:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
560 case Bytecodes.NEW:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
561 case Bytecodes.ANEWARRAY:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
562 case Bytecodes.MULTIANEWARRAY:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
563 case Bytecodes.LDC:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
564 case Bytecodes.LDC_W:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
565 case Bytecodes.LDC2_W:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
566 index = cpi;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
567 break;
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
568 case Bytecodes.INVOKEDYNAMIC:
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
569 // invokedynamic instructions point to a constant pool cache entry.
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
570 index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag;
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
571 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index);
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
572 break;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
573 default:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
574 index = toConstantPoolIndex(cpi, opcode);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
575 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index);
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
576 }
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
577
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
578 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
579 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
580 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
581 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
582 }
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
583 switch (tag) {
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
584 case Fieldref:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
585 case MethodRef:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
586 case InterfaceMethodref:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
587 index = getUncachedKlassRefIndexAt(index);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
588 tag = getTagAt(index);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
589 assert tag == JVM_CONSTANT.Class || tag == JVM_CONSTANT.UnresolvedClass || tag == JVM_CONSTANT.UnresolvedClassInError : tag;
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
590 // fall through
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
591 case Class:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
592 case UnresolvedClass:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
593 case UnresolvedClassInError:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
594 final long metaspaceKlass = runtime().getCompilerToVM().constantPoolKlassAt(metaspaceConstantPool, index);
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
595 HotSpotResolvedObjectTypeImpl type = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
596 Class<?> klass = type.mirror();
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
597 if (!klass.isPrimitive() && !klass.isArray()) {
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
598 unsafe.ensureClassInitialized(klass);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
599 }
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
600 break;
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
601 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
602 if (isInvokedynamicIndex(cpi)) {
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
603 runtime().getCompilerToVM().resolveInvokeDynamic(metaspaceConstantPool, 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
604 }
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
605 break;
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
606 default:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
607 // nothing
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
608 break;
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
609 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
610 }
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
611
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
612 @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
613 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
614 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
615 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
616 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
617 }