Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java @ 22672:1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 17:28:41 -0700 |
parents | jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaFieldImpl.java@47f047ae2b4b |
children | a130b51efb07 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
22598
ed53e370f04c
Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22581
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 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
25 import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
26 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22432
diff
changeset
|
27 |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22432
diff
changeset
|
28 import java.lang.annotation.Annotation; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22432
diff
changeset
|
29 import java.lang.reflect.Field; |
8949
da5140eedfa1
made format of toString() consistent across HotSpot subclasses of JavaField and JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
8415
diff
changeset
|
30 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
31 import jdk.vm.ci.common.JVMCIError; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
32 import jdk.vm.ci.meta.JavaType; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
33 import jdk.vm.ci.meta.LocationIdentity; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
34 import jdk.vm.ci.meta.MetaAccessProvider; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
35 import jdk.vm.ci.meta.ModifiersProvider; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
36 import jdk.vm.ci.meta.ResolvedJavaField; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
37 import jdk.vm.ci.meta.ResolvedJavaType; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
38 import jdk.vm.ci.options.Option; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
39 import jdk.vm.ci.options.OptionType; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22664
diff
changeset
|
40 import jdk.vm.ci.options.OptionValue; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 * Represents a field in a HotSpot type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 */ |
22598
ed53e370f04c
Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22581
diff
changeset
|
45 class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 |
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
|
47 static class Options { |
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
|
48 //@formatter:off |
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
|
49 @Option(help = "Mark well-known stable fields as such.", type = OptionType.Debug) |
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
|
50 public static final OptionValue<Boolean> ImplicitStableValues = new OptionValue<>(true); |
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
|
51 //@formatter:on |
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
|
52 } |
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
|
53 |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
54 private final HotSpotResolvedObjectTypeImpl holder; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 private final String name; |
14047
fde464340755
don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14012
diff
changeset
|
56 private JavaType type; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 private final int offset; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
59 /** |
14012 | 60 * This value contains all flags as stored in the VM including internal ones. |
61 */ | |
62 private final int modifiers; | |
19852
3d0116ec99c5
Create utilities LocationIdentity#isAny, LocationIdentity#isSingle, LocationIdentity#any, LocationIdentity#overlaps.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19850
diff
changeset
|
63 private final LocationIdentity locationIdentity = new FieldLocationIdentity(this); |
19850
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
64 |
19852
3d0116ec99c5
Create utilities LocationIdentity#isAny, LocationIdentity#isSingle, LocationIdentity#any, LocationIdentity#overlaps.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19850
diff
changeset
|
65 public static class FieldLocationIdentity extends LocationIdentity { |
20103
7815c4d4a07f
removed/replaced references to non replay-serializable objects from replay-serializable objects
Doug Simon <doug.simon@oracle.com>
parents:
19917
diff
changeset
|
66 HotSpotResolvedJavaField inner; |
19850
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
67 |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
68 public FieldLocationIdentity(HotSpotResolvedJavaFieldImpl inner) { |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
69 this.inner = inner; |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
70 } |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
71 |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
72 @Override |
21390
f9024b74dd9e
Allow subclasses of LocationIdentity to provide immuatability information
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20878
diff
changeset
|
73 public boolean isImmutable() { |
f9024b74dd9e
Allow subclasses of LocationIdentity to provide immuatability information
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20878
diff
changeset
|
74 return false; |
f9024b74dd9e
Allow subclasses of LocationIdentity to provide immuatability information
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20878
diff
changeset
|
75 } |
f9024b74dd9e
Allow subclasses of LocationIdentity to provide immuatability information
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20878
diff
changeset
|
76 |
f9024b74dd9e
Allow subclasses of LocationIdentity to provide immuatability information
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20878
diff
changeset
|
77 @Override |
19850
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
78 public boolean equals(Object obj) { |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
79 if (this == obj) { |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
80 return true; |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
81 } |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
82 if (obj instanceof FieldLocationIdentity) { |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
83 FieldLocationIdentity fieldLocationIdentity = (FieldLocationIdentity) obj; |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
84 return inner.equals(fieldLocationIdentity.inner); |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
85 |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
86 } |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
87 return false; |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
88 } |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
89 |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
90 @Override |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
91 public int hashCode() { |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
92 return inner.hashCode(); |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
93 } |
19855
e532af44f9f9
Fix WriteBarrierAdditionTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19852
diff
changeset
|
94 |
e532af44f9f9
Fix WriteBarrierAdditionTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19852
diff
changeset
|
95 @Override |
e532af44f9f9
Fix WriteBarrierAdditionTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19852
diff
changeset
|
96 public String toString() { |
20103
7815c4d4a07f
removed/replaced references to non replay-serializable objects from replay-serializable objects
Doug Simon <doug.simon@oracle.com>
parents:
19917
diff
changeset
|
97 return inner.getName(); |
19855
e532af44f9f9
Fix WriteBarrierAdditionTest.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19852
diff
changeset
|
98 } |
19850
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
99 } |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
100 |
22598
ed53e370f04c
Make implementation classes package private.
Roland Schatz <roland.schatz@oracle.com>
parents:
22581
diff
changeset
|
101 HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 this.holder = holder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 this.name = name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 this.type = type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 assert offset != -1; |
13263 | 106 assert offset == (int) offset : "offset larger than int"; |
107 this.offset = (int) offset; | |
14012 | 108 this.modifiers = modifiers; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 @Override |
14158
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
112 public boolean equals(Object obj) { |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
113 if (this == obj) { |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
114 return true; |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
115 } |
14525
5e55de0379d9
fixed bug in HotSpotResolvedJavaField.equals
Doug Simon <doug.simon@oracle.com>
parents:
14158
diff
changeset
|
116 if (obj instanceof HotSpotResolvedJavaField) { |
18264
e28aa8468d5e
converted HotSpotResolvedJavaField to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
117 HotSpotResolvedJavaFieldImpl that = (HotSpotResolvedJavaFieldImpl) obj; |
19042
0d7302ddcc90
Bugfix: static and instance field with same offset are not equal
Christian Wimmer <christian.wimmer@oracle.com>
parents:
19005
diff
changeset
|
118 if (that.offset != this.offset || that.isStatic() != this.isStatic()) { |
19005
a64863622854
Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
119 return false; |
a64863622854
Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
120 } else if (this.holder.equals(that.holder)) { |
a64863622854
Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
121 assert this.name.equals(that.name) && this.type.equals(that.type); |
a64863622854
Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
122 return true; |
a64863622854
Shorter comparison of HotSpotResolvedFieldImpl instances.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18867
diff
changeset
|
123 } |
14158
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
124 } |
14525
5e55de0379d9
fixed bug in HotSpotResolvedJavaField.equals
Doug Simon <doug.simon@oracle.com>
parents:
14158
diff
changeset
|
125 return false; |
14158
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
126 } |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
127 |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
128 @Override |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
129 public int hashCode() { |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
130 return name.hashCode(); |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
131 } |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
132 |
fd7fcd2d2072
replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents:
14138
diff
changeset
|
133 @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:
6525
diff
changeset
|
134 public int getModifiers() { |
22011
4c9d4fe1cbd8
Add ModifiersProvider.isSynthetic, isVarArgs and isBridge.
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21798
diff
changeset
|
135 return modifiers & ModifiersProvider.jvmFieldModifiers(); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
139 public boolean isInternal() { |
22581
3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
140 return (modifiers & config().jvmAccFieldInternal) != 0; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
141 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
142 |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
143 /** |
12628
c36bdee8ca29
added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents:
12559
diff
changeset
|
144 * Determines if a given object contains this field. |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
145 * |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
146 * @return true iff this is a non-static field and its declaring class is assignable from |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
147 * {@code object}'s class |
12628
c36bdee8ca29
added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents:
12559
diff
changeset
|
148 */ |
c36bdee8ca29
added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents:
12559
diff
changeset
|
149 public boolean isInObject(Object object) { |
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:
15259
diff
changeset
|
150 if (isStatic()) { |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
151 return false; |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
152 } |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
153 return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectTypeImpl.fromObjectClass(object.getClass())); |
12628
c36bdee8ca29
added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents:
12559
diff
changeset
|
154 } |
c36bdee8ca29
added type check for object before reading a field value from it during compilation
Doug Simon <doug.simon@oracle.com>
parents:
12559
diff
changeset
|
155 |
5629
26a060cc58ca
Initial implementation of closed world analysis by iteratively expanding the universe starting at method entry points.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5554
diff
changeset
|
156 @Override |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18187
diff
changeset
|
157 public HotSpotResolvedObjectTypeImpl getDeclaringClass() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 return holder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 @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:
6525
diff
changeset
|
162 public String getName() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 return name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 @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:
6525
diff
changeset
|
167 public JavaType getType() { |
20878
673e0b242d4d
fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents:
20821
diff
changeset
|
168 // Pull field into local variable to prevent a race causing |
673e0b242d4d
fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents:
20821
diff
changeset
|
169 // a ClassCastException below |
673e0b242d4d
fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents:
20821
diff
changeset
|
170 JavaType currentType = type; |
673e0b242d4d
fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents:
20821
diff
changeset
|
171 if (currentType instanceof HotSpotUnresolvedJavaType) { |
14047
fde464340755
don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14012
diff
changeset
|
172 // Don't allow unresolved types to hang around forever |
20878
673e0b242d4d
fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents:
20821
diff
changeset
|
173 HotSpotUnresolvedJavaType unresolvedType = (HotSpotUnresolvedJavaType) currentType; |
673e0b242d4d
fixed race in HotSpotResolvedJavaFieldImpl.getType()
Doug Simon <doug.simon@oracle.com>
parents:
20821
diff
changeset
|
174 ResolvedJavaType resolved = unresolvedType.reresolve(holder); |
14047
fde464340755
don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14012
diff
changeset
|
175 if (resolved != null) { |
fde464340755
don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14012
diff
changeset
|
176 type = resolved; |
fde464340755
don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14012
diff
changeset
|
177 } |
fde464340755
don't allow unresolved field types to hang around
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14012
diff
changeset
|
178 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 return type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 public int offset() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 return offset; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 public String toString() { |
16481
e7fc65330742
moved format(String format, JavaField field) from MetaUtil to be a default method in JavaField
Doug Simon <doug.simon@oracle.com>
parents:
16383
diff
changeset
|
188 return format("HotSpotField<%H.%n %t:") + offset + ">"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 @Override |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
192 public boolean isSynthetic() { |
22581
3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
193 return (config().syntheticFlag & modifiers) != 0; |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
194 } |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
195 |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
196 /** |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
197 * Checks if this field has the {@link Stable} annotation. |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
198 * |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
199 * @return true if field has {@link Stable} annotation, false otherwise |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
200 */ |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
201 public boolean isStable() { |
22581
3884a98ebcde
consistently use HotSpotVMConfig.config() for static access to the HotSpotVMConfig instance
Doug Simon <doug.simon@oracle.com>
parents:
22569
diff
changeset
|
202 if ((config().jvmAccFieldStable & modifiers) != 0) { |
17334
0563b652c052
Unify parsing of graal and hotspot Stable annotations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16481
diff
changeset
|
203 return true; |
0563b652c052
Unify parsing of graal and hotspot Stable annotations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16481
diff
changeset
|
204 } |
0563b652c052
Unify parsing of graal and hotspot Stable annotations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16481
diff
changeset
|
205 assert getAnnotation(Stable.class) == null; |
22661
db43de18c170
Remove static imports to work around Eclipse bug
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22598
diff
changeset
|
206 if (Options.ImplicitStableValues.getValue() && isImplicitStableField()) { |
18507
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
207 return true; |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
208 } |
17334
0563b652c052
Unify parsing of graal and hotspot Stable annotations
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16481
diff
changeset
|
209 return false; |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
210 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
211 |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
212 @Override |
22432
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
213 public Annotation[] getAnnotations() { |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
214 Field javaField = toJava(); |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
215 if (javaField != null) { |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
216 return javaField.getAnnotations(); |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
217 } |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
218 return new Annotation[0]; |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
219 } |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
220 |
e4f0d819fe22
Add getAnnotations() method to ResolvedJavaType and ResolvedJavaField
Christian Wimmer <christian.wimmer@oracle.com>
parents:
22054
diff
changeset
|
221 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 Field javaField = toJava(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 if (javaField != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 return javaField.getAnnotation(annotationClass); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 |
20821
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
230 private Field toJavaCache; |
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
231 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 private Field toJava() { |
20821
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
233 if (toJavaCache != null) { |
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
234 return toJavaCache; |
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
235 } |
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
236 |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
237 if (isInternal()) { |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
238 return null; |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
239 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 try { |
20821
1bfa14fd1275
Cache the reflection Field in HotSpotResolvedFieldImpl, since it is accessed repeatedly when accessing the annotations of the field
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20103
diff
changeset
|
241 return toJavaCache = holder.mirror().getDeclaredField(name); |
19917
6575b4e3f629
Don't force resolution for unloaded field types
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19855
diff
changeset
|
242 } catch (NoSuchFieldException | NoClassDefFoundError e) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 } |
18507
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
246 |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
247 private boolean isArray() { |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
248 JavaType fieldType = getType(); |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
249 return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray(); |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
250 } |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
251 |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
252 private boolean isImplicitStableField() { |
22664
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
253 if (isSyntheticEnumSwitchMap()) { |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
254 return true; |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
255 } |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
256 if (isWellKnownImplicitStableField()) { |
18508
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
257 return true; |
18507
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
258 } |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
259 return false; |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
260 } |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
261 |
22664
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
262 public boolean isDefaultStable() { |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
263 assert this.isStable(); |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
264 if (isSyntheticEnumSwitchMap()) { |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
265 return true; |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
266 } |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
267 return false; |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
268 } |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
269 |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
270 private boolean isSyntheticEnumSwitchMap() { |
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
271 if (isSynthetic() && isStatic() && isArray()) { |
18507
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
272 if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) { |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
273 // generated int[] field for EnumClass::values() |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
274 return true; |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
275 } else if (name.startsWith("$SwitchMap$") || name.startsWith("$SWITCH_TABLE$")) { |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
276 // javac and ecj generate a static field in an inner class for a switch on an enum |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
277 // named $SwitchMap$p$k$g$EnumClass and $SWITCH_TABLE$p$k$g$EnumClass, respectively |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
278 return true; |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
279 } |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
280 } |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
281 return false; |
c2b45b536677
Constant fold elements of switch table and enum values() arrays
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
282 } |
18508
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
283 |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
284 private boolean isWellKnownImplicitStableField() { |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
285 return WellKnownImplicitStableField.test(this); |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
286 } |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
287 |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
288 static class WellKnownImplicitStableField { |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
289 /** |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
290 * @return {@code true} if the field is a well-known stable field. |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
291 */ |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
292 public static boolean test(HotSpotResolvedJavaField field) { |
18583
12bd2b344b08
replace usages of == with .equals()
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
293 return field.equals(STRING_VALUE_FIELD); |
18508
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
294 } |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
295 |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
296 private static final ResolvedJavaField STRING_VALUE_FIELD; |
22664
47f047ae2b4b
Make default values stable in enum switch maps
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
22661
diff
changeset
|
297 |
18508
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
298 static { |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
299 try { |
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
|
300 MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); |
18508
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
301 STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
302 } catch (SecurityException | NoSuchFieldException e) { |
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
|
303 throw new JVMCIError(e); |
18508
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
304 } |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
305 } |
f56a5c4cd859
Treat String.value as implicit stable field
Andreas Woess <andreas.woess@jku.at>
parents:
18507
diff
changeset
|
306 } |
19850
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
307 |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
308 public LocationIdentity getLocationIdentity() { |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
309 return locationIdentity; |
c2124d859d91
Remove LocationIdentity interface from ResolvedJavaField and add ResolvedJavaField#getLocationIdentity method instead.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19042
diff
changeset
|
310 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 } |