annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java @ 10065:5ba3763d6986

HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
author Bernhard Urban <bernhard.urban@jku.at>
date Sun, 16 Jun 2013 23:55:22 +0200
parents 9e688291fc53
children 295ef03139f4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23
5548
8872bc0eebdf Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
24 package com.oracle.graal.hotspot.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25
8949
da5140eedfa1 made format of toString() consistent across HotSpot subclasses of JavaField and JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 8415
diff changeset
26 import static com.oracle.graal.api.meta.MetaUtil.*;
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 8960
diff changeset
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
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.*;
8949
da5140eedfa1 made format of toString() consistent across HotSpot subclasses of JavaField and JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 8415
diff changeset
29
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.lang.annotation.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import java.lang.reflect.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5503
diff changeset
33 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
34 import com.oracle.graal.graph.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 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
36 import com.oracle.graal.options.*;
8415
2361bf148c06 rename packages: *snippets* -> *replacements*
Doug Simon <doug.simon@oracle.com>
parents: 7709
diff changeset
37 import com.oracle.graal.replacements.*;
10065
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
38 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
39 import com.oracle.graal.replacements.SnippetTemplate.Arguments;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
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 * Represents a field in a HotSpot type.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 */
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9289
diff changeset
44 public class HotSpotResolvedJavaField extends CompilerObject implements ResolvedJavaField, LocationIdentity {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7104
diff changeset
46 // Must not conflict with any fields flags used by the VM - the assertion in the constructor
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7104
diff changeset
47 // checks this assumption
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
48 private static final int FIELD_INTERNAL_FLAG = 0x80000000;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
49
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
50 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
51 private final HotSpotResolvedObjectType holder;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 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
53 private final JavaType type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 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
55 private final int flags;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
56 private Constant constant;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7053
diff changeset
58 public HotSpotResolvedJavaField(HotSpotResolvedObjectType holder, String name, JavaType type, int offset, int flags, boolean internal) {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
59 assert (flags & FIELD_INTERNAL_FLAG) == 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 this.holder = holder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 this.name = name;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 this.type = type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 assert offset != -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 this.offset = offset;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
65 if (internal) {
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
66 this.flags = flags | FIELD_INTERNAL_FLAG;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
67 } else {
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
68 this.flags = flags;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
69 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 @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
73 public int getModifiers() {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
74 return flags & Modifier.fieldModifiers();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 @Override
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
78 public boolean isInternal() {
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
79 return (flags & FIELD_INTERNAL_FLAG) != 0;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
80 }
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
81
10065
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
82 /**
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
83 * if the compiler is configured for AOT mode, {@link #readConstantValue(Constant)} should be
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
84 * 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
85 */
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
86 private static boolean isCalledForSnippets() {
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
87 HotSpotRuntime runtime = graalRuntime().getRuntime();
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
88
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
89 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
90 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
91 try {
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
92 Class<?> rjm = ResolvedJavaMethod.class;
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
93 makeGraphMethod = runtime.lookupJavaMethod(ReplacementsImpl.class.getDeclaredMethod("makeGraph", rjm, rjm, SnippetInliningPolicy.class));
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
94 initMethod = runtime.lookupJavaMethod(SnippetTemplate.AbstractTemplates.class.getDeclaredMethod("template", Arguments.class));
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
95 } 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
96 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
97 }
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
98 StackTraceElement makeGraphSTE = makeGraphMethod.asStackTraceElement(1);
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
99 StackTraceElement initSTE = initMethod.asStackTraceElement(30);
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
100
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
101 for (StackTraceElement element : new Exception().getStackTrace()) {
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
102 if (makeGraphSTE.equals(element) || initSTE.equals(element)) {
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
103 return true;
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
104 }
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
105 }
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
106 return false;
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
107 }
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
108
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
109 private static final String SystemClassName = MetaUtil.toInternalName(System.class.getName());
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
110 private static final String IntegerCacheClassName = "Ljava/lang/Integer$IntegerCache;";
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
111 private static final String LongCacheClassName = "Ljava/lang/Long$LongCache;";
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
112 private static final String BooleanCacheName = MetaUtil.toInternalName(Boolean.class.getName());
10063
9e688291fc53 HotSpotResolvedJavaField: don't embed object for empty stack trace for replacements when compiled in AOT mode (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10062
diff changeset
113 private static final String ThrowableClassName = MetaUtil.toInternalName(Throwable.class.getName());
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
114
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
115 private boolean isConstantCache() {
10065
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
116 if (AOTCompilation.getValue()) {
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
117 String n = holder.getName();
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
118 return n.equals(IntegerCacheClassName) || n.equals(LongCacheClassName) || n.equals(BooleanCacheName) || n.equals(ThrowableClassName);
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
119 }
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
120 return false;
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
121 }
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
122
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
123 @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
124 public Constant readConstantValue(Constant receiver) {
10065
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
125 assert !AOTCompilation.getValue() || isCalledForSnippets();
5ba3763d6986 HotSpotResolvedJavaField: check if method is called from snippet/replacements (GRAAL-290)
Bernhard Urban <bernhard.urban@jku.at>
parents: 10063
diff changeset
126
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 if (receiver == null) {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
128 assert Modifier.isStatic(flags);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 if (constant == null) {
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
130 if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && !isConstantCache()) {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9792
diff changeset
131 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
132 constant = readValue(receiver);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 return constant;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 } else {
7689
ed51e7237e94 extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7530
diff changeset
138 /*
ed51e7237e94 extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7530
diff changeset
139 * 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
140 * have a non-default value.
ed51e7237e94 extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7530
diff changeset
141 */
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
142 assert !Modifier.isStatic(flags);
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
143 Object object = receiver.asObject();
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
144 if (Modifier.isFinal(getModifiers())) {
7689
ed51e7237e94 extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7530
diff changeset
145 Constant value = readValue(receiver);
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
146 if (assumeNonStaticFinalFieldsAsFinal(object.getClass()) || !value.isDefaultForKind()) {
7689
ed51e7237e94 extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7530
diff changeset
147 return value;
ed51e7237e94 extracted TODOs as issues
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7530
diff changeset
148 }
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
149 } else {
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
150 Class<?> clazz = object.getClass();
9914
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
151 if (StableOptionValue.class.isAssignableFrom(clazz)) {
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
152 StableOptionValue<?> option = (StableOptionValue<?>) object;
84890660eefb cleaner implementation of stable options
Doug Simon <doug.simon@oracle.com>
parents: 9912
diff changeset
153 return Constant.forObject(option.getValue());
9912
fbad7372eccd added support for stable options
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
154 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159
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
160 @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
161 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
162 if (receiver == null) {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
163 assert Modifier.isStatic(flags);
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
164 if (holder.isInitialized()) {
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 8960
diff changeset
165 return graalRuntime().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset);
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
166 }
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
167 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
168 } else {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
169 assert !Modifier.isStatic(flags);
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 8960
diff changeset
170 return graalRuntime().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset);
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
171 }
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
172 }
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
173
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
174 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
175 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
176 }
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
177
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 @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
179 public HotSpotResolvedObjectType getDeclaringClass() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 return holder;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 @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
184 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
185 return getType().getKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 @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
189 public String getName() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 return name;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 @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
194 public JavaType getType() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 return type;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 public int offset() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 return offset;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 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
204 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
205 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 @Override
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
208 public boolean isSynthetic() {
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
209 Field javaField = toJava();
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
210 if (javaField != null) {
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
211 return javaField.isSynthetic();
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
212 }
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
213 return false;
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
214 }
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
215
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9914
diff changeset
216 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 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
218 Field javaField = toJava();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 if (javaField != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 return javaField.getAnnotation(annotationClass);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 return null;
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 private Field toJava() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 try {
7053
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
227 return holder.mirror().getDeclaredField(name);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 } catch (NoSuchFieldException e) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 }