annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java @ 21252:39ee26e85256

Use boxed cache in HotSpotConstantpool instead of synchronization
author Stefan Anzinger <stefan.anzinger@oracle.com>
date Tue, 05 May 2015 17:30:47 +0200
parents e11eb6ec180e
children 082417ac43e4
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 /*
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5548
8872bc0eebdf Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
23 package com.oracle.graal.hotspot.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
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.*;
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 9108
diff changeset
26 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 9108
diff changeset
27
14093
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.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.hotspot.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 /**
5775
2c088af17e59 Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5554
diff changeset
36 * Implementation of {@link ConstantPool} for HotSpot.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 */
18867
7f4cb7587f4c localized replay compilation marker interface to HotSpot specific code
Doug Simon <doug.simon@oracle.com>
parents: 18540
diff changeset
38 public class HotSpotConstantPool extends CompilerObject implements ConstantPool, HotSpotProxified {
5278
74dfa6f86879 removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
39
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
40 private static final long serialVersionUID = -5443206401485234850L;
5278
74dfa6f86879 removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
41
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
42 /**
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
43 * 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
44 * internal ones.
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
45 */
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
46 private enum JVM_CONSTANT {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
47 // @formatter:off
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
48 Utf8(config().jvmConstantUtf8),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
49 Integer(config().jvmConstantInteger),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
50 Long(config().jvmConstantLong),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
51 Float(config().jvmConstantFloat),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
52 Double(config().jvmConstantDouble),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
53 Class(config().jvmConstantClass),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
54 UnresolvedClass(config().jvmConstantUnresolvedClass),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
55 UnresolvedClassInError(config().jvmConstantUnresolvedClassInError),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
56 String(config().jvmConstantString),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
57 Fieldref(config().jvmConstantFieldref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
58 MethodRef(config().jvmConstantMethodref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
59 InterfaceMethodref(config().jvmConstantInterfaceMethodref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
60 NameAndType(config().jvmConstantNameAndType),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
61 MethodHandle(config().jvmConstantMethodHandle),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
62 MethodHandleInError(config().jvmConstantMethodHandleInError),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
63 MethodType(config().jvmConstantMethodType),
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
64 MethodTypeInError(config().jvmConstantMethodTypeInError),
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
65 InvokeDynamic(config().jvmConstantInvokeDynamic);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
66 // @formatter:on
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
67
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
68 private final int tag;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
69
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
70 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
71 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
72 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
73
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
74 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
75 this.tag = tag;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
76 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
77
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
78 private static HotSpotVMConfig config() {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
79 return runtime().getConfig();
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
80 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
81
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
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 * 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
84 * 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
85 */
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 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
87 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
88 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
89 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
90 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
91 table[indexOf(e.tag)] = e;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
92 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
93 }
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
94
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 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
96 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
97 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
98 } 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
99 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
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 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
102 }
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
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 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
105 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
106 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
107 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
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 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
110 }
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 }
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
112
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
113 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
114 return TagValueMap.get(tag);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
115 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
116 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
117
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
118 private static class LookupTypeCacheElement {
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
119 int lastCpi = Integer.MIN_VALUE;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
120 JavaType javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
121
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
122 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
123 super();
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
124 this.lastCpi = lastCpi;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
125 this.javaType = javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
126 }
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
127 }
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
128
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
129 /**
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
130 * Reference to the C++ ConstantPool object.
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
131 */
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
132 private final long metaspaceConstantPool;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
133 private final Object[] cache;
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
134 private volatile LookupTypeCacheElement lastLookupType;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
136 public HotSpotConstantPool(long metaspaceConstantPool) {
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
137 this.metaspaceConstantPool = metaspaceConstantPool;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
138 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
139 }
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
140
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
141 /**
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
142 * 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
143 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
144 * @return holder for this constant pool
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
145 */
14117
2b2f0022900f removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents: 14093
diff changeset
146 private HotSpotResolvedObjectType getHolder() {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
147 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
148 return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
149 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
150
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
151 /**
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
152 * 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
153 * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
154 *
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
155 * @param rawIndex index from the bytecode
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
156 * @param opcode bytecode to convert the index for
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
157 * @return constant pool index
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
158 */
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
159 private static int toConstantPoolIndex(int rawIndex, int opcode) {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
160 int index;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
161 if (opcode == Bytecodes.INVOKEDYNAMIC) {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
162 index = rawIndex;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
163 // See: ConstantPool::is_invokedynamic_index
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
164 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
165 } else {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
166 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
167 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
168 index = rawIndex + runtime().getConfig().constantPoolCpCacheIndexTag;
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 return index;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
171 }
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
172
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
173 /**
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
174 * 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
175 *
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
176 * See {@code ConstantPool::decode_cpcache_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 * @param index constant pool cache index
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
179 * @return decoded index
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
180 */
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
181 private static int decodeConstantPoolCacheIndex(int index) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
182 if (isInvokedynamicIndex(index)) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
183 return decodeInvokedynamicIndex(index);
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
184 } else {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
185 return index - runtime().getConfig().constantPoolCpCacheIndexTag;
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 }
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 /**
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
190 * See {@code ConstantPool::is_invokedynamic_index}.
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 private static boolean isInvokedynamicIndex(int index) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
193 return index < 0;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
194 }
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 /**
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
197 * See {@code ConstantPool::decode_invokedynamic_index}.
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
198 */
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
199 private static int decodeInvokedynamicIndex(int i) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
200 assert isInvokedynamicIndex(i) : i;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
201 return ~i;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
202 }
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
203
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
204 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
205 * 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
206 *
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
207 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
208 * @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
209 */
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
210 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
211 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
212 HotSpotVMConfig config = runtime().getConfig();
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
213 final long metaspaceConstantPoolTags = unsafe.getAddress(metaspaceConstantPool + config.constantPoolTagsOffset);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
214 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
215 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
216 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
217 }
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
218 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
219 }
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
220
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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
222 * 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
223 *
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
224 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
225 * @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
226 */
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 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
228 assertBounds(index);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
229 return unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
230 }
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
231
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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
233 * 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
234 *
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
235 * @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
236 * @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
237 */
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 private int getIntAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
239 assertTag(index, JVM_CONSTANT.Integer);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
240 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
241 }
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
242
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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
244 * 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
245 *
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
246 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
247 * @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
248 */
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 private long getLongAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
250 assertTag(index, JVM_CONSTANT.Long);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
251 return unsafe.getLong(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
252 }
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
253
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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
255 * 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
256 *
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
257 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
258 * @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
259 */
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 private float getFloatAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
261 assertTag(index, JVM_CONSTANT.Float);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
262 return unsafe.getFloat(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
263 }
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
264
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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
266 * 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
267 *
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
268 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
269 * @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
270 */
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 private double getDoubleAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
272 assertTag(index, JVM_CONSTANT.Double);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
273 return unsafe.getDouble(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
274 }
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
275
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
276 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
277 * 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
278 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
279 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
280 * @return {@code JVM_CONSTANT_NameAndType} constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
281 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
282 private int getNameAndTypeAt(int index) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
283 assertTag(index, JVM_CONSTANT.NameAndType);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
284 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
285 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
286
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
287 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
288 * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
289 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
290 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
291 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
292 * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
293 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
294 private int getNameAndTypeRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
295 return runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(metaspaceConstantPool, index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
296 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
297
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
298 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
299 * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
300 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
301 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
302 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
303 * @return name as {@link String}
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
304 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
305 private String getNameRefAt(int index) {
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
306 return runtime().getCompilerToVM().lookupNameRefInPool(metaspaceConstantPool, index);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
307 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
308
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
309 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
310 * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
311 * index {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
312 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
313 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
314 * @return name reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
315 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
316 private int getNameRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
317 final int refIndex = getNameAndTypeAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
318 // name ref index is in the low 16-bits.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
319 return refIndex & 0xFFFF;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
320 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
321
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
322 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
323 * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
324 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
325 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
326 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
327 * @return signature as {@link String}
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
328 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
329 private String getSignatureRefAt(int index) {
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
330 return runtime().getCompilerToVM().lookupSignatureRefInPool(metaspaceConstantPool, index);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
331 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
332
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
333 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
334 * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
335 * at index {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
336 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
337 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
338 * @return signature reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
339 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
340 private int getSignatureRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
341 final int refIndex = getNameAndTypeAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
342 // signature ref index is in the high 16-bits.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
343 return refIndex >>> 16;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
344 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
345
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
346 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
347 * 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
348 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
349 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
350 * @return klass reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
351 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
352 private int getKlassRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
353 return runtime().getCompilerToVM().lookupKlassRefIndexInPool(metaspaceConstantPool, index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
354 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
355
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
356 /**
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
357 * 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
358 * {@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
359 *
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
360 * @param index constant pool index
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
361 * @return klass reference index
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
362 */
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
363 private int getUncachedKlassRefIndexAt(int index) {
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
364 assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref;
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
365 final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
366 // klass ref index is in the low 16-bits.
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
367 return refIndex & 0xFFFF;
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
368 }
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
369
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
370 /**
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
371 * 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
372 *
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
373 * @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
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 private void assertBounds(int index) {
13261
0ffe9e4bb364 don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents: 13259
diff changeset
376 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
377 }
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
378
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 /**
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 * 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
381 *
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
382 * @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
383 * @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
384 */
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
385 private void assertTag(int index, JVM_CONSTANT tag) {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
386 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
387 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
388
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 @Override
9108
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
390 public int length() {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
391 return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolLengthOffset);
9108
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
392 }
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
393
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
394 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 public Object lookupConstant(int cpi) {
7002
74f0207b82f5 fixed bug in bytecode reconstitution
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
396 assert cpi != 0;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
397 final JVM_CONSTANT tag = getTagAt(cpi);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
398 switch (tag) {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
399 case Integer:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
400 return JavaConstant.forInt(getIntAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
401 case Long:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
402 return JavaConstant.forLong(getLongAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
403 case Float:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
404 return JavaConstant.forFloat(getFloatAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
405 case Double:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
406 return JavaConstant.forDouble(getDoubleAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
407 case Class:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
408 case UnresolvedClass:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
409 case UnresolvedClassInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
410 final int opcode = -1; // opcode is not used
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
411 return lookupType(cpi, opcode);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
412 case String:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
413 Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi);
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
414 return HotSpotObjectConstantImpl.forObject(string);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
415 case MethodHandle:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
416 case MethodHandleInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
417 case MethodType:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
418 case MethodTypeInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
419 Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi);
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
420 return HotSpotObjectConstantImpl.forObject(obj);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
421 default:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
422 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
423 }
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 }
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
425
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
426 @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
427 public String lookupUtf8(int cpi) {
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
428 assertTag(cpi, JVM_CONSTANT.Utf8);
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
429 return runtime().getCompilerToVM().getSymbol(getEntryAt(cpi));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 @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
433 public Signature lookupSignature(int cpi) {
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
434 return new HotSpotSignature(runtime(), lookupUtf8(cpi));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
438 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
439 assert Bytecodes.isInvoke(opcode);
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
440 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
441 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
442 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
443 return null;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14979
diff changeset
444 } else {
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
445 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
446 }
8945
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
447 }
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
448
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
449 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
450 * Gets a {@link JavaType} corresponding a given metaspace Klass or a metaspace Symbol depending
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
451 * 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
452 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
453 * @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
454 */
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
455 private static JavaType getJavaType(final long metaspacePointer) {
18524
c538c2c6b7e2 changed most references to HotSpotGraalRuntime to use HotSpotGraalRuntimeProvider instead
Doug Simon <doug.simon@oracle.com>
parents: 18262
diff changeset
456 HotSpotGraalRuntimeProvider runtime = runtime();
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
457 HotSpotVMConfig config = runtime.getConfig();
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
458 if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
459 final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag;
15968
42eaa579e134 more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents: 15730
diff changeset
460 String name = runtime.getCompilerToVM().getSymbol(metaspaceSymbol);
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
461 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
462 } else {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
463 assert (metaspacePointer & config.compilerToVMKlassTag) == 0;
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
464 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
465 }
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
466 }
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
467
8945
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
468 @Override
6588
b89b5038ad7e removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
469 public JavaMethod lookupMethod(int cpi, int opcode) {
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
470 if (opcode != Bytecodes.INVOKEDYNAMIC) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
471 Object result = cache[cpi];
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
472 if (result != null) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
473 return (ResolvedJavaMethod) result;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
474 }
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
475 }
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
476 final int index = toConstantPoolIndex(cpi, opcode);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
477 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
478 if (metaspaceMethod != 0L) {
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
479 HotSpotResolvedJavaMethod result = HotSpotResolvedJavaMethodImpl.fromMetaspace(metaspaceMethod);
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
480 if (opcode != Bytecodes.INVOKEDYNAMIC) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
481 cache[cpi] = result;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
482 }
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
483 return result;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
484 } else {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
485 // Get the method's name and signature.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
486 String name = getNameRefAt(index);
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
487 HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureRefAt(index));
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
488 if (opcode == Bytecodes.INVOKEDYNAMIC) {
18540
21384a8fbb64 removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents: 18530
diff changeset
489 HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
490 return new HotSpotMethodUnresolved(name, signature, holder);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
491 } else {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
492 final int klassIndex = getKlassRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
493 final long metaspacePointer = runtime().getCompilerToVM().lookupKlassInPool(metaspaceConstantPool, klassIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
494 JavaType holder = getJavaType(metaspacePointer);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
495 return new HotSpotMethodUnresolved(name, signature, holder);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
496 }
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
497 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 @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
501 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
502 final LookupTypeCacheElement elem = this.lastLookupType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
503 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
504 return elem.javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
505 } else {
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
506 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
507 JavaType result = getJavaType(metaspacePointer);
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
508 this.lastLookupType = new LookupTypeCacheElement(cpi, result);
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
509 return result;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
510 }
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 @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
514 public JavaField lookupField(int cpi, int opcode) {
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
515 Object resolvedJavaField = cache[cpi];
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
516 if (resolvedJavaField != null) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
517 return (ResolvedJavaField) resolvedJavaField;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
518 }
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
519 final int index = toConstantPoolIndex(cpi, opcode);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
520 final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
521 final int nameIndex = getNameRefIndexAt(nameAndTypeIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
522 String name = lookupUtf8(nameIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
523 final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
524 String typeName = lookupUtf8(typeIndex);
14117
2b2f0022900f removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents: 14093
diff changeset
525 JavaType type = runtime().lookupType(typeName, getHolder(), false);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
526
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
527 final int holderIndex = getKlassRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
528 JavaType holder = lookupType(holderIndex, opcode);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
529
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
530 if (holder instanceof HotSpotResolvedObjectTypeImpl) {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
531 long[] info = new long[2];
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
532 long metaspaceKlass;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
533 try {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
534 metaspaceKlass = runtime().getCompilerToVM().resolveField(metaspaceConstantPool, index, (byte) opcode, info);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
535 } catch (Throwable t) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
536 /*
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
537 * If there was an exception resolving the field we give up and return an unresolved
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
538 * field.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
539 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
540 return new HotSpotUnresolvedField(holder, name, type);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
541 }
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
542 HotSpotResolvedObjectTypeImpl resolvedHolder = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
543 final int flags = (int) info[0];
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
544 final long offset = info[1];
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
545 HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags);
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
546 if (type instanceof ResolvedJavaType) {
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
547 cache[cpi] = result;
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
548 }
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
549 return result;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
550 } else {
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
551 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
552 }
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
555 @Override
6588
b89b5038ad7e removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
556 public void loadReferencedType(int cpi, int opcode) {
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
557 int index;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
558 switch (opcode) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
559 case Bytecodes.CHECKCAST:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
560 case Bytecodes.INSTANCEOF:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
561 case Bytecodes.NEW:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
562 case Bytecodes.ANEWARRAY:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
563 case Bytecodes.MULTIANEWARRAY:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
564 case Bytecodes.LDC:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
565 case Bytecodes.LDC_W:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
566 case Bytecodes.LDC2_W:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
567 index = cpi;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
568 break;
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
569 case Bytecodes.INVOKEDYNAMIC:
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
570 // 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
571 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
572 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index);
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
573 break;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
574 default:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
575 index = toConstantPoolIndex(cpi, opcode);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
576 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index);
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
577 }
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
578
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
579 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
580 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
581 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
582 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
583 }
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
584 switch (tag) {
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
585 case Fieldref:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
586 case MethodRef:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
587 case InterfaceMethodref:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
588 index = getUncachedKlassRefIndexAt(index);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
589 tag = getTagAt(index);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
590 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
591 // fall through
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
592 case Class:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
593 case UnresolvedClass:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
594 case UnresolvedClassInError:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
595 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
596 HotSpotResolvedObjectTypeImpl type = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
597 Class<?> klass = type.mirror();
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
598 if (!klass.isPrimitive() && !klass.isArray()) {
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
599 unsafe.ensureClassInitialized(klass);
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
600 }
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
601 break;
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
602 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
603 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
604 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
605 }
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
606 break;
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
607 default:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
608 // nothing
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
609 break;
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
610 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 }
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
612
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 @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
614 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
615 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
616 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
617 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
618 }