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
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 /*
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
40 public class SelfReplacingMethodCallTargetNode extends MethodCallTargetNode implements Lowerable {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
41
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
54 ValueNode[] replacementArguments, JavaType replacementReturnType) {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
55 super(invokeKind, targetMethod, arguments, returnType);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
56 this.replacementTargetMethod = replacementTargetMethod;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
57 this.replacementReturnType = replacementReturnType;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
58 this.replacementArguments = new NodeInputList<>(this, replacementArguments);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
59 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
60
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
61 public ResolvedJavaMethod replacementTargetMethod() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
62 return replacementTargetMethod;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
63 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
64
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
65 public JavaType replacementReturnType() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
66 return replacementReturnType;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
67 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
68
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
69 public NodeInputList<ValueNode> replacementArguments() {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
70 return replacementArguments;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
71 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
72
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
78
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
79 // Replace myself...
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
80 this.replaceAndDelete(replacement);
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
81 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
82
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
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
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
85 throw GraalInternalError.shouldNotReachHere("should have replaced itself");
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
86 }
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents:
diff changeset
87 }