annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java @ 19378:1a9d5e9ab0f4

Fix "materialize" Truffle graph builder plugins.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 15 Feb 2015 14:28:01 +0100
parents 595ee09dfda6
children 669f746ad3b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.truffle.substitutions;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
25 import static java.lang.Character.*;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
26
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 import java.util.concurrent.*;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.code.*;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.meta.*;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
31 import com.oracle.graal.compiler.common.*;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
32 import com.oracle.graal.compiler.common.calc.*;
19148
276bc2752feb Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
33 import com.oracle.graal.compiler.common.type.*;
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.java.*;
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
35 import com.oracle.graal.java.GraphBuilderPlugins.InvocationPlugin;
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
36 import com.oracle.graal.java.GraphBuilderPlugins.Registration;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
37 import com.oracle.graal.java.GraphBuilderPlugins.Registration.Receiver;
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.nodes.*;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
39 import com.oracle.graal.nodes.calc.*;
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.nodes.extended.*;
19148
276bc2752feb Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
41 import com.oracle.graal.truffle.*;
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
42 import com.oracle.graal.truffle.nodes.*;
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
43 import com.oracle.graal.truffle.nodes.arithmetic.*;
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.truffle.nodes.frame.*;
19309
c386ace07981 Truffle: move unsafe access methods out of CompilerDirectives
Andreas Woess <andreas.woess@oracle.com>
parents: 19308
diff changeset
45 import com.oracle.graal.truffle.unsafe.*;
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 import com.oracle.truffle.api.*;
19148
276bc2752feb Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
47 import com.oracle.truffle.api.frame.*;
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 /**
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 * Provider of {@link GraphBuilderPlugin}s for Truffle classes.
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 */
19180
e99be967a753 renamed TruffleGraphBuilderPluginsProvider to TruffleGraphBuilderPlugins to reflect the fact that it is no longer a service provider
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
52 public class TruffleGraphBuilderPlugins {
e99be967a753 renamed TruffleGraphBuilderPluginsProvider to TruffleGraphBuilderPlugins to reflect the fact that it is no longer a service provider
Doug Simon <doug.simon@oracle.com>
parents: 19178
diff changeset
53 public static void registerPlugins(MetaAccessProvider metaAccess, GraphBuilderPlugins plugins) {
19148
276bc2752feb Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19104
diff changeset
54
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
55 // OptimizedAssumption.class
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
56 Registration r = new Registration(plugins, metaAccess, OptimizedAssumption.class);
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
57 r.register1("isValid", Receiver.class, new InvocationPlugin() {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
58 public boolean apply(GraphBuilderContext builder, ValueNode arg) {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
59 if (arg.isConstant()) {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
60 Constant constant = arg.asConstant();
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
61 OptimizedAssumption assumption = builder.getSnippetReflection().asObject(OptimizedAssumption.class, (JavaConstant) constant);
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
62 builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(assumption.isValid())));
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
63 builder.getAssumptions().record(new AssumptionValidAssumption(assumption));
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
64 } else {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
65 throw new BailoutException("assumption could not be reduced to a constant");
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
66 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
67 return true;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
68 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
69 });
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
70
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
71 // ExactMath.class
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
72 r = new Registration(plugins, metaAccess, ExactMath.class);
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
73 r.register2("addExact", Integer.TYPE, Integer.TYPE, new InvocationPlugin() {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
74 public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
75 builder.push(Kind.Int.getStackKind(), builder.append(new IntegerAddExactNode(x, y)));
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
76 return true;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
77 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
78 });
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
79
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
80 // CompilerDirectives.class
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
81 r = new Registration(plugins, metaAccess, CompilerDirectives.class);
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
82 r.register0("inInterpreter", new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
83 public boolean apply(GraphBuilderContext builder) {
19177
1a7b33c96c0d Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19148
diff changeset
84 builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(false)));
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
87 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
88 r.register0("inCompiledCode", new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
89 public boolean apply(GraphBuilderContext builder) {
19177
1a7b33c96c0d Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19148
diff changeset
90 builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(true)));
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
91 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
92 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
93 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
94 r.register0("transferToInterpreter", new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
95 public boolean apply(GraphBuilderContext builder) {
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96 builder.append(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter));
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
97 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
98 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
99 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
100 r.register0("transferToInterpreterAndInvalidate", new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
101 public boolean apply(GraphBuilderContext builder) {
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 builder.append(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TransferToInterpreter));
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
105 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
106 r.register1("interpreterOnly", Runnable.class, new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
107 public boolean apply(GraphBuilderContext builder, ValueNode arg) {
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
109 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
110 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
111 r.register1("interpreterOnly", Callable.class, new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
112 public boolean apply(GraphBuilderContext builder, ValueNode arg) {
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
114 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
115 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
116 r.register2("injectBranchProbability", double.class, boolean.class, new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
117 public boolean apply(GraphBuilderContext builder, ValueNode probability, ValueNode condition) {
19239
637ca4d37bca Extensions and fixes to inline and canonicalize during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19177
diff changeset
118 builder.push(Kind.Boolean.getStackKind(), builder.append(new BranchProbabilityNode(probability, condition)));
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
120 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
121 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
122 r.register1("bailout", String.class, new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
123 public boolean apply(GraphBuilderContext builder, ValueNode message) {
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 if (message.isConstant()) {
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 throw new BailoutException(message.asConstant().toValueString());
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 }
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 throw new BailoutException("bailout (message is not compile-time constant, so no additional information is available)");
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
129 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
130 r.register1("isCompilationConstant", Object.class, new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
131 public boolean apply(GraphBuilderContext builder, ValueNode value) {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
132 if ((value instanceof BoxNode ? ((BoxNode) value).getValue() : value).isConstant()) {
19177
1a7b33c96c0d Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19148
diff changeset
133 builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(true)));
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135 }
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
136 return false;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
137 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
138 });
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
139 r.register1("materialize", Object.class, new InvocationPlugin() {
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
140 public boolean apply(GraphBuilderContext builder, ValueNode value) {
19378
1a9d5e9ab0f4 Fix "materialize" Truffle graph builder plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19362
diff changeset
141 builder.push(Kind.Object, builder.append(new ForceMaterializeNode(value)));
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
142 return true;
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
143 }
19104
81be933b83eb use anonymous classes for GraphBuilderPlugins instead of enums to common out registration logic and add better static checking
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
144 });
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
145
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
146 // OptimizedCallTarget.class
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
147 r = new Registration(plugins, metaAccess, OptimizedCallTarget.class);
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
148 r.register2("createFrame", FrameDescriptor.class, Object[].class, new InvocationPlugin() {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
149 public boolean apply(GraphBuilderContext builder, ValueNode arg1, ValueNode arg2) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
150 builder.push(Kind.Object, builder.append(new NewFrameNode(StampFactory.exactNonNull(metaAccess.lookupJavaType(FrameWithoutBoxing.class)), arg1, arg2)));
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
151 return true;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
152 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
153 });
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
154
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
155 // FrameWithoutBoxing.class
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
156 r = new Registration(plugins, metaAccess, FrameWithoutBoxing.class);
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
157 r.register1("materialize", Receiver.class, new InvocationPlugin() {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
158 public boolean apply(GraphBuilderContext builder, ValueNode frame) {
19378
1a9d5e9ab0f4 Fix "materialize" Truffle graph builder plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19362
diff changeset
159 builder.push(Kind.Object, builder.append(new MaterializeFrameNode(frame)));
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
160 return true;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
161 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
162 });
19362
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
163 registerUnsafeCast(r);
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
164
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
165 registerUnsafeLoadStorePlugins(r, Kind.Int, Kind.Long, Kind.Float, Kind.Double, Kind.Object);
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
166
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
167 // CompilerDirectives.class
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
168 r = new Registration(plugins, metaAccess, UnsafeAccessImpl.class);
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
169 registerUnsafeCast(r);
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
170 registerUnsafeLoadStorePlugins(r, Kind.Boolean, Kind.Byte, Kind.Int, Kind.Short, Kind.Long, Kind.Float, Kind.Double, Kind.Object);
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
171 }
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
172
595ee09dfda6 Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19330
diff changeset
173 private static void registerUnsafeCast(Registration r) {
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
174 r.register4("unsafeCast", Object.class, Class.class, boolean.class, boolean.class, new InvocationPlugin() {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
175 public boolean apply(GraphBuilderContext builder, ValueNode object, ValueNode clazz, ValueNode condition, ValueNode nonNull) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
176 if (clazz.isConstant() && nonNull.isConstant()) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
177 ConstantReflectionProvider constantReflection = builder.getConstantReflection();
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
178 ResolvedJavaType javaType = constantReflection.asJavaType(clazz.asConstant());
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
179 if (javaType == null) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
180 builder.push(Kind.Object, object);
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
181 } else {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
182 Stamp piStamp = StampFactory.declaredTrusted(javaType, nonNull.asJavaConstant().asInt() != 0);
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
183 LogicNode compareNode = CompareNode.createCompareNode(object.graph(), Condition.EQ, condition, ConstantNode.forBoolean(true, object.graph()), constantReflection);
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
184 boolean skipAnchor = false;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
185 if (compareNode instanceof LogicConstantNode) {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
186 LogicConstantNode logicConstantNode = (LogicConstantNode) compareNode;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
187 if (logicConstantNode.getValue()) {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
188 skipAnchor = true;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
189 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
190 }
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
191 ConditionAnchorNode valueAnchorNode = null;
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
192 if (!skipAnchor) {
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
193 valueAnchorNode = builder.append(new ConditionAnchorNode(compareNode));
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
194 }
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
195 PiNode piCast = builder.append(new PiNode(object, piStamp, valueAnchorNode));
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
196 builder.push(Kind.Object, piCast);
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
197 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
198 return true;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
199 }
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
200 throw GraalInternalError.shouldNotReachHere("unsafeCast arguments could not reduce to a constant: " + clazz + ", " + nonNull);
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
201 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
202 });
19246
d3e835fa6bbf added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
203 }
d3e835fa6bbf added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
204
d3e835fa6bbf added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
205 protected static void registerUnsafeLoadStorePlugins(Registration r, Kind... kinds) {
d3e835fa6bbf added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
206 for (Kind kind : kinds) {
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
207 String kindName = kind.getJavaName();
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
208 kindName = toUpperCase(kindName.charAt(0)) + kindName.substring(1);
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
209 String getName = "unsafeGet" + kindName;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
210 String putName = "unsafePut" + kindName;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
211 r.register4(getName, Object.class, long.class, boolean.class, Object.class, new CustomizedUnsafeLoadPlugin(kind));
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
212 r.register4(putName, Object.class, long.class, kind == Kind.Object ? Object.class : kind.toJavaClass(), Object.class, new CustomizedUnsafeStorePlugin(kind));
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
213 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
214 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
215
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
216 static class CustomizedUnsafeLoadPlugin implements InvocationPlugin {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
217
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
218 private final Kind returnKind;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
219
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
220 public CustomizedUnsafeLoadPlugin(Kind returnKind) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
221 this.returnKind = returnKind;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
222 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
223
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
224 public boolean apply(GraphBuilderContext builder, ValueNode object, ValueNode offset, ValueNode condition, ValueNode location) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
225 if (location.isConstant()) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
226 LocationIdentity locationIdentity;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
227 if (location.isNullConstant()) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
228 locationIdentity = LocationIdentity.ANY_LOCATION;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
229 } else {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
230 locationIdentity = ObjectLocationIdentity.create(location.asJavaConstant());
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
231 }
19241
30c8d110b281 More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19240
diff changeset
232 LogicNode compare = builder.append(CompareNode.createCompareNode(Condition.EQ, condition, ConstantNode.forBoolean(true, object.graph()), builder.getConstantReflection()));
19178
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
233 builder.push(returnKind.getStackKind(), builder.append(new UnsafeLoadNode(object, offset, returnKind, locationIdentity, compare)));
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
234 return true;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
235 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
236 // TODO: should we throw GraalInternalError.shouldNotReachHere() here?
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
237 return false;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
238 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
239 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
240
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
241 static class CustomizedUnsafeStorePlugin implements InvocationPlugin {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
242
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
243 private final Kind kind;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
244
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
245 public CustomizedUnsafeStorePlugin(Kind kind) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
246 this.kind = kind;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
247 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
248
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
249 public boolean apply(GraphBuilderContext builder, ValueNode object, ValueNode offset, ValueNode value, ValueNode location) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
250 ValueNode locationArgument = location;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
251 if (locationArgument.isConstant()) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
252 LocationIdentity locationIdentity;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
253 if (locationArgument.isNullConstant()) {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
254 locationIdentity = LocationIdentity.ANY_LOCATION;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
255 } else {
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
256 locationIdentity = ObjectLocationIdentity.create(locationArgument.asJavaConstant());
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
257 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
258
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
259 builder.append(new UnsafeStoreNode(object, offset, value, kind, locationIdentity, null));
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
260 return true;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
261 }
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
262 // TODO: should we throw GraalInternalError.shouldNotReachHere() here?
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
263 return false;
c8091ec0fdc0 added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents: 19177
diff changeset
264 }
19067
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
265 }
835819187e23 added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
266 }