annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java @ 20852:1f7ef92cb660

use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
author Doug Simon <doug.simon@oracle.com>
date Wed, 08 Apr 2015 11:06:07 +0200
parents 91a25b017111
children a74c785068e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
23 package com.oracle.graal.replacements;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
25 import static com.oracle.graal.api.code.MemoryBarriers.*;
20847
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
26
20851
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
27 import java.lang.reflect.*;
20847
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
28 import java.util.*;
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
29
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
30 import sun.misc.*;
19138
149427a9a397 Add null check in Unbox graph builder plugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19133
diff changeset
31
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
32 import com.oracle.graal.api.code.*;
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
33 import com.oracle.graal.api.directives.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.meta.*;
20852
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
35 import com.oracle.graal.compiler.common.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
36 import com.oracle.graal.compiler.common.calc.*;
20135
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
37 import com.oracle.graal.compiler.common.type.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
38 import com.oracle.graal.graph.*;
19883
4d33cd6e0c8f refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents: 19880
diff changeset
39 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: 19951
diff changeset
40 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: 19951
diff changeset
41 import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.nodes.*;
19388
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
43 import com.oracle.graal.nodes.calc.*;
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
44 import com.oracle.graal.nodes.debug.*;
19070
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
45 import com.oracle.graal.nodes.extended.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.nodes.java.*;
20135
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
47 import com.oracle.graal.nodes.util.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
48 import com.oracle.graal.options.*;
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
49 import com.oracle.graal.replacements.nodes.*;
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: 20173
diff changeset
50 import com.oracle.graal.replacements.nodes.arithmetic.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51
19067
ed8ce7fb8dc2 extra javadoc
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
52 /**
19407
40deedbc4f9b rename: registerPlugins -> registerInvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19390
diff changeset
53 * Provides non-runtime specific {@link InvocationPlugin}s.
19067
ed8ce7fb8dc2 extra javadoc
Doug Simon <doug.simon@oracle.com>
parents: 19050
diff changeset
54 */
19243
006e321d592b removed use of ServiceLoader for graph builder plugins
Doug Simon <doug.simon@oracle.com>
parents: 19241
diff changeset
55 public class StandardGraphBuilderPlugins {
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
56
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
57 // @formatter:off
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
58 static class Options {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
59 @Option(help = "Enable use of intrinsics for the JMH Blackhole class")
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
60 public static final OptionValue<Boolean> UseBlackholeSubstitution = new OptionValue<>(true);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
61 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
62 // @formatter:on
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
63
20846
63e4f33dce84 moved registration of AMD64 specific plugins to AMD64GraphBuilderPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20845
diff changeset
64 public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean useBoxingPlugins) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
65 registerObjectPlugins(plugins);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
66 registerClassPlugins(plugins);
20846
63e4f33dce84 moved registration of AMD64 specific plugins to AMD64GraphBuilderPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20845
diff changeset
67 registerMathPlugins(plugins);
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
68 registerUnsignedMathPlugins(plugins);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
69 registerCharacterPlugins(plugins);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
70 registerShortPlugins(plugins);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
71 registerIntegerLongPlugins(plugins, Kind.Int);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
72 registerIntegerLongPlugins(plugins, Kind.Long);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
73 registerFloatPlugins(plugins);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
74 registerDoublePlugins(plugins);
20852
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
75 registerStringPlugins(plugins);
20847
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
76 registerArraysPlugins(plugins);
20851
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
77 registerArrayPlugins(plugins);
20846
63e4f33dce84 moved registration of AMD64 specific plugins to AMD64GraphBuilderPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20845
diff changeset
78 registerUnsafePlugins(plugins);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
79 registerEdgesPlugins(metaAccess, plugins);
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
80 registerGraalDirectivesPlugins(plugins);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
81 if (useBoxingPlugins) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
82 registerBoxingPlugins(plugins);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
83 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
84 if (Options.UseBlackholeSubstitution.getValue()) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
85 registerJMHBlackholePlugins(plugins);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
86 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
87 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
88
20852
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
89 private static final Field STRING_VALUE_FIELD;
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
90 static {
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
91 try {
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
92 STRING_VALUE_FIELD = String.class.getDeclaredField("value");
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
93 } catch (NoSuchFieldException e) {
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
94 throw new GraalInternalError(e);
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
95 }
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
96 }
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
97
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
98 private static void registerStringPlugins(InvocationPlugins plugins) {
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
99 Registration r = new Registration(plugins, StringSubstitutions.class);
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
100 r.register1("getValue", String.class, new InvocationPlugin() {
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
101 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
102 ResolvedJavaField field = b.getMetaAccess().lookupJavaField(STRING_VALUE_FIELD);
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
103 b.addPush(new LoadFieldNode(value, field));
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
104 return true;
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
105 }
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
106 });
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
107 }
1f7ef92cb660 use InvocationPlugin instead of Unsafe to access String.value from within substitution for String.equals
Doug Simon <doug.simon@oracle.com>
parents: 20851
diff changeset
108
20847
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
109 private static void registerArraysPlugins(InvocationPlugins plugins) {
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
110 Registration r = new Registration(plugins, Arrays.class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
111 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", boolean[].class, boolean[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
112 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", byte[].class, byte[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
113 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", short[].class, short[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
114 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", char[].class, char[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
115 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", int[].class, int[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
116 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", float[].class, float[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
117 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", long[].class, long[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
118 r.registerMethodSubstitution(ArraysSubstitutions.class, "equals", double[].class, double[].class);
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
119 }
f2a357ee14e4 converted @MethodSubstitutions for java.util.Arrays to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20846
diff changeset
120
20851
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
121 private static void registerArrayPlugins(InvocationPlugins plugins) {
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
122 Registration r = new Registration(plugins, Array.class);
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
123 r.registerMethodSubstitution(ArraySubstitutions.class, "newInstance", Class.class, int.class);
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
124 r.registerMethodSubstitution(ArraySubstitutions.class, "getLength", Object.class);
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
125 }
91a25b017111 converted @MethodSubstitutions for java.lang.reflect.Array to MethodSubstitutionPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20847
diff changeset
126
20846
63e4f33dce84 moved registration of AMD64 specific plugins to AMD64GraphBuilderPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20845
diff changeset
127 private static void registerUnsafePlugins(InvocationPlugins plugins) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
128 Registration r = new Registration(plugins, Unsafe.class);
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
129 for (Kind kind : Kind.values()) {
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
130 if ((kind.isPrimitive() && kind != Kind.Void) || kind == Kind.Object) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
131 Class<?> javaClass = kind == Kind.Object ? Object.class : kind.toJavaClass();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
132 String kindName = kind.name();
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
133 String getName = "get" + kindName;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
134 String putName = "put" + kindName;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
135 // Object-based accesses
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
136 r.register3(getName, Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, false));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
137 r.register4(putName, Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, false));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
138 // Volatile object-based accesses
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
139 r.register3(getName + "Volatile", Receiver.class, Object.class, long.class, new UnsafeGetPlugin(kind, true));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
140 r.register4(putName + "Volatile", Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, true));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
141 // Ordered object-based accesses
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
142 if (kind == Kind.Int || kind == Kind.Long || kind == Kind.Object) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
143 r.register4("putOrdered" + kindName, Receiver.class, Object.class, long.class, javaClass, new UnsafePutPlugin(kind, true));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
144 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
145 if (kind != Kind.Boolean && kind != Kind.Object) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
146 // Raw accesses to memory addresses
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
147 r.register2(getName, Receiver.class, long.class, new UnsafeGetPlugin(kind, false));
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
148 r.register3(putName, Receiver.class, long.class, kind.toJavaClass(), new UnsafePutPlugin(kind, false));
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
151 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
152
20173
c6ba61a3d05a Add getAddress/putAddress to Unsafe plugin.
twisti
parents: 20164
diff changeset
153 // Accesses to native memory addresses.
c6ba61a3d05a Add getAddress/putAddress to Unsafe plugin.
twisti
parents: 20164
diff changeset
154 r.register2("getAddress", Receiver.class, long.class, new UnsafeGetPlugin(Kind.Long, false));
c6ba61a3d05a Add getAddress/putAddress to Unsafe plugin.
twisti
parents: 20164
diff changeset
155 r.register3("putAddress", Receiver.class, long.class, long.class, new UnsafePutPlugin(Kind.Long, false));
c6ba61a3d05a Add getAddress/putAddress to Unsafe plugin.
twisti
parents: 20164
diff changeset
156
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
157 for (Kind kind : new Kind[]{Kind.Int, Kind.Long, Kind.Object}) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
158 Class<?> javaClass = kind == Kind.Object ? Object.class : kind.toJavaClass();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
159 r.register5("compareAndSwap" + kind.name(), Receiver.class, Object.class, long.class, javaClass, javaClass, 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: 19951
diff changeset
160 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode expected, ValueNode x) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
161 // Emits a null-check for the otherwise unused receiver
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
162 unsafe.get();
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
163 b.addPush(Kind.Int, new CompareAndSwapNode(object, offset, expected, x, kind, LocationIdentity.any()));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
164 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
165 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
166 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
167 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
168 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
169
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
170 private static void registerIntegerLongPlugins(InvocationPlugins plugins, Kind kind) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
171 Class<?> declaringClass = kind.toBoxedJavaClass();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
172 Class<?> type = kind.toJavaClass();
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
173 Registration r = new Registration(plugins, declaringClass);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
174 r.register1("reverseBytes", 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: 19951
diff changeset
175 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
176 b.push(kind, b.recursiveAppend(new ReverseBytesNode(value).canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
177 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
178 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
179 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
180 r.register1("bitCount", 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: 19951
diff changeset
181 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
182 b.push(Kind.Int, b.recursiveAppend(new BitCountNode(value).canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
183 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
184 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
185 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
186 r.register2("divideUnsigned", 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: 19951
diff changeset
187 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode dividend, ValueNode divisor) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
188 b.push(kind, b.recursiveAppend(new UnsignedDivNode(dividend, divisor).canonical(null, dividend, divisor)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
189 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
190 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
191 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
192 r.register2("remainderUnsigned", 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: 19951
diff changeset
193 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode dividend, ValueNode divisor) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
194 b.push(kind, b.recursiveAppend(new UnsignedDivNode(dividend, divisor).canonical(null, dividend, divisor)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
195 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
196 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
197 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
198 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
199
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
200 private static void registerCharacterPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
201 Registration r = new Registration(plugins, Character.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
202 r.register1("reverseBytes", char.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: 19951
diff changeset
203 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
204 // return (char) (Integer.reverse(i) >> 16);
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
205 ReverseBytesNode reverse = b.add(new ReverseBytesNode(value));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
206 RightShiftNode rightShift = b.add(new RightShiftNode(reverse, b.add(ConstantNode.forInt(16))));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
207 ZeroExtendNode charCast = b.add(new ZeroExtendNode(b.add(new NarrowNode(rightShift, 16)), 32));
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
208 b.push(Kind.Char.getStackKind(), b.recursiveAppend(charCast.canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
209 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
210 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
211 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
212 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
213
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
214 private static void registerShortPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
215 Registration r = new Registration(plugins, Short.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
216 r.register1("reverseBytes", short.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: 19951
diff changeset
217 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
218 // return (short) (Integer.reverse(i) >> 16);
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
219 ReverseBytesNode reverse = b.add(new ReverseBytesNode(value));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
220 RightShiftNode rightShift = b.add(new RightShiftNode(reverse, b.add(ConstantNode.forInt(16))));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
221 SignExtendNode charCast = b.add(new SignExtendNode(b.add(new NarrowNode(rightShift, 16)), 32));
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
222 b.push(Kind.Short.getStackKind(), b.recursiveAppend(charCast.canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
223 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
224 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
225 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
226 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
227
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
228 private static void registerFloatPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
229 Registration r = new Registration(plugins, Float.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
230 r.register1("floatToRawIntBits", float.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: 19951
diff changeset
231 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
232 b.push(Kind.Int, b.recursiveAppend(new ReinterpretNode(Kind.Int, value).canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
233 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
234 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
235 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
236 r.register1("intBitsToFloat", 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: 19951
diff changeset
237 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
238 b.push(Kind.Float, b.recursiveAppend(new ReinterpretNode(Kind.Float, value).canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
239 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
240 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
241 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
242 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
243
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
244 private static void registerDoublePlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
245 Registration r = new Registration(plugins, Double.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
246 r.register1("doubleToRawLongBits", double.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: 19951
diff changeset
247 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
248 b.push(Kind.Long, b.recursiveAppend(new ReinterpretNode(Kind.Long, value).canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
249 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
250 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
251 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
252 r.register1("longBitsToDouble", long.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: 19951
diff changeset
253 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
254 b.push(Kind.Double, b.recursiveAppend(new ReinterpretNode(Kind.Double, value).canonical(null, value)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
255 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
256 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
257 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
258 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
259
20846
63e4f33dce84 moved registration of AMD64 specific plugins to AMD64GraphBuilderPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20845
diff changeset
260 private static void registerMathPlugins(InvocationPlugins plugins) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
261 Registration r = new Registration(plugins, Math.class);
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: 20173
diff changeset
262 for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) {
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: 20173
diff changeset
263 Class<?> type = kind.toJavaClass();
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: 20173
diff changeset
264 r.register2("addExact", type, type, new InvocationPlugin() {
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: 20173
diff changeset
265 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
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: 20173
diff changeset
266 b.addPush(kind.getStackKind(), new IntegerAddExactNode(x, y));
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: 20173
diff changeset
267 return true;
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: 20173
diff changeset
268 }
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: 20173
diff changeset
269 });
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: 20173
diff changeset
270 r.register2("subtractExact", type, type, new InvocationPlugin() {
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: 20173
diff changeset
271 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
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: 20173
diff changeset
272 b.addPush(kind.getStackKind(), new IntegerSubExactNode(x, y));
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: 20173
diff changeset
273 return true;
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: 20173
diff changeset
274 }
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: 20173
diff changeset
275 });
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: 20173
diff changeset
276 r.register2("multiplyExact", type, type, new InvocationPlugin() {
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: 20173
diff changeset
277 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
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: 20173
diff changeset
278 b.addPush(kind.getStackKind(), new IntegerMulExactNode(x, y));
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: 20173
diff changeset
279 return true;
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: 20173
diff changeset
280 }
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: 20173
diff changeset
281 });
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: 20173
diff changeset
282 }
19388
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
283 r.register1("abs", Float.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: 19951
diff changeset
284 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
285 b.push(Kind.Float, b.recursiveAppend(new AbsNode(value).canonical(null, value)));
19388
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
286 return true;
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
287 }
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
288 });
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
289 r.register1("abs", Double.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: 19951
diff changeset
290 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
291 b.push(Kind.Double, b.recursiveAppend(new AbsNode(value).canonical(null, value)));
19388
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
292 return true;
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
293 }
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
294 });
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
295 r.register1("sqrt", Double.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: 19951
diff changeset
296 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
297 b.push(Kind.Double, b.recursiveAppend(new SqrtNode(value).canonical(null, value)));
19388
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
298 return true;
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
299 }
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
300 });
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
301 r.register2("pow", Double.TYPE, Double.TYPE, new InvocationPlugin() {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
302 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
303 ValueNode folded = MathPowNode.tryFold(x, y);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
304 if (folded != null) {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
305 b.addPush(Kind.Double, folded);
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
306 } else {
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
307 b.addPush(Kind.Double, new MathPowNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnType(), x, y));
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
308 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
309 return true;
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
310 }
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
311 });
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
312 }
19388
aadf2fd0a4a2 Graph builder plugins for Math#abs and Math#sqrt. Apply macro substitutions for invokes with still missing plugins.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19245
diff changeset
313
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
314 public static class UnsignedMathPlugin implements InvocationPlugin {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
315 private final Condition condition;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
316
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
317 public UnsignedMathPlugin(Condition condition) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
318 this.condition = condition;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
319 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
320
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
321 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
322 // the mirroring and negation operations get the condition into canonical form
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
323 boolean mirror = condition.canonicalMirror();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
324 boolean negate = condition.canonicalNegate();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
325 StructuredGraph graph = b.getGraph();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
326
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
327 ValueNode lhs = mirror ? y : x;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
328 ValueNode rhs = mirror ? x : y;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
329
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
330 ValueNode trueValue = ConstantNode.forBoolean(!negate, graph);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
331 ValueNode falseValue = ConstantNode.forBoolean(negate, graph);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
332
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
333 Condition cond = mirror ? condition.mirror() : condition;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
334 if (negate) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
335 cond = cond.negate();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
336 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
337
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
338 LogicNode compare = CompareNode.createCompareNode(graph, cond, lhs, rhs, b.getConstantReflection());
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
339 b.addPush(Kind.Boolean.getStackKind(), new ConditionalNode(compare, trueValue, falseValue));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
340 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
341 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
342 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
343
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
344 private static void registerUnsignedMathPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
345 Registration r = new Registration(plugins, UnsignedMath.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
346 r.register2("aboveThan", int.class, int.class, new UnsignedMathPlugin(Condition.AT));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
347 r.register2("aboveThan", long.class, long.class, new UnsignedMathPlugin(Condition.AT));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
348 r.register2("belowThan", int.class, int.class, new UnsignedMathPlugin(Condition.BT));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
349 r.register2("belowThan", long.class, long.class, new UnsignedMathPlugin(Condition.BT));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
350 r.register2("aboveOrEqual", int.class, int.class, new UnsignedMathPlugin(Condition.AE));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
351 r.register2("aboveOrEqual", long.class, long.class, new UnsignedMathPlugin(Condition.AE));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
352 r.register2("belowOrEqual", int.class, int.class, new UnsignedMathPlugin(Condition.BE));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
353 r.register2("belowOrEqual", long.class, long.class, new UnsignedMathPlugin(Condition.BE));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
354 r.register2("divide", int.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: 19951
diff changeset
355 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
356 b.push(Kind.Int, b.recursiveAppend(new UnsignedDivNode(x, y).canonical(null, x, y)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
357 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
358 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
359 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
360 r.register2("divide", long.class, long.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: 19951
diff changeset
361 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
362 b.push(Kind.Long, b.recursiveAppend(new UnsignedDivNode(x, y).canonical(null, x, y)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
363 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
364 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
365 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
366 r.register2("remainder", int.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: 19951
diff changeset
367 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
368 b.push(Kind.Int, b.recursiveAppend(new UnsignedRemNode(x, y).canonical(null, x, y)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
369 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
370 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
371 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
372 r.register2("remainder", long.class, long.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: 19951
diff changeset
373 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
374 b.push(Kind.Long, b.recursiveAppend(new UnsignedRemNode(x, y).canonical(null, x, y)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
375 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
376 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
377 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
378 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
379
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
380 protected static void registerBoxingPlugins(InvocationPlugins plugins) {
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: 19070
diff changeset
381 for (Kind kind : Kind.values()) {
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: 19070
diff changeset
382 if (kind.isPrimitive() && kind != Kind.Void) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
383 new BoxPlugin(kind).register(plugins);
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
384 new UnboxPlugin(kind).register(plugins);
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
385 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
386 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
387 }
19245
03444c54a267 Backed out of changeset 19244:957fcb7fb14d
Doug Simon <doug.simon@oracle.com>
parents: 19244
diff changeset
388
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
389 private static void registerObjectPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
390 Registration r = new Registration(plugins, Object.class);
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
391 r.register1("<init>", 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: 19951
diff changeset
392 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: 19951
diff changeset
393 ValueNode object = receiver.get();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
394 if (RegisterFinalizerNode.mayHaveFinalizer(object, b.getAssumptions())) {
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
395 b.add(new RegisterFinalizerNode(object));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
396 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
397 return true;
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
398 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
399 });
20135
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
400 r.register1("getClass", Receiver.class, new InvocationPlugin() {
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
401 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
402 ValueNode object = receiver.get();
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
403 ValueNode folded = GetClassNode.tryFold(b.getMetaAccess(), GraphUtil.originalValue(object));
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
404 if (folded != null) {
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
405 b.addPush(Kind.Object, folded);
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
406 } else {
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
407 Stamp stamp = StampFactory.declaredNonNull(b.getMetaAccess().lookupJavaType(Class.class));
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
408 b.addPush(Kind.Object, new GetClassNode(stamp, object));
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
409 }
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
410 return true;
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
411 }
987b4c42aef9 add GetClassNode and use it in a non-HotSpot specific InvocationPlugin for Object.getClass()
Doug Simon <doug.simon@oracle.com>
parents: 20045
diff changeset
412 });
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
413 }
19070
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
414
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
415 private static void registerClassPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
416 Registration r = new Registration(plugins, Class.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
417 r.register2("isInstance", Receiver.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: 19951
diff changeset
418 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode object) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
419 LogicNode condition = b.add(InstanceOfDynamicNode.create(b.getConstantReflection(), type.get(), object));
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
420 b.push(Kind.Boolean.getStackKind(), b.recursiveAppend(new ConditionalNode(condition).canonical(null)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
421 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
422 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
423 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
424 r.register2("isAssignableFrom", Receiver.class, Class.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: 19951
diff changeset
425 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode otherType) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
426 ClassIsAssignableFromNode condition = b.recursiveAppend(new ClassIsAssignableFromNode(type.get(), otherType));
19951
a252927dfbfd Fix an issue when the result of canonicalization is appended in the graph builder. Introduce GraphBuilderPhase#recursiveAppend.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19886
diff changeset
427 b.push(Kind.Boolean.getStackKind(), b.recursiveAppend(new ConditionalNode(condition).canonical(null)));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
428 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
429 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
430 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
431 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
432
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
433 /**
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
434 * Substitutions for improving the performance of some critical methods in {@link Edges}. These
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
435 * substitutions improve the performance by forcing the relevant methods to be inlined
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
436 * (intrinsification being a special form of inlining) and removing a checked cast. The latter
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
437 * cannot be done directly in Java code as {@link DeferredPiNode} is not available to the
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
438 * project containing {@link Edges}.
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
439 */
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
440 private static void registerEdgesPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
441 Registration r = new Registration(plugins, Edges.class);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
442 for (Class<?> c : new Class<?>[]{Node.class, NodeList.class}) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
443 r.register2("get" + c.getSimpleName() + "Unsafe", Node.class, long.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: 19951
diff changeset
444 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode node, ValueNode offset) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
445 ValueNode value = b.add(new UnsafeLoadNode(node, offset, Kind.Object, LocationIdentity.any()));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
446 boolean exactType = false;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
447 boolean nonNull = false;
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
448 b.addPush(Kind.Object, new PiNode(value, metaAccess.lookupJavaType(c), exactType, nonNull));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
449 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
450 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
451 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
452 r.register3("put" + c.getSimpleName() + "Unsafe", Node.class, long.class, c, 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: 19951
diff changeset
453 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode node, ValueNode offset, ValueNode value) {
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
454 b.add(new UnsafeStoreNode(node, offset, value, Kind.Object, LocationIdentity.any()));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
455 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
456 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
457 });
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
458 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
459 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
460
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
461 public static class BoxPlugin implements InvocationPlugin {
19070
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
462
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: 19070
diff changeset
463 private final Kind kind;
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: 19070
diff changeset
464
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: 19070
diff changeset
465 BoxPlugin(Kind kind) {
19070
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
466 this.kind = kind;
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
467 }
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
468
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
469 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
470 if (b.parsingReplacement()) {
20164
c36ab3cd360c removed GraphBuilderContext.getRootMethod()
Doug Simon <doug.simon@oracle.com>
parents: 20135
diff changeset
471 ResolvedJavaMethod rootMethod = b.getGraph().method();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
472 if (b.getMetaAccess().lookupJavaType(BoxingSnippets.class).isAssignableFrom(rootMethod.getDeclaringClass())) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
473 // Disable invocation plugins for boxing snippets so that the
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
474 // original JDK methods are inlined
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
475 return false;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
476 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
477 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
478 ResolvedJavaType resultType = b.getMetaAccess().lookupJavaType(kind.toBoxedJavaClass());
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
479 b.addPush(Kind.Object, new BoxNode(value, resultType, kind));
19070
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
480 return true;
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
481 }
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
482
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
483 void register(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
484 plugins.register(this, kind.toBoxedJavaClass(), "valueOf", kind.toJavaClass());
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: 19070
diff changeset
485 }
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: 19070
diff changeset
486 }
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: 19070
diff changeset
487
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
488 public static class UnboxPlugin implements InvocationPlugin {
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: 19070
diff changeset
489
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: 19070
diff changeset
490 private final Kind kind;
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: 19070
diff changeset
491
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: 19070
diff changeset
492 UnboxPlugin(Kind kind) {
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: 19070
diff changeset
493 this.kind = kind;
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: 19070
diff changeset
494 }
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: 19070
diff changeset
495
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
496 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
497 if (b.parsingReplacement()) {
20164
c36ab3cd360c removed GraphBuilderContext.getRootMethod()
Doug Simon <doug.simon@oracle.com>
parents: 20135
diff changeset
498 ResolvedJavaMethod rootMethod = b.getGraph().method();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
499 if (b.getMetaAccess().lookupJavaType(BoxingSnippets.class).isAssignableFrom(rootMethod.getDeclaringClass())) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
500 // Disable invocation plugins for unboxing snippets so that the
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
501 // original JDK methods are inlined
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
502 return false;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
503 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
504 }
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
505 ValueNode valueNode = UnboxNode.create(b.getMetaAccess(), b.getConstantReflection(), receiver.get(), kind);
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
506 b.addPush(kind.getStackKind(), valueNode);
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: 19070
diff changeset
507 return true;
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: 19070
diff changeset
508 }
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: 19070
diff changeset
509
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
510 void register(InvocationPlugins plugins) {
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: 19070
diff changeset
511 String name = kind.toJavaClass().getSimpleName() + "Value";
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
512 plugins.register(this, kind.toBoxedJavaClass(), name, Receiver.class);
19070
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
513 }
69f2926cd2ab added GraphBuilderPlugins for standard boxing/unboxing methods
Doug Simon <doug.simon@oracle.com>
parents: 19069
diff changeset
514 }
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
515
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
516 public static class UnsafeGetPlugin implements InvocationPlugin {
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
517
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
518 private final Kind returnKind;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
519 private final boolean isVolatile;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
520
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
521 public UnsafeGetPlugin(Kind returnKind, boolean isVolatile) {
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
522 this.returnKind = returnKind;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
523 this.isVolatile = isVolatile;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
524 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
525
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
526 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode address) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
527 // Emits a null-check for the otherwise unused receiver
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
528 unsafe.get();
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
529 b.addPush(returnKind.getStackKind(), new DirectReadNode(address, returnKind));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
530 return true;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
531 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
532
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
533 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
534 // Emits a null-check for the otherwise unused receiver
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
535 unsafe.get();
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
536 if (isVolatile) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
537 b.add(new MembarNode(JMM_PRE_VOLATILE_READ));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
538 }
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
539 b.addPush(returnKind.getStackKind(), new UnsafeLoadNode(object, offset, returnKind, LocationIdentity.any()));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
540 if (isVolatile) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
541 b.add(new MembarNode(JMM_POST_VOLATILE_READ));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
542 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
543 return true;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
544 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
545 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
546
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
547 static class UnsafePutPlugin implements InvocationPlugin {
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
548
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
549 private final Kind kind;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
550 private final boolean isVolatile;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
551
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
552 public UnsafePutPlugin(Kind kind, boolean isVolatile) {
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
553 this.kind = kind;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
554 this.isVolatile = isVolatile;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
555 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
556
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
557 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode address, ValueNode value) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
558 // Emits a null-check for the otherwise unused receiver
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
559 unsafe.get();
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
560 b.add(new DirectStoreNode(address, value, kind));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
561 return true;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
562 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
563
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
564 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
565 // Emits a null-check for the otherwise unused receiver
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
566 unsafe.get();
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
567 if (isVolatile) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
568 b.add(new MembarNode(JMM_PRE_VOLATILE_WRITE));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
569 }
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
570 b.add(new UnsafeStoreNode(object, offset, value, kind, LocationIdentity.any()));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
571 if (isVolatile) {
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
572 b.add(new MembarNode(JMM_PRE_VOLATILE_WRITE));
19500
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
573 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
574 return true;
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
575 }
b828f1f74625 add graph builder plugins for Unsafe and Word
Doug Simon <doug.simon@oracle.com>
parents: 19407
diff changeset
576 }
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
577
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
578 private static void registerGraalDirectivesPlugins(InvocationPlugins plugins) {
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
579 Registration r = new Registration(plugins, GraalDirectives.class);
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
580 r.register0("deoptimize", 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: 19951
diff changeset
581 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
582 b.add(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter));
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
583 return true;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
584 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
585 });
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
586
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
587 r.register0("deoptimizeAndInvalidate", 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: 19951
diff changeset
588 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
589 b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TransferToInterpreter));
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
590 return true;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
591 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
592 });
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
593
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
594 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: 19951
diff changeset
595 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: 19970
diff changeset
596 b.addPush(Kind.Int, ConstantNode.forInt(1));
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
597 return true;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
598 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
599 });
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
600
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
601 r.register0("controlFlowAnchor", 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: 19951
diff changeset
602 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
603 b.add(new ControlFlowAnchorNode());
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
604 return true;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
605 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
606 });
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
607
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
608 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: 19951
diff changeset
609 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: 19970
diff changeset
610 b.addPush(Kind.Int, new BranchProbabilityNode(probability, condition));
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
611 return true;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
612 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
613 });
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
614
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
615 InvocationPlugin blackholePlugin = 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: 19951
diff changeset
616 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
617 b.add(new BlackholeNode(value));
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
618 return true;
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
619 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
620 };
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
621
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
622 for (Kind kind : Kind.values()) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
623 if ((kind.isPrimitive() && kind != Kind.Void) || kind == Kind.Object) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
624 Class<?> javaClass = kind == Kind.Object ? Object.class : kind.toJavaClass();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
625 r.register1("blackhole", javaClass, blackholePlugin);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
626
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
627 final Kind stackKind = kind.getStackKind();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
628 r.register1("opaque", javaClass, 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: 19951
diff changeset
629 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
20006
2d51a92a301a added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents: 19970
diff changeset
630 b.addPush(stackKind, new OpaqueNode(value));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
631 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
632 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
633 });
19504
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
634 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
635 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
636 }
95aa11d4822d refactored per-class InvocationPlugins registration into separate methods
Doug Simon <doug.simon@oracle.com>
parents: 19500
diff changeset
637
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
638 private static void registerJMHBlackholePlugins(InvocationPlugins plugins) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
639 InvocationPlugin blackholePlugin = 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: 19951
diff changeset
640 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver blackhole, ValueNode value) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19951
diff changeset
641 blackhole.get();
20045
8470e81631f8 converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 20006
diff changeset
642 b.add(new BlackholeNode(value));
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
643 return true;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
644 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
645 };
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
646 String[] names = {"org.openjdk.jmh.infra.Blackhole", "org.openjdk.jmh.logic.BlackHole"};
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
647 for (String name : names) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
648 Class<?> blackholeClass;
20845
a2cd0e7072e2 added MethodSubstitutionPlugin as (eventual) replacement for @MethodSubstitution mechanism
Doug Simon <doug.simon@oracle.com>
parents: 20182
diff changeset
649 blackholeClass = MethodSubstitutionPlugin.resolveClass(name, true);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
650 if (blackholeClass != null) {
19880
3cc8aa066ed3 made resolution of method with InvocationPlugins lazy
Doug Simon <doug.simon@oracle.com>
parents: 19791
diff changeset
651 Registration r = new Registration(plugins, blackholeClass);
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
652 for (Kind kind : Kind.values()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
653 if ((kind.isPrimitive() && kind != Kind.Void) || kind == Kind.Object) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
654 Class<?> javaClass = kind == Kind.Object ? Object.class : kind.toJavaClass();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
655 r.register2("consume", Receiver.class, javaClass, blackholePlugin);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
656 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
657 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
658 r.register2("consume", Receiver.class, Object[].class, blackholePlugin);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
659 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
660 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19780
diff changeset
661 }
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
662 }