Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java @ 13818:d2f520f46180
added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 30 Jan 2014 00:48:41 +0100 |
parents | 818d2885db2f |
children | 6dd8b95a7fbb |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5545
diff
changeset
|
23 package com.oracle.graal.hotspot.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
7044
34753b057324
added unit tests for JavaType, JavaMethod and ResolvedJavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
7037
diff
changeset
|
25 import static com.oracle.graal.api.meta.MetaUtil.*; |
9126
bc26f978b0ce
HotSpotResolvedObjectType: implement hasFinalizeSubclass() correctly
Bernhard Urban <bernhard.urban@jku.at>
parents:
9100
diff
changeset
|
26 import static com.oracle.graal.graph.UnsafeAccess.*; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
28 import static java.lang.reflect.Modifier.*; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
29 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import java.lang.annotation.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import java.lang.reflect.*; |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
32 import java.net.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5504
diff
changeset
|
35 import com.oracle.graal.api.meta.*; |
11431
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
36 import com.oracle.graal.graph.*; |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
37 import com.oracle.graal.hotspot.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 /** |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
40 * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 */ |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
42 public final class HotSpotResolvedObjectType extends HotSpotResolvedJavaType { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
44 private static final long serialVersionUID = 3481514353553840471L; |
5287
e96c8d2925da
let NodeClass.getDebugProperties handle arrays and doubles
Lukas Stadler <lukas.stadler@jku.at>
parents:
5278
diff
changeset
|
45 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
46 /** |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
47 * The Java class this type represents. |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
48 */ |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
49 private final Class<?> javaClass; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
50 |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
51 /** |
11431
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
52 * Used for implemented a lazy binding from a {@link Node} type to a {@link NodeClass} value. |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
53 */ |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
54 private NodeClass nodeClass; |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
55 |
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:
5540
diff
changeset
|
56 private HashMap<Long, ResolvedJavaField> fieldCache; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
57 private HashMap<Long, HotSpotResolvedJavaMethod> methodCache; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
58 private HotSpotResolvedJavaField[] instanceFields; |
6699
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
59 private ResolvedJavaType[] interfaces; |
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:
5540
diff
changeset
|
60 private ConstantPool constantPool; |
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:
5540
diff
changeset
|
61 private ResolvedJavaType arrayOfType; |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5686
diff
changeset
|
62 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
63 /** |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
64 * Gets the Graal mirror from a HotSpot metaspace Klass native object. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
65 * |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
66 * @param metaspaceKlass a metaspace Klass object boxed in a {@link Constant} |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
67 * @return the {@link ResolvedJavaType} corresponding to {@code klassConstant} |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
68 */ |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
69 public static ResolvedJavaType fromMetaspaceKlass(Constant metaspaceKlass) { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7097
diff
changeset
|
70 assert metaspaceKlass.getKind() == Kind.Long; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
71 return fromMetaspaceKlass(metaspaceKlass.asLong()); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
72 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
73 |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
74 /** |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
75 * Gets the Graal mirror from a HotSpot metaspace Klass native object. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
76 * |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
77 * @param metaspaceKlass a metaspace Klass object |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
78 * @return the {@link ResolvedJavaType} corresponding to {@code metaspaceKlass} |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
79 */ |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
80 public static ResolvedJavaType fromMetaspaceKlass(long metaspaceKlass) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
81 assert metaspaceKlass != 0; |
12436
39308acea2f7
revert Unsafe.getObject hack to read uncompressed pointers
twisti
parents:
12431
diff
changeset
|
82 Class javaClass = (Class) runtime().getCompilerToVM().readUnsafeUncompressedPointer(null, metaspaceKlass + runtime().getConfig().classMirrorOffset); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
83 assert javaClass != null; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
84 return fromClass(javaClass); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
85 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
86 |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
87 /** |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
88 * Creates the Graal mirror for a {@link Class} object. |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
89 * |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
90 * <p> |
13479 | 91 * <b>NOTE</b>: Creating an instance of this class does not install the mirror for the |
92 * {@link Class} type. Use {@link #fromClass(Class)}, {@link #fromMetaspaceKlass(Constant)} or | |
93 * {@link #fromMetaspaceKlass(long)} instead. | |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
94 * </p> |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
95 * |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
96 * @param javaClass the Class to create the mirror for |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
97 */ |
13479 | 98 public HotSpotResolvedObjectType(Class<?> javaClass) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
99 super(getSignatureName(javaClass)); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
100 this.javaClass = javaClass; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
101 assert getName().charAt(0) != '[' || isArray() : getName(); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
102 } |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
103 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
104 /** |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
105 * Returns the name of this type as it would appear in a signature. |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
106 */ |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
107 private static String getSignatureName(Class<?> javaClass) { |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
108 if (javaClass.isArray()) { |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
109 return javaClass.getName().replace('.', '/'); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
110 } |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
111 return "L" + javaClass.getName().replace('.', '/') + ";"; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
112 } |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
113 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
114 /** |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
115 * Gets the address of the C++ Klass object for this type. |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
116 */ |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
117 private long metaspaceKlass() { |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
118 return HotSpotGraalRuntime.unsafeReadWord(javaClass, runtime().getConfig().klassOffset); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
122 public int getModifiers() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
123 return javaClass.getModifiers(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
126 public int getAccessFlags() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
127 HotSpotVMConfig config = runtime().getConfig(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
128 return unsafe.getInt(metaspaceKlass() + config.klassAccessFlagsOffset); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
132 public ResolvedJavaType getArrayClass() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 if (arrayOfType == null) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
134 arrayOfType = fromClass(Array.newInstance(javaClass, 0).getClass()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 return arrayOfType; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
140 public ResolvedJavaType getComponentType() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
141 Class javaComponentType = javaClass.getComponentType(); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
142 return javaComponentType == null ? null : fromClass(javaComponentType); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
146 public ResolvedJavaType findUniqueConcreteSubtype() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
147 HotSpotVMConfig config = runtime().getConfig(); |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
148 if (isArray()) { |
7087
4c0d132dca4d
made HotSpotResolvedObjectType.findUniqueConcreteSubtype() more conservative for array types to fix issue with frequent invalidation of Graal compiled methods
Doug Simon <doug.simon@oracle.com>
parents:
7084
diff
changeset
|
149 return isFinal(getElementalType(this).getModifiers()) ? this : null; |
7225
31c4d9f9e922
adder better CHA support
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7221
diff
changeset
|
150 } else if (isInterface()) { |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
151 final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(metaspaceKlass()); |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
152 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
153 // No implementor. |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
154 if (implementorMetaspaceKlass == 0) { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
155 return null; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
156 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
157 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
158 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) fromMetaspaceKlass(implementorMetaspaceKlass); |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
159 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
160 /* |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
161 * If the implementor field contains itself that indicates that the interface has more |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
162 * than one implementors (see: InstanceKlass::add_implementor). The isInterface check |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
163 * takes care of this fact since this class is an interface. |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
164 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
165 if (isAbstract(type.getModifiers()) || type.isInterface() || !type.isLeafClass()) { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
166 return null; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
167 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
168 return type; |
4433
b494d6f329a3
some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents:
4220
diff
changeset
|
169 } else { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
170 HotSpotResolvedObjectType type = this; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
171 while (isAbstract(type.getModifiers())) { |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
172 long subklass = type.getSubklass(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
173 if (subklass == 0 || unsafeReadWord(subklass + config.nextSiblingOffset) != 0) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
174 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
175 } |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
176 type = (HotSpotResolvedObjectType) fromMetaspaceKlass(subklass); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
177 } |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
178 if (isAbstract(type.getModifiers()) || type.isInterface() || !type.isLeafClass()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
179 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
180 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
181 return type; |
4433
b494d6f329a3
some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents:
4220
diff
changeset
|
182 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
185 /** |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
186 * Returns if type {@code type} is a leaf class. This is the case if the |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
187 * {@code Klass::_subklass} field of the underlying class is zero. |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
188 * |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
189 * @return true if the type is a leaf class |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
190 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
191 private boolean isLeafClass() { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
192 return getSubklass() == 0; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
193 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
194 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
195 /** |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
196 * Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
197 * type {@code type}. |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
198 * |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
199 * @return value of the subklass field as metaspace klass pointer |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
200 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
201 private long getSubklass() { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
202 return unsafeReadWord(metaspaceKlass() + runtime().getConfig().subklassOffset); |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
203 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
204 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 @Override |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
206 public HotSpotResolvedObjectType getSuperclass() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
207 Class javaSuperclass = javaClass.getSuperclass(); |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
208 return javaSuperclass == null ? null : (HotSpotResolvedObjectType) fromClass(javaSuperclass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 @Override |
6699
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
212 public ResolvedJavaType[] getInterfaces() { |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
213 if (interfaces == null) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
214 Class[] javaInterfaces = javaClass.getInterfaces(); |
6699
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
215 ResolvedJavaType[] result = new ResolvedJavaType[javaInterfaces.length]; |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
216 for (int i = 0; i < javaInterfaces.length; i++) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
217 result[i] = fromClass(javaInterfaces[i]); |
6699
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
218 } |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
219 interfaces = result; |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
220 } |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
221 return interfaces; |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
222 } |
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
223 |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
224 public HotSpotResolvedObjectType getSupertype() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
225 if (isArray()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
226 ResolvedJavaType componentType = getComponentType(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
227 if (javaClass == Object[].class || componentType.isPrimitive()) { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
228 return (HotSpotResolvedObjectType) fromClass(Object.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
229 } |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
230 return (HotSpotResolvedObjectType) ((HotSpotResolvedObjectType) componentType).getSupertype().getArrayClass(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
231 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
232 if (isInterface()) { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
233 return (HotSpotResolvedObjectType) fromClass(Object.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
234 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
235 return getSuperclass(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
236 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
237 |
6699
d79098b9db3b
Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6588
diff
changeset
|
238 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
239 public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { |
7059
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
240 if (otherType.isPrimitive()) { |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
241 return null; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
242 } else { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
243 HotSpotResolvedObjectType t1 = this; |
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
244 HotSpotResolvedObjectType t2 = (HotSpotResolvedObjectType) otherType; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
245 while (true) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
246 if (t1.isAssignableFrom(t2)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
247 return t1; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
248 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
249 if (t2.isAssignableFrom(t1)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
250 return t2; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
251 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
252 t1 = t1.getSupertype(); |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
253 t2 = t2.getSupertype(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
254 } |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
255 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
256 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
257 |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
258 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
259 public ResolvedJavaType asExactType() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
260 if (isArray()) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
261 return getComponentType().asExactType() != null ? this : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 } |
7087
4c0d132dca4d
made HotSpotResolvedObjectType.findUniqueConcreteSubtype() more conservative for array types to fix issue with frequent invalidation of Graal compiled methods
Doug Simon <doug.simon@oracle.com>
parents:
7084
diff
changeset
|
263 return isFinal(getModifiers()) ? this : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 @Override |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
267 public Constant getEncoding(Representation r) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 switch (r) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 case JavaClass: |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
270 return Constant.forObject(javaClass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 case ObjectHub: |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
272 return klass(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 default: |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
274 throw GraalInternalError.shouldNotReachHere("unexpected representation " + r); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 public boolean hasFinalizableSubclass() { |
9126
bc26f978b0ce
HotSpotResolvedObjectType: implement hasFinalizeSubclass() correctly
Bernhard Urban <bernhard.urban@jku.at>
parents:
9100
diff
changeset
|
280 assert !isArray(); |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
281 return runtime().getCompilerToVM().hasFinalizableSubclass(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 public boolean hasFinalizer() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
286 HotSpotVMConfig config = runtime().getConfig(); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
287 return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 @Override |
7059
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
291 public boolean isPrimitive() { |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
292 return false; |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
293 } |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
294 |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
295 @Override |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
296 public boolean isArray() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
297 return javaClass.isArray(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 public boolean isInitialized() { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
302 final int state = getState(); |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
303 return state == runtime().getConfig().klassStateFullyInitialized; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 @Override |
11520
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
307 public boolean isLinked() { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
308 final int state = getState(); |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
309 return state >= runtime().getConfig().klassStateLinked; |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
310 } |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
311 |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
312 /** |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
313 * Returns the value of the state field {@code InstanceKlass::_init_state} of the metaspace |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
314 * klass. |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
315 * |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
316 * @return state field value of this type |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
317 */ |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
318 private int getState() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
319 return unsafe.getByte(metaspaceKlass() + runtime().getConfig().klassStateOffset) & 0xFF; |
11520
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
320 } |
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
321 |
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
322 @Override |
6549
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
323 public void initialize() { |
13214
3f34b8f91cc5
moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents:
12559
diff
changeset
|
324 if (!isInitialized()) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
325 unsafe.ensureClassInitialized(javaClass); |
13214
3f34b8f91cc5
moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents:
12559
diff
changeset
|
326 assert isInitialized(); |
6549
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
327 } |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
328 } |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
329 |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
330 @Override |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
331 public boolean isInstance(Constant obj) { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7097
diff
changeset
|
332 if (obj.getKind() == Kind.Object && !obj.isNull()) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
333 return javaClass.isInstance(obj.asObject()); |
7015
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6996
diff
changeset
|
334 } |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6996
diff
changeset
|
335 return false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 public boolean isInstanceClass() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
340 return !isArray() && !isInterface(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 public boolean isInterface() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
345 return javaClass.isInterface(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 @Override |
7097
6644cecbd3a7
Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7096
diff
changeset
|
349 public boolean isAssignableFrom(ResolvedJavaType other) { |
9835
fcfedd3dd2eb
ResolvedJavaType.isAssignableFrom must not be called with null argument. Check that with assertions in HotSpot implementation.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9289
diff
changeset
|
350 assert other != null; |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
351 if (other instanceof HotSpotResolvedObjectType) { |
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
352 HotSpotResolvedObjectType otherType = (HotSpotResolvedObjectType) other; |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
353 return javaClass.isAssignableFrom(otherType.javaClass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
355 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
356 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
359 public Kind getKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
360 return Kind.Object; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
362 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
364 public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 assert method instanceof HotSpotMethod; |
13374
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
366 final long resolvedMetaspaceMethod = runtime().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).getMethodDescriptor()); |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
367 if (resolvedMetaspaceMethod == 0) { |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
368 return null; |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
369 } |
13374
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
370 HotSpotResolvedJavaMethod resolvedMethod = HotSpotResolvedJavaMethod.fromMetaspace(resolvedMetaspaceMethod); |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
371 if (isAbstract(resolvedMethod.getModifiers())) { |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
372 return null; |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
373 } |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
374 return resolvedMethod; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 |
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:
5540
diff
changeset
|
377 public ConstantPool constantPool() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
378 if (constantPool == null) { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
379 final long metaspaceConstantPool = unsafe.getAddress(metaspaceKlass() + runtime().getConfig().instanceKlassConstantsOffset); |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
380 constantPool = new HotSpotConstantPool(metaspaceConstantPool); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
381 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
382 return constantPool; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
383 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 |
5616
310ed6650682
added check to ensure fast path allocation is never used for types that don't allow it
Doug Simon <doug.simon@oracle.com>
parents:
5554
diff
changeset
|
385 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
386 * Gets the instance size of this type. If an instance of this type cannot be fast path |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
387 * allocated, then the returned value is negative (its absolute value gives the size). Must not |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
388 * be called if this is an array or interface type. |
5616
310ed6650682
added check to ensure fast path allocation is never used for types that don't allow it
Doug Simon <doug.simon@oracle.com>
parents:
5554
diff
changeset
|
389 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 public int instanceSize() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
391 assert !isArray(); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
392 assert !isInterface(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
393 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
394 HotSpotVMConfig config = runtime().getConfig(); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
395 final int layoutHelper = unsafe.getInt(metaspaceKlass() + config.klassLayoutHelperOffset); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
396 assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
397 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
398 // See: Klass::layout_helper_size_in_bytes |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
399 int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
400 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
401 // See: Klass::layout_helper_needs_slow_path |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
402 boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
403 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
404 return needsSlowPath ? -size : size; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
407 public synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceMethod) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
408 HotSpotResolvedJavaMethod method = null; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
409 if (methodCache == null) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
410 methodCache = new HashMap<>(8); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
411 } else { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
412 method = methodCache.get(metaspaceMethod); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
413 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
414 if (method == null) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
415 method = new HotSpotResolvedJavaMethod(this, metaspaceMethod); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
416 methodCache.put(metaspaceMethod, method); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
417 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
418 return method; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
419 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
420 |
13495
818d2885db2f
Bugfix: Canonicalize field flags before looking up cached fields, to avoid creating the same field twice with different flags
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13479
diff
changeset
|
421 public synchronized ResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags, boolean internal) { |
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:
5540
diff
changeset
|
422 ResolvedJavaField result = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 |
13495
818d2885db2f
Bugfix: Canonicalize field flags before looking up cached fields, to avoid creating the same field twice with different flags
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13479
diff
changeset
|
424 /* |
13818
d2f520f46180
added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
13495
diff
changeset
|
425 * Filter flags to be only those return by Field.getModifiers() to get a canonical id value. |
d2f520f46180
added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
13495
diff
changeset
|
426 * Strangely, Field.getModifiers() uses JVM_RECOGNIZED_FIELD_MODIFIERS in jvm.h instead of |
d2f520f46180
added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
13495
diff
changeset
|
427 * Modifier.fieldModifiers() to mask out HotSpot internal flags. |
13495
818d2885db2f
Bugfix: Canonicalize field flags before looking up cached fields, to avoid creating the same field twice with different flags
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13479
diff
changeset
|
428 */ |
13818
d2f520f46180
added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
13495
diff
changeset
|
429 int reflectionFieldModifiers = runtime().getConfig().recognizedFieldModifiers; |
d2f520f46180
added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents:
13495
diff
changeset
|
430 int flags = rawFlags & reflectionFieldModifiers; |
13495
818d2885db2f
Bugfix: Canonicalize field flags before looking up cached fields, to avoid creating the same field twice with different flags
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13479
diff
changeset
|
431 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 long id = offset + ((long) flags << 32); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
434 // (thomaswue) Must cache the fields, because the local load elimination only works if the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
435 // objects from two field lookups are identical. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 if (fieldCache == null) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
437 fieldCache = new HashMap<>(8); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
439 result = fieldCache.get(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 if (result == null) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
443 result = new HotSpotResolvedJavaField(this, fieldName, type, offset, flags, internal); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 fieldCache.put(id, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 } else { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
446 assert result.getName().equals(fieldName); |
13495
818d2885db2f
Bugfix: Canonicalize field flags before looking up cached fields, to avoid creating the same field twice with different flags
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13479
diff
changeset
|
447 assert result.getModifiers() == flags; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
453 @Override |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6430
diff
changeset
|
454 public ResolvedJavaMethod findUniqueConcreteMethod(ResolvedJavaMethod method) { |
5554
70f715dfbb41
Bring Java renamings and restructurings to the C++ part.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5548
diff
changeset
|
455 return ((HotSpotResolvedJavaMethod) method).uniqueConcreteMethod(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
456 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
457 |
7136
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
458 private static class OffsetComparator implements Comparator<HotSpotResolvedJavaField> { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
459 |
7136
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
460 @Override |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
461 public int compare(HotSpotResolvedJavaField o1, HotSpotResolvedJavaField o2) { |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
462 return o1.offset() - o2.offset(); |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
463 } |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
464 } |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
465 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
467 public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
468 if (instanceFields == null) { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
469 if (isArray() || isInterface()) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
470 instanceFields = new HotSpotResolvedJavaField[0]; |
6293
6550737d7807
an empty array is now returned by ResolvedJavaType.declaredFields() for array and primitive types
Doug Simon <doug.simon@oracle.com>
parents:
6277
diff
changeset
|
471 } else { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
472 HotSpotResolvedJavaField[] myFields = runtime().getCompilerToVM().getInstanceFields(this); |
7136
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
473 Arrays.sort(myFields, new OffsetComparator()); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
474 if (javaClass != Object.class) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
475 HotSpotResolvedJavaField[] superFields = (HotSpotResolvedJavaField[]) getSuperclass().getInstanceFields(true); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
476 HotSpotResolvedJavaField[] fields = Arrays.copyOf(superFields, superFields.length + myFields.length); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
477 System.arraycopy(myFields, 0, fields, superFields.length, myFields.length); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
478 instanceFields = fields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
479 } else { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
480 assert myFields.length == 0 : "java.lang.Object has fields!"; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
481 instanceFields = myFields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
482 } |
6293
6550737d7807
an empty array is now returned by ResolvedJavaType.declaredFields() for array and primitive types
Doug Simon <doug.simon@oracle.com>
parents:
6277
diff
changeset
|
483 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
485 if (!includeSuperclasses) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
486 int myFieldsStart = 0; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
487 while (myFieldsStart < instanceFields.length && instanceFields[myFieldsStart].getDeclaringClass() != this) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
488 myFieldsStart++; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
489 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
490 if (myFieldsStart == 0) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
491 return instanceFields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
492 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
493 if (myFieldsStart == instanceFields.length) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
494 return new HotSpotResolvedJavaField[0]; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
495 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
496 return Arrays.copyOfRange(instanceFields, myFieldsStart, instanceFields.length); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
497 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
498 return instanceFields; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 @Override |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
502 public Class<?> mirror() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
503 return javaClass; |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
504 } |
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
505 |
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
506 @Override |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
507 public String getSourceFileName() { |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
13214
diff
changeset
|
508 HotSpotVMConfig config = runtime().getConfig(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
509 final int sourceFileNameIndex = unsafe.getChar(metaspaceKlass() + config.klassSourceFileNameIndexOffset); |
13254
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
13214
diff
changeset
|
510 if (sourceFileNameIndex == 0) { |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
13214
diff
changeset
|
511 return null; |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
13214
diff
changeset
|
512 } |
42aaf7306707
Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents:
13214
diff
changeset
|
513 return constantPool().lookupUtf8(sourceFileNameIndex); |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
514 } |
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
515 |
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
516 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
518 return javaClass.getAnnotation(annotationClass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 } |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
520 |
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
521 @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:
5540
diff
changeset
|
522 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
523 return this; |
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
524 } |
5326
a53162ca8219
introduced HotSpotKlassOop type to convey a klassOop value from the compiler to the C++ code instead of relying on the C++ code automagically converting a HotSpotTypeResolvedImpl value to a klassOop
Doug Simon <doug.simon@oracle.com>
parents:
5287
diff
changeset
|
525 |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
526 /** |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
527 * Gets the address of the C++ Klass object for this type. |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
528 */ |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
529 public Constant klass() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
530 return Constant.forIntegerKind(runtime().getTarget().wordKind, metaspaceKlass(), this); |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
531 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
532 |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
533 public boolean isPrimaryType() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
534 return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset(); |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
535 } |
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
536 |
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
537 public int superCheckOffset() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
538 HotSpotVMConfig config = runtime().getConfig(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
539 return unsafe.getInt(metaspaceKlass() + config.superCheckOffsetOffset); |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
540 } |
5686
6cb39a47da14
replaced loading of instance prototype header word with a constant obtained from HotSpotResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
5682
diff
changeset
|
541 |
6375
1d7c73b5d787
terminology change to match C++ code and biased locking paper: "initial mark word" -> "prototype mark word"
Doug Simon <doug.simon@oracle.com>
parents:
6367
diff
changeset
|
542 public long prototypeMarkWord() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
543 HotSpotVMConfig config = runtime().getConfig(); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
544 if (isArray()) { |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
545 return config.arrayPrototypeMarkWord(); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
546 } else { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
547 return unsafeReadWord(metaspaceKlass() + config.prototypeMarkWordOffset); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
548 } |
5686
6cb39a47da14
replaced loading of instance prototype header word with a constant obtained from HotSpotResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
5682
diff
changeset
|
549 } |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
550 |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
551 @Override |
7057
c37022832f1a
rename: findFieldWithOffset -> findInstanceFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7055
diff
changeset
|
552 public ResolvedJavaField findInstanceFieldWithOffset(long offset) { |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
553 ResolvedJavaField[] declaredFields = getInstanceFields(true); |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
554 for (ResolvedJavaField field : declaredFields) { |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
555 if (((HotSpotResolvedJavaField) field).offset() == offset) { |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
556 return field; |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
557 } |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
558 } |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
559 return null; |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
560 } |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
561 |
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
562 @Override |
7828
49921d2ee9ce
class file path retrieval returns URL
Michael Haupt <michael.haupt@oracle.com>
parents:
7820
diff
changeset
|
563 public URL getClassFilePath() { |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
564 Class<?> cls = mirror(); |
7831
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
565 return cls.getResource(MetaUtil.getSimpleName(cls, true).replace('.', '$') + ".class"); |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
566 } |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
567 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
568 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
569 public boolean isLocal() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
570 return mirror().isLocalClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
571 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
572 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
573 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
574 public boolean isMember() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
575 return mirror().isMemberClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
576 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
577 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
578 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
579 public ResolvedJavaType getEnclosingType() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
580 final Class<?> encl = mirror().getEnclosingClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
581 return encl == null ? null : fromClass(encl); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
582 } |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
583 |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
584 @Override |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
585 public ResolvedJavaMethod[] getDeclaredConstructors() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
586 Constructor[] constructors = javaClass.getDeclaredConstructors(); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
587 ResolvedJavaMethod[] result = new ResolvedJavaMethod[constructors.length]; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
588 for (int i = 0; i < constructors.length; i++) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12436
diff
changeset
|
589 result[i] = runtime().getHostProviders().getMetaAccess().lookupJavaConstructor(constructors[i]); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
590 assert result[i].isConstructor(); |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
591 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
592 return result; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
593 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
594 |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
595 @Override |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
596 public ResolvedJavaMethod[] getDeclaredMethods() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
597 Method[] methods = javaClass.getDeclaredMethods(); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
598 ResolvedJavaMethod[] result = new ResolvedJavaMethod[methods.length]; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
599 for (int i = 0; i < methods.length; i++) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12436
diff
changeset
|
600 result[i] = runtime().getHostProviders().getMetaAccess().lookupJavaMethod(methods[i]); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
601 assert !result[i].isConstructor(); |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
602 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
603 return result; |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
604 } |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
605 |
11952
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
606 public ResolvedJavaMethod getClassInitializer() { |
13295
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
607 long metaspaceMethod = runtime().getCompilerToVM().getClassInitializer(this); |
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
608 if (metaspaceMethod != 0L) { |
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
609 return createMethod(metaspaceMethod); |
11952
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
610 } |
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
611 return null; |
9985
e6bd1004082a
added HotSpotResolvedObjectType.getMethods() to get all methods of a class including those (such as <clinit>) not normally exposed by Java reflection
Doug Simon <doug.simon@oracle.com>
parents:
9835
diff
changeset
|
612 } |
e6bd1004082a
added HotSpotResolvedObjectType.getMethods() to get all methods of a class including those (such as <clinit>) not normally exposed by Java reflection
Doug Simon <doug.simon@oracle.com>
parents:
9835
diff
changeset
|
613 |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
614 @Override |
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
615 public Constant newArray(int length) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
616 return Constant.forObject(Array.newInstance(javaClass, length)); |
9100
d24955427b0b
Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents:
8959
diff
changeset
|
617 } |
11431
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
618 |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
619 /** |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
620 * @return the {@link NodeClass} value (which may be {@code null}) associated with this type |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
621 */ |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
622 public NodeClass getNodeClass() { |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
623 return nodeClass; |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
624 } |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
625 |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
626 /** |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
627 * Sets the {@link NodeClass} value associated with this type. |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
628 */ |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
629 public void setNodeClass(NodeClass nodeClass) { |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
630 this.nodeClass = nodeClass; |
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
631 } |
13305
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
632 |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
633 @Override |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
634 public boolean equals(Object obj) { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
635 if (!(obj instanceof HotSpotResolvedObjectType)) { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
636 return false; |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
637 } |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
638 HotSpotResolvedObjectType that = (HotSpotResolvedObjectType) obj; |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
639 return this.mirror() == that.mirror(); |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
640 } |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
641 |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
642 @Override |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
643 public int hashCode() { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
644 return super.hashCode(); |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
645 } |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
646 |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
647 @Override |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
648 public String toString() { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
649 String simpleName; |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
650 if (isArray() || isInterface()) { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
651 simpleName = getName(); |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
652 } else { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
653 simpleName = getName().substring(1, getName().length() - 1); |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
654 } |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
655 return "HotSpotType<" + simpleName + ", resolved>"; |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
656 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 } |