Mercurial > hg > truffle
annotate graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/DefaultGenericInvocationPlugin.java @ 20045:8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 27 Mar 2015 13:29:08 +0100 |
parents | 01290be48def |
children | 90b5605032bc |
rev | line source |
---|---|
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.replacements; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.api.meta.MetaUtil.*; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import static com.oracle.graal.replacements.NodeIntrinsificationPhase.*; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.api.replacements.*; |
20033
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
32 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:
diff
changeset
|
33 import com.oracle.graal.compiler.common.type.*; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.graph.Node.NodeIntrinsic; |
19883
4d33cd6e0c8f
refactored GraphBuilderConfiguration (and its component classes) into a separate project
Doug Simon <doug.simon@oracle.com>
parents:
19801
diff
changeset
|
35 import com.oracle.graal.graphbuilderconf.*; |
20033
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
36 import com.oracle.graal.nodeinfo.*; |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
37 import com.oracle.graal.nodeinfo.StructuralInput.MarkerType; |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.*; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.nodes.extended.*; |
19801
2e6e20ac56b4
moved WordTypes from c.o.g.word.phases to c.o.g.word
Doug Simon <doug.simon@oracle.com>
parents:
19797
diff
changeset
|
40 import com.oracle.graal.word.*; |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 /** |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 * An {@link GenericInvocationPlugin} that handles methods annotated by {@link Fold}, |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 * {@link NodeIntrinsic} and all annotations supported by a given {@link WordOperationPlugin}. |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 */ |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 public class DefaultGenericInvocationPlugin implements GenericInvocationPlugin { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 protected final NodeIntrinsificationPhase nodeIntrinsification; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 protected final WordOperationPlugin wordOperationPlugin; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 |
20033
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
50 private final ResolvedJavaType structuralInputType; |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
51 |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
52 public DefaultGenericInvocationPlugin(MetaAccessProvider metaAccess, NodeIntrinsificationPhase nodeIntrinsification, WordOperationPlugin wordOperationPlugin) { |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 this.nodeIntrinsification = nodeIntrinsification; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 this.wordOperationPlugin = wordOperationPlugin; |
20033
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
55 |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
56 this.structuralInputType = metaAccess.lookupJavaType(StructuralInput.class); |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 public boolean apply(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) { |
20039
c38296febf23
don't process Word operations unless parsing a snippet or intrinsic
Doug Simon <doug.simon@oracle.com>
parents:
20024
diff
changeset
|
60 if (b.parsingReplacement() && wordOperationPlugin.apply(b, method, args)) { |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 return true; |
20024
d8275b3e1bd3
Do node intrinsification and word type rewriting only during replacement parsing.
Roland Schatz <roland.schatz@oracle.com>
parents:
20006
diff
changeset
|
62 } else if (b.parsingReplacement()) { |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 NodeIntrinsic intrinsic = nodeIntrinsification.getIntrinsic(method); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 if (intrinsic != null) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 Signature sig = method.getSignature(); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 Kind returnKind = sig.getReturnKind(); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 Stamp stamp = StampFactory.forKind(returnKind); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 if (returnKind == Kind.Object) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 JavaType returnType = sig.getReturnType(method.getDeclaringClass()); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 if (returnType instanceof ResolvedJavaType) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 ResolvedJavaType resolvedReturnType = (ResolvedJavaType) returnType; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 WordTypes wordTypes = wordOperationPlugin.getWordTypes(); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 if (wordTypes.isWord(resolvedReturnType)) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 stamp = wordTypes.getWordStamp(resolvedReturnType); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 } else { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 stamp = StampFactory.declared(resolvedReturnType); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 return processNodeIntrinsic(b, method, intrinsic, Arrays.asList(args), returnKind, stamp); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 } else if (nodeIntrinsification.isFoldable(method)) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 ResolvedJavaType[] parameterTypes = resolveJavaTypes(method.toParameterTypes(), method.getDeclaringClass()); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 JavaConstant constant = nodeIntrinsification.tryFold(Arrays.asList(args), parameterTypes, method); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 if (!COULD_NOT_FOLD.equals(constant)) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 if (constant != null) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 // Replace the invoke with the result of the call |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20041
diff
changeset
|
88 ConstantNode res = b.add(ConstantNode.forConstant(constant, b.getMetaAccess())); |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19886
diff
changeset
|
89 b.addPush(res.getKind().getStackKind(), res); |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 } else { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 // This must be a void invoke |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 assert method.getSignature().getReturnKind() == Kind.Void; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 return true; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 return false; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 |
20033
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
101 private InputType getInputType(ObjectStamp stamp) { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
102 ResolvedJavaType type = stamp.type(); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
103 if (type != null && structuralInputType.isAssignableFrom(type)) { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
104 while (type != null) { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
105 MarkerType markerType = type.getAnnotation(MarkerType.class); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
106 if (markerType != null) { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
107 return markerType.value(); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
108 } |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
109 |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
110 type = type.getSuperclass(); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
111 } |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
112 |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
113 throw GraalInternalError.shouldNotReachHere(String.format("%s extends StructuralInput, but is not annotated with @MarkerType", stamp.type())); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
114 } else { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
115 return InputType.Value; |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
116 } |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
117 } |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
118 |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 protected boolean processNodeIntrinsic(GraphBuilderContext b, ResolvedJavaMethod method, NodeIntrinsic intrinsic, List<ValueNode> args, Kind returnKind, Stamp stamp) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 ValueNode res = createNodeIntrinsic(b, method, intrinsic, args, stamp); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 if (res == null) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 return false; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 if (res instanceof UnsafeCopyNode) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 UnsafeCopyNode copy = (UnsafeCopyNode) res; |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20041
diff
changeset
|
126 UnsafeLoadNode value = b.add(new UnsafeLoadNode(copy.sourceObject(), copy.sourceOffset(), copy.accessKind(), copy.getLocationIdentity())); |
20006
2d51a92a301a
added helper methods to GraphBuilderContext for common operation combinations
Doug Simon <doug.simon@oracle.com>
parents:
19886
diff
changeset
|
127 b.add(new UnsafeStoreNode(copy.destinationObject(), copy.destinationOffset(), value, copy.accessKind(), copy.getLocationIdentity())); |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 return true; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 } else if (res instanceof ForeignCallNode) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 ForeignCallNode foreign = (ForeignCallNode) res; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 foreign.setBci(b.bci()); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 |
20045
8470e81631f8
converted all @MacroSubstitution uses to InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents:
20041
diff
changeset
|
134 res = b.add(res); |
20033
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
135 |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
136 InputType inputType = InputType.Value; |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
137 if (returnKind == Kind.Object && stamp instanceof ObjectStamp) { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
138 inputType = getInputType((ObjectStamp) stamp); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
139 } |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
140 |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
141 if (inputType != InputType.Value) { |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
142 assert res.isAllowedUsageType(inputType); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
143 b.push(Kind.Object, res); |
39c0ccfcd070
Allow InputTypes that are not Value in snippets.
Roland Schatz <roland.schatz@oracle.com>
parents:
20024
diff
changeset
|
144 } else if (returnKind != Kind.Void) { |
19797
9594538080a8
ensure voidness of a @NodeIntrinsic method's return kind agrees with the voidness of the stamp of the intrinsified node
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
145 assert res.getKind().getStackKind() != Kind.Void; |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 b.push(returnKind.getStackKind(), res); |
19797
9594538080a8
ensure voidness of a @NodeIntrinsic method's return kind agrees with the voidness of the stamp of the intrinsified node
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
147 } else { |
9594538080a8
ensure voidness of a @NodeIntrinsic method's return kind agrees with the voidness of the stamp of the intrinsified node
Doug Simon <doug.simon@oracle.com>
parents:
19791
diff
changeset
|
148 assert res.getKind().getStackKind() == Kind.Void; |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 |
19854
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
151 if (res instanceof StateSplit) { |
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
152 StateSplit stateSplit = (StateSplit) res; |
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
153 if (stateSplit.stateAfter() == null) { |
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
154 stateSplit.setStateAfter(b.createStateAfter()); |
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
155 } |
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
156 } |
4178f9830a27
Assign the state after when appending the node and not automatically in the main graph builder loop.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19801
diff
changeset
|
157 |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 return true; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 protected ValueNode createNodeIntrinsic(GraphBuilderContext b, ResolvedJavaMethod method, NodeIntrinsic intrinsic, List<ValueNode> args, Stamp stamp) { |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 ValueNode res = nodeIntrinsification.createIntrinsicNode(args, stamp, method, b.getGraph(), intrinsic); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 assert res != null || b.getRootMethod().getAnnotation(Snippet.class) != null : String.format( |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 "Could not create node intrinsic for call to %s as one of the arguments expected to be constant isn't: arguments=%s", method.format("%H.%n(%p)"), args); |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 return res; |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 } |
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 } |