Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotConstantPool.java @ 22487:a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
author | twisti |
---|---|
date | Fri, 28 Aug 2015 12:42:06 -1000 |
parents | 7ad03bf3d4a9 |
children | b5ebb80da4f1 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
22054 | 23 package jdk.internal.jvmci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22054 | 25 import static jdk.internal.jvmci.common.UnsafeAccess.*; |
26 import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; | |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
9108
diff
changeset
|
27 |
14093 | 28 import java.lang.invoke.*; |
29 | |
22054 | 30 import jdk.internal.jvmci.common.*; |
31 import jdk.internal.jvmci.meta.*; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 /** |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5554
diff
changeset
|
34 * Implementation of {@link ConstantPool} for HotSpot. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 */ |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
36 public final class HotSpotConstantPool implements ConstantPool, HotSpotProxified, MetaspaceWrapperObject { |
5278
74dfa6f86879
removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
37 |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
38 /** |
21720
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
39 * Subset of JVM bytecode opcodes used by {@link HotSpotConstantPool}. |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
40 */ |
21780
3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21720
diff
changeset
|
41 public static class Bytecodes { |
21720
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
42 public static final int LDC = 18; // 0x12 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
43 public static final int LDC_W = 19; // 0x13 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
44 public static final int LDC2_W = 20; // 0x14 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
45 public static final int GETSTATIC = 178; // 0xB2 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
46 public static final int PUTSTATIC = 179; // 0xB3 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
47 public static final int GETFIELD = 180; // 0xB4 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
48 public static final int PUTFIELD = 181; // 0xB5 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
49 public static final int INVOKEVIRTUAL = 182; // 0xB6 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
50 public static final int INVOKESPECIAL = 183; // 0xB7 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
51 public static final int INVOKESTATIC = 184; // 0xB8 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
52 public static final int INVOKEINTERFACE = 185; // 0xB9 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
53 public static final int INVOKEDYNAMIC = 186; // 0xBA |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
54 public static final int NEW = 187; // 0xBB |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
55 public static final int NEWARRAY = 188; // 0xBC |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
56 public static final int ANEWARRAY = 189; // 0xBD |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
57 public static final int CHECKCAST = 192; // 0xC0 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
58 public static final int INSTANCEOF = 193; // 0xC1 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
59 public static final int MULTIANEWARRAY = 197; // 0xC5 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
60 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
61 static boolean isInvoke(int opcode) { |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
62 switch (opcode) { |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
63 case INVOKEVIRTUAL: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
64 case INVOKESPECIAL: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
65 case INVOKESTATIC: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
66 case INVOKEINTERFACE: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
67 case INVOKEDYNAMIC: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
68 return true; |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
69 default: |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
70 return false; |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
71 } |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
72 } |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
73 |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
74 /** |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
75 * See: {@code Rewriter::maybe_rewrite_invokehandle}. |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
76 */ |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
77 static boolean isInvokeHandleAlias(int opcode) { |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
78 switch (opcode) { |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
79 case INVOKEVIRTUAL: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
80 case INVOKESPECIAL: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
81 return true; |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
82 default: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
83 return false; |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
84 } |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
85 } |
21720
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
86 } |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
87 |
d915361cc3a1
moved asm, bytecode and asm.test code back to com.oracle.graal name space (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21713
diff
changeset
|
88 /** |
14529 | 89 * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and |
90 * internal ones. | |
91 */ | |
92 private enum JVM_CONSTANT { | |
93 // @formatter:off | |
94 Utf8(config().jvmConstantUtf8), | |
95 Integer(config().jvmConstantInteger), | |
96 Long(config().jvmConstantLong), | |
97 Float(config().jvmConstantFloat), | |
98 Double(config().jvmConstantDouble), | |
99 Class(config().jvmConstantClass), | |
100 UnresolvedClass(config().jvmConstantUnresolvedClass), | |
101 UnresolvedClassInError(config().jvmConstantUnresolvedClassInError), | |
102 String(config().jvmConstantString), | |
103 Fieldref(config().jvmConstantFieldref), | |
104 MethodRef(config().jvmConstantMethodref), | |
105 InterfaceMethodref(config().jvmConstantInterfaceMethodref), | |
106 NameAndType(config().jvmConstantNameAndType), | |
107 MethodHandle(config().jvmConstantMethodHandle), | |
108 MethodHandleInError(config().jvmConstantMethodHandleInError), | |
109 MethodType(config().jvmConstantMethodType), | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
110 MethodTypeInError(config().jvmConstantMethodTypeInError), |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
111 InvokeDynamic(config().jvmConstantInvokeDynamic); |
14529 | 112 // @formatter:on |
113 | |
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
|
114 private final int tag; |
14529 | 115 |
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
|
116 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
|
117 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
|
118 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
|
119 |
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
|
120 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
|
121 this.tag = tag; |
14529 | 122 } |
123 | |
124 private static HotSpotVMConfig config() { | |
125 return runtime().getConfig(); | |
126 } | |
127 | |
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
|
128 /** |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
129 * 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
|
130 * 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
|
131 */ |
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
|
132 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
|
133 private static final JVM_CONSTANT[] table = new JVM_CONSTANT[ExternalMax + 1 + (InternalMax - InternalMin) + 1]; |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
134 |
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
|
135 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
|
136 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
|
137 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
|
138 table[indexOf(e.tag)] = e; |
14529 | 139 } |
140 } | |
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
|
141 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
142 private static 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
|
143 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
|
144 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
|
145 } 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
|
146 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
|
147 } |
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
|
148 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
|
149 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
150 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 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
|
155 } |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
156 throw new JVMCIError("Unknown JVM_CONSTANT tag %s", tag); |
17393
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
157 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
158 } |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
159 |
a8186c7f73e9
added table to speed up mapping JVM_CONSTANT tag value to JVM_CONSTANT enum object
Doug Simon <doug.simon@oracle.com>
parents:
15968
diff
changeset
|
160 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
|
161 return TagValueMap.get(tag); |
14529 | 162 } |
163 } | |
164 | |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
165 private static class LookupTypeCacheElement { |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
166 int lastCpi = Integer.MIN_VALUE; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
167 JavaType javaType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
168 |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
169 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
|
170 super(); |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
171 this.lastCpi = lastCpi; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
172 this.javaType = javaType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
173 } |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
174 } |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
175 |
14529 | 176 /** |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
177 * Reference to the C++ ConstantPool object. |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
178 */ |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
179 private final long metaspaceConstantPool; |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
180 private volatile LookupTypeCacheElement lastLookupType; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
182 /** |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
183 * Gets the JVMCI mirror from a HotSpot constant pool.The VM is responsible for ensuring that |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
184 * the ConstantPool is kept alive for the duration of this call and the |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
185 * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that. |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
186 * |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
187 * Called from the VM. |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
188 * |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
189 * @param metaspaceConstantPool a metaspace ConstantPool object |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
190 * @return the {@link HotSpotConstantPool} corresponding to {@code metaspaceConstantPool} |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
191 */ |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
192 @SuppressWarnings("unused") |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
193 private static HotSpotConstantPool fromMetaspace(long metaspaceConstantPool) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
194 return new HotSpotConstantPool(metaspaceConstantPool); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
195 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
196 |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
197 private HotSpotConstantPool(long metaspaceConstantPool) { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13254
diff
changeset
|
198 this.metaspaceConstantPool = metaspaceConstantPool; |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
199 } |
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
|
200 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
201 /** |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
202 * 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
|
203 * |
14093 | 204 * @return holder for this constant pool |
205 */ | |
14117
2b2f0022900f
removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents:
14093
diff
changeset
|
206 private HotSpotResolvedObjectType getHolder() { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
207 return runtime().getCompilerToVM().getResolvedJavaType(this, runtime().getConfig().constantPoolHolderOffset, false); |
14093 | 208 } |
209 | |
210 /** | |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
211 * 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
|
212 * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
213 * |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
214 * @param rawIndex index from the bytecode |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
215 * @param opcode bytecode to convert the index for |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
216 * @return constant pool index |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
217 */ |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
218 private static int rawIndexToConstantPoolIndex(int rawIndex, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
219 int index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
220 if (opcode == Bytecodes.INVOKEDYNAMIC) { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
221 index = rawIndex; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
222 // See: ConstantPool::is_invokedynamic_index |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
223 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
|
224 } else { |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
225 assert opcode == Bytecodes.GETFIELD || opcode == Bytecodes.PUTFIELD || opcode == Bytecodes.GETSTATIC || opcode == Bytecodes.PUTSTATIC || opcode == Bytecodes.INVOKEINTERFACE || |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
226 opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + opcode; |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
227 index = rawIndex + runtime().getConfig().constantPoolCpCacheIndexTag; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
228 } |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
229 return index; |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
230 } |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
231 |
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
232 /** |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
233 * 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
|
234 * |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
235 * See {@code ConstantPool::decode_cpcache_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
236 * |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
237 * @param index constant pool cache index |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
238 * @return decoded index |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
239 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
240 private static int decodeConstantPoolCacheIndex(int index) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
241 if (isInvokedynamicIndex(index)) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
242 return decodeInvokedynamicIndex(index); |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
243 } else { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
244 return index - runtime().getConfig().constantPoolCpCacheIndexTag; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
245 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
246 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
247 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
248 /** |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
249 * See {@code ConstantPool::is_invokedynamic_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
250 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
251 private static boolean isInvokedynamicIndex(int index) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
252 return index < 0; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
253 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
254 |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
255 /** |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
256 * See {@code ConstantPool::decode_invokedynamic_index}. |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
257 */ |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
258 private static int decodeInvokedynamicIndex(int i) { |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
259 assert isInvokedynamicIndex(i) : i; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
260 return ~i; |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
261 } |
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
262 |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
263 public long getMetaspaceConstantPool() { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
264 return metaspaceConstantPool; |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
265 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
266 |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
267 public long getMetaspacePointer() { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
268 return getMetaspaceConstantPool(); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
269 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
270 |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
271 /** |
14093 | 272 * 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
|
273 * |
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 * @param index constant pool index |
14093 | 275 * @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
|
276 */ |
14529 | 277 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
|
278 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
|
279 HotSpotVMConfig config = runtime().getConfig(); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
280 final long metaspaceConstantPoolTags = unsafe.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset); |
14529 | 281 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
|
282 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
|
283 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
|
284 } |
14529 | 285 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
|
286 } |
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
|
287 |
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
|
288 /** |
14093 | 289 * 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
|
290 * |
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
|
291 * @param index constant pool index |
14093 | 292 * @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
|
293 */ |
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
|
294 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
|
295 assertBounds(index); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
296 return unsafe.getAddress(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
297 } |
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
|
298 |
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
|
299 /** |
14093 | 300 * 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
|
301 * |
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
|
302 * @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
|
303 * @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
|
304 */ |
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
|
305 private int getIntAt(int index) { |
14529 | 306 assertTag(index, JVM_CONSTANT.Integer); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
307 return unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
308 } |
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
|
309 |
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
|
310 /** |
14093 | 311 * 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
|
312 * |
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
|
313 * @param index constant pool index |
14093 | 314 * @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
|
315 */ |
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
|
316 private long getLongAt(int index) { |
14529 | 317 assertTag(index, JVM_CONSTANT.Long); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
318 return unsafe.getLong(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
319 } |
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
|
320 |
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
|
321 /** |
14093 | 322 * 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
|
323 * |
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
|
324 * @param index constant pool index |
14093 | 325 * @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
|
326 */ |
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
|
327 private float getFloatAt(int index) { |
14529 | 328 assertTag(index, JVM_CONSTANT.Float); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
329 return unsafe.getFloat(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
330 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
331 |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
332 /** |
14093 | 333 * 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
|
334 * |
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
|
335 * @param index constant pool index |
14093 | 336 * @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
|
337 */ |
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
|
338 private double getDoubleAt(int index) { |
14529 | 339 assertTag(index, JVM_CONSTANT.Double); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
340 return unsafe.getDouble(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
341 } |
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
|
342 |
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
|
343 /** |
14093 | 344 * 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
|
345 * |
14093 | 346 * @param index constant pool index |
347 * @return {@code JVM_CONSTANT_NameAndType} constant pool entry | |
348 */ | |
349 private int getNameAndTypeAt(int index) { | |
14529 | 350 assertTag(index, JVM_CONSTANT.NameAndType); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
351 return unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
14093 | 352 } |
353 | |
354 /** | |
355 * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index | |
356 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
357 * |
14093 | 358 * @param index constant pool index |
359 * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry | |
360 */ | |
361 private int getNameAndTypeRefIndexAt(int index) { | |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
362 return runtime().getCompilerToVM().lookupNameAndTypeRefIndexInPool(this, index); |
14093 | 363 } |
364 | |
365 /** | |
366 * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index | |
367 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
368 * |
14093 | 369 * @param index constant pool index |
370 * @return name as {@link String} | |
371 */ | |
372 private String getNameRefAt(int index) { | |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
373 return runtime().getCompilerToVM().lookupNameRefInPool(this, index); |
14093 | 374 } |
375 | |
376 /** | |
377 * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at | |
378 * index {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
379 * |
14093 | 380 * @param index constant pool index |
381 * @return name reference index | |
382 */ | |
383 private int getNameRefIndexAt(int index) { | |
384 final int refIndex = getNameAndTypeAt(index); | |
385 // name ref index is in the low 16-bits. | |
386 return refIndex & 0xFFFF; | |
387 } | |
388 | |
389 /** | |
390 * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry at index | |
391 * {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
392 * |
14093 | 393 * @param index constant pool index |
394 * @return signature as {@link String} | |
395 */ | |
396 private String getSignatureRefAt(int index) { | |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
397 return runtime().getCompilerToVM().lookupSignatureRefInPool(this, index); |
14093 | 398 } |
399 | |
400 /** | |
401 * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry | |
402 * at index {@code index}. | |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
403 * |
14093 | 404 * @param index constant pool index |
405 * @return signature reference index | |
406 */ | |
407 private int getSignatureRefIndexAt(int index) { | |
408 final int refIndex = getNameAndTypeAt(index); | |
409 // signature ref index is in the high 16-bits. | |
410 return refIndex >>> 16; | |
411 } | |
412 | |
413 /** | |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
414 * 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
|
415 * |
14093 | 416 * @param index constant pool index |
417 * @return klass reference index | |
418 */ | |
419 private int getKlassRefIndexAt(int index) { | |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
420 return runtime().getCompilerToVM().lookupKlassRefIndexInPool(this, index); |
14093 | 421 } |
422 | |
423 /** | |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
424 * 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
|
425 * {@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
|
426 * |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
427 * @param index constant pool index |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
428 * @return klass reference index |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
429 */ |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
430 private int getUncachedKlassRefIndexAt(int index) { |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
431 assertTagIsFieldOrMethod(index); |
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
432 final int refIndex = unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); |
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
433 // klass ref index is in the low 16-bits. |
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
434 return refIndex & 0xFFFF; |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
435 } |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
436 |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
437 /** |
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
|
438 * 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
|
439 * |
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
|
440 * @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
|
441 */ |
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
|
442 private void assertBounds(int index) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13259
diff
changeset
|
443 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
|
444 } |
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
|
445 |
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
|
446 /** |
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
|
447 * 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
|
448 * |
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
|
449 * @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
|
450 * @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
|
451 */ |
14529 | 452 private void assertTag(int index, JVM_CONSTANT tag) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
453 final JVM_CONSTANT tagAt = getTagAt(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
454 assert tagAt == tag : "constant pool tag at index " + index + " is " + tagAt + " but expected " + tag; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
455 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
456 |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
457 /** |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
458 * Asserts that the constant pool tag at index {@code index} is a {@link JVM_CONSTANT#Fieldref}, |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
459 * or a {@link JVM_CONSTANT#MethodRef}, or a {@link JVM_CONSTANT#InterfaceMethodref}. |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
460 * |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
461 * @param index constant pool index |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
462 */ |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
463 private void assertTagIsFieldOrMethod(int index) { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
464 final JVM_CONSTANT tagAt = getTagAt(index); |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
465 assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt; |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
466 } |
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
|
467 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 @Override |
9108 | 469 public int length() { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
470 return unsafe.getInt(getMetaspaceConstantPool() + runtime().getConfig().constantPoolLengthOffset); |
9108 | 471 } |
472 | |
473 @Override | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
474 public Object lookupConstant(int cpi) { |
7002
74f0207b82f5
fixed bug in bytecode reconstitution
Doug Simon <doug.simon@oracle.com>
parents:
6588
diff
changeset
|
475 assert cpi != 0; |
14529 | 476 final JVM_CONSTANT tag = getTagAt(cpi); |
477 switch (tag) { | |
478 case Integer: | |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
479 return JavaConstant.forInt(getIntAt(cpi)); |
14529 | 480 case Long: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
481 return JavaConstant.forLong(getLongAt(cpi)); |
14529 | 482 case Float: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
483 return JavaConstant.forFloat(getFloatAt(cpi)); |
14529 | 484 case Double: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
485 return JavaConstant.forDouble(getDoubleAt(cpi)); |
14529 | 486 case Class: |
487 case UnresolvedClass: | |
488 case UnresolvedClassInError: | |
489 final int opcode = -1; // opcode is not used | |
490 return lookupType(cpi, opcode); | |
491 case String: | |
22272
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
492 /* |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
493 * Normally, we would expect a String here, but anonymous classes can have |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
494 * "pseudo strings" (arbitrary live objects) patched into a String entry. Such |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
495 * entries do not have a symbol in the constant pool slot. |
b6d504612b3f
fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents:
22234
diff
changeset
|
496 */ |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
497 Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
498 return HotSpotObjectConstantImpl.forObject(string); |
14529 | 499 case MethodHandle: |
500 case MethodHandleInError: | |
501 case MethodType: | |
502 case MethodTypeInError: | |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
503 Object obj = runtime().getCompilerToVM().resolveConstantInPool(this, cpi); |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
504 return HotSpotObjectConstantImpl.forObject(obj); |
14529 | 505 default: |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21431
diff
changeset
|
506 throw new JVMCIError("Unknown constant pool tag %s", tag); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
507 } |
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
|
508 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
12559
diff
changeset
|
509 |
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
|
510 @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
|
511 public String lookupUtf8(int cpi) { |
14529 | 512 assertTag(cpi, JVM_CONSTANT.Utf8); |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
513 return runtime().getCompilerToVM().getSymbol(getEntryAt(cpi)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 @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
|
517 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
|
518 return new HotSpotSignature(runtime(), lookupUtf8(cpi)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
522 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
|
523 assert Bytecodes.isInvoke(opcode); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
524 final int index = rawIndexToConstantPoolIndex(cpi, opcode); |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
525 Object appendix = runtime().getCompilerToVM().lookupAppendixInPool(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
526 if (appendix == null) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
527 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
528 } else { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
529 return HotSpotObjectConstantImpl.forObject(appendix); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14979
diff
changeset
|
530 } |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
531 } |
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
532 |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
533 /** |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
534 * Gets a {@link JavaType} corresponding a given resolved or unresolved type. |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
535 * |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
536 * @param type either a ResolvedJavaType or a String naming a unresolved type. |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
537 */ |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
538 private static JavaType getJavaType(final Object type) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
539 if (type instanceof String) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
540 String name = (String) type; |
18540
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
541 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
|
542 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
543 return (JavaType) type; |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
544 } |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
545 } |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
546 |
8945
7ef66078d837
add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents:
7084
diff
changeset
|
547 @Override |
6588
b89b5038ad7e
removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
548 public JavaMethod lookupMethod(int cpi, int opcode) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
549 final int index = rawIndexToConstantPoolIndex(cpi, opcode); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
550 final HotSpotResolvedJavaMethod method = runtime().getCompilerToVM().lookupMethodInPool(this, index, (byte) opcode); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
551 if (method != null) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
552 return method; |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
553 } else { |
14093 | 554 // Get the method's name and signature. |
555 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
|
556 HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureRefAt(index)); |
14093 | 557 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
|
558 HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class); |
14093 | 559 return new HotSpotMethodUnresolved(name, signature, holder); |
560 } else { | |
561 final int klassIndex = getKlassRefIndexAt(index); | |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
562 final Object type = runtime().getCompilerToVM().lookupKlassInPool(this, klassIndex); |
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
563 JavaType holder = getJavaType(type); |
14093 | 564 return new HotSpotMethodUnresolved(name, signature, holder); |
565 } | |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
566 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
567 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
568 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
569 @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
|
570 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
|
571 final LookupTypeCacheElement elem = this.lastLookupType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
572 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
|
573 return elem.javaType; |
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
574 } else { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
575 final Object type = runtime().getCompilerToVM().lookupKlassInPool(this, cpi); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
576 JavaType result = getJavaType(type); |
21431
90c55b9ad309
only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21411
diff
changeset
|
577 if (result instanceof ResolvedJavaType) { |
90c55b9ad309
only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21411
diff
changeset
|
578 this.lastLookupType = new LookupTypeCacheElement(cpi, result); |
90c55b9ad309
only put type in HotSpotConstantPool cache if it's resolved
Lukas Stadler <lukas.stadler@oracle.com>
parents:
21411
diff
changeset
|
579 } |
21252
39ee26e85256
Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
21215
diff
changeset
|
580 return result; |
19377
2ff3a30501da
Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
581 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
582 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
583 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
584 @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
|
585 public JavaField lookupField(int cpi, int opcode) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
586 final int index = rawIndexToConstantPoolIndex(cpi, opcode); |
14093 | 587 final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index); |
588 final int nameIndex = getNameRefIndexAt(nameAndTypeIndex); | |
589 String name = lookupUtf8(nameIndex); | |
590 final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); | |
591 String typeName = lookupUtf8(typeIndex); | |
14117
2b2f0022900f
removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents:
14093
diff
changeset
|
592 JavaType type = runtime().lookupType(typeName, getHolder(), false); |
14093 | 593 |
594 final int holderIndex = getKlassRefIndexAt(index); | |
595 JavaType holder = lookupType(holderIndex, opcode); | |
596 | |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
597 if (holder instanceof HotSpotResolvedObjectTypeImpl) { |
14093 | 598 long[] info = new long[2]; |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
599 HotSpotResolvedObjectTypeImpl resolvedHolder; |
14093 | 600 try { |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
601 resolvedHolder = runtime().getCompilerToVM().resolveFieldInPool(this, index, (byte) opcode, info); |
14093 | 602 } catch (Throwable t) { |
603 /* | |
604 * If there was an exception resolving the field we give up and return an unresolved | |
605 * field. | |
606 */ | |
607 return new HotSpotUnresolvedField(holder, name, type); | |
608 } | |
609 final int flags = (int) info[0]; | |
610 final long offset = info[1]; | |
19377
2ff3a30501da
Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
611 HotSpotResolvedJavaField result = resolvedHolder.createField(name, type, offset, flags); |
2ff3a30501da
Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
612 return result; |
14069
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
613 } else { |
2f37b0e442fe
removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents:
14052
diff
changeset
|
614 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
|
615 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
617 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
618 @Override |
6588
b89b5038ad7e
removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents:
5775
diff
changeset
|
619 public void loadReferencedType(int cpi, int opcode) { |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
620 int index; |
14093 | 621 switch (opcode) { |
622 case Bytecodes.CHECKCAST: | |
623 case Bytecodes.INSTANCEOF: | |
624 case Bytecodes.NEW: | |
625 case Bytecodes.ANEWARRAY: | |
626 case Bytecodes.MULTIANEWARRAY: | |
627 case Bytecodes.LDC: | |
628 case Bytecodes.LDC_W: | |
629 case Bytecodes.LDC2_W: | |
630 index = cpi; | |
631 break; | |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
632 case Bytecodes.INVOKEDYNAMIC: { |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
633 // invokedynamic instructions point to a constant pool cache entry. |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
634 index = decodeConstantPoolCacheIndex(cpi) + runtime().getConfig().constantPoolCpCacheIndexTag; |
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
635 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); |
14979
5dfaaa91be37
fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents:
14530
diff
changeset
|
636 break; |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
637 } |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
638 case Bytecodes.GETSTATIC: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
639 case Bytecodes.PUTSTATIC: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
640 case Bytecodes.GETFIELD: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
641 case Bytecodes.PUTFIELD: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
642 case Bytecodes.INVOKEVIRTUAL: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
643 case Bytecodes.INVOKESPECIAL: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
644 case Bytecodes.INVOKESTATIC: |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
645 case Bytecodes.INVOKEINTERFACE: { |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
646 // invoke and field instructions point to a constant pool cache entry. |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
647 index = rawIndexToConstantPoolIndex(cpi, opcode); |
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
648 index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, index); |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
649 break; |
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
650 } |
14093 | 651 default: |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
652 throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode); |
14052
361acb279104
moved to-constant-pool-index conversion up to Java
twisti
parents:
13261
diff
changeset
|
653 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
654 |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
655 final JVM_CONSTANT tag = getTagAt(index); |
17394
f520089af480
made HotSpotConstantPool.loadReferencedType handle attempts to resolve constant pool indexes that do not refer to a type
Doug Simon <doug.simon@oracle.com>
parents:
17393
diff
changeset
|
656 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
|
657 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
|
658 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
|
659 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
660 switch (tag) { |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
661 case MethodRef: |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
662 case Fieldref: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
663 case InterfaceMethodref: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
664 index = getUncachedKlassRefIndexAt(index); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
665 // Read the tag only once because it could change between multiple reads. |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
666 final JVM_CONSTANT klassTag = getTagAt(index); |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
667 assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag; |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17394
diff
changeset
|
668 // fall through |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
669 case Class: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
670 case UnresolvedClass: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
671 case UnresolvedClassInError: |
22455
7ad03bf3d4a9
renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
672 final HotSpotResolvedObjectTypeImpl type = runtime().getCompilerToVM().resolveTypeInPool(this, index); |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
673 Class<?> klass = type.mirror(); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
674 if (!klass.isPrimitive() && !klass.isArray()) { |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
675 unsafe.ensureClassInitialized(klass); |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
676 } |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
677 switch (tag) { |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
678 case MethodRef: |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
679 if (Bytecodes.isInvokeHandleAlias(opcode)) { |
22234
179db500f6e5
Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents:
22100
diff
changeset
|
680 final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
681 if (isInvokeHandle(methodRefCacheIndex, type)) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
682 runtime().getCompilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
683 } |
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
684 } |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
685 } |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
686 break; |
15205
affef8631cf4
Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
687 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
|
688 if (isInvokedynamicIndex(cpi)) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22420
diff
changeset
|
689 runtime().getCompilerToVM().resolveInvokeDynamicInPool(this, cpi); |
15255
cf6aedb39215
Prevent using loadReferencedType with LDC when the constant pool index refers to InvokeDynamic entry but isn't an invokedynamic index.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15205
diff
changeset
|
690 } |
15205
affef8631cf4
Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15193
diff
changeset
|
691 break; |
14530
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
692 default: |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
693 // nothing |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
694 break; |
d87b84dade7d
moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents:
14529
diff
changeset
|
695 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
696 } |
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
|
697 |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
698 private boolean isInvokeHandle(int methodRefCacheIndex, HotSpotResolvedObjectTypeImpl klass) { |
22487
a0e5714d5436
Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents:
22455
diff
changeset
|
699 assertTag(runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef); |
22089
13a50cb905b7
Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents:
22054
diff
changeset
|
700 return ResolvedJavaMethod.isSignaturePolymorphic(klass, getNameRefAt(methodRefCacheIndex), runtime().getHostJVMCIBackend().getMetaAccess()); |
22013
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
701 } |
3904e33db5b3
Make sure HotSpotConstantPool.loadReferencedType resolves invokehandle call sites properly. Fixes eager resolution problems at those call sites.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
702 |
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
|
703 @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
|
704 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
|
705 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
|
706 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
|
707 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 } |