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