Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java @ 14012:1f34717ccafa
remove CompilerToVM.getInstanceFields
author | twisti |
---|---|
date | Mon, 24 Feb 2014 15:08:02 -0800 |
parents | 6dd8b95a7fbb |
children | fde464340755 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
23 package com.oracle.graal.hotspot.meta; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
8949
da5140eedfa1
made format of toString() consistent across HotSpot subclasses of JavaField and JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
8415
diff
changeset
|
25 import static com.oracle.graal.api.meta.MetaUtil.*; |
9289
261a43921c5e
rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents:
8960
diff
changeset
|
26 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
27 import static com.oracle.graal.hotspot.meta.HotSpotResolvedObjectType.*; |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
28 import static com.oracle.graal.phases.GraalOptions.*; |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
29 import static java.lang.reflect.Modifier.*; |
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 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 import java.lang.annotation.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import java.lang.reflect.*; |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
33 import java.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5503
diff
changeset
|
35 import com.oracle.graal.api.meta.*; |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
36 import com.oracle.graal.graph.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.hotspot.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
38 import com.oracle.graal.options.*; |
8415
2361bf148c06
rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents:
7709
diff
changeset
|
39 import com.oracle.graal.replacements.*; |
13619
5a076e52220a
update method signatures for makeGraph
Bernhard Urban <bernhard.urban@jku.at>
parents:
13607
diff
changeset
|
40 import com.oracle.graal.replacements.ReplacementsImpl.FrameStateProcessing; |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
41 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy; |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
42 import com.oracle.graal.replacements.SnippetTemplate.Arguments; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 * Represents a field in a HotSpot type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 */ |
13356
47d184ba15b6
HotSpotResolvedJavaField already implements LocationIdentity through ResolvedJavaField
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13263
diff
changeset
|
47 public class HotSpotResolvedJavaField extends CompilerObject implements ResolvedJavaField { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
49 private static final long serialVersionUID = 7692985878836955683L; |
7084
9ba90252ce08
HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7053
diff
changeset
|
50 private final HotSpotResolvedObjectType holder; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 private final String name; |
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
|
52 private final JavaType type; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 private final int offset; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
54 private Constant constant; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
56 /** |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
57 * The {@linkplain HotSpotResolvedObjectType#getReflectionFieldModifiers() reflection} modifiers |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
58 * for this field plus the {@link #FIELD_INTERNAL_FLAG} if it applies. |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
59 */ |
14012 | 60 /** |
61 * This value contains all flags as stored in the VM including internal ones. | |
62 */ | |
63 private final int modifiers; | |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
64 |
14012 | 65 public HotSpotResolvedJavaField(HotSpotResolvedObjectType 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
|
66 this.holder = holder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 this.name = name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 this.type = type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 assert offset != -1; |
13263 | 70 assert offset == (int) offset : "offset larger than int"; |
71 this.offset = (int) offset; | |
14012 | 72 this.modifiers = modifiers; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 @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
|
76 public int getModifiers() { |
14012 | 77 return modifiers & getReflectionFieldModifiers(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 @Override |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
81 public boolean isInternal() { |
14012 | 82 return (modifiers & runtime().getConfig().jvmAccFieldInternal) != 0; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
83 } |
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
84 |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
85 /** |
11389
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
86 * Compares two {@link StackTraceElement}s for equality, ignoring differences in |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
87 * {@linkplain StackTraceElement#getLineNumber() line number}. |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
88 */ |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
89 private static boolean equalsIgnoringLine(StackTraceElement left, StackTraceElement right) { |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
90 return left.getClassName().equals(right.getClassName()) && left.getMethodName().equals(right.getMethodName()) && left.getFileName().equals(right.getFileName()); |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
91 } |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
92 |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
93 /** |
10074
e8fbc5fd3440
aot: add/fix some javadoc
Bernhard Urban <bernhard.urban@jku.at>
parents:
10073
diff
changeset
|
94 * If the compiler is configured for AOT mode, {@link #readConstantValue(Constant)} should be |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
95 * only called for snippets or replacements. |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
96 */ |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
97 private static boolean isCalledForSnippets() { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
98 MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
99 ResolvedJavaMethod makeGraphMethod = null; |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
100 ResolvedJavaMethod initMethod = null; |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
101 try { |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
102 Class<?> rjm = ResolvedJavaMethod.class; |
13619
5a076e52220a
update method signatures for makeGraph
Bernhard Urban <bernhard.urban@jku.at>
parents:
13607
diff
changeset
|
103 makeGraphMethod = metaAccess.lookupJavaMethod(ReplacementsImpl.class.getDeclaredMethod("makeGraph", rjm, rjm, rjm, SnippetInliningPolicy.class, FrameStateProcessing.class)); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
11877
diff
changeset
|
104 initMethod = metaAccess.lookupJavaMethod(SnippetTemplate.AbstractTemplates.class.getDeclaredMethod("template", Arguments.class)); |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
105 } catch (NoSuchMethodException | SecurityException e) { |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
106 throw new GraalInternalError(e); |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
107 } |
11389
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
108 StackTraceElement makeGraphSTE = makeGraphMethod.asStackTraceElement(0); |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
109 StackTraceElement initSTE = initMethod.asStackTraceElement(0); |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
110 |
11389
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
111 StackTraceElement[] stackTrace = new Exception().getStackTrace(); |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
112 for (StackTraceElement element : stackTrace) { |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
113 // Ignoring line numbers should not weaken this check too much while at |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
114 // the same time making it more robust against source code changes |
7040c65689c5
slightly weakened check in HotSpotResolvedJavaField.readConstantField()
Doug Simon <doug.simon@oracle.com>
parents:
10863
diff
changeset
|
115 if (equalsIgnoringLine(makeGraphSTE, element) || equalsIgnoringLine(initSTE, element)) { |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
116 return true; |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
117 } |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
118 } |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
119 return false; |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
120 } |
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
121 |
13367
413040ab993e
remove some usages of HashSet
Bernhard Urban <bernhard.urban@jku.at>
parents:
13356
diff
changeset
|
122 private static final List<ResolvedJavaField> notEmbeddable = new ArrayList<>(); |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
123 |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
124 private static void addResolvedToSet(Field field) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
125 MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
11877
diff
changeset
|
126 notEmbeddable.add(metaAccess.lookupJavaField(field)); |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
127 } |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
128 |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
129 static { |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
130 try { |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
131 addResolvedToSet(Boolean.class.getDeclaredField("TRUE")); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
132 addResolvedToSet(Boolean.class.getDeclaredField("FALSE")); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
133 |
10073
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
134 Class<?> characterCacheClass = Character.class.getDeclaredClasses()[0]; |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
135 assert "java.lang.Character$CharacterCache".equals(characterCacheClass.getName()); |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
136 addResolvedToSet(characterCacheClass.getDeclaredField("cache")); |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
137 |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
138 Class<?> byteCacheClass = Byte.class.getDeclaredClasses()[0]; |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
139 assert "java.lang.Byte$ByteCache".equals(byteCacheClass.getName()); |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
140 addResolvedToSet(byteCacheClass.getDeclaredField("cache")); |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
141 |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
142 Class<?> shortCacheClass = Short.class.getDeclaredClasses()[0]; |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
143 assert "java.lang.Short$ShortCache".equals(shortCacheClass.getName()); |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
144 addResolvedToSet(shortCacheClass.getDeclaredField("cache")); |
1397c3e1f642
HotSpotResolvedJavaField: add cache of java.lang.{Character,Byte,Short} to not embeddable list (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10066
diff
changeset
|
145 |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
146 Class<?> integerCacheClass = Integer.class.getDeclaredClasses()[0]; |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
147 assert "java.lang.Integer$IntegerCache".equals(integerCacheClass.getName()); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
148 addResolvedToSet(integerCacheClass.getDeclaredField("cache")); |
10062
56fc40ca4ae0
HotSpotResolvedJavaField: don't embed caches of java.lang.{Integer,Long,Boolean} for replacements when compiled in AOT mode (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
9984
diff
changeset
|
149 |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
150 Class<?> longCacheClass = Long.class.getDeclaredClasses()[0]; |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
151 assert "java.lang.Long$LongCache".equals(longCacheClass.getName()); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
152 addResolvedToSet(longCacheClass.getDeclaredField("cache")); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
153 |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
154 addResolvedToSet(Throwable.class.getDeclaredField("UNASSIGNED_STACK")); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
155 addResolvedToSet(Throwable.class.getDeclaredField("SUPPRESSED_SENTINEL")); |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
156 } catch (SecurityException | NoSuchFieldException e) { |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
157 throw new GraalInternalError(e); |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
158 } |
10062
56fc40ca4ae0
HotSpotResolvedJavaField: don't embed caches of java.lang.{Integer,Long,Boolean} for replacements when compiled in AOT mode (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
9984
diff
changeset
|
159 } |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
160 |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
161 /** |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
162 * in AOT mode, some fields should never be embedded even for snippets/replacements. |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
163 */ |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
164 private boolean isEmbeddable() { |
13378
16d99e9d77ad
Options: rename flag (AOTCompilation -> ImmutableCode)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13367
diff
changeset
|
165 if (ImmutableCode.getValue() && notEmbeddable.contains(this)) { |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
166 return false; |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
167 } |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
168 return true; |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
169 } |
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
170 |
11553
8a2664ad5c55
replaced computed internal name for java.lang.System with a constant to workaround deadlock issue involving class initializer of HotSpotResolvedJavaField (CR-1405)
Doug Simon <doug.simon@oracle.com>
parents:
11389
diff
changeset
|
171 private static final String SystemClassName = "Ljava/lang/System;"; |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
172 |
11824
e1a1264cb0a7
improved javadoc for ResolvedJavaField.readConstantValue and .readValue
Doug Simon <doug.simon@oracle.com>
parents:
11553
diff
changeset
|
173 /** |
e1a1264cb0a7
improved javadoc for ResolvedJavaField.readConstantValue and .readValue
Doug Simon <doug.simon@oracle.com>
parents:
11553
diff
changeset
|
174 * {@inheritDoc} |
e1a1264cb0a7
improved javadoc for ResolvedJavaField.readConstantValue and .readValue
Doug Simon <doug.simon@oracle.com>
parents:
11553
diff
changeset
|
175 * <p> |
e1a1264cb0a7
improved javadoc for ResolvedJavaField.readConstantValue and .readValue
Doug Simon <doug.simon@oracle.com>
parents:
11553
diff
changeset
|
176 * The {@code value} field in {@link OptionValue} is considered constant if the type of |
e1a1264cb0a7
improved javadoc for ResolvedJavaField.readConstantValue and .readValue
Doug Simon <doug.simon@oracle.com>
parents:
11553
diff
changeset
|
177 * {@code receiver} is (assignable to) {@link StableOptionValue}. |
e1a1264cb0a7
improved javadoc for ResolvedJavaField.readConstantValue and .readValue
Doug Simon <doug.simon@oracle.com>
parents:
11553
diff
changeset
|
178 */ |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
179 @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
|
180 public Constant readConstantValue(Constant receiver) { |
13378
16d99e9d77ad
Options: rename flag (AOTCompilation -> ImmutableCode)
Bernhard Urban <bernhard.urban@jku.at>
parents:
13367
diff
changeset
|
181 assert !ImmutableCode.getValue() || isCalledForSnippets() : receiver; |
10065
5ba3763d6986
HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10063
diff
changeset
|
182 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 if (receiver == null) { |
14012 | 184 assert isStatic(modifiers); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 if (constant == null) { |
10066
295ef03139f4
HotSpotResolvedJavaField: be more precise about fields that are not embeddable (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10065
diff
changeset
|
186 if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && isEmbeddable()) { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
187 if (Modifier.isFinal(getModifiers())) { |
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
|
188 constant = readValue(receiver); |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 return constant; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 } else { |
7689
ed51e7237e94
extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
194 /* |
ed51e7237e94
extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
195 * for non-static final fields, we must assume that they are only initialized if they |
ed51e7237e94
extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
196 * have a non-default value. |
ed51e7237e94
extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
197 */ |
14012 | 198 assert !isStatic(modifiers); |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
199 Object object = receiver.asObject(); |
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
|
200 |
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
|
201 // Canonicalization may attempt to process an unsafe read before |
13788
6c5c17d0f57d
guard again null receiver object when reading a constant field
Doug Simon <doug.simon@oracle.com>
parents:
13619
diff
changeset
|
202 // processing a guard (e.g. a null check or a type check) for this read |
6c5c17d0f57d
guard again null receiver object when reading a constant field
Doug Simon <doug.simon@oracle.com>
parents:
13619
diff
changeset
|
203 // so we need to check the object being read |
6c5c17d0f57d
guard again null receiver object when reading a constant field
Doug Simon <doug.simon@oracle.com>
parents:
13619
diff
changeset
|
204 if (object != null && isInObject(object)) { |
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
|
205 if (Modifier.isFinal(getModifiers())) { |
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
|
206 Constant value = readValue(receiver); |
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
|
207 if (assumeNonStaticFinalFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) { |
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
|
208 return value; |
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
|
209 } |
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
|
210 } else if (isStable()) { |
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
|
211 Constant value = readValue(receiver); |
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
|
212 if (assumeDefaultStableFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) { |
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
|
213 return value; |
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
|
214 } |
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
|
215 } else { |
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
|
216 Class<?> clazz = object.getClass(); |
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
|
217 if (StableOptionValue.class.isAssignableFrom(clazz)) { |
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
|
218 assert getName().equals("value") : "Unexpected field in " + StableOptionValue.class.getName() + " hierarchy:" + this; |
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
|
219 StableOptionValue<?> option = (StableOptionValue<?>) object; |
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
|
220 return Constant.forObject(option.getValue()); |
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
|
221 } |
9912
fbad7372eccd
added support for stable options
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
222 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 return null; |
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 |
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
|
228 /** |
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
|
229 * Determines if a given object contains this field. |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
230 * |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
231 * @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
|
232 * {@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
|
233 */ |
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
|
234 public boolean isInObject(Object object) { |
14012 | 235 if (isStatic(modifiers)) { |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
236 return false; |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
237 } |
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
|
238 return getDeclaringClass().isAssignableFrom(HotSpotResolvedObjectType.fromClass(object.getClass())); |
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
|
239 } |
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
|
240 |
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
|
241 @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
|
242 public Constant readValue(Constant receiver) { |
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
|
243 if (receiver == null) { |
14012 | 244 assert isStatic(modifiers); |
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
|
245 if (holder.isInitialized()) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
246 return runtime().getHostProviders().getConstantReflection().readUnsafeConstant(getKind(), holder.mirror(), offset, getKind() == Kind.Object); |
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
|
247 } |
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
|
248 return null; |
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
|
249 } else { |
14012 | 250 assert !isStatic(modifiers); |
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
|
251 Object object = receiver.asObject(); |
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
|
252 assert object != null && isInObject(object); |
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
|
253 return runtime().getHostProviders().getConstantReflection().readUnsafeConstant(getKind(), object, offset, getKind() == Kind.Object); |
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
|
254 } |
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
|
255 } |
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
|
256 |
7691
014092acf009
fixed bootstrap performance issue that occurred because non-static final fields are no longer assumed constant
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7689
diff
changeset
|
257 private static boolean assumeNonStaticFinalFieldsAsFinal(Class<?> clazz) { |
014092acf009
fixed bootstrap performance issue that occurred because non-static final fields are no longer assumed constant
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7689
diff
changeset
|
258 return clazz == SnippetCounter.class; |
014092acf009
fixed bootstrap performance issue that occurred because non-static final fields are no longer assumed constant
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7689
diff
changeset
|
259 } |
014092acf009
fixed bootstrap performance issue that occurred because non-static final fields are no longer assumed constant
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7689
diff
changeset
|
260 |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
261 /** |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
262 * Usually {@link Stable} fields are not considered constant if the value is the |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
263 * {@link Constant#isDefaultForKind default value}. For some special classes we want to override |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
264 * this behavior. |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
265 */ |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
266 private static boolean assumeDefaultStableFieldsAsFinal(Class<?> clazz) { |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
267 // HotSpotVMConfig has a lot of zero-value fields which we know are stable and want to be |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
268 // considered as constants. |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
269 if (clazz == HotSpotVMConfig.class) { |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
270 return true; |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
271 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
272 return false; |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
273 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
274 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 @Override |
7104
5c25483b5515
Remove the ResolvedJavaType.Representation for static fields. It is not necessary to emit the constant holder for static fields in the GraphBuilder. Only the VM-specific lowering needs to create the constants, and it can access the VM-specific metadata objects directly.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7099
diff
changeset
|
276 public HotSpotResolvedObjectType getDeclaringClass() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 return holder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 @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
|
281 public Kind getKind() { |
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
|
282 return getType().getKind(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 @Override |
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
|
286 public String getName() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 return name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 @Override |
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
|
291 public JavaType getType() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 return type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 public int offset() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 return offset; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 public String toString() { |
8949
da5140eedfa1
made format of toString() consistent across HotSpot subclasses of JavaField and JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
8415
diff
changeset
|
301 return format("HotSpotField<%H.%n %t:", this) + offset + ">"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 @Override |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
305 public boolean isSynthetic() { |
14012 | 306 return (runtime().getConfig().syntheticFlag & modifiers) != 0; |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
307 } |
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
308 |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
309 /** |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
310 * Checks if this field has the {@link Stable} annotation. |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
311 * |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
312 * @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
|
313 */ |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
314 public boolean isStable() { |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
315 Annotation annotation = getAnnotation(Stable.class); |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
316 return annotation != null; |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
317 } |
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
318 |
9984
f3330a4487eb
added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents:
9914
diff
changeset
|
319 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 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
|
321 Field javaField = toJava(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 if (javaField != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 return javaField.getAnnotation(annotationClass); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 } |
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 private Field toJava() { |
13823
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
329 if (isInternal()) { |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
330 return null; |
6dd8b95a7fbb
fixed HotSpotResolvedJavaField.getModifiers() to mask out FIELD_INTERNAL_FLAG
Doug Simon <doug.simon@oracle.com>
parents:
13818
diff
changeset
|
331 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 try { |
7053
014727292ae0
removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents:
6950
diff
changeset
|
333 return holder.mirror().getDeclaredField(name); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 } catch (NoSuchFieldException e) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 } |