Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java @ 15291:471e28b8f03b
Move UnsafeAccess to graal.compiler.common.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 22 Apr 2014 15:24:14 +0200 |
parents | 96bb07a5d667 |
children | 820c6d353358 |
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.*; |
15291
471e28b8f03b
Move UnsafeAccess to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
26 import static com.oracle.graal.compiler.common.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.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15053
diff
changeset
|
36 import com.oracle.graal.compiler.common.*; |
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 |
14012 | 51 private HashMap<Long, HotSpotResolvedJavaField> fieldCache; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
58 /** |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
59 * Gets the Graal mirror from a HotSpot metaspace Klass native object. |
14980 | 60 * |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
61 * @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
|
62 * @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
|
63 */ |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
64 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
|
65 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
|
66 return fromMetaspaceKlass(metaspaceKlass.asLong()); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
67 } |
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 /** |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
70 * Gets the Graal mirror from a HotSpot metaspace Klass native object. |
14980 | 71 * |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
72 * @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
|
73 * @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
|
74 */ |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
75 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
|
76 assert metaspaceKlass != 0; |
15053 | 77 Class<?> javaClass = runtime().getCompilerToVM().getJavaMirror(metaspaceKlass); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
78 assert javaClass != null; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
79 return fromClass(javaClass); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
80 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
81 |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
82 /** |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
83 * Creates the Graal mirror for a {@link Class} object. |
14980 | 84 * |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
85 * <p> |
13479 | 86 * <b>NOTE</b>: Creating an instance of this class does not install the mirror for the |
87 * {@link Class} type. Use {@link #fromClass(Class)}, {@link #fromMetaspaceKlass(Constant)} or | |
88 * {@link #fromMetaspaceKlass(long)} instead. | |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
89 * </p> |
14980 | 90 * |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
91 * @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
|
92 */ |
13479 | 93 public HotSpotResolvedObjectType(Class<?> javaClass) { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
94 super(getSignatureName(javaClass)); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
95 this.javaClass = javaClass; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
96 assert getName().charAt(0) != '[' || isArray() : getName(); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
97 } |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
98 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
99 /** |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
100 * 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
|
101 */ |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
102 private static String getSignatureName(Class<?> javaClass) { |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
103 if (javaClass.isArray()) { |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
104 return javaClass.getName().replace('.', '/'); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
105 } |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
106 return "L" + javaClass.getName().replace('.', '/') + ";"; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
107 } |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
108 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
109 /** |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
110 * Gets the metaspace Klass for this type. |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
111 */ |
14093 | 112 private long metaspaceKlass() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
113 return HotSpotGraalRuntime.unsafeReadWord(javaClass, runtime().getConfig().klassOffset); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 @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
|
117 public int getModifiers() { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
118 return mirror().getModifiers(); |
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 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
121 public int getAccessFlags() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
122 HotSpotVMConfig config = runtime().getConfig(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
123 return unsafe.getInt(metaspaceKlass() + config.klassAccessFlagsOffset); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 @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
|
127 public ResolvedJavaType getArrayClass() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 if (arrayOfType == null) { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
129 arrayOfType = fromClass(Array.newInstance(mirror(), 0).getClass()); |
3733
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 return arrayOfType; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 @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
|
135 public ResolvedJavaType getComponentType() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
136 Class<?> javaComponentType = mirror().getComponentType(); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
137 return javaComponentType == null ? null : fromClass(javaComponentType); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 @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
|
141 public ResolvedJavaType findUniqueConcreteSubtype() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
142 HotSpotVMConfig config = runtime().getConfig(); |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
143 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
|
144 return isFinal(getElementalType(this).getModifiers()) ? this : null; |
7225
31c4d9f9e922
adder better CHA support
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7221
diff
changeset
|
145 } else if (isInterface()) { |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
146 final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(metaspaceKlass()); |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
147 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
148 // No implementor. |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
149 if (implementorMetaspaceKlass == 0) { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
150 return null; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
151 } |
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 HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) fromMetaspaceKlass(implementorMetaspaceKlass); |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
154 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
155 /* |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
156 * 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
|
157 * 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
|
158 * 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
|
159 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
160 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
|
161 return null; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
162 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
163 return type; |
4433
b494d6f329a3
some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents:
4220
diff
changeset
|
164 } else { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
165 HotSpotResolvedObjectType type = this; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
166 while (isAbstract(type.getModifiers())) { |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
167 long subklass = type.getSubklass(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
168 if (subklass == 0 || unsafeReadWord(subklass + config.nextSiblingOffset) != 0) { |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
169 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
170 } |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
171 type = (HotSpotResolvedObjectType) fromMetaspaceKlass(subklass); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
172 } |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
173 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
|
174 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
175 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
176 return type; |
4433
b494d6f329a3
some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents:
4220
diff
changeset
|
177 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
180 /** |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
181 * 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
|
182 * {@code Klass::_subklass} field of the underlying class is zero. |
14980 | 183 * |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
184 * @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
|
185 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
186 private boolean isLeafClass() { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
187 return getSubklass() == 0; |
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 |
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 * 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
|
192 * type {@code type}. |
14980 | 193 * |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
194 * @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
|
195 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
196 private long getSubklass() { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
197 return unsafeReadWord(metaspaceKlass() + runtime().getConfig().subklassOffset); |
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 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 @Override |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
201 public HotSpotResolvedObjectType getSuperclass() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
202 Class<?> javaSuperclass = mirror().getSuperclass(); |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
203 return javaSuperclass == null ? null : (HotSpotResolvedObjectType) fromClass(javaSuperclass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 @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
|
207 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
|
208 if (interfaces == null) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
209 Class<?>[] javaInterfaces = mirror().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
|
210 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
|
211 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
|
212 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
|
213 } |
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
|
214 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
|
215 } |
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 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
|
217 } |
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 |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
219 public HotSpotResolvedObjectType getSupertype() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
220 if (isArray()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
221 ResolvedJavaType componentType = getComponentType(); |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
222 if (mirror() == Object[].class || componentType.isPrimitive()) { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
223 return (HotSpotResolvedObjectType) fromClass(Object.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
224 } |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
225 return (HotSpotResolvedObjectType) ((HotSpotResolvedObjectType) componentType).getSupertype().getArrayClass(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
226 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
227 if (isInterface()) { |
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 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
230 return getSuperclass(); |
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 |
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
|
233 @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
|
234 public ResolvedJavaType findLeastCommonAncestor(ResolvedJavaType otherType) { |
7059
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
235 if (otherType.isPrimitive()) { |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
236 return null; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
237 } else { |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
238 HotSpotResolvedObjectType t1 = this; |
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
239 HotSpotResolvedObjectType t2 = (HotSpotResolvedObjectType) otherType; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
240 while (true) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
241 if (t1.isAssignableFrom(t2)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
242 return t1; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
243 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
244 if (t2.isAssignableFrom(t1)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
245 return t2; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
246 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
247 t1 = t1.getSupertype(); |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
248 t2 = t2.getSupertype(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
249 } |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
250 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
251 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
252 |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
253 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
254 public ResolvedJavaType asExactType() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
255 if (isArray()) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
256 return getComponentType().asExactType() != null ? this : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 } |
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
|
258 return isFinal(getModifiers()) ? this : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 @Override |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
262 public Constant getEncoding(Representation r) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 switch (r) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 case JavaClass: |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14980
diff
changeset
|
265 return HotSpotObjectConstant.forObject(mirror()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 case ObjectHub: |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
267 return klass(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 default: |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
269 throw GraalInternalError.shouldNotReachHere("unexpected representation " + r); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 public boolean hasFinalizableSubclass() { |
9126
bc26f978b0ce
HotSpotResolvedObjectType: implement hasFinalizeSubclass() correctly
Bernhard Urban <bernhard.urban@jku.at>
parents:
9100
diff
changeset
|
275 assert !isArray(); |
14104 | 276 return runtime().getCompilerToVM().hasFinalizableSubclass(metaspaceKlass()); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 public boolean hasFinalizer() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
281 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
|
282 return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 @Override |
7059
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
286 public boolean isPrimitive() { |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
287 return false; |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
288 } |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
289 |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
290 @Override |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
291 public boolean isArray() { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
292 return mirror().isArray(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 public boolean isInitialized() { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
297 final int state = getState(); |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
298 return state == runtime().getConfig().klassStateFullyInitialized; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 @Override |
11520
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
302 public boolean isLinked() { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
303 final int state = getState(); |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
304 return state >= runtime().getConfig().klassStateLinked; |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
305 } |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
306 |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
307 /** |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
308 * 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
|
309 * klass. |
14980 | 310 * |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
311 * @return state field value of this type |
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 private int getState() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
314 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
|
315 } |
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
316 |
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
317 @Override |
6549
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
318 public void initialize() { |
13214
3f34b8f91cc5
moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents:
12559
diff
changeset
|
319 if (!isInitialized()) { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
320 unsafe.ensureClassInitialized(mirror()); |
13214
3f34b8f91cc5
moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents:
12559
diff
changeset
|
321 assert isInitialized(); |
6549
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
322 } |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
323 } |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
324 |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
325 @Override |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5534
diff
changeset
|
326 public boolean isInstance(Constant obj) { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7097
diff
changeset
|
327 if (obj.getKind() == Kind.Object && !obj.isNull()) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14980
diff
changeset
|
328 return mirror().isInstance(HotSpotObjectConstant.asObject(obj)); |
7015
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6996
diff
changeset
|
329 } |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6996
diff
changeset
|
330 return false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 public boolean isInstanceClass() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
335 return !isArray() && !isInterface(); |
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 isInterface() { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
340 return mirror().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 |
7097
6644cecbd3a7
Replace ResolvedJavaType.isAssignableTo with isAssignableFrom to be consistent with java.lang.Class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7096
diff
changeset
|
344 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
|
345 assert other != null; |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
346 if (other instanceof HotSpotResolvedObjectType) { |
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7083
diff
changeset
|
347 HotSpotResolvedObjectType otherType = (HotSpotResolvedObjectType) other; |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
348 return mirror().isAssignableFrom(otherType.mirror()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 @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
|
354 public Kind getKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
355 return Kind.Object; |
3733
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 ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 assert method instanceof HotSpotMethod; |
14604
bd7cf02d1756
added fast path for HotSpotResolvedObjectType.resolveMethod() when the receiver is the declarer of the method
Doug Simon <doug.simon@oracle.com>
parents:
14158
diff
changeset
|
361 if (!isAbstract(method.getModifiers()) && method.getDeclaringClass().equals(this)) { |
bd7cf02d1756
added fast path for HotSpotResolvedObjectType.resolveMethod() when the receiver is the declarer of the method
Doug Simon <doug.simon@oracle.com>
parents:
14158
diff
changeset
|
362 return method; |
bd7cf02d1756
added fast path for HotSpotResolvedObjectType.resolveMethod() when the receiver is the declarer of the method
Doug Simon <doug.simon@oracle.com>
parents:
14158
diff
changeset
|
363 } |
bd7cf02d1756
added fast path for HotSpotResolvedObjectType.resolveMethod() when the receiver is the declarer of the method
Doug Simon <doug.simon@oracle.com>
parents:
14158
diff
changeset
|
364 |
14104 | 365 final long resolvedMetaspaceMethod = runtime().getCompilerToVM().resolveMethod(metaspaceKlass(), method.getName(), ((HotSpotSignature) method.getSignature()).getMethodDescriptor()); |
13374
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
366 if (resolvedMetaspaceMethod == 0) { |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
367 return null; |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
368 } |
13374
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
369 HotSpotResolvedJavaMethod resolvedMethod = HotSpotResolvedJavaMethod.fromMetaspace(resolvedMetaspaceMethod); |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
370 if (isAbstract(resolvedMethod.getModifiers())) { |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
371 return null; |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
372 } |
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
373 return resolvedMethod; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 |
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
|
376 public ConstantPool constantPool() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
377 if (constantPool == null) { |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
378 final long metaspaceConstantPool = unsafe.getAddress(metaspaceKlass() + runtime().getConfig().instanceKlassConstantsOffset); |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
379 constantPool = new HotSpotConstantPool(metaspaceConstantPool); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
380 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
381 return constantPool; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
382 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
383 |
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
|
384 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
385 * 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
|
386 * 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
|
387 * 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
|
388 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 public int instanceSize() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
390 assert !isArray(); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
391 assert !isInterface(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
392 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
393 HotSpotVMConfig config = runtime().getConfig(); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
394 final int layoutHelper = unsafe.getInt(metaspaceKlass() + config.klassLayoutHelperOffset); |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
395 assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
396 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
397 // See: Klass::layout_helper_size_in_bytes |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
398 int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
399 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
400 // See: Klass::layout_helper_needs_slow_path |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
401 boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
402 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
403 return needsSlowPath ? -size : size; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
406 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
|
407 HotSpotResolvedJavaMethod method = null; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
408 if (methodCache == null) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
409 methodCache = new HashMap<>(8); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
410 } else { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
411 method = methodCache.get(metaspaceMethod); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
412 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
413 if (method == null) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
414 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
|
415 methodCache.put(metaspaceMethod, method); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
416 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
417 return method; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
418 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
419 |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
420 /** |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
421 * Gets the mask used to filter out HotSpot internal flags for fields when a {@link Field} |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
422 * object is created. This is the value of {@code JVM_RECOGNIZED_FIELD_MODIFIERS} in |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
423 * {@code jvm.h}, <b>not</b> {@link Modifier#fieldModifiers()}. |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
424 */ |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
425 public static int getReflectionFieldModifiers() { |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
426 return runtime().getConfig().recognizedFieldModifiers; |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
427 } |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
428 |
14012 | 429 public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) { |
430 HotSpotResolvedJavaField result = null; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 |
14012 | 432 final int flags = rawFlags & getReflectionFieldModifiers(); |
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
|
433 |
14012 | 434 final long id = offset + ((long) flags << 32); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
436 // (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
|
437 // objects from two field lookups are identical. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 if (fieldCache == null) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
439 fieldCache = new HashMap<>(8); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 result = fieldCache.get(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 if (result == null) { |
14012 | 445 result = new HotSpotResolvedJavaField(this, fieldName, type, offset, rawFlags); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 fieldCache.put(id, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 } 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
|
448 assert result.getName().equals(fieldName); |
14012 | 449 // assert result.getType().equals(type); |
450 assert result.offset() == offset; | |
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
|
451 assert result.getModifiers() == flags; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
455 } |
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 @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
|
458 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
|
459 return ((HotSpotResolvedJavaMethod) method).uniqueConcreteMethod(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
461 |
14012 | 462 /** |
463 * This class represents the field information for one field contained in the fields array of an | |
464 * {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class. | |
465 */ | |
466 private class FieldInfo { | |
467 /** | |
468 * Native pointer into the array of Java shorts. | |
469 */ | |
470 private final long metaspaceData; | |
471 | |
472 /** | |
473 * Creates a field info for the field in the fields array at index {@code index}. | |
14980 | 474 * |
14012 | 475 * @param index index to the fields array |
476 */ | |
477 public FieldInfo(int index) { | |
478 HotSpotVMConfig config = runtime().getConfig(); | |
479 // Get Klass::_fields | |
480 final long metaspaceFields = unsafe.getAddress(metaspaceKlass() + config.instanceKlassFieldsOffset); | |
481 assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code"; | |
14980 | 482 metaspaceData = metaspaceFields + config.arrayU2DataOffset + config.fieldInfoFieldSlots * Short.BYTES * index; |
14012 | 483 } |
484 | |
485 private int getAccessFlags() { | |
486 return readFieldSlot(runtime().getConfig().fieldInfoAccessFlagsOffset); | |
487 } | |
488 | |
489 private int getNameIndex() { | |
490 return readFieldSlot(runtime().getConfig().fieldInfoNameIndexOffset); | |
491 } | |
492 | |
493 private int getSignatureIndex() { | |
494 return readFieldSlot(runtime().getConfig().fieldInfoSignatureIndexOffset); | |
495 } | |
496 | |
497 public int getOffset() { | |
498 HotSpotVMConfig config = runtime().getConfig(); | |
499 final int lowPacked = readFieldSlot(config.fieldInfoLowPackedOffset); | |
500 final int highPacked = readFieldSlot(config.fieldInfoHighPackedOffset); | |
501 final int offset = ((highPacked << Short.SIZE) | lowPacked) >> config.fieldInfoTagSize; | |
502 return offset; | |
503 } | |
504 | |
505 /** | |
506 * Helper method to read an entry (slot) from the field array. Currently field info is laid | |
507 * on top an array of Java shorts. | |
508 */ | |
509 private int readFieldSlot(int index) { | |
14980 | 510 return unsafe.getChar(metaspaceData + Short.BYTES * index); |
14012 | 511 } |
512 | |
513 /** | |
514 * Returns the name of this field as a {@link String}. If the field is an internal field the | |
515 * name index is pointing into the vmSymbols table. | |
516 */ | |
517 public String getName() { | |
518 final int nameIndex = getNameIndex(); | |
519 return isInternal() ? HotSpotVmSymbols.symbolAt(nameIndex) : constantPool().lookupUtf8(nameIndex); | |
520 } | |
521 | |
522 /** | |
523 * Returns the signature of this field as {@link String}. If the field is an internal field | |
524 * the signature index is pointing into the vmSymbols table. | |
525 */ | |
526 public String getSignature() { | |
527 final int signatureIndex = getSignatureIndex(); | |
528 return isInternal() ? HotSpotVmSymbols.symbolAt(signatureIndex) : constantPool().lookupUtf8(signatureIndex); | |
529 } | |
530 | |
531 public JavaType getType() { | |
532 String signature = getSignature(); | |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
533 return runtime().lookupType(signature, HotSpotResolvedObjectType.this, false); |
14012 | 534 } |
535 | |
536 private boolean isInternal() { | |
537 return (getAccessFlags() & runtime().getConfig().jvmAccFieldInternal) != 0; | |
538 } | |
539 | |
540 public boolean isStatic() { | |
541 return Modifier.isStatic(getAccessFlags()); | |
542 } | |
543 | |
544 public boolean hasGenericSignature() { | |
545 return (getAccessFlags() & runtime().getConfig().jvmAccFieldHasGenericSignature) != 0; | |
546 } | |
547 } | |
548 | |
7136
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
549 private static class OffsetComparator implements Comparator<HotSpotResolvedJavaField> { |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
550 @Override |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
551 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
|
552 return o1.offset() - o2.offset(); |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
553 } |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
554 } |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
555 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
557 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
|
558 if (instanceFields == null) { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
559 if (isArray() || isInterface()) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
560 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
|
561 } else { |
14012 | 562 final int fieldCount = getFieldCount(); |
563 ArrayList<HotSpotResolvedJavaField> fieldsArray = new ArrayList<>(fieldCount); | |
564 | |
565 for (int i = 0; i < fieldCount; i++) { | |
566 FieldInfo field = new FieldInfo(i); | |
567 | |
568 // We are only interested in instance fields. | |
569 if (!field.isStatic()) { | |
570 HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); | |
571 fieldsArray.add(resolvedJavaField); | |
572 } | |
573 } | |
574 | |
14980 | 575 fieldsArray.sort(new OffsetComparator()); |
14012 | 576 |
577 HotSpotResolvedJavaField[] myFields = fieldsArray.toArray(new HotSpotResolvedJavaField[0]); | |
578 | |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
579 if (mirror() != Object.class) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
580 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
|
581 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
|
582 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
|
583 instanceFields = fields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
584 } else { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
585 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
|
586 instanceFields = myFields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
587 } |
14012 | 588 |
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
|
589 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
590 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
591 if (!includeSuperclasses) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
592 int myFieldsStart = 0; |
14158
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14105
diff
changeset
|
593 while (myFieldsStart < instanceFields.length && !instanceFields[myFieldsStart].getDeclaringClass().equals(this)) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
594 myFieldsStart++; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
595 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
596 if (myFieldsStart == 0) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
597 return instanceFields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
598 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
599 if (myFieldsStart == instanceFields.length) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
600 return new HotSpotResolvedJavaField[0]; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
601 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
602 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
|
603 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
604 return instanceFields; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
605 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
606 |
14012 | 607 /** |
608 * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array | |
609 * by walking the array and discounting the generic signature slots at the end of the array. | |
14980 | 610 * |
14012 | 611 * <p> |
612 * See {@code FieldStreamBase::init_generic_signature_start_slot} | |
613 */ | |
614 private int getFieldCount() { | |
615 HotSpotVMConfig config = runtime().getConfig(); | |
616 final long metaspaceFields = unsafe.getAddress(metaspaceKlass() + config.instanceKlassFieldsOffset); | |
617 int metaspaceFieldsLength = unsafe.getInt(metaspaceFields + config.arrayU1LengthOffset); | |
618 int fieldCount = 0; | |
619 | |
620 for (int i = 0, index = 0; i < metaspaceFieldsLength; i += config.fieldInfoFieldSlots, index++) { | |
621 FieldInfo field = new FieldInfo(index); | |
622 if (field.hasGenericSignature()) { | |
623 metaspaceFieldsLength--; | |
624 } | |
625 fieldCount++; | |
626 } | |
627 return fieldCount; | |
628 } | |
629 | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
630 @Override |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
631 public Class<?> mirror() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
632 return javaClass; |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
633 } |
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
634 |
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
635 @Override |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
636 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
|
637 HotSpotVMConfig config = runtime().getConfig(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
638 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
|
639 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
|
640 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
|
641 } |
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
|
642 return constantPool().lookupUtf8(sourceFileNameIndex); |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
643 } |
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
644 |
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
645 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
647 return mirror().getAnnotation(annotationClass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 } |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
649 |
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
650 @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
|
651 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
652 return this; |
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
653 } |
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
|
654 |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
655 /** |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
656 * Gets the metaspace Klass boxed in a {@link Constant}. |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
657 */ |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
658 public Constant klass() { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14980
diff
changeset
|
659 return HotSpotMetaspaceConstant.forMetaspaceObject(runtime().getTarget().wordKind, metaspaceKlass(), this); |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
660 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
661 |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
662 public boolean isPrimaryType() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
663 return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset(); |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
664 } |
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
665 |
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
666 public int superCheckOffset() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
667 HotSpotVMConfig config = runtime().getConfig(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
668 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
|
669 } |
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
|
670 |
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
|
671 public long prototypeMarkWord() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
672 HotSpotVMConfig config = runtime().getConfig(); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
673 if (isArray()) { |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
674 return config.arrayPrototypeMarkWord(); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
675 } else { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
676 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
|
677 } |
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
|
678 } |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
679 |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
680 @Override |
7057
c37022832f1a
rename: findFieldWithOffset -> findInstanceFieldWithOffset
Doug Simon <doug.simon@oracle.com>
parents:
7055
diff
changeset
|
681 public ResolvedJavaField findInstanceFieldWithOffset(long offset) { |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
682 ResolvedJavaField[] declaredFields = getInstanceFields(true); |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
683 for (ResolvedJavaField field : declaredFields) { |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
684 if (((HotSpotResolvedJavaField) field).offset() == offset) { |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
685 return field; |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
686 } |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
687 } |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
688 return null; |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
689 } |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
690 |
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
691 @Override |
7828
49921d2ee9ce
class file path retrieval returns URL
Michael Haupt <michael.haupt@oracle.com>
parents:
7820
diff
changeset
|
692 public URL getClassFilePath() { |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
693 Class<?> cls = mirror(); |
7831
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
694 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
|
695 } |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
696 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
697 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
698 public boolean isLocal() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
699 return mirror().isLocalClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
700 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
701 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
702 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
703 public boolean isMember() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
704 return mirror().isMemberClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
705 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
706 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
707 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
708 public ResolvedJavaType getEnclosingType() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
709 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
|
710 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
|
711 } |
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
|
712 |
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
|
713 @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
|
714 public ResolvedJavaMethod[] getDeclaredConstructors() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
715 Constructor<?>[] constructors = mirror().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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 } |
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
|
721 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
|
722 } |
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
|
723 |
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
|
724 @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
|
725 public ResolvedJavaMethod[] getDeclaredMethods() { |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
726 Method[] methods = mirror().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
|
727 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
|
728 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
|
729 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
|
730 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
|
731 } |
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
|
732 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
|
733 } |
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
|
734 |
11952
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
735 public ResolvedJavaMethod getClassInitializer() { |
14104 | 736 final long metaspaceMethod = runtime().getCompilerToVM().getClassInitializer(metaspaceKlass()); |
13295
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
737 if (metaspaceMethod != 0L) { |
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
738 return createMethod(metaspaceMethod); |
11952
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
739 } |
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
740 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
|
741 } |
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
|
742 |
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
|
743 @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
|
744 public Constant newArray(int length) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14980
diff
changeset
|
745 return HotSpotObjectConstant.forObject(Array.newInstance(mirror(), 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
|
746 } |
11431
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9985
diff
changeset
|
747 |
13305
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
748 @Override |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
749 public String toString() { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
750 String simpleName; |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
751 if (isArray() || isInterface()) { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
752 simpleName = getName(); |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
753 } else { |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
754 simpleName = getName().substring(1, getName().length() - 1); |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
755 } |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
756 return "HotSpotType<" + simpleName + ", resolved>"; |
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
757 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
758 } |