annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNodePlugin.java @ 21683:c74d3c9b9de7

Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
author Christian Wimmer <christian.wimmer@oracle.com>
date Tue, 02 Jun 2015 18:25:16 -0700
parents 625b2b12b418
children 67e28e817d32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.meta;
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.compiler.common.GraalOptions.*;
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
26 import static com.oracle.graal.hotspot.meta.HotSpotGraalConstantReflectionProvider.*;
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
28 import com.oracle.graal.api.replacements.*;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
29 import com.oracle.graal.compiler.common.type.*;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
30 import com.oracle.graal.graph.Node.*;
19883
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
31 import com.oracle.graal.graphbuilderconf.*;
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.nodes.*;
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
33 import com.oracle.graal.nodes.calc.*;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
34 import com.oracle.graal.replacements.*;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
35 import com.oracle.graal.word.*;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
36 import com.oracle.jvmci.meta.*;
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
38 /**
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
39 * This plugin handles the HotSpot-specific customizations of bytecode parsing:
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
40 * <p>
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
41 * {@link Word}-type rewriting for {@link GraphBuilderContext#parsingIntrinsic intrinsic} functions
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
42 * (snippets and method substitutions), by forwarding to the {@link WordOperationPlugin}. Note that
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
43 * we forward the {@link NodePlugin} and {@link ParameterPlugin} methods, but not the
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
44 * {@link InlineInvokePlugin} methods implemented by {@link WordOperationPlugin}. The latter is not
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
45 * necessary because HotSpot only uses the {@link Word} type in methods that are force-inlined,
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
46 * i.e., there are never non-inlined invokes that involve the {@link Word} type.
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
47 * <p>
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
48 * Handling of {@link Fold} and {@link NodeIntrinsic} annotated methods, by forwarding to the
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
49 * {@link NodeIntrinsificationPlugin} when parsing intrinsic functions.
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
50 * <p>
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
51 * Constant folding of field loads.
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
52 */
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
53 public final class HotSpotNodePlugin implements NodePlugin, ParameterPlugin {
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 private final MetaAccessProvider metaAccess;
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 private final ConstantReflectionProvider constantReflection;
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
57 protected final WordOperationPlugin wordOperationPlugin;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
58 protected final NodeIntrinsificationPlugin nodeIntrinsificationPlugin;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
59
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
60 public HotSpotNodePlugin(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, WordOperationPlugin wordOperationPlugin,
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
61 NodeIntrinsificationPlugin nodeIntrinsificationPlugin) {
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 this.metaAccess = metaAccess;
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 this.constantReflection = constantReflection;
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
64 this.wordOperationPlugin = wordOperationPlugin;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
65 this.nodeIntrinsificationPlugin = nodeIntrinsificationPlugin;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
66 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
67
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
68 @Override
21683
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
69 public boolean canChangeStackKind(GraphBuilderContext b) {
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
70 if (b.parsingIntrinsic()) {
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
71 return wordOperationPlugin.canChangeStackKind(b) || nodeIntrinsificationPlugin.canChangeStackKind(b);
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
72 }
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
73 return false;
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
74 }
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
75
c74d3c9b9de7 Use a marker value in second slot of a two-slot value during parsing; improve assertion checking in FrameStateBuilder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21606
diff changeset
76 @Override
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
77 public FloatingNode interceptParameter(GraphBuilderContext b, int index, Stamp stamp) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
78 if (b.parsingIntrinsic()) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
79 return wordOperationPlugin.interceptParameter(b, index, stamp);
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
80 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
81 return null;
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 }
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
84 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
85 public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
86 if (b.parsingIntrinsic() && wordOperationPlugin.handleInvoke(b, method, args)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
87 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
88 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
89 if (b.parsingIntrinsic() && nodeIntrinsificationPlugin.handleInvoke(b, method, args)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
90 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
91 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
92 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
93 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
94
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
95 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
96 public boolean handleLoadField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 20073
diff changeset
97 if (!ImmutableCode.getValue() || b.parsingIntrinsic()) {
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
98 if (object.isConstant()) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
99 JavaConstant asJavaConstant = object.asJavaConstant();
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
100 if (tryReadField(b, field, asJavaConstant)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
101 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
102 }
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 }
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 }
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
105 if (b.parsingIntrinsic() && wordOperationPlugin.handleLoadField(b, object, field)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
106 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
107 }
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 return false;
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 }
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
110
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
111 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
112 public boolean handleLoadStaticField(GraphBuilderContext b, ResolvedJavaField field) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
113 if (!ImmutableCode.getValue() || b.parsingIntrinsic()) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
114 if (tryReadField(b, field, null)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
115 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
116 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
117 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
118 if (b.parsingIntrinsic() && wordOperationPlugin.handleLoadStaticField(b, field)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
119 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
120 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
121 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
122 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
123
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
124 private boolean tryReadField(GraphBuilderContext b, ResolvedJavaField field, JavaConstant object) {
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
125 // FieldReadEnabledInImmutableCode is non null only if assertions are enabled
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
126 if (FieldReadEnabledInImmutableCode != null && ImmutableCode.getValue()) {
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
127 FieldReadEnabledInImmutableCode.set(Boolean.TRUE);
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
128 try {
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
129 return tryConstantFold(b, field, object);
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
130 } finally {
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
131 FieldReadEnabledInImmutableCode.set(null);
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
132 }
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21529
diff changeset
133 } else {
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
134 return tryConstantFold(b, field, object);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19778
diff changeset
135 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19778
diff changeset
136 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19778
diff changeset
137
21606
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
138 private boolean tryConstantFold(GraphBuilderContext b, ResolvedJavaField field, JavaConstant object) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
139 JavaConstant result = constantReflection.readConstantFieldValue(field, object);
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
140 if (result != null) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
141 ConstantNode constantNode = ConstantNode.forConstant(result, metaAccess, b.getGraph());
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
142 b.push(field.getKind(), constantNode);
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
143 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
144 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
145 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
146 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
147
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
148 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
149 public boolean handleStoreField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field, ValueNode value) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
150 if (b.parsingIntrinsic() && wordOperationPlugin.handleStoreField(b, object, field, value)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
151 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
152 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
153 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
154 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
155
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
156 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
157 public boolean handleStoreStaticField(GraphBuilderContext b, ResolvedJavaField field, ValueNode value) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
158 if (b.parsingIntrinsic() && wordOperationPlugin.handleStoreStaticField(b, field, value)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
159 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
160 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
161 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
162 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
163
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
164 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
165 public boolean handleLoadIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, Kind elementKind) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
166 if (b.parsingIntrinsic() && wordOperationPlugin.handleLoadIndexed(b, array, index, elementKind)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
167 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
168 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
169 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
170 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
171
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
172 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
173 public boolean handleStoreIndexed(GraphBuilderContext b, ValueNode array, ValueNode index, Kind elementKind, ValueNode value) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
174 if (b.parsingIntrinsic() && wordOperationPlugin.handleStoreIndexed(b, array, index, elementKind, value)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
175 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
176 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
177 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
178 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
179
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
180 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
181 public boolean handleCheckCast(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
182 if (b.parsingIntrinsic() && wordOperationPlugin.handleCheckCast(b, object, type, profile)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
183 return true;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
184 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
185 return false;
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
186 }
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
187
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
188 @Override
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
189 public boolean handleInstanceOf(GraphBuilderContext b, ValueNode object, ResolvedJavaType type, JavaTypeProfile profile) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
190 if (b.parsingIntrinsic() && wordOperationPlugin.handleInstanceOf(b, object, type, profile)) {
625b2b12b418 Cleanup and generalize graph builder plugins
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21556
diff changeset
191 return true;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19778
diff changeset
192 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19778
diff changeset
193 return false;
19778
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
194 }
09dfba3dbfb2 refactored HotSpot graph builder plugins into top level classes
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 }