Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/SelfReplacingMethodCallTargetNode.java @ 17328:c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 03 Oct 2014 14:19:58 +0200 |
parents | 655f3e6b467b |
children | 45b45f902bed |
rev | line source |
---|---|
9691 | 1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
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 |
9691 | 40 public class SelfReplacingMethodCallTargetNode extends MethodCallTargetNode implements Lowerable { |
41 | |
42 // Replacement method data | |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
43 protected final ResolvedJavaMethod replacementTargetMethod; |
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
44 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
|
45 @Input NodeInputList<ValueNode> replacementArguments; |
9691 | 46 |
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
|
47 public static SelfReplacingMethodCallTargetNode create(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, |
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
|
48 ResolvedJavaMethod replacementTargetMethod, ValueNode[] replacementArguments, JavaType replacementReturnType) { |
16920
77981382473e
fixed eclipseformat issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
49 return USE_GENERATED_NODES ? new SelfReplacingMethodCallTargetNodeGen(invokeKind, targetMethod, arguments, returnType, replacementTargetMethod, replacementArguments, replacementReturnType) |
77981382473e
fixed eclipseformat issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
50 : new SelfReplacingMethodCallTargetNode(invokeKind, targetMethod, arguments, returnType, replacementTargetMethod, replacementArguments, replacementReturnType); |
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
|
51 } |
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
|
52 |
17306
845e881ce054
constructors in a Node class must be protected
Doug Simon <doug.simon@oracle.com>
parents:
17276
diff
changeset
|
53 protected SelfReplacingMethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, ResolvedJavaMethod replacementTargetMethod, |
9691 | 54 ValueNode[] replacementArguments, JavaType replacementReturnType) { |
55 super(invokeKind, targetMethod, arguments, returnType); | |
56 this.replacementTargetMethod = replacementTargetMethod; | |
57 this.replacementReturnType = replacementReturnType; | |
58 this.replacementArguments = new NodeInputList<>(this, replacementArguments); | |
59 } | |
60 | |
61 public ResolvedJavaMethod replacementTargetMethod() { | |
62 return replacementTargetMethod; | |
63 } | |
64 | |
65 public JavaType replacementReturnType() { | |
66 return replacementReturnType; | |
67 } | |
68 | |
69 public NodeInputList<ValueNode> replacementArguments() { | |
70 return replacementArguments; | |
71 } | |
72 | |
73 @Override | |
11579
ae619d70bf4b
Rename LoweringType to GuardsPhase and make it an attribute of StructuredGraphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
9691
diff
changeset
|
74 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
|
75 InvokeKind replacementInvokeKind = replacementTargetMethod.isStatic() ? InvokeKind.Static : InvokeKind.Special; |
9691 | 76 MethodCallTargetNode replacement = graph().add( |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
16920
diff
changeset
|
77 MethodCallTargetNode.create(replacementInvokeKind, replacementTargetMethod, replacementArguments.toArray(new ValueNode[replacementArguments.size()]), replacementReturnType)); |
9691 | 78 |
79 // Replace myself... | |
80 this.replaceAndDelete(replacement); | |
81 } | |
82 | |
83 @Override | |
14950
d5a1206e1923
NodeLIRBuilderTool: fix typo in interface name.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
84 public void generate(NodeLIRBuilderTool gen) { |
9691 | 85 throw GraalInternalError.shouldNotReachHere("should have replaced itself"); |
86 } | |
87 } |