Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java @ 20827:5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 08 Apr 2015 22:38:40 -0700 |
parents | c5ae0424f822 |
children | 7c94786aad9a |
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.meta.*; |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
30 import com.oracle.graal.compiler.common.calc.*; |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
31 import com.oracle.graal.compiler.common.type.*; |
19643
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
32 import com.oracle.graal.graph.*; |
19820
4d33cd6e0c8f
refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents:
19817
diff
changeset
|
33 import com.oracle.graal.graphbuilderconf.*; |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
34 import com.oracle.graal.graphbuilderconf.InvocationPlugins.Receiver; |
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
35 import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.*; |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
37 import com.oracle.graal.nodes.calc.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.extended.*; |
20182
c5ae0424f822
Move special arithemtic nodes from graal.truffle to graal and use them to inrinsify some of the JDK8 Math methods
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
20045
diff
changeset
|
39 import com.oracle.graal.replacements.nodes.arithmetic.*; |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
40 import com.oracle.graal.truffle.*; |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
41 import com.oracle.graal.truffle.nodes.*; |
19745
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
42 import com.oracle.graal.truffle.nodes.asserts.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 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
|
44 import com.oracle.graal.truffle.unsafe.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 import com.oracle.truffle.api.*; |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
46 import com.oracle.truffle.api.frame.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 /** |
19395
40deedbc4f9b
rename: registerPlugins -> registerInvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19393
diff
changeset
|
49 * Provides {@link InvocationPlugin}s for Truffle classes. |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 */ |
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
|
51 public class TruffleGraphBuilderPlugins { |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
52 public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean canDelayIntrinsification) { |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
53 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
54 registerOptimizedAssumptionPlugins(plugins, canDelayIntrinsification); |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
55 registerExactMathPlugins(plugins); |
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
56 registerCompilerDirectivesPlugins(plugins); |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
57 registerCompilerAssertsPlugins(plugins, canDelayIntrinsification); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
58 registerOptimizedCallTargetPlugins(metaAccess, plugins); |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
59 registerUnsafeAccessImplPlugins(plugins, canDelayIntrinsification); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
60 |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
61 if (TruffleCompilerOptions.TruffleUseFrameWithoutBoxing.getValue()) { |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
62 registerFrameWithoutBoxingPlugins(plugins, canDelayIntrinsification); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
63 } else { |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
64 registerFrameWithBoxingPlugins(plugins, canDelayIntrinsification); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
65 } |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
66 |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
67 } |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
68 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
69 public static void registerOptimizedAssumptionPlugins(InvocationPlugins plugins, boolean canDelayIntrinsification) { |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
70 Registration r = new Registration(plugins, OptimizedAssumption.class); |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
71 InvocationPlugin plugin = new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
72 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
73 if (receiver.isConstant()) { |
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
74 Constant constant = receiver.get().asConstant(); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
75 OptimizedAssumption assumption = b.getSnippetReflection().asObject(OptimizedAssumption.class, (JavaConstant) constant); |
19383
669f746ad3b1
Truffle graph builder plugin isValid should only record assumption is true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19378
diff
changeset
|
76 if (assumption.isValid()) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
77 if (targetMethod.getName().equals("isValid")) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
78 b.addPush(ConstantNode.forBoolean(true)); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
79 } else { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
80 assert targetMethod.getName().equals("check") : targetMethod; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
81 } |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
82 b.getAssumptions().record(new AssumptionValidAssumption(assumption)); |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
83 } else { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
84 if (targetMethod.getName().equals("isValid")) { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
85 b.addPush(ConstantNode.forBoolean(false)); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
86 } else { |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
87 assert targetMethod.getName().equals("check") : targetMethod; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
88 b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.None)); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
89 } |
19383
669f746ad3b1
Truffle graph builder plugin isValid should only record assumption is true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19378
diff
changeset
|
90 } |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
91 return true; |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
92 } else if (canDelayIntrinsification) { |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
93 return false; |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
94 } else { |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
95 throw b.bailout("assumption could not be reduced to a constant"); |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
96 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
97 } |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
98 }; |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
99 r.register1("isValid", Receiver.class, plugin); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
100 r.register1("check", Receiver.class, plugin); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
101 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
102 |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
103 public static void registerExactMathPlugins(InvocationPlugins plugins) { |
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
104 Registration r = new Registration(plugins, ExactMath.class); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
105 for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) { |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
106 Class<?> type = kind.toJavaClass(); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
107 r.register2("addExact", type, type, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
108 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
109 b.addPush(kind.getStackKind(), new IntegerAddExactNode(x, y)); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
110 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
111 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
112 }); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
113 r.register2("subtractExact", type, type, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
114 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
115 b.addPush(kind.getStackKind(), new IntegerSubExactNode(x, y)); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
116 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
117 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
118 }); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
119 r.register2("multiplyExact", type, type, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
120 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
121 b.addPush(kind.getStackKind(), new IntegerMulExactNode(x, y)); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
122 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
123 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
124 }); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
125 r.register2("multiplyHigh", type, type, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
126 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
127 b.addPush(kind.getStackKind(), new IntegerMulHighNode(x, y)); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
128 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
129 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
130 }); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
131 r.register2("multiplyHighUnsigned", type, type, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
132 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
133 b.addPush(kind.getStackKind(), new UnsignedMulHighNode(x, y)); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
134 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
135 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
136 }); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
137 } |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
138 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
139 |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
140 public static void registerCompilerDirectivesPlugins(InvocationPlugins plugins) { |
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
141 Registration r = new Registration(plugins, 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
|
142 r.register0("inInterpreter", new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
143 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
144 b.addPush(Kind.Boolean.getStackKind(), ConstantNode.forBoolean(false)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 } |
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
|
147 }); |
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
|
148 r.register0("inCompiledCode", new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
149 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
150 b.addPush(Kind.Boolean.getStackKind(), ConstantNode.forBoolean(true)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 } |
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
|
153 }); |
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
|
154 r.register0("transferToInterpreter", new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
155 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
156 b.add(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 } |
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
|
159 }); |
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
|
160 r.register0("transferToInterpreterAndInvalidate", new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
161 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
162 b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TransferToInterpreter)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |
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
|
165 }); |
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
|
166 r.register1("interpreterOnly", Runnable.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
167 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 } |
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
|
170 }); |
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
|
171 r.register1("interpreterOnly", Callable.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
172 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 } |
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
|
175 }); |
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
|
176 r.register2("injectBranchProbability", double.class, boolean.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
177 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode probability, ValueNode condition) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
178 b.addPush(Kind.Boolean.getStackKind(), new BranchProbabilityNode(probability, condition)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
180 } |
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
|
181 }); |
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
|
182 r.register1("bailout", String.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
183 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 if (message.isConstant()) { |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
185 throw b.bailout(message.asConstant().toValueString()); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 } |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
187 throw b.bailout("bailout (message is not compile-time constant, so no additional information is available)"); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 } |
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
|
189 }); |
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
|
190 r.register1("isCompilationConstant", Object.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
191 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
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
|
192 if ((value instanceof BoxNode ? ((BoxNode) value).getValue() : value).isConstant()) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
193 b.addPush(Kind.Boolean.getStackKind(), ConstantNode.forBoolean(true)); |
19456
3e5c4e59c586
Correctly create IsCompilationConstantNode in FastPE mode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19444
diff
changeset
|
194 } else { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
195 b.addPush(Kind.Boolean.getStackKind(), new IsCompilationConstantNode(value)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
196 } |
19456
3e5c4e59c586
Correctly create IsCompilationConstantNode in FastPE mode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19444
diff
changeset
|
197 return true; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
198 } |
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
|
199 }); |
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
|
200 r.register1("materialize", Object.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
201 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
202 b.add(new ForceMaterializeNode(value)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
204 } |
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
|
205 }); |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
206 } |
19625
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
207 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
208 public static void registerCompilerAssertsPlugins(InvocationPlugins plugins, boolean canDelayIntrinsification) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
209 Registration r = new Registration(plugins, CompilerAsserts.class); |
19625
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
210 r.register1("partialEvaluationConstant", Object.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
211 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { |
19625
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
212 ValueNode curValue = value; |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
213 if (curValue instanceof BoxNode) { |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
214 BoxNode boxNode = (BoxNode) curValue; |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
215 curValue = boxNode.getValue(); |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
216 } |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
217 if (curValue.isConstant()) { |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
218 return true; |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
219 } else if (canDelayIntrinsification) { |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
220 return false; |
19625
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
221 } else { |
19643
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
222 StringBuilder sb = new StringBuilder(); |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
223 sb.append(curValue); |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
224 if (curValue instanceof ValuePhiNode) { |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
225 ValuePhiNode valuePhi = (ValuePhiNode) curValue; |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
226 sb.append(" ("); |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
227 for (Node n : valuePhi.inputs()) { |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
228 sb.append(n); |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
229 sb.append("; "); |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
230 } |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
231 sb.append(")"); |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
232 } |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
233 throw b.bailout("Partial evaluation did not reduce value to a constant, is a regular compiler node: " + sb.toString()); |
19625
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
234 } |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
235 } |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
236 }); |
19745
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
237 r.register1("neverPartOfCompilation", String.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
238 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) { |
19745
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
239 if (message.isConstant()) { |
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
240 String messageString = message.asConstant().toValueString(); |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
241 b.add(new NeverPartOfCompilationNode(messageString, b.createStateAfter())); |
19745
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
242 return true; |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
243 } else if (canDelayIntrinsification) { |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
244 return false; |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
245 } else { |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
246 throw b.bailout("message for never part of compilation is non-constant"); |
19745
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
247 } |
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
248 } |
2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19643
diff
changeset
|
249 }); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
250 } |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
251 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
252 public static void registerOptimizedCallTargetPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
253 Registration r = new Registration(plugins, OptimizedCallTarget.class); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
254 r.register2("createFrame", FrameDescriptor.class, Object[].class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
255 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode descriptor, ValueNode args) { |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
256 Class<?> frameClass = TruffleCompilerOptions.TruffleUseFrameWithoutBoxing.getValue() ? FrameWithoutBoxing.class : FrameWithBoxing.class; |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
257 b.addPush(Kind.Object, new NewFrameNode(StampFactory.exactNonNull(metaAccess.lookupJavaType(frameClass)), descriptor, args)); |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
258 return true; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
259 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
260 }); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
261 r.register2("castArrayFixedLength", Object[].class, int.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
262 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode args, ValueNode length) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
263 b.addPush(Kind.Object, new PiArrayNode(args, length, args.stamp())); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
264 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
265 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
266 }); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
267 } |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
268 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
269 public static void registerFrameWithoutBoxingPlugins(InvocationPlugins plugins, boolean canDelayIntrinsification) { |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
270 Registration r = new Registration(plugins, FrameWithoutBoxing.class); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
271 registerMaterialize(r); |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
272 registerUnsafeCast(r, canDelayIntrinsification); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
273 registerUnsafeLoadStorePlugins(r, Kind.Int, Kind.Long, Kind.Float, Kind.Double, Kind.Object); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
274 } |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
275 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
276 public static void registerFrameWithBoxingPlugins(InvocationPlugins plugins, boolean canDelayIntrinsification) { |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
277 Registration r = new Registration(plugins, FrameWithBoxing.class); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
278 registerMaterialize(r); |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
279 registerUnsafeCast(r, canDelayIntrinsification); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
280 } |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
281 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
282 public static void registerUnsafeAccessImplPlugins(InvocationPlugins plugins, boolean canDelayIntrinsification) { |
19817
3cc8aa066ed3
made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents:
19775
diff
changeset
|
283 Registration r = new Registration(plugins, UnsafeAccessImpl.class); |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
284 registerUnsafeCast(r, canDelayIntrinsification); |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
285 registerUnsafeLoadStorePlugins(r, Kind.Boolean, Kind.Byte, Kind.Int, Kind.Short, Kind.Long, Kind.Float, Kind.Double, Kind.Object); |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
286 } |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
287 |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
288 private static void registerMaterialize(Registration r) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
289 r.register1("materialize", Receiver.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
290 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frame) { |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
291 b.addPush(Kind.Object, new MaterializeFrameNode(frame.get())); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
292 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
293 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
294 }); |
19362
595ee09dfda6
Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19330
diff
changeset
|
295 } |
595ee09dfda6
Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19330
diff
changeset
|
296 |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
297 private static void registerUnsafeCast(Registration r, boolean canDelayIntrinsification) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
298 r.register4("unsafeCast", Object.class, Class.class, boolean.class, boolean.class, new InvocationPlugin() { |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
299 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode clazz, ValueNode condition, ValueNode nonNull) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
300 if (clazz.isConstant() && nonNull.isConstant()) { |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
301 ConstantReflectionProvider constantReflection = b.getConstantReflection(); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
302 ResolvedJavaType javaType = constantReflection.asJavaType(clazz.asConstant()); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
303 if (javaType == null) { |
19775
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19745
diff
changeset
|
304 b.push(Kind.Object, object); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
305 } else { |
19439
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
306 Stamp piStamp = null; |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
307 if (javaType.isArray()) { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
308 if (nonNull.asJavaConstant().asInt() != 0) { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
309 piStamp = StampFactory.exactNonNull(javaType); |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
310 } else { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
311 piStamp = StampFactory.exact(javaType); |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
312 } |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
313 } else { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
314 piStamp = StampFactory.declaredTrusted(javaType, nonNull.asJavaConstant().asInt() != 0); |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
315 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
316 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
|
317 boolean skipAnchor = false; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
318 if (compareNode instanceof LogicConstantNode) { |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
319 LogicConstantNode logicConstantNode = (LogicConstantNode) compareNode; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
320 if (logicConstantNode.getValue()) { |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
321 skipAnchor = true; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
322 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
323 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
324 ConditionAnchorNode valueAnchorNode = null; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
325 if (!skipAnchor) { |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
326 valueAnchorNode = b.add(new ConditionAnchorNode(compareNode)); |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
327 } |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
328 b.addPush(Kind.Object, new PiNode(object, piStamp, valueAnchorNode)); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
329 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
330 return true; |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
331 } else if (canDelayIntrinsification) { |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
332 return false; |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
333 } else { |
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
334 throw b.bailout("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
|
335 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
336 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
337 }); |
19246
d3e835fa6bbf
added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
19241
diff
changeset
|
338 } |
d3e835fa6bbf
added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
19241
diff
changeset
|
339 |
d3e835fa6bbf
added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
19241
diff
changeset
|
340 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
|
341 for (Kind kind : kinds) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
342 String kindName = kind.getJavaName(); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
343 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
|
344 String getName = "unsafeGet" + kindName; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
345 String putName = "unsafePut" + kindName; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
346 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
|
347 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
|
348 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
349 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
350 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
351 static class CustomizedUnsafeLoadPlugin implements InvocationPlugin { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
352 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
353 private final Kind returnKind; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
354 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
355 public CustomizedUnsafeLoadPlugin(Kind returnKind) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
356 this.returnKind = returnKind; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
357 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
358 |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
359 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode offset, ValueNode condition, ValueNode location) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
360 if (location.isConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
361 LocationIdentity locationIdentity; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
362 if (location.isNullConstant()) { |
19852
3d0116ec99c5
Create utilities LocationIdentity#isAny, LocationIdentity#isSingle, LocationIdentity#any, LocationIdentity#overlaps.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19775
diff
changeset
|
363 locationIdentity = LocationIdentity.any(); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
364 } else { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
365 locationIdentity = ObjectLocationIdentity.create(location.asJavaConstant()); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
366 } |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
367 LogicNode compare = b.add(CompareNode.createCompareNode(Condition.EQ, condition, ConstantNode.forBoolean(true, object.graph()), b.getConstantReflection())); |
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20006
diff
changeset
|
368 b.addPush(returnKind.getStackKind(), b.add(new UnsafeLoadNode(object, offset, returnKind, locationIdentity, compare))); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
369 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
370 } |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
371 // TODO: should we throw b.bailout() here? |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
372 return false; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
373 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
374 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
375 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
376 static class CustomizedUnsafeStorePlugin implements InvocationPlugin { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
377 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
378 private final Kind kind; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
379 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
380 public CustomizedUnsafeStorePlugin(Kind kind) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
381 this.kind = kind; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
382 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
383 |
19962
9b669776bf8a
added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents:
19889
diff
changeset
|
384 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode offset, ValueNode value, ValueNode location) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
385 ValueNode locationArgument = location; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
386 if (locationArgument.isConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
387 LocationIdentity locationIdentity; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
388 if (locationArgument.isNullConstant()) { |
19852
3d0116ec99c5
Create utilities LocationIdentity#isAny, LocationIdentity#isSingle, LocationIdentity#any, LocationIdentity#overlaps.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19775
diff
changeset
|
389 locationIdentity = LocationIdentity.any(); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
390 } else { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
391 locationIdentity = ObjectLocationIdentity.create(locationArgument.asJavaConstant()); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
392 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
393 |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19962
diff
changeset
|
394 b.add(new UnsafeStoreNode(object, offset, value, kind, locationIdentity, null)); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
395 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
396 } |
20827
5bf195ce816a
New partial evaluator that works on encoded graphs (instead of on bytecodes)
Christian Wimmer <christian.wimmer@oracle.com>
parents:
20182
diff
changeset
|
397 // TODO: should we throw b.bailout() here? |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
398 return false; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
399 } |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
400 } |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
401 } |