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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
4 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
8 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
13 * accompanied this code).
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
14 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
18 *
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
21 * questions.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
22 */
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
23 package com.oracle.graal.nodes.java;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
31
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
32 /**
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
33 * A SelfReplacingMethodCallTargetNode replaces itself in the graph when being lowered with a
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
36 * This node is used for method handle call nodes which have a constant call target but are not
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
37 * inlined.
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
51 this.replacementTargetMethod = replacementTargetMethod;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
52 this.replacementReturnType = replacementReturnType;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
53 this.replacementArguments = new NodeInputList<>(this, replacementArguments);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
54 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
55
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
56 public ResolvedJavaMethod replacementTargetMethod() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
57 return replacementTargetMethod;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
58 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
59
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
60 public JavaType replacementReturnType() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
61 return replacementReturnType;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
62 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
63
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
64 public NodeInputList<ValueNode> replacementArguments() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
65 return replacementArguments;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
66 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
67
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
73
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
74 // Replace myself...
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
75 this.replaceAndDelete(replacement);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
76 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
77
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
80 throw GraalInternalError.shouldNotReachHere("should have replaced itself");
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
81 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
82 }