Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/TruffleGraphBuilderPlugins.java @ 19745:2bad5984e4fe
Evaluate neverPartOfCompilation assertion only after partial escape analysis and conditional elimination. Create explicit SourceStackTrace exception. Add neverPartOfCompilation unit test.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 09 Mar 2015 21:07:38 +0100 |
parents | d2e3d8202ed3 |
children | 14e703edb2ab |
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.*; |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
30 import com.oracle.graal.compiler.common.*; |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
31 import com.oracle.graal.compiler.common.calc.*; |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
32 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
|
33 import com.oracle.graal.graph.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.java.*; |
19390
7f4201b633e7
renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents:
19383
diff
changeset
|
35 import com.oracle.graal.java.GraphBuilderPlugin.InvocationPlugin; |
7f4201b633e7
renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents:
19383
diff
changeset
|
36 import com.oracle.graal.java.InvocationPlugins.Registration; |
7f4201b633e7
renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents:
19383
diff
changeset
|
37 import com.oracle.graal.java.InvocationPlugins.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.*; |
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
|
44 import com.oracle.graal.truffle.nodes.asserts.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 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
|
46 import com.oracle.graal.truffle.unsafe.*; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 import com.oracle.truffle.api.*; |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
48 import com.oracle.truffle.api.frame.*; |
19067
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 /** |
19395
40deedbc4f9b
rename: registerPlugins -> registerInvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19393
diff
changeset
|
51 * Provides {@link InvocationPlugin}s for Truffle classes. |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 */ |
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
|
53 public class TruffleGraphBuilderPlugins { |
19395
40deedbc4f9b
rename: registerPlugins -> registerInvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
19393
diff
changeset
|
54 public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
19148
276bc2752feb
Register plugin for NewFrame intrinsic.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19104
diff
changeset
|
55 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
56 registerOptimizedAssumptionPlugins(metaAccess, plugins); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
57 registerExactMathPlugins(metaAccess, plugins); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
58 registerCompilerDirectivesPlugins(metaAccess, plugins); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
59 registerOptimizedCallTargetPlugins(metaAccess, plugins); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
60 registerUnsafeAccessImplPlugins(metaAccess, plugins); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
61 |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
62 if (TruffleCompilerOptions.TruffleUseFrameWithoutBoxing.getValue()) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
63 registerFrameWithoutBoxingPlugins(metaAccess, plugins); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
64 } else { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
65 registerFrameWithBoxingPlugins(metaAccess, plugins); |
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 } |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
69 |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
70 public static void registerOptimizedAssumptionPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 if (arg.isConstant()) { |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
75 Constant constant = arg.asConstant(); |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
76 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
|
77 builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(assumption.isValid()))); |
19383
669f746ad3b1
Truffle graph builder plugin isValid should only record assumption is true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19378
diff
changeset
|
78 if (assumption.isValid()) { |
669f746ad3b1
Truffle graph builder plugin isValid should only record assumption is true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19378
diff
changeset
|
79 builder.getAssumptions().record(new AssumptionValidAssumption(assumption)); |
669f746ad3b1
Truffle graph builder plugin isValid should only record assumption is true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19378
diff
changeset
|
80 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
81 } else { |
19524
9c4168877444
Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19504
diff
changeset
|
82 throw builder.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
|
83 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
84 return true; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
85 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
86 }); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
87 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
88 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
89 public static void registerExactMathPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
90 Registration r = new Registration(plugins, metaAccess, ExactMath.class); |
19612
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
91 for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
92 r.register2("addExact", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
93 public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
94 builder.push(kind.getStackKind(), builder.append(new IntegerAddExactNode(x, y))); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
95 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
96 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
97 }); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
98 r.register2("subtractExact", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
99 public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
100 builder.push(kind.getStackKind(), builder.append(new IntegerSubExactNode(x, y))); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
101 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
102 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
103 }); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
104 r.register2("multiplyExact", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
105 public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
106 builder.push(kind.getStackKind(), builder.append(new IntegerMulExactNode(x, y))); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
107 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
108 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
109 }); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
110 r.register2("multiplyHigh", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
111 public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
112 builder.push(kind.getStackKind(), builder.append(new IntegerMulHighNode(x, y))); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
113 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
114 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
115 }); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
116 r.register2("multiplyHighUnsigned", kind.toJavaClass(), kind.toJavaClass(), new InvocationPlugin() { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
117 public boolean apply(GraphBuilderContext builder, ValueNode x, ValueNode y) { |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
118 builder.push(kind.getStackKind(), builder.append(new UnsignedMulHighNode(x, y))); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
119 return true; |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
120 } |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
121 }); |
4efe39251424
Truffle: add ExactMath.multiplyHigh[Unsigned] graph builder invocation plugins
Andreas Woess <andreas.woess@oracle.com>
parents:
19524
diff
changeset
|
122 } |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
123 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
124 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
125 public static void registerCompilerDirectivesPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
126 Registration 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
|
127 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
|
128 public boolean apply(GraphBuilderContext builder) { |
19177
1a7b33c96c0d
Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19148
diff
changeset
|
129 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
|
130 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 } |
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
|
132 }); |
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
|
133 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
|
134 public boolean apply(GraphBuilderContext builder) { |
19177
1a7b33c96c0d
Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19148
diff
changeset
|
135 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
|
136 return true; |
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.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
|
140 public boolean apply(GraphBuilderContext builder) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 builder.append(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter)); |
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 }); |
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
|
145 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
|
146 public boolean apply(GraphBuilderContext builder) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 builder.append(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TransferToInterpreter)); |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } |
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
|
150 }); |
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
|
151 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
|
152 public boolean apply(GraphBuilderContext builder, ValueNode arg) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 } |
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
|
155 }); |
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
|
156 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
|
157 public boolean apply(GraphBuilderContext builder, ValueNode arg) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 } |
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
|
160 }); |
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
|
161 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
|
162 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
|
163 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
|
164 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 } |
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
|
166 }); |
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
|
167 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
|
168 public boolean apply(GraphBuilderContext builder, ValueNode message) { |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 if (message.isConstant()) { |
19524
9c4168877444
Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19504
diff
changeset
|
170 throw builder.bailout(message.asConstant().toValueString()); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 } |
19524
9c4168877444
Create CompilerAsserts tests. Add graph builder context on bailout. Consolidate CompilerAsserts Truffle API class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19504
diff
changeset
|
172 throw builder.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
|
173 } |
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
|
174 }); |
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 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
|
176 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
|
177 if ((value instanceof BoxNode ? ((BoxNode) value).getValue() : value).isConstant()) { |
19177
1a7b33c96c0d
Fixes for TruffleGraphBuilderPluginsProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19148
diff
changeset
|
178 builder.push(Kind.Boolean.getStackKind(), builder.append(ConstantNode.forBoolean(true))); |
19456
3e5c4e59c586
Correctly create IsCompilationConstantNode in FastPE mode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19444
diff
changeset
|
179 } else { |
3e5c4e59c586
Correctly create IsCompilationConstantNode in FastPE mode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19444
diff
changeset
|
180 builder.push(Kind.Boolean.getStackKind(), builder.append(new IsCompilationConstantNode(value))); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
181 } |
19456
3e5c4e59c586
Correctly create IsCompilationConstantNode in FastPE mode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19444
diff
changeset
|
182 return true; |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
183 } |
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
|
184 }); |
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
|
185 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
|
186 public boolean apply(GraphBuilderContext builder, ValueNode value) { |
19476
bd2dd97f2bdb
Truffle: fix CompilerDirectives.materialize invocation plugin
Andreas Woess <andreas.woess@oracle.com>
parents:
19474
diff
changeset
|
187 builder.append(new ForceMaterializeNode(value)); |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 return true; |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
189 } |
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
|
190 }); |
19625
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
191 |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
192 r = new Registration(plugins, metaAccess, CompilerAsserts.class); |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
193 r.register1("partialEvaluationConstant", Object.class, new InvocationPlugin() { |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
194 public boolean apply(GraphBuilderContext builder, ValueNode value) { |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
195 ValueNode curValue = value; |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
196 if (curValue instanceof BoxNode) { |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
197 BoxNode boxNode = (BoxNode) curValue; |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
198 curValue = boxNode.getValue(); |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
199 } |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
200 if (curValue.isConstant()) { |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
201 return true; |
98d7ecef3657
New Truffle API method CompilerAsserts#partialEvaluationConstant(Object).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19524
diff
changeset
|
202 } 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 } |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
212 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
|
213 } |
d2e3d8202ed3
Improve error message for partialEvaluationConstant assert to include the values of phis.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19633
diff
changeset
|
214 throw builder.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
|
215 } |
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 }); |
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
|
218 r.register1("neverPartOfCompilation", String.class, new InvocationPlugin() { |
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
|
219 public boolean apply(GraphBuilderContext builder, ValueNode message) { |
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
|
220 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
|
221 String messageString = message.asConstant().toValueString(); |
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
|
222 builder.append(new NeverPartOfCompilationNode(messageString)); |
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
|
223 return true; |
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
|
224 } |
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
|
225 throw builder.bailout("message for never part of compilation is non-constant"); |
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
|
226 } |
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
|
227 }); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
228 } |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
229 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
230 public static void registerOptimizedCallTargetPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
231 Registration r = new Registration(plugins, metaAccess, OptimizedCallTarget.class); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
232 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
|
233 public boolean apply(GraphBuilderContext builder, ValueNode arg1, ValueNode arg2) { |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
234 Class<?> frameClass = TruffleCompilerOptions.TruffleUseFrameWithoutBoxing.getValue() ? FrameWithoutBoxing.class : FrameWithBoxing.class; |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
235 builder.push(Kind.Object, builder.append(new NewFrameNode(StampFactory.exactNonNull(metaAccess.lookupJavaType(frameClass)), arg1, arg2))); |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
236 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
237 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
238 }); |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
239 } |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
240 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
241 public static void registerFrameWithoutBoxingPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
242 Registration r = new Registration(plugins, metaAccess, FrameWithoutBoxing.class); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
243 registerMaterialize(r); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
244 registerUnsafeCast(r); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
245 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
|
246 } |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
247 |
19504
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
248 public static void registerFrameWithBoxingPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
249 Registration r = new Registration(plugins, metaAccess, FrameWithBoxing.class); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
250 registerMaterialize(r); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
251 registerUnsafeCast(r); |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
252 } |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
253 |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
254 public static void registerUnsafeAccessImplPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) { |
95aa11d4822d
refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents:
19476
diff
changeset
|
255 Registration r = new Registration(plugins, metaAccess, UnsafeAccessImpl.class); |
19441
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
256 registerUnsafeCast(r); |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
257 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
|
258 } |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
259 |
2e91c189b0d8
Introduce option TruffleUseFrameWithoutBoxing, default to true.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19439
diff
changeset
|
260 private static void registerMaterialize(Registration r) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
261 r.register1("materialize", Receiver.class, new InvocationPlugin() { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
262 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
|
263 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
|
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 }); |
19362
595ee09dfda6
Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19330
diff
changeset
|
267 } |
595ee09dfda6
Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19330
diff
changeset
|
268 |
595ee09dfda6
Correctly register unsafe cast graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19330
diff
changeset
|
269 private static void registerUnsafeCast(Registration r) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
270 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
|
271 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
|
272 if (clazz.isConstant() && nonNull.isConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
273 ConstantReflectionProvider constantReflection = builder.getConstantReflection(); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
274 ResolvedJavaType javaType = constantReflection.asJavaType(clazz.asConstant()); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
275 if (javaType == null) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
276 builder.push(Kind.Object, object); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
277 } else { |
19439
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
278 Stamp piStamp = null; |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
279 if (javaType.isArray()) { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
280 if (nonNull.asJavaConstant().asInt() != 0) { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
281 piStamp = StampFactory.exactNonNull(javaType); |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
282 } else { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
283 piStamp = StampFactory.exact(javaType); |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
284 } |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
285 } else { |
cb470d088b74
Make array types exact types in unsafe casts.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19393
diff
changeset
|
286 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
|
287 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
288 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
|
289 boolean skipAnchor = false; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
290 if (compareNode instanceof LogicConstantNode) { |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
291 LogicConstantNode logicConstantNode = (LogicConstantNode) compareNode; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
292 if (logicConstantNode.getValue()) { |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
293 skipAnchor = true; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
294 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
295 } |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
296 ConditionAnchorNode valueAnchorNode = null; |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
297 if (!skipAnchor) { |
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
298 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
|
299 } |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
300 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
|
301 builder.push(Kind.Object, piCast); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
302 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
303 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
304 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
305 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
|
306 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
307 }); |
19246
d3e835fa6bbf
added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
19241
diff
changeset
|
308 } |
d3e835fa6bbf
added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
19241
diff
changeset
|
309 |
d3e835fa6bbf
added graph builder plugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
19241
diff
changeset
|
310 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
|
311 for (Kind kind : kinds) { |
19178
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
312 String kindName = kind.getJavaName(); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
313 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
|
314 String getName = "unsafeGet" + kindName; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
315 String putName = "unsafePut" + kindName; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
316 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
|
317 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
|
318 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
319 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
320 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
321 static class CustomizedUnsafeLoadPlugin implements InvocationPlugin { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
322 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
323 private final Kind returnKind; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
324 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
325 public CustomizedUnsafeLoadPlugin(Kind returnKind) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
326 this.returnKind = returnKind; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
327 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
328 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
329 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
|
330 if (location.isConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
331 LocationIdentity locationIdentity; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
332 if (location.isNullConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
333 locationIdentity = LocationIdentity.ANY_LOCATION; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
334 } else { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
335 locationIdentity = ObjectLocationIdentity.create(location.asJavaConstant()); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
336 } |
19241
30c8d110b281
More Truffle graph builder plugins and parse time canonicalizations.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19240
diff
changeset
|
337 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
|
338 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
|
339 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
340 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
341 // TODO: should we throw GraalInternalError.shouldNotReachHere() here? |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
342 return false; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
343 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
344 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
345 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
346 static class CustomizedUnsafeStorePlugin implements InvocationPlugin { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
347 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
348 private final Kind kind; |
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 public CustomizedUnsafeStorePlugin(Kind kind) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
351 this.kind = kind; |
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 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
354 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
|
355 ValueNode locationArgument = location; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
356 if (locationArgument.isConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
357 LocationIdentity locationIdentity; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
358 if (locationArgument.isNullConstant()) { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
359 locationIdentity = LocationIdentity.ANY_LOCATION; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
360 } else { |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
361 locationIdentity = ObjectLocationIdentity.create(locationArgument.asJavaConstant()); |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
362 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
363 |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
364 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
|
365 return true; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
366 } |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
367 // TODO: should we throw GraalInternalError.shouldNotReachHere() here? |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
368 return false; |
c8091ec0fdc0
added graph builder plugins for FrameWithoutBoxing
Doug Simon <doug.simon@oracle.com>
parents:
19177
diff
changeset
|
369 } |
19067
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
370 } |
835819187e23
added GraphBuilderPlugins for CompilerDirectives
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
371 } |