Mercurial > hg > graal-compiler
annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl.java @ 21652:5f3dda39d205
Truffle: add DynamicObject#containsKey, make flags parameter optional, minor simplifications
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 12:55:56 +0200 |
parents | 48c1ebd24120 |
children | 5b9adb645217 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
23 package com.oracle.jvmci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
25 import static com.oracle.jvmci.common.UnsafeAccess.*; |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
26 import static com.oracle.jvmci.hotspot.HotSpotJVMCIRuntime.*; |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
27 import static java.util.Objects.*; |
15722
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15311
diff
changeset
|
28 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import java.lang.annotation.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import java.lang.reflect.*; |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
31 import java.net.*; |
18950
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
32 import java.nio.*; |
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 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
35 import com.oracle.jvmci.common.*; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
36 import com.oracle.jvmci.meta.Assumptions.AssumptionResult; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
37 import com.oracle.jvmci.meta.Assumptions.ConcreteMethod; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
38 import com.oracle.jvmci.meta.Assumptions.ConcreteSubtype; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
39 import com.oracle.jvmci.meta.Assumptions.LeafType; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
40 import com.oracle.jvmci.meta.Assumptions.NoFinalizableSubclass; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
41 import com.oracle.jvmci.meta.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 /** |
5775
2c088af17e59
Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
44 * 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
|
45 */ |
18867
7f4cb7587f4c
localized replay compilation marker interface to HotSpot specific code
Doug Simon <doug.simon@oracle.com>
parents:
18823
diff
changeset
|
46 public final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, HotSpotProxified { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
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 * 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
|
50 */ |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
51 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
|
52 |
14012 | 53 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
|
54 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
|
55 private HotSpotResolvedJavaField[] instanceFields; |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
56 private HotSpotResolvedObjectTypeImpl[] 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
|
57 private ConstantPool constantPool; |
18556
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
58 private HotSpotResolvedObjectType arrayOfType; |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
59 |
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
60 /** |
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
61 * Gets the Graal mirror for a {@link Class} object. |
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
62 * |
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
63 * @return the {@link HotSpotResolvedJavaType} corresponding to {@code javaClass} |
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
64 */ |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
65 public static HotSpotResolvedObjectTypeImpl fromObjectClass(Class<?> javaClass) { |
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
66 return (HotSpotResolvedObjectTypeImpl) runtime().fromClass(javaClass); |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
67 } |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
5686
diff
changeset
|
68 |
6950
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 */ |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
75 public static HotSpotResolvedObjectTypeImpl fromMetaspaceKlass(long metaspaceKlass) { |
6950
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; |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
79 return fromObjectClass(javaClass); |
6950
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 |
18556
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
87 * {@link Class} type. Use {@link #fromObjectClass(Class)} or {@link #fromMetaspaceKlass(long)} |
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
88 * 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 */ |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
93 public HotSpotResolvedObjectTypeImpl(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 */ |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
112 public long getMetaspaceKlass() { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
113 if (HotSpotJVMCIRuntime.getHostWordKind() == Kind.Long) { |
18556
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
114 return unsafe.getLong(javaClass, (long) runtime().getConfig().klassOffset); |
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
115 } |
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
116 return unsafe.getInt(javaClass, (long) runtime().getConfig().klassOffset) & 0xFFFFFFFFL; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 @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
|
120 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
|
121 return mirror().getModifiers(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
124 public int getAccessFlags() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
125 HotSpotVMConfig config = runtime().getConfig(); |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
126 return unsafe.getInt(getMetaspaceKlass() + config.klassAccessFlagsOffset); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
130 public HotSpotResolvedObjectType getArrayClass() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 if (arrayOfType == null) { |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
132 arrayOfType = fromObjectClass(Array.newInstance(mirror(), 0).getClass()); |
3733
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 return arrayOfType; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 @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
|
138 public ResolvedJavaType getComponentType() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
139 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
|
140 return javaComponentType == null ? null : fromClass(javaComponentType); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 @Override |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
144 public AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
145 HotSpotVMConfig config = runtime().getConfig(); |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
146 if (isArray()) { |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
147 return getElementalType().isFinal() ? new AssumptionResult<>(this) : null; |
7225
31c4d9f9e922
adder better CHA support
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7221
diff
changeset
|
148 } else if (isInterface()) { |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
149 HotSpotResolvedObjectTypeImpl implementor = getSingleImplementor(); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
150 /* |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
151 * If the implementor field contains itself that indicates that the interface has more |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
152 * than one implementors (see: InstanceKlass::add_implementor). |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
153 */ |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
154 if (implementor == null || implementor.equals(this)) { |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
155 return null; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
156 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
157 |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
158 assert !implementor.isInterface(); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
159 if (implementor.isAbstract() || !implementor.isLeafClass()) { |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
160 AssumptionResult<ResolvedJavaType> leafConcreteSubtype = implementor.findLeafConcreteSubtype(); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
161 if (leafConcreteSubtype != null) { |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
162 assert !leafConcreteSubtype.getResult().equals(implementor); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
163 AssumptionResult<ResolvedJavaType> newResult = new AssumptionResult<>(leafConcreteSubtype.getResult(), new ConcreteSubtype(this, implementor)); |
20009
426e45c75771
Properly accumulate assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19801
diff
changeset
|
164 // Accumulate leaf assumptions and return the combined result. |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
165 newResult.add(leafConcreteSubtype); |
20009
426e45c75771
Properly accumulate assumptions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19801
diff
changeset
|
166 return newResult; |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
167 } |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
168 return null; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
169 } |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
170 |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
171 return new AssumptionResult<>(implementor, new LeafType(implementor), new ConcreteSubtype(this, implementor)); |
4433
b494d6f329a3
some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents:
4220
diff
changeset
|
172 } else { |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
173 HotSpotResolvedObjectTypeImpl type = this; |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15291
diff
changeset
|
174 while (type.isAbstract()) { |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
175 long subklass = type.getSubklass(); |
18556
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
176 if (subklass == 0 || unsafe.getAddress(subklass + config.nextSiblingOffset) != 0) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
177 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
178 } |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
179 type = fromMetaspaceKlass(subklass); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
180 } |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15291
diff
changeset
|
181 if (type.isAbstract() || type.isInterface() || !type.isLeafClass()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
182 return null; |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
183 } |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
184 if (this.isAbstract()) { |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
185 return new AssumptionResult<>(type, new LeafType(type), new ConcreteSubtype(this, type)); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
186 } else { |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
187 assert this.equals(type); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
188 return new AssumptionResult<>(type, new LeafType(type)); |
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
189 } |
4433
b494d6f329a3
some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents:
4220
diff
changeset
|
190 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
193 /** |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
194 * 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
|
195 * {@code Klass::_subklass} field of the underlying class is zero. |
14980 | 196 * |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
197 * @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
|
198 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
199 private boolean isLeafClass() { |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
200 return getSubklass() == 0; |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
201 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
202 |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
203 /** |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
204 * 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
|
205 * type {@code type}. |
14980 | 206 * |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
207 * @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
|
208 */ |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
209 private long getSubklass() { |
18556
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
210 return unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().subklassOffset); |
13478
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
211 } |
fe03864a2c72
replaced CompilerToVM.getUniqueImplementor with getKlassImplementor and moved the logic into Java
twisti
parents:
13375
diff
changeset
|
212 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
214 public HotSpotResolvedObjectTypeImpl getSuperclass() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
215 Class<?> javaSuperclass = mirror().getSuperclass(); |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
216 return javaSuperclass == null ? null : (HotSpotResolvedObjectTypeImpl) fromObjectClass(javaSuperclass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
220 public HotSpotResolvedObjectTypeImpl[] 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
|
221 if (interfaces == null) { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
222 Class<?>[] javaInterfaces = mirror().getInterfaces(); |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
223 HotSpotResolvedObjectTypeImpl[] result = new HotSpotResolvedObjectTypeImpl[javaInterfaces.length]; |
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
|
224 for (int i = 0; i < javaInterfaces.length; i++) { |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
225 result[i] = fromObjectClass(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
|
226 } |
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
|
227 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
|
228 } |
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
|
229 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
|
230 } |
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
|
231 |
18182
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
232 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
233 public HotSpotResolvedObjectTypeImpl getSingleImplementor() { |
18182
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
234 if (!isInterface()) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
235 throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); |
18182
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
236 } |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
237 final long implementorMetaspaceKlass = runtime().getCompilerToVM().getKlassImplementor(getMetaspaceKlass()); |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
238 |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
239 // No implementor. |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
240 if (implementorMetaspaceKlass == 0) { |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
241 return null; |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
242 } |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
243 |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
244 return fromMetaspaceKlass(implementorMetaspaceKlass); |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
245 } |
e8c54fd622a4
Add ResolvedJavaType.getImplementor().
Josef Eisl <josef.eisl@jku.at>
parents:
18176
diff
changeset
|
246 |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
247 public HotSpotResolvedObjectTypeImpl getSupertype() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
248 if (isArray()) { |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
249 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
|
250 if (mirror() == Object[].class || componentType.isPrimitive()) { |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
251 return fromObjectClass(Object.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
252 } |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
253 return (HotSpotResolvedObjectTypeImpl) ((HotSpotResolvedObjectTypeImpl) componentType).getSupertype().getArrayClass(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
254 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
255 if (isInterface()) { |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
256 return fromObjectClass(Object.class); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
257 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
258 return getSuperclass(); |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
259 } |
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
260 |
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
|
261 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
262 public HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType) { |
7059
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
263 if (otherType.isPrimitive()) { |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
264 return null; |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
265 } else { |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
266 HotSpotResolvedObjectTypeImpl t1 = this; |
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
267 HotSpotResolvedObjectTypeImpl t2 = (HotSpotResolvedObjectTypeImpl) otherType; |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
268 while (true) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
269 if (t1.isAssignableFrom(t2)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
270 return t1; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
271 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
272 if (t2.isAssignableFrom(t1)) { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
273 return t2; |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
274 } |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
275 t1 = t1.getSupertype(); |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
276 t2 = t2.getSupertype(); |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
277 } |
4635
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
278 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
279 } |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
280 |
f35c183f33ce
fixed checkcast when inlining more than one method
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4484
diff
changeset
|
281 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
282 public HotSpotResolvedObjectType asExactType() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
283 if (isArray()) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
284 return getComponentType().asExactType() != null ? this : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 } |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15291
diff
changeset
|
286 return isFinal() ? this : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 @Override |
18361
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
290 public JavaConstant getJavaClass() { |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
291 return HotSpotObjectConstantImpl.forObject(mirror()); |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
292 } |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
293 |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
294 @Override |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
295 public JavaConstant getObjectHub() { |
6ac7e9c85be6
Split getEncoding into two methods.
Roland Schatz <roland.schatz@oracle.com>
parents:
18323
diff
changeset
|
296 return klass(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 @Override |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
300 public AssumptionResult<Boolean> hasFinalizableSubclass() { |
9126
bc26f978b0ce
HotSpotResolvedObjectType: implement hasFinalizeSubclass() correctly
Bernhard Urban <bernhard.urban@jku.at>
parents:
9100
diff
changeset
|
301 assert !isArray(); |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
302 if (!runtime().getCompilerToVM().hasFinalizableSubclass(getMetaspaceKlass())) { |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
303 return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
304 } |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
305 return new AssumptionResult<>(true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 public boolean hasFinalizer() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
310 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
|
311 return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 @Override |
7059
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
315 public boolean isPrimitive() { |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
316 return false; |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
317 } |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
318 |
e4d9f153934f
removed ResolvedJavaType.toJava() and introduced ResolvedJavaType.isPrimitive()
Doug Simon <doug.simon@oracle.com>
parents:
7057
diff
changeset
|
319 @Override |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
320 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
|
321 return mirror().isArray(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 public boolean isInitialized() { |
16386
9ce3b1efc4e7
InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16384
diff
changeset
|
326 return isArray() ? true : getInitState() == runtime().getConfig().instanceKlassStateFullyInitialized; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 @Override |
11520
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
330 public boolean isLinked() { |
16386
9ce3b1efc4e7
InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16384
diff
changeset
|
331 return isArray() ? true : getInitState() >= runtime().getConfig().instanceKlassStateLinked; |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
332 } |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
333 |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
334 /** |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
335 * 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
|
336 * klass. |
14980 | 337 * |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
338 * @return state field value of this type |
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
339 */ |
16386
9ce3b1efc4e7
InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16384
diff
changeset
|
340 private int getInitState() { |
9ce3b1efc4e7
InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16384
diff
changeset
|
341 assert !isArray() : "_init_state only exists in InstanceKlass"; |
9ce3b1efc4e7
InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16384
diff
changeset
|
342 return unsafe.getByte(getMetaspaceKlass() + runtime().getConfig().instanceKlassInitStateOffset) & 0xFF; |
11520
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
343 } |
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
344 |
7cca436d600b
Add isLinked method to ResolvedJavaType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11431
diff
changeset
|
345 @Override |
6549
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
346 public void initialize() { |
13214
3f34b8f91cc5
moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents:
12559
diff
changeset
|
347 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
|
348 unsafe.ensureClassInitialized(mirror()); |
13214
3f34b8f91cc5
moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents:
12559
diff
changeset
|
349 assert isInitialized(); |
6549
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
350 } |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
351 } |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
352 |
15e04f248d6b
Add functionality to initialize a type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
353 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18182
diff
changeset
|
354 public boolean isInstance(JavaConstant obj) { |
7098
e23980f4a890
Cleanup of Kind class: remove isXxx methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7097
diff
changeset
|
355 if (obj.getKind() == Kind.Object && !obj.isNull()) { |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
356 return mirror().isInstance(((HotSpotObjectConstantImpl) obj).object()); |
7015
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6996
diff
changeset
|
357 } |
62818f156081
added ResolvedJavaType.isClass(Class c) to replace some uses of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6996
diff
changeset
|
358 return false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
362 public boolean isInstanceClass() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
363 return !isArray() && !isInterface(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
367 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
|
368 return mirror().isInterface(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
369 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
370 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 @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
|
372 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
|
373 assert other != null; |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
374 if (other instanceof HotSpotResolvedObjectTypeImpl) { |
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
375 HotSpotResolvedObjectTypeImpl otherType = (HotSpotResolvedObjectTypeImpl) 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
|
376 return mirror().isAssignableFrom(otherType.mirror()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
377 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
378 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
379 } |
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 @Override |
16491
4d7a9829315e
moved isJavaLangObject(ResolvedJavaType type) from MetaUtil to be a default method in ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
16476
diff
changeset
|
382 public boolean isJavaLangObject() { |
4d7a9829315e
moved isJavaLangObject(ResolvedJavaType type) from MetaUtil to be a default method in ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
16476
diff
changeset
|
383 return javaClass.equals(Object.class); |
4d7a9829315e
moved isJavaLangObject(ResolvedJavaType type) from MetaUtil to be a default method in ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
16476
diff
changeset
|
384 } |
4d7a9829315e
moved isJavaLangObject(ResolvedJavaType type) from MetaUtil to be a default method in ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
16476
diff
changeset
|
385 |
4d7a9829315e
moved isJavaLangObject(ResolvedJavaType type) from MetaUtil to be a default method in ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
16476
diff
changeset
|
386 @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
|
387 public Kind getKind() { |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
388 return Kind.Object; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 @Override |
18191
839f97696479
Rename ResolvedJavaMethod.resolvedMethod() to resolveConcreteMethod() the reflect its actual behavior.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
392 public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { |
18192
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
393 ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType, true); |
16384
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
394 if (resolvedMethod == null || resolvedMethod.isAbstract()) { |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
395 return null; |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
396 } |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
397 return resolvedMethod; |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
398 } |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
399 |
18192
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
400 @Override |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
401 public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType, boolean includeAbstract) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
402 if (!includeAbstract) { |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
403 return resolveConcreteMethod(method, callerType); |
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
404 } |
15722
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15311
diff
changeset
|
405 assert !callerType.isArray(); |
18823
5a21cac1968f
Add utilities ModifiersProvider#isConcrete, ResolvedJavaMethod#hasReceiver, ResolvedJavaMethod#hasBytecodes to Graal API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18789
diff
changeset
|
406 if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic()) { |
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
|
407 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
|
408 } |
15722
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15311
diff
changeset
|
409 if (!method.getDeclaringClass().isAssignableFrom(this)) { |
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15311
diff
changeset
|
410 return null; |
c583759bbcfd
ResolvedJavaType.resolveMethod now takes a callerType that is used to check access rules. Make it work for default methods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15311
diff
changeset
|
411 } |
18222
a8cff27ca2e1
converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18194
diff
changeset
|
412 HotSpotResolvedJavaMethodImpl hotSpotMethod = (HotSpotResolvedJavaMethodImpl) method; |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
413 HotSpotResolvedObjectTypeImpl hotSpotCallerType = (HotSpotResolvedObjectTypeImpl) callerType; |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
414 final long resolvedMetaspaceMethod = runtime().getCompilerToVM().resolveMethod(getMetaspaceKlass(), hotSpotMethod.getMetaspaceMethod(), hotSpotCallerType.getMetaspaceKlass()); |
13374
ad187607b784
make CompilerToVM.resolveMethod return a metadata method instead of a Java type
twisti
parents:
13305
diff
changeset
|
415 if (resolvedMetaspaceMethod == 0) { |
11823
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
416 return null; |
6440f50c1ea8
improved documentation and testing for ResolvedJavaType.resolveMethod() (GRAAL-489)
Doug Simon <doug.simon@oracle.com>
parents:
11520
diff
changeset
|
417 } |
18222
a8cff27ca2e1
converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18194
diff
changeset
|
418 return HotSpotResolvedJavaMethodImpl.fromMetaspace(resolvedMetaspaceMethod); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 |
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
|
421 public ConstantPool constantPool() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 if (constantPool == null) { |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
423 final long metaspaceConstantPool = unsafe.getAddress(getMetaspaceKlass() + runtime().getConfig().instanceKlassConstantsOffset); |
13259
b16fb0b7479b
every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents:
13258
diff
changeset
|
424 constantPool = new HotSpotConstantPool(metaspaceConstantPool); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
425 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 return constantPool; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
428 |
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
|
429 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
430 * 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
|
431 * 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
|
432 * 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
|
433 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 public int instanceSize() { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
435 assert !isArray(); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
436 assert !isInterface(); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
437 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
438 HotSpotVMConfig config = runtime().getConfig(); |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
439 final int layoutHelper = unsafe.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
440 assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
441 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
442 // See: Klass::layout_helper_size_in_bytes |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
443 int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
444 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
445 // See: Klass::layout_helper_needs_slow_path |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
446 boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
447 |
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
448 return needsSlowPath ? -size : size; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
451 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
|
452 HotSpotResolvedJavaMethod method = null; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
453 if (methodCache == null) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
454 methodCache = new HashMap<>(8); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
455 } else { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
456 method = methodCache.get(metaspaceMethod); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
457 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
458 if (method == null) { |
18222
a8cff27ca2e1
converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18194
diff
changeset
|
459 method = new HotSpotResolvedJavaMethodImpl(this, metaspaceMethod); |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
460 methodCache.put(metaspaceMethod, method); |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
461 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
462 return method; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
463 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
464 |
16615
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
465 public int getVtableLength() { |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
466 HotSpotVMConfig config = runtime().getConfig(); |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
467 if (isInterface() || isArray()) { |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
468 /* Everything has the core vtable of java.lang.Object */ |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
469 return config.baseVtableLength; |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
470 } |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
471 int result = unsafe.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
472 assert result >= config.baseVtableLength : unsafe.getInt(getMetaspaceKlass() + config.instanceKlassVtableLengthOffset) + " " + config.vtableEntrySize; |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
473 return result; |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
474 } |
3812931f9350
Don't read beyond end of known vtable
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16575
diff
changeset
|
475 |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
476 /** |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
477 * 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
|
478 * 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
|
479 * {@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
|
480 */ |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
481 public static int getReflectionFieldModifiers() { |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
482 return runtime().getConfig().recognizedFieldModifiers; |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
483 } |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
484 |
14012 | 485 public synchronized HotSpotResolvedJavaField createField(String fieldName, JavaType type, long offset, int rawFlags) { |
486 HotSpotResolvedJavaField result = null; | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
487 |
14012 | 488 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
|
489 |
14012 | 490 final long id = offset + ((long) flags << 32); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
491 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7359
diff
changeset
|
492 // (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
|
493 // objects from two field lookups are identical. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
494 if (fieldCache == null) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
495 fieldCache = new HashMap<>(8); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 result = fieldCache.get(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 if (result == null) { |
18264
e28aa8468d5e
converted HotSpotResolvedJavaField to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
501 result = new HotSpotResolvedJavaFieldImpl(this, fieldName, type, offset, rawFlags); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 fieldCache.put(id, result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 } 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
|
504 assert result.getName().equals(fieldName); |
14012 | 505 // assert result.getType().equals(type); |
506 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
|
507 assert result.getModifiers() == flags; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 @Override |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
514 public AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method) { |
16184
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
515 HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method; |
18323
301c5e3d683a
removed *Impl types in signatures of Remote interfaces
Doug Simon <doug.simon@oracle.com>
parents:
18290
diff
changeset
|
516 HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass(); |
16184
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
517 /* |
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
518 * Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared |
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
519 * holder, usually because of phis, so make sure that the type is related to the declared |
16384
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
520 * type before using it for lookup. Unlinked types should also be ignored because we can't |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
521 * resolve the proper method to invoke. Generally unlinked types in invokes should result in |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
522 * a deopt instead since they can't really be used if they aren't linked yet. |
16184
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
523 */ |
16384
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
524 if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) { |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
525 ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder); |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
526 if (result != null) { |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
527 return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result)); |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
528 } |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
529 return null; |
16184
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
530 } |
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
531 /* |
18789 | 532 * The holder may be a subtype of the declaredHolder so make sure to resolve the method to |
16184
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
533 * the correct method for the subtype. |
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
534 */ |
18192
660875e586f0
Add ResolvedJavaType.resolveMethod() (get the like-time resolved method).
Josef Eisl <josef.eisl@jku.at>
parents:
18191
diff
changeset
|
535 HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) resolveMethod(hmethod, this, true); |
16384
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
536 if (resolvedMethod == null) { |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
537 // The type isn't known to implement the method. |
5d7b90ab9787
Ensure that uniqueConcreteMethod is called with a resolved concrete method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16184
diff
changeset
|
538 return null; |
16184
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
539 } |
8fde32ece68e
use receiver type in findUniqueConcreteMethod
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15839
diff
changeset
|
540 |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
541 ResolvedJavaMethod result = resolvedMethod.uniqueConcreteMethod(this); |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
542 if (result != null) { |
19801
deab43a789ad
Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19800
diff
changeset
|
543 return new AssumptionResult<>(result, new ConcreteMethod(method, this, result)); |
19800
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
544 } |
3362ba500371
Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19743
diff
changeset
|
545 return null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 |
14012 | 548 /** |
549 * This class represents the field information for one field contained in the fields array of an | |
550 * {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class. | |
551 */ | |
552 private class FieldInfo { | |
553 /** | |
554 * Native pointer into the array of Java shorts. | |
555 */ | |
556 private final long metaspaceData; | |
557 | |
558 /** | |
559 * Creates a field info for the field in the fields array at index {@code index}. | |
14980 | 560 * |
14012 | 561 * @param index index to the fields array |
562 */ | |
563 public FieldInfo(int index) { | |
564 HotSpotVMConfig config = runtime().getConfig(); | |
565 // Get Klass::_fields | |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
566 final long metaspaceFields = unsafe.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); |
14012 | 567 assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code"; |
14980 | 568 metaspaceData = metaspaceFields + config.arrayU2DataOffset + config.fieldInfoFieldSlots * Short.BYTES * index; |
14012 | 569 } |
570 | |
571 private int getAccessFlags() { | |
572 return readFieldSlot(runtime().getConfig().fieldInfoAccessFlagsOffset); | |
573 } | |
574 | |
575 private int getNameIndex() { | |
576 return readFieldSlot(runtime().getConfig().fieldInfoNameIndexOffset); | |
577 } | |
578 | |
579 private int getSignatureIndex() { | |
580 return readFieldSlot(runtime().getConfig().fieldInfoSignatureIndexOffset); | |
581 } | |
582 | |
583 public int getOffset() { | |
584 HotSpotVMConfig config = runtime().getConfig(); | |
585 final int lowPacked = readFieldSlot(config.fieldInfoLowPackedOffset); | |
586 final int highPacked = readFieldSlot(config.fieldInfoHighPackedOffset); | |
587 final int offset = ((highPacked << Short.SIZE) | lowPacked) >> config.fieldInfoTagSize; | |
588 return offset; | |
589 } | |
590 | |
591 /** | |
592 * Helper method to read an entry (slot) from the field array. Currently field info is laid | |
593 * on top an array of Java shorts. | |
594 */ | |
595 private int readFieldSlot(int index) { | |
14980 | 596 return unsafe.getChar(metaspaceData + Short.BYTES * index); |
14012 | 597 } |
598 | |
599 /** | |
600 * Returns the name of this field as a {@link String}. If the field is an internal field the | |
601 * name index is pointing into the vmSymbols table. | |
602 */ | |
603 public String getName() { | |
604 final int nameIndex = getNameIndex(); | |
605 return isInternal() ? HotSpotVmSymbols.symbolAt(nameIndex) : constantPool().lookupUtf8(nameIndex); | |
606 } | |
607 | |
608 /** | |
609 * Returns the signature of this field as {@link String}. If the field is an internal field | |
610 * the signature index is pointing into the vmSymbols table. | |
611 */ | |
612 public String getSignature() { | |
613 final int signatureIndex = getSignatureIndex(); | |
614 return isInternal() ? HotSpotVmSymbols.symbolAt(signatureIndex) : constantPool().lookupUtf8(signatureIndex); | |
615 } | |
616 | |
617 public JavaType getType() { | |
618 String signature = getSignature(); | |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
619 return runtime().lookupType(signature, HotSpotResolvedObjectTypeImpl.this, false); |
14012 | 620 } |
621 | |
622 private boolean isInternal() { | |
623 return (getAccessFlags() & runtime().getConfig().jvmAccFieldInternal) != 0; | |
624 } | |
625 | |
626 public boolean isStatic() { | |
627 return Modifier.isStatic(getAccessFlags()); | |
628 } | |
629 | |
630 public boolean hasGenericSignature() { | |
631 return (getAccessFlags() & runtime().getConfig().jvmAccFieldHasGenericSignature) != 0; | |
632 } | |
633 } | |
634 | |
18222
a8cff27ca2e1
converted HotSpotResolvedJavaMethod to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18194
diff
changeset
|
635 private static class OffsetComparator implements java.util.Comparator<HotSpotResolvedJavaField> { |
7136
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
636 @Override |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
637 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
|
638 return o1.offset() - o2.offset(); |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
639 } |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
640 } |
4f62a7fa7f9f
sort the fields returned by getInstanceFields by offset
Lukas Stadler <lukas.stadler@jku.at>
parents:
7128
diff
changeset
|
641 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
642 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
643 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
|
644 if (instanceFields == null) { |
7060
06d5f450f32b
rename: ResolvedJavaType.isArrayClass() -> ResolvedJavaType.isArray()
Doug Simon <doug.simon@oracle.com>
parents:
7059
diff
changeset
|
645 if (isArray() || isInterface()) { |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
646 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
|
647 } else { |
14012 | 648 final int fieldCount = getFieldCount(); |
649 ArrayList<HotSpotResolvedJavaField> fieldsArray = new ArrayList<>(fieldCount); | |
650 | |
651 for (int i = 0; i < fieldCount; i++) { | |
652 FieldInfo field = new FieldInfo(i); | |
653 | |
654 // We are only interested in instance fields. | |
655 if (!field.isStatic()) { | |
656 HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); | |
657 fieldsArray.add(resolvedJavaField); | |
658 } | |
659 } | |
660 | |
14980 | 661 fieldsArray.sort(new OffsetComparator()); |
14012 | 662 |
663 HotSpotResolvedJavaField[] myFields = fieldsArray.toArray(new HotSpotResolvedJavaField[0]); | |
664 | |
14091
ed92bc6900d5
simplified HotSpotResolvedObjectType.FieldInfo.getType(); encapsulated all access to javaClass in HotSpotResolvedObjectType more
Doug Simon <doug.simon@oracle.com>
parents:
14069
diff
changeset
|
665 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
|
666 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
|
667 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
|
668 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
|
669 instanceFields = fields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
670 } else { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
671 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
|
672 instanceFields = myFields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
673 } |
14012 | 674 |
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
|
675 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
676 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
677 if (!includeSuperclasses) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
678 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
|
679 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
|
680 myFieldsStart++; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
681 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
682 if (myFieldsStart == 0) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
683 return instanceFields; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
684 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
685 if (myFieldsStart == instanceFields.length) { |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
686 return new HotSpotResolvedJavaField[0]; |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
687 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
688 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
|
689 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6699
diff
changeset
|
690 return instanceFields; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 |
15839
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
693 @Override |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
694 public ResolvedJavaField[] getStaticFields() { |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
695 if (isArray()) { |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
696 return new HotSpotResolvedJavaField[0]; |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
697 } else { |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
698 final int fieldCount = getFieldCount(); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
699 ArrayList<HotSpotResolvedJavaField> fieldsArray = new ArrayList<>(fieldCount); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
700 |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
701 for (int i = 0; i < fieldCount; i++) { |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
702 FieldInfo field = new FieldInfo(i); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
703 |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
704 // We are only interested in static fields. |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
705 if (field.isStatic()) { |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
706 HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
707 fieldsArray.add(resolvedJavaField); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
708 } |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
709 } |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
710 |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
711 fieldsArray.sort(new OffsetComparator()); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
712 return fieldsArray.toArray(new HotSpotResolvedJavaField[fieldsArray.size()]); |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
713 } |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
714 } |
2838203d4231
Add method ResolvedJavaType.getStaticFields
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15730
diff
changeset
|
715 |
14012 | 716 /** |
717 * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array | |
718 * by walking the array and discounting the generic signature slots at the end of the array. | |
14980 | 719 * |
14012 | 720 * <p> |
721 * See {@code FieldStreamBase::init_generic_signature_start_slot} | |
722 */ | |
723 private int getFieldCount() { | |
724 HotSpotVMConfig config = runtime().getConfig(); | |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
725 final long metaspaceFields = unsafe.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); |
14012 | 726 int metaspaceFieldsLength = unsafe.getInt(metaspaceFields + config.arrayU1LengthOffset); |
727 int fieldCount = 0; | |
728 | |
729 for (int i = 0, index = 0; i < metaspaceFieldsLength; i += config.fieldInfoFieldSlots, index++) { | |
730 FieldInfo field = new FieldInfo(index); | |
731 if (field.hasGenericSignature()) { | |
732 metaspaceFieldsLength--; | |
733 } | |
734 fieldCount++; | |
735 } | |
736 return fieldCount; | |
737 } | |
738 | |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 @Override |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
740 public Class<?> mirror() { |
13261
0ffe9e4bb364
don't go through VM to create HotSpotResolvedObjectType (part 1)
twisti
parents:
13260
diff
changeset
|
741 return javaClass; |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
742 } |
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
743 |
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
7045
diff
changeset
|
744 @Override |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
745 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
|
746 HotSpotVMConfig config = runtime().getConfig(); |
16386
9ce3b1efc4e7
InstanceKlass::_init_state only exists for InstanceKlasses
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16384
diff
changeset
|
747 final int sourceFileNameIndex = unsafe.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); |
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
|
748 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
|
749 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
|
750 } |
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
|
751 return constantPool().lookupUtf8(sourceFileNameIndex); |
7307
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
752 } |
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
753 |
dc3e86fd3be1
Introduce cutomization capability for canonicalizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7226
diff
changeset
|
754 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
755 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
|
756 return mirror().getAnnotation(annotationClass); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
757 } |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
758 |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
759 /** |
16575
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
760 * Performs a fast-path check that this type is resolved in the context of a given accessing |
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
761 * class. A negative result does not mean this type is not resolved with respect to |
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
762 * {@code accessingClass}. That can only be determined by |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
763 * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) |
16575
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
764 * re-resolving} the type. |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
765 */ |
16575
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
766 public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) { |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
767 assert accessingClass != null; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
768 ResolvedJavaType elementType = getElementalType(); |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
769 if (elementType.isPrimitive()) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
770 // Primitive type resolution is context free. |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
771 return true; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
772 } |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
773 if (elementType.getName().startsWith("Ljava/")) { |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
774 // Classes in a java.* package can only be defined by the |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
775 // boot class loader. This is enforced by ClassLoader.preDefineClass() |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
776 assert mirror().getClassLoader() == null; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
777 return true; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
778 } |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
779 ClassLoader thisCl = mirror().getClassLoader(); |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
780 ClassLoader accessingClassCl = ((HotSpotResolvedObjectTypeImpl) accessingClass).mirror().getClassLoader(); |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
781 return thisCl == accessingClassCl; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
782 } |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
783 |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
784 @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
|
785 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { |
16575
adafceb4da4a
improved name and documentation for method implementing fast-path check for type resolution
Doug Simon <doug.simon@oracle.com>
parents:
16492
diff
changeset
|
786 if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) { |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
787 return this; |
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
788 } |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
789 HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass; |
16492
8853b9304083
made type resolution require an accessing class context
Doug Simon <doug.simon@oracle.com>
parents:
16491
diff
changeset
|
790 return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true); |
4484
14a00ee82980
Implement eager type resolving.
Andreas Woess <andreas.woess@jku.at>
parents:
4433
diff
changeset
|
791 } |
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
|
792 |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
793 /** |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18182
diff
changeset
|
794 * Gets the metaspace Klass boxed in a {@link JavaConstant}. |
7037
dd81042f4eb1
added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents:
7030
diff
changeset
|
795 */ |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18182
diff
changeset
|
796 public JavaConstant klass() { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
797 return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime().getHostJVMCIBackend().getTarget().wordKind, getMetaspaceKlass(), this, false); |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
798 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
799 |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
800 public boolean isPrimaryType() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
801 return runtime().getConfig().secondarySuperCacheOffset != superCheckOffset(); |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
802 } |
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
803 |
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
804 public int superCheckOffset() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
805 HotSpotVMConfig config = runtime().getConfig(); |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
806 return unsafe.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); |
5466
af07e798947d
lifted fast subtype check into checkcast snippets
Doug Simon <doug.simon@oracle.com>
parents:
5326
diff
changeset
|
807 } |
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
|
808 |
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
|
809 public long prototypeMarkWord() { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
810 HotSpotVMConfig config = runtime().getConfig(); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
811 if (isArray()) { |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
812 return config.arrayPrototypeMarkWord(); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
813 } else { |
18556
7484f5fcd41d
removed a usages of HotSpotGraalRuntime.unsafeReadWord(); tidied up some comments
Doug Simon <doug.simon@oracle.com>
parents:
18534
diff
changeset
|
814 return unsafe.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset); |
7147
88d626e2c2a8
added TLAB fast refill stub for array allocation
Doug Simon <doug.simon@oracle.com>
parents:
7143
diff
changeset
|
815 } |
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
|
816 } |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
817 |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
818 @Override |
18950
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
819 public ResolvedJavaField findInstanceFieldWithOffset(long offset, Kind expectedEntryKind) { |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
820 ResolvedJavaField[] declaredFields = getInstanceFields(true); |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
821 for (ResolvedJavaField field : declaredFields) { |
18950
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
822 HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field; |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
823 long resolvedFieldOffset = resolvedField.offset(); |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
824 // @formatter:off |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
825 if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN && |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
826 expectedEntryKind.isPrimitive() && |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
827 !expectedEntryKind.equals(Kind.Void) && |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
828 resolvedField.getKind().isPrimitive()) { |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
829 resolvedFieldOffset += |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
830 resolvedField.getKind().getByteCount() - |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
831 Math.min(resolvedField.getKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
832 } |
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
833 if (resolvedFieldOffset == offset) { |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
834 return field; |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
835 } |
18950
3fc907b46313
[SPARC] Fix Partial Escape Analysis for SPARC in Truffle
Stefan Anzinger <stefan.anzinger@oracle.com>
parents:
18867
diff
changeset
|
836 // @formatter:on |
7049
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
837 } |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
838 return null; |
ccade022ec83
virtualization of unsafeload and unsafestore
Lukas Stadler <lukas.stadler@jku.at>
parents:
7037
diff
changeset
|
839 } |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
840 |
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
841 @Override |
7828
49921d2ee9ce
class file path retrieval returns URL
Michael Haupt <michael.haupt@oracle.com>
parents:
7820
diff
changeset
|
842 public URL getClassFilePath() { |
7819
aa022eaf1569
class file path retrieval
Michael Haupt <michael.haupt@oracle.com>
parents:
7530
diff
changeset
|
843 Class<?> cls = mirror(); |
7831
fb0ef768d877
simplified class file path retrieval, added test
Michael Haupt <michael.haupt@oracle.com>
parents:
7829
diff
changeset
|
844 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
|
845 } |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
846 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
847 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
848 public boolean isLocal() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
849 return mirror().isLocalClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
850 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
851 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
852 @Override |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
853 public boolean isMember() { |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
854 return mirror().isMemberClass(); |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
855 } |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
856 |
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
857 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18222
diff
changeset
|
858 public HotSpotResolvedObjectTypeImpl getEnclosingType() { |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
859 final Class<?> encl = mirror().getEnclosingClass(); |
18167
2bf5ea10eea7
sharpened return types for HotSpot specific Graal API implementations
Doug Simon <doug.simon@oracle.com>
parents:
17156
diff
changeset
|
860 return encl == null ? null : fromObjectClass(encl); |
7829
a44887443b0c
support for inner classes (local/member) in meta API
Michael Haupt <michael.haupt@oracle.com>
parents:
7828
diff
changeset
|
861 } |
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
|
862 |
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
|
863 @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
|
864 public ResolvedJavaMethod[] getDeclaredConstructors() { |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
865 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
|
866 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
|
867 for (int i = 0; i < constructors.length; i++) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
868 result[i] = runtime().getHostJVMCIBackend().getMetaAccess().lookupJavaMethod(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
|
869 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
|
870 } |
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
|
871 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
|
872 } |
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
|
873 |
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
|
874 @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
|
875 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
|
876 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
|
877 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
|
878 for (int i = 0; i < methods.length; i++) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21411
diff
changeset
|
879 result[i] = runtime().getHostJVMCIBackend().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
|
880 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
|
881 } |
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
|
882 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
|
883 } |
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
|
884 |
11952
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
885 public ResolvedJavaMethod getClassInitializer() { |
15726
668d158f780c
Rename HotSpotResolvedObjectType.metaspaceKlass to getMetaspaceKlass
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15725
diff
changeset
|
886 final long metaspaceMethod = runtime().getCompilerToVM().getClassInitializer(getMetaspaceKlass()); |
13295
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
887 if (metaspaceMethod != 0L) { |
903fd774dd61
simplified implementation of HotSpotResolvedObjectType.getClassInitializer()
Doug Simon <doug.simon@oracle.com>
parents:
13263
diff
changeset
|
888 return createMethod(metaspaceMethod); |
11952
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
889 } |
c0807f5fdca5
added ResolvedJavaType.getClassInititalizer()
Doug Simon <doug.simon@oracle.com>
parents:
11823
diff
changeset
|
890 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
|
891 } |
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
|
892 |
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
|
893 @Override |
13305
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
894 public String toString() { |
15730
920b7bb058a6
Simplify HotSpotUnresolvedJavaType, harmonize toString for HotSpotUnresolvedJavaType and HotSpotResolvedObjectType
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15726
diff
changeset
|
895 return "HotSpotType<" + getName() + ", resolved>"; |
13305
a63d65b682a8
moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents:
13295
diff
changeset
|
896 } |
17156
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16615
diff
changeset
|
897 |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16615
diff
changeset
|
898 @Override |
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16615
diff
changeset
|
899 public boolean isTrustedInterfaceType() { |
19743
d526b6bffc7c
removed HotSpotResolvedObjectTypeImpl.trustedInterfaceType
Doug Simon <doug.simon@oracle.com>
parents:
18950
diff
changeset
|
900 return TrustedInterface.class.isAssignableFrom(mirror()); |
17156
ac6e25901d62
Add trusted interface concept and use it for WordBase, fix a NPE and some tests
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16615
diff
changeset
|
901 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
902 } |