annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java @ 24218:719853999215 jvmci-0.32

Merge with jdk8u141-b15
author Doug Simon <doug.simon@oracle.com>
date Mon, 14 Aug 2017 23:20:38 +0200
parents 839dcc4f2cf6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
2 * Copyright (c) 2011, 2017, 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 */
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
23 package jdk.vm.ci.hotspot;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
25 import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
26 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
27 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
28 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE;
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 9108
diff changeset
29
22569
ec96f33a101d updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22542
diff changeset
30 import java.lang.invoke.MethodHandle;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
31
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
32 import jdk.vm.ci.common.JVMCIError;
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
33 import jdk.vm.ci.meta.ConstantPool;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
34 import jdk.vm.ci.meta.JavaConstant;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
35 import jdk.vm.ci.meta.JavaField;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
36 import jdk.vm.ci.meta.JavaMethod;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
37 import jdk.vm.ci.meta.JavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
38 import jdk.vm.ci.meta.ResolvedJavaMethod;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
39 import jdk.vm.ci.meta.ResolvedJavaType;
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22605
diff changeset
40 import jdk.vm.ci.meta.Signature;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 /**
5775
2c088af17e59 Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5554
diff changeset
43 * Implementation of {@link ConstantPool} for HotSpot.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 */
23393
1d4ce2d19e52 clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents: 23392
diff changeset
45 final class HotSpotConstantPool implements ConstantPool, MetaspaceWrapperObject {
5278
74dfa6f86879 removed last remaining references to vmEntries and vmExits
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
46
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
47 /**
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
48 * 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
49 */
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21720
diff changeset
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69
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 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
71 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
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 }
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
81 }
22089
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
82
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
83 /**
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
84 * See: {@code Rewriter::maybe_rewrite_invokehandle}.
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
85 */
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
86 static boolean isInvokeHandleAlias(int opcode) {
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
87 switch (opcode) {
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
88 case INVOKEVIRTUAL:
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
89 case INVOKESPECIAL:
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
90 return true;
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
91 default:
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
92 return false;
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
93 }
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
94 }
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
95 }
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
96
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
97 /**
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
98 * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
99 * internal ones.
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
100 */
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
101 private enum JVM_CONSTANT {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
102 // @formatter:off
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
103 Utf8(config().jvmConstantUtf8),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
104 Integer(config().jvmConstantInteger),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
105 Long(config().jvmConstantLong),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
106 Float(config().jvmConstantFloat),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
107 Double(config().jvmConstantDouble),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
108 Class(config().jvmConstantClass),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
109 UnresolvedClass(config().jvmConstantUnresolvedClass),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
110 UnresolvedClassInError(config().jvmConstantUnresolvedClassInError),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
111 String(config().jvmConstantString),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
112 Fieldref(config().jvmConstantFieldref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
113 MethodRef(config().jvmConstantMethodref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
114 InterfaceMethodref(config().jvmConstantInterfaceMethodref),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
115 NameAndType(config().jvmConstantNameAndType),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
116 MethodHandle(config().jvmConstantMethodHandle),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
117 MethodHandleInError(config().jvmConstantMethodHandleInError),
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
118 MethodType(config().jvmConstantMethodType),
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
119 MethodTypeInError(config().jvmConstantMethodTypeInError),
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
120 InvokeDynamic(config().jvmConstantInvokeDynamic);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
121 // @formatter:on
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
122
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
123 private final int tag;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
124
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
125 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
126 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
127 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
128
23297
4b58c92e939b remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents: 22672
diff changeset
129 JVM_CONSTANT(int 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
130 this.tag = tag;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
131 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
132
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
133 /**
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 * 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
135 * 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
136 */
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 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
138 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
139
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
140 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
141 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
142 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
143 table[indexOf(e.tag)] = e;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
144 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
145 }
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
146
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 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
148 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
149 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
150 } 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
151 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
152 }
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 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
154 }
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
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
156 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
157 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
158 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
159 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
160 }
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
161 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
162 }
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
163 }
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
164
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
165 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
166 return TagValueMap.get(tag);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
167 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
168 }
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
169
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
170 private static class LookupTypeCacheElement {
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
171 int lastCpi = Integer.MIN_VALUE;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
172 JavaType javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
173
23297
4b58c92e939b remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents: 22672
diff changeset
174 LookupTypeCacheElement(int lastCpi, JavaType javaType) {
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
175 super();
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
176 this.lastCpi = lastCpi;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
177 this.javaType = javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
178 }
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
179 }
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
180
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
181 /**
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
182 * Reference to the C++ ConstantPool object.
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
183 */
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
184 private final long metaspaceConstantPool;
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
185 private volatile LookupTypeCacheElement lastLookupType;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
187 /**
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
188 * 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
189 * 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
190 * {@link HotSpotJVMCIMetaAccessContext} keeps it alive after that.
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 * Called from the VM.
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
193 *
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
194 * @param metaspaceConstantPool a metaspace ConstantPool object
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
195 * @return the {@link HotSpotConstantPool} corresponding to {@code metaspaceConstantPool}
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 @SuppressWarnings("unused")
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
198 private static HotSpotConstantPool fromMetaspace(long metaspaceConstantPool) {
23677
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23671
diff changeset
199 HotSpotConstantPool cp = new HotSpotConstantPool(metaspaceConstantPool);
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23671
diff changeset
200 runtime().metaAccessContext.add(cp);
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23671
diff changeset
201 return cp;
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
202 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
203
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
204 private HotSpotConstantPool(long metaspaceConstantPool) {
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
205 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
206 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
207
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
208 /**
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
209 * 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
210 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
211 * @return holder for this constant pool
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
212 */
14117
2b2f0022900f removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents: 14093
diff changeset
213 private HotSpotResolvedObjectType getHolder() {
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
214 return compilerToVM().getResolvedJavaType(this, config().constantPoolHolderOffset, false);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
215 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
216
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
217 /**
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
218 * 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
219 * {@link HotSpotVMConfig#constantPoolCpCacheIndexTag constant}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
220 *
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
221 * @param rawIndex index from the bytecode
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
222 * @param opcode bytecode to convert the index for
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
223 * @return constant pool index
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
224 */
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
225 private static int rawIndexToConstantPoolIndex(int rawIndex, int opcode) {
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
226 int index;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
227 if (opcode == Bytecodes.INVOKEDYNAMIC) {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
228 index = rawIndex;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
229 // See: ConstantPool::is_invokedynamic_index
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
230 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
231 } else {
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
232 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
233 opcode == Bytecodes.INVOKEVIRTUAL || opcode == Bytecodes.INVOKESPECIAL || opcode == Bytecodes.INVOKESTATIC : "unexpected invoke opcode " + opcode;
22581
3884a98ebcde consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents: 22569
diff changeset
234 index = rawIndex + config().constantPoolCpCacheIndexTag;
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
235 }
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
236 return index;
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
237 }
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
238
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
239 /**
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
240 * 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
241 *
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
242 * See {@code ConstantPool::decode_cpcache_index}.
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
243 *
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
244 * @param index constant pool cache index
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
245 * @return decoded index
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 private static int decodeConstantPoolCacheIndex(int index) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
248 if (isInvokedynamicIndex(index)) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
249 return decodeInvokedynamicIndex(index);
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
250 } else {
22581
3884a98ebcde consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents: 22569
diff changeset
251 return index - config().constantPoolCpCacheIndexTag;
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
252 }
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::is_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 boolean isInvokedynamicIndex(int index) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
259 return index < 0;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
260 }
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 /**
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
263 * See {@code ConstantPool::decode_invokedynamic_index}.
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
264 */
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
265 private static int decodeInvokedynamicIndex(int i) {
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
266 assert isInvokedynamicIndex(i) : i;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
267 return ~i;
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
268 }
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
269
22598
ed53e370f04c Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents: 22582
diff changeset
270 long getMetaspaceConstantPool() {
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
271 return metaspaceConstantPool;
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
272 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
273
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
274 public long getMetaspacePointer() {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
275 return getMetaspaceConstantPool();
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
276 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
277
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
278 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
279 * 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
280 *
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
281 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
282 * @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
283 */
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
284 private JVM_CONSTANT getTagAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
285 assert checkBounds(index);
22581
3884a98ebcde consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents: 22569
diff changeset
286 HotSpotVMConfig config = config();
22542
15579668ec3a renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents: 22541
diff changeset
287 final long metaspaceConstantPoolTags = UNSAFE.getAddress(getMetaspaceConstantPool() + config.constantPoolTagsOffset);
15579668ec3a renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents: 22541
diff changeset
288 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
289 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
290 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
291 }
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
292 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
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
42aaf7306707 Teach 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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
296 * 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
297 *
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
298 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
299 * @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
300 */
23997
9a740aa0d87b use raw method name symbol for isConstructor and isClassInitializer
Doug Simon <doug.simon@oracle.com>
parents: 23989
diff changeset
301 long getEntryAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
302 assert checkBounds(index);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
303 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
304 return UNSAFE.getAddress(getMetaspaceConstantPool() + config().constantPoolSize + offset);
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
305 }
42aaf7306707 Teach 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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
308 * 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
309 *
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
310 * @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
311 * @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
312 */
42aaf7306707 Teach 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 private int getIntAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
314 assert checkTag(index, JVM_CONSTANT.Integer);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
315 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
316 return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + offset);
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
317 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
318
42aaf7306707 Teach 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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
320 * 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
321 *
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
322 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
323 * @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
324 */
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
325 private long getLongAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
326 assert checkTag(index, JVM_CONSTANT.Long);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
327 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
328 return UNSAFE.getLong(getMetaspaceConstantPool() + config().constantPoolSize + offset);
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
329 }
42aaf7306707 Teach 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 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
332 * 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
333 *
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
334 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
335 * @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
336 */
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
337 private float getFloatAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
338 assert checkTag(index, JVM_CONSTANT.Float);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
339 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
340 return UNSAFE.getFloat(getMetaspaceConstantPool() + config().constantPoolSize + offset);
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
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
344 * 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
345 *
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
346 * @param index constant pool index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
347 * @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
348 */
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
349 private double getDoubleAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
350 assert checkTag(index, JVM_CONSTANT.Double);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
351 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
352 return UNSAFE.getDouble(getMetaspaceConstantPool() + config().constantPoolSize + offset);
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
353 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
354
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
355 /**
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
356 * 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
357 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
358 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
359 * @return {@code JVM_CONSTANT_NameAndType} constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
360 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
361 private int getNameAndTypeAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
362 assert checkTag(index, JVM_CONSTANT.NameAndType);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
363 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
364 return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + offset);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
365 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
366
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
367 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
368 * Gets the {@code JVM_CONSTANT_NameAndType} reference index constant pool entry at index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
369 * {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
370 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
371 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
372 * @return {@code JVM_CONSTANT_NameAndType} reference constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
373 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
374 private int getNameAndTypeRefIndexAt(int index) {
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
375 return compilerToVM().lookupNameAndTypeRefIndexInPool(this, index);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
376 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
377
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
378 /**
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
379 * Gets the name of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by another
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
380 * entry denoted by {@code which}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
381 *
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
382 * @param which constant pool index or constant pool cache index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
383 * @return name as {@link String}
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
384 */
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
385 private String getNameOf(int which) {
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
386 return compilerToVM().lookupNameInPool(this, which);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
387 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
388
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
389 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
390 * Gets the name reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry at
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
391 * index {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
392 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
393 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
394 * @return name reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
395 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
396 private int getNameRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
397 final int refIndex = getNameAndTypeAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
398 // name ref index is in the low 16-bits.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
399 return refIndex & 0xFFFF;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
400 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
401
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
402 /**
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
403 * Gets the signature of a {@code JVM_CONSTANT_NameAndType} constant pool entry referenced by
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
404 * another entry denoted by {@code which}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
405 *
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
406 * @param which constant pool index or constant pool cache index
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
407 * @return signature as {@link String}
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
408 */
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
409 private String getSignatureOf(int which) {
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
410 return compilerToVM().lookupSignatureInPool(this, which);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
411 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
412
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
413 /**
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
414 * Gets the signature reference index of a {@code JVM_CONSTANT_NameAndType} constant pool entry
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
415 * at index {@code index}.
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
416 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
417 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
418 * @return signature reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
419 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
420 private int getSignatureRefIndexAt(int index) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
421 final int refIndex = getNameAndTypeAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
422 // signature ref index is in the high 16-bits.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
423 return refIndex >>> 16;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
424 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
425
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
426 /**
22487
a0e5714d5436 Remove Java implementation of HotSpotConstantPool Cache and ResolvedReferences and HotSpotSymbol.
twisti
parents: 22455
diff changeset
427 * 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
428 *
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
429 * @param index constant pool index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
430 * @return klass reference index
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
431 */
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
432 private int getKlassRefIndexAt(int index) {
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
433 return compilerToVM().lookupKlassRefIndexInPool(this, index);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
434 }
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
435
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
436 /**
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
437 * 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
438 * {@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
439 *
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
440 * @param index constant pool index
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
441 * @return klass reference index
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
442 */
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
443 private int getUncachedKlassRefIndexAt(int index) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
444 assert checkTagIsFieldOrMethod(index);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
445 int offset = index * runtime().getHostJVMCIBackend().getTarget().wordSize;
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
446 final int refIndex = UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolSize + offset);
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
447 // klass ref index is in the low 16-bits.
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
448 return refIndex & 0xFFFF;
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
449 }
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
450
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
451 /**
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
452 * Checks 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
453 *
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
454 * @param index constant pool index
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
455 * @throws AssertionError if the check fails
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
456 */
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
457 private boolean checkBounds(int index) {
13261
0ffe9e4bb364 don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents: 13259
diff changeset
458 assert 0 <= index && index < length() : "index " + index + " not between 0 and " + length();
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
459 return true;
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
460 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
461
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
462 /**
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
463 * Checks 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
464 *
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
465 * @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
466 * @param tag expected tag
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
467 * @throws AssertionError if the check fails
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
468 */
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
469 private boolean checkTag(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
470 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
471 assert tagAt == tag : "constant pool tag at index " + index + " is " + tagAt + " but expected " + tag;
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
472 return true;
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
473 }
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
474
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
475 /**
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
476 * 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
477 * 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
478 *
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
479 * @param index constant pool index
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
480 * @throws AssertionError if the check fails
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
481 */
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
482 private boolean checkTagIsFieldOrMethod(int index) {
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
483 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
484 assert tagAt == JVM_CONSTANT.Fieldref || tagAt == JVM_CONSTANT.MethodRef || tagAt == JVM_CONSTANT.InterfaceMethodref : tagAt;
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
485 return true;
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
486 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
487
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 @Override
9108
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
489 public int length() {
22581
3884a98ebcde consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents: 22569
diff changeset
490 return UNSAFE.getInt(getMetaspaceConstantPool() + config().constantPoolLengthOffset);
9108
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
491 }
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
492
b78686983a75 GRAAL-218: add CompileTheWorld functionality
twisti
parents: 9011
diff changeset
493 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 public Object lookupConstant(int cpi) {
7002
74f0207b82f5 fixed bug in bytecode reconstitution
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
495 assert cpi != 0;
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
496 final JVM_CONSTANT tag = getTagAt(cpi);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
497 switch (tag) {
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
498 case Integer:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
499 return JavaConstant.forInt(getIntAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
500 case Long:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
501 return JavaConstant.forLong(getLongAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
502 case Float:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
503 return JavaConstant.forFloat(getFloatAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
504 case Double:
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
505 return JavaConstant.forDouble(getDoubleAt(cpi));
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
506 case Class:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
507 case UnresolvedClass:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
508 case UnresolvedClassInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
509 final int opcode = -1; // opcode is not used
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
510 return lookupType(cpi, opcode);
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
511 case String:
22272
b6d504612b3f fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents: 22234
diff changeset
512 /*
b6d504612b3f fix HotSpotConstantPool#lookupConstant for pseudo-string entries
Andreas Woess <andreas.woess@oracle.com>
parents: 22234
diff changeset
513 * 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
514 * "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
515 * 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
516 */
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
517 Object string = compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi);
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
518 return HotSpotObjectConstantImpl.forObject(string);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
519 case MethodHandle:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
520 case MethodHandleInError:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
521 case MethodType:
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
522 case MethodTypeInError:
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
523 Object obj = compilerToVM().resolveConstantInPool(this, cpi);
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18223
diff changeset
524 return HotSpotObjectConstantImpl.forObject(obj);
14529
82c3b54d1f08 added HotSpotConstantPool.JVM_CONSTANT enum
twisti
parents: 14117
diff changeset
525 default:
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
526 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
527 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
528 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
529
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 12559
diff changeset
530 @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
531 public String lookupUtf8(int cpi) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
532 assert checkTag(cpi, JVM_CONSTANT.Utf8);
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
533 return compilerToVM().getSymbol(getEntryAt(cpi));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536 @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
537 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
538 return new HotSpotSignature(runtime(), lookupUtf8(cpi));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
539 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
540
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
541 @Override
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18167
diff changeset
542 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
543 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
544 final int index = rawIndexToConstantPoolIndex(cpi, opcode);
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
545 Object appendix = compilerToVM().lookupAppendixInPool(this, index);
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
546 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
547 return null;
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14979
diff changeset
548 } else {
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
549 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
550 }
8945
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
551 }
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
552
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
553 /**
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
554 * 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
555 *
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
556 * @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
557 */
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
558 private static JavaType getJavaType(final Object type) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
559 if (type instanceof String) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
560 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
561 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
562 } else {
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
563 return (JavaType) type;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
564 }
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
565 }
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
566
8945
7ef66078d837 add basic invokedynamic support
Andreas Woess <andreas.woess@jku.at>
parents: 7084
diff changeset
567 @Override
6588
b89b5038ad7e removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
568 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
569 final int index = rawIndexToConstantPoolIndex(cpi, opcode);
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
570 final HotSpotResolvedJavaMethod method = compilerToVM().lookupMethodInPool(this, index, (byte) opcode);
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
571 if (method != null) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
572 return method;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
573 } else {
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
574 // Get the method's name and signature.
22605
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
575 String name = getNameOf(index);
f0ec628cb987 fixed javadoc for lookupNameRefInPool and lookupSignatureRefInPool in CompilerToVM and renamed them to lookupNameInPool and lookupSignatureInPool
Doug Simon <doug.simon@oracle.com>
parents: 22598
diff changeset
576 HotSpotSignature signature = new HotSpotSignature(runtime(), getSignatureOf(index));
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
577 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
578 HotSpotResolvedObjectType holder = HotSpotResolvedObjectTypeImpl.fromObjectClass(MethodHandle.class);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
579 return new HotSpotMethodUnresolved(name, signature, holder);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
580 } else {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
581 final int klassIndex = getKlassRefIndexAt(index);
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
582 final Object type = compilerToVM().lookupKlassInPool(this, klassIndex);
22455
7ad03bf3d4a9 renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents: 22454
diff changeset
583 JavaType holder = getJavaType(type);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
584 return new HotSpotMethodUnresolved(name, signature, holder);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
585 }
14069
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
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
590 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
591 final LookupTypeCacheElement elem = this.lastLookupType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
592 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
593 return elem.javaType;
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
594 } else {
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
595 final Object type = compilerToVM().lookupKlassInPool(this, cpi);
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22420
diff changeset
596 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
597 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
598 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
599 }
21252
39ee26e85256 Use boxed cache in HotSpotConstantpool instead of synchronization
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21215
diff changeset
600 return result;
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
601 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
602 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604 @Override
23689
d814713e3b02 backport of changes from JDK-8157181
Doug Simon <doug.simon@oracle.com>
parents: 23677
diff changeset
605 public JavaField lookupField(int cpi, ResolvedJavaMethod method, int opcode) {
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
606 final int index = rawIndexToConstantPoolIndex(cpi, opcode);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
607 final int nameAndTypeIndex = getNameAndTypeRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
608 final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
609 String typeName = lookupUtf8(typeIndex);
14117
2b2f0022900f removed unnecessary lookupKlassByName method
Doug Simon <doug.simon@oracle.com>
parents: 14093
diff changeset
610 JavaType type = runtime().lookupType(typeName, getHolder(), false);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
611
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
612 final int holderIndex = getKlassRefIndexAt(index);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
613 JavaType holder = lookupType(holderIndex, opcode);
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
614
18223
17c98fad6980 converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18222
diff changeset
615 if (holder instanceof HotSpotResolvedObjectTypeImpl) {
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
616 int[] info = new int[3];
22455
7ad03bf3d4a9 renames related to using metaspace wrappers instead of raw metaspace values
Doug Simon <doug.simon@oracle.com>
parents: 22454
diff changeset
617 HotSpotResolvedObjectTypeImpl resolvedHolder;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
618 try {
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
619 resolvedHolder = compilerToVM().resolveFieldInPool(this, index, (byte) opcode, info);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
620 } catch (Throwable t) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
621 /*
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
622 * If there was an exception resolving the field we give up and return an unresolved
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
623 * field.
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
624 */
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
625 return new HotSpotUnresolvedField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
626 }
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
627 final int flags = info[0];
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
628 final int offset = info[1];
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
629 final int fieldIndex = info[2];
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
630 HotSpotResolvedJavaField result = resolvedHolder.createField(type, offset, flags, fieldIndex);
19377
2ff3a30501da Prototype caching in HotSpotConstantPool.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18867
diff changeset
631 return result;
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
632 } else {
23989
115d4e0d7b87 removed HotSpotResolvedJavaFieldImpl.name field
Doug Simon <doug.simon@oracle.com>
parents: 23742
diff changeset
633 return new HotSpotUnresolvedField(holder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
14069
2f37b0e442fe removed remaining VMToCompiler calls for allocating Graal API objects
Doug Simon <doug.simon@oracle.com>
parents: 14052
diff changeset
634 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
635 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
637 @Override
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
638 @SuppressWarnings("fallthrough")
6588
b89b5038ad7e removed _'s from method names in CompilerToVM
Doug Simon <doug.simon@oracle.com>
parents: 5775
diff changeset
639 public void loadReferencedType(int cpi, int opcode) {
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
640 int index;
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
641 switch (opcode) {
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
642 case Bytecodes.CHECKCAST:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
643 case Bytecodes.INSTANCEOF:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
644 case Bytecodes.NEW:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
645 case Bytecodes.ANEWARRAY:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
646 case Bytecodes.MULTIANEWARRAY:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
647 case Bytecodes.LDC:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
648 case Bytecodes.LDC_W:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
649 case Bytecodes.LDC2_W:
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
650 index = cpi;
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
651 break;
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
652 case Bytecodes.INVOKEDYNAMIC: {
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
653 // invokedynamic instructions point to a constant pool cache entry.
22581
3884a98ebcde consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents: 22569
diff changeset
654 index = decodeConstantPoolCacheIndex(cpi) + config().constantPoolCpCacheIndexTag;
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
655 index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index);
14979
5dfaaa91be37 fixed com.oracle.graal.hotspot.meta.HotSpotConstantPool.loadReferencedType(int, int) for invokedynamic
twisti
parents: 14530
diff changeset
656 break;
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
657 }
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
658 case Bytecodes.GETSTATIC:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
659 case Bytecodes.PUTSTATIC:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
660 case Bytecodes.GETFIELD:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
661 case Bytecodes.PUTFIELD:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
662 case Bytecodes.INVOKEVIRTUAL:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
663 case Bytecodes.INVOKESPECIAL:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
664 case Bytecodes.INVOKESTATIC:
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
665 case Bytecodes.INVOKEINTERFACE: {
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
666 // invoke and field instructions point to a constant pool cache entry.
22488
b5ebb80da4f1 Correct formatting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22487
diff changeset
667 index = rawIndexToConstantPoolIndex(cpi, opcode);
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
668 index = compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index);
22234
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
669 break;
179db500f6e5 Add Java code for reading the constant pool cache plus sun.reflect.ConstantPool substitutions.
twisti
parents: 22100
diff changeset
670 }
14093
dd783f0ecf17 refactor CompilerToVM interface
twisti
parents: 14069
diff changeset
671 default:
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
672 throw JVMCIError.shouldNotReachHere("Unexpected opcode " + opcode);
14052
361acb279104 moved to-constant-pool-index conversion up to Java
twisti
parents: 13261
diff changeset
673 }
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
674
22089
13a50cb905b7 Only invokevirtual and invokespecial are invokehandle aliases.
twisti
parents: 22054
diff changeset
675 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
676 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
677 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
678 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
679 }
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
680 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
681 case MethodRef:
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
682 case Fieldref:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
683 case InterfaceMethodref:
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
684 index = getUncachedKlassRefIndexAt(index);
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
685 // Read the tag only once because it could change between multiple reads.
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
686 final JVM_CONSTANT klassTag = getTagAt(index);
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
687 assert klassTag == JVM_CONSTANT.Class || klassTag == JVM_CONSTANT.UnresolvedClass || klassTag == JVM_CONSTANT.UnresolvedClassInError : klassTag;
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22505
diff changeset
688 // fall through
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
689 case Class:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
690 case UnresolvedClass:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
691 case UnresolvedClassInError:
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
692 final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, index);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
693 Class<?> klass = type.mirror();
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
694 if (!klass.isPrimitive() && !klass.isArray()) {
22542
15579668ec3a renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents: 22541
diff changeset
695 UNSAFE.ensureClassInitialized(klass);
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
696 }
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
697 if (tag == JVM_CONSTANT.MethodRef) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
698 if (Bytecodes.isInvokeHandleAlias(opcode) && isSignaturePolymorphicHolder(type)) {
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
699 final int methodRefCacheIndex = rawIndexToConstantPoolIndex(cpi, opcode);
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
700 assert checkTag(compilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef);
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
701 compilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex);
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
702 }
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
703 }
23700
9e1235406b59 [Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents: 23689
diff changeset
704
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
705 break;
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
706 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
707 if (isInvokedynamicIndex(cpi)) {
22582
232c53e17ea0 added CompilerToVM.compilerToVM() for static access to the CompilerToVM instance
Doug Simon <doug.simon@oracle.com>
parents: 22581
diff changeset
708 compilerToVM().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
709 }
15205
affef8631cf4 Add eager resolving for indy call sites
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15193
diff changeset
710 break;
14530
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
711 default:
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
712 // nothing
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
713 break;
d87b84dade7d moved CompilerToVM.loadReferencedTypeInPool logic into Java
twisti
parents: 14529
diff changeset
714 }
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
715
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
716 }
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
717
24100
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
718 // Lazily initialized.
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
719 private static String[] signaturePolymorphicHolders;
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
720
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
721 /**
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
722 * Determines if {@code type} contains signature polymorphic methods.
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
723 */
24100
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
724 @SuppressFBWarnings(value = "LI_LAZY_INIT_STATIC", justification = "signaturePolymorphicHolders is a cache, not a singleton that must be constructed exactly once" +
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
725 "and compiler re-ordering is not an issue due to the VM call")
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
726 static boolean isSignaturePolymorphicHolder(final ResolvedJavaType type) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
727 String name = type.getName();
24100
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
728 if (signaturePolymorphicHolders == null) {
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
729 signaturePolymorphicHolders = compilerToVM().getSignaturePolymorphicHolders();
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
730 }
839dcc4f2cf6 handle signature polymorphic methods correctly (JDK-8161550)
Doug Simon <doug.simon@oracle.com>
parents: 23997
diff changeset
731 for (String holder : signaturePolymorphicHolders) {
23741
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
732 if (name.equals(holder)) {
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
733 return true;
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
734 }
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
735 }
6542cd8da2da include VarHandle in signature polymorphic method test (JDK-8164214)
Doug Simon <doug.simon@oracle.com>
parents: 23700
diff changeset
736 return false;
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
737 }
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
738
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
739 @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
740 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
741 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
742 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
743 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
744 }