Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java @ 19403:7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 16 Feb 2015 15:43:03 +0100 |
parents | f57d86eb036f |
children | 61d3cb8e1280 |
rev | line source |
---|---|
9691 | 1 /* |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
9691 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.nodes.java; | |
24 | |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14950
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14991
diff
changeset
|
26 import com.oracle.graal.compiler.common.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14950
diff
changeset
|
27 import com.oracle.graal.graph.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16811
diff
changeset
|
28 import com.oracle.graal.nodeinfo.*; |
11579
ae619d70bf4b
Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9691
diff
changeset
|
29 import com.oracle.graal.nodes.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14950
diff
changeset
|
30 import com.oracle.graal.nodes.spi.*; |
9691 | 31 |
32 /** | |
33 * A SelfReplacingMethodCallTargetNode replaces itself in the graph when being lowered with a | |
34 * {@link MethodCallTargetNode} that calls the stored replacement target method. | |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
35 * |
9691 | 36 * This node is used for method handle call nodes which have a constant call target but are not |
37 * inlined. | |
38 */ | |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
15311
diff
changeset
|
39 @NodeInfo |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
40 public final class SelfReplacingMethodCallTargetNode extends MethodCallTargetNode implements Lowerable { |
9691 | 41 |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
42 public static final NodeClass TYPE = NodeClass.get(SelfReplacingMethodCallTargetNode.class); |
9691 | 43 // Replacement method data |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
44 protected final ResolvedJavaMethod replacementTargetMethod; |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
45 protected final JavaType replacementReturnType; |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
46 @Input NodeInputList<ValueNode> replacementArguments; |
9691 | 47 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18571
diff
changeset
|
48 public SelfReplacingMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod replacementTargetMethod, |
9691 | 49 ValueNode[] replacementArguments, JavaType replacementReturnType) { |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
50 super(TYPE, invokeKind, targetMethod, arguments, returnType); |
9691 | 51 this.replacementTargetMethod = replacementTargetMethod; |
52 this.replacementReturnType = replacementReturnType; | |
53 this.replacementArguments = new NodeInputList<>(this, replacementArguments); | |
54 } | |
55 | |
56 public ResolvedJavaMethod replacementTargetMethod() { | |
57 return replacementTargetMethod; | |
58 } | |
59 | |
60 public JavaType replacementReturnType() { | |
61 return replacementReturnType; | |
62 } | |
63 | |
64 public NodeInputList<ValueNode> replacementArguments() { | |
65 return replacementArguments; | |
66 } | |
67 | |
68 @Override | |
11579
ae619d70bf4b
Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9691
diff
changeset
|
69 public void lower(LoweringTool tool) { |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16920
diff
changeset
|
70 InvokeKind replacementInvokeKind = replacementTargetMethod.isStatic() ? InvokeKind.Static : InvokeKind.Special; |
9691 | 71 MethodCallTargetNode replacement = graph().add( |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18571
diff
changeset
|
72 new MethodCallTargetNode(replacementInvokeKind, replacementTargetMethod, replacementArguments.toArray(new ValueNode[replacementArguments.size()]), replacementReturnType)); |
9691 | 73 |
74 // Replace myself... | |
75 this.replaceAndDelete(replacement); | |
76 } | |
77 | |
78 @Override | |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
79 public void generate(NodeLIRBuilderTool gen) { |
9691 | 80 throw GraalInternalError.shouldNotReachHere("should have replaced itself"); |
81 } | |
82 } |