annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java @ 23394:964f28c04d7b default tip

Don't fill the code cache with nmethods from CTW
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Fri, 05 Feb 2016 22:48:36 -0800
parents 615f3bbbb174
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19313
diff changeset
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.nodes.java;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
22790
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
25 import jdk.vm.ci.code.BytecodeFrame;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
26 import jdk.vm.ci.meta.Assumptions;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
27 import jdk.vm.ci.meta.Assumptions.AssumptionResult;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
28 import jdk.vm.ci.meta.DeoptimizationAction;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
29 import jdk.vm.ci.meta.DeoptimizationReason;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
30 import jdk.vm.ci.meta.JavaKind;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
31 import jdk.vm.ci.meta.JavaType;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
32 import jdk.vm.ci.meta.JavaTypeProfile;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
33 import jdk.vm.ci.meta.ResolvedJavaMethod;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
34 import jdk.vm.ci.meta.ResolvedJavaType;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 22037
diff changeset
35
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
36 import com.oracle.graal.compiler.common.type.Stamp;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
37 import com.oracle.graal.compiler.common.type.StampFactory;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
38 import com.oracle.graal.graph.IterableNodeType;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
39 import com.oracle.graal.graph.Node;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
40 import com.oracle.graal.graph.NodeClass;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
41 import com.oracle.graal.graph.spi.Simplifiable;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
42 import com.oracle.graal.graph.spi.SimplifierTool;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
43 import com.oracle.graal.nodeinfo.NodeInfo;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
44 import com.oracle.graal.nodeinfo.Verbosity;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
45 import com.oracle.graal.nodes.CallTargetNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
46 import com.oracle.graal.nodes.FixedGuardNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
47 import com.oracle.graal.nodes.Invoke;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
48 import com.oracle.graal.nodes.LogicNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
49 import com.oracle.graal.nodes.PiNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
50 import com.oracle.graal.nodes.StructuredGraph;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
51 import com.oracle.graal.nodes.ValueNode;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
52 import com.oracle.graal.nodes.spi.UncheckedInterfaceProvider;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22604
diff changeset
53 import com.oracle.graal.nodes.type.StampTool;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54
16811
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16565
diff changeset
55 @NodeInfo
18184
49898cb251d8 Make MethodCallTargetNode Simplifiable (instead of Canonicalizable).
Josef Eisl <josef.eisl@jku.at>
parents: 17450
diff changeset
56 public class MethodCallTargetNode extends CallTargetNode implements IterableNodeType, Simplifiable {
19529
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19471
diff changeset
57 public static final NodeClass<MethodCallTargetNode> TYPE = NodeClass.create(MethodCallTargetNode.class);
17328
c9bb0da795d4 Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents: 17327
diff changeset
58 protected final JavaType returnType;
22037
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
59 protected JavaTypeProfile profile;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60
22037
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
61 public MethodCallTargetNode(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType, JavaTypeProfile profile) {
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
62 this(TYPE, invokeKind, targetMethod, arguments, returnType, profile);
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19313
diff changeset
63 }
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19313
diff changeset
64
22037
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
65 protected MethodCallTargetNode(NodeClass<? extends MethodCallTargetNode> c, InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] arguments, JavaType returnType,
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
66 JavaTypeProfile profile) {
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19313
diff changeset
67 super(c, arguments, targetMethod, invokeKind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 this.returnType = returnType;
22037
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
69 this.profile = profile;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 * Gets the instruction that produces the receiver object for this invocation, if any.
15102
175111728365 improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14908
diff changeset
74 *
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
75 * @return the instruction that produces the receiver object for this invocation if any,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7510
diff changeset
76 * {@code null} if this invocation does not take a receiver object
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 public ValueNode receiver() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 return isStatic() ? null : arguments().get(0);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 * Checks whether this is an invocation of a static method.
15102
175111728365 improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14908
diff changeset
84 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 * @return {@code true} if the invocation is a static invocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 public boolean isStatic() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 return invokeKind() == InvokeKind.Static;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22531
diff changeset
91 public JavaKind returnKind() {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6409
diff changeset
92 return targetMethod().getSignature().getReturnKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 public Invoke invoke() {
4411
cd2b68ef8e23 cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4309
diff changeset
96 return (Invoke) this.usages().first();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 public boolean verify() {
18969
14496953435e Use Node#getUsageCount wherever possible.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18845
diff changeset
101 assert getUsageCount() <= 1 : "call target may only be used by a single invoke";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 for (Node n : usages()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 assertTrue(n instanceof Invoke, "call target can only be used from an invoke (%s)", n);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 }
18822
fad37aaed6d2 Add utilities isDirect and isIndirect to InvokeKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18687
diff changeset
105 if (invokeKind().isDirect()) {
18823
5a21cac1968f Add utilities ModifiersProvider#isConcrete, ResolvedJavaMethod#hasReceiver, ResolvedJavaMethod#hasBytecodes to Graal API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18822
diff changeset
106 assertTrue(targetMethod().isConcrete(), "special calls or static calls are only allowed for concrete methods (%s)", targetMethod());
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
107 }
16565
2b63e51e7789 Move invokeKind into CallTragetNode from its subclasses
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16564
diff changeset
108 if (invokeKind() == InvokeKind.Static) {
16564
688f84e397a3 Move the target method from MethodCallTargetNode and LoweredCallTargetNode to their superclass CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
109 assertTrue(targetMethod().isStatic(), "static calls are only allowed for static methods (%s)", targetMethod());
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
110 } else {
16564
688f84e397a3 Move the target method from MethodCallTargetNode and LoweredCallTargetNode to their superclass CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
111 assertFalse(targetMethod().isStatic(), "static calls are only allowed for non-static methods (%s)", targetMethod());
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7686
diff changeset
112 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 return super.verify();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 public String toString(Verbosity verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 if (verbosity == Verbosity.Long) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 return super.toString(Verbosity.Short) + "(" + targetMethod() + ")";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 return super.toString(verbosity);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19134
diff changeset
125 public static ResolvedJavaMethod findSpecialCallTarget(InvokeKind invokeKind, ValueNode receiver, ResolvedJavaMethod targetMethod, ResolvedJavaType contextType) {
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
126 if (invokeKind.isDirect()) {
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
127 return null;
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
128 }
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
129
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
130 // check for trivial cases (e.g. final methods, nonvirtual methods)
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
131 if (targetMethod.canBeStaticallyBound()) {
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
132 return targetMethod;
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
133 }
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
135 ResolvedJavaType type = StampTool.typeOrNull(receiver);
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
136 if (type == null && invokeKind == InvokeKind.Virtual) {
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
137 // For virtual calls, we are guaranteed to receive a correct receiver type.
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
138 type = targetMethod.getDeclaringClass();
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
139 }
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
140
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
141 if (type != null) {
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
142 /*
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
143 * either the holder class is exact, or the receiver object has an exact type, or it's
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
144 * an array type
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
145 */
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
146 ResolvedJavaMethod resolvedMethod = type.resolveConcreteMethod(targetMethod, contextType);
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
147 if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || StampTool.isExactType(receiver) || type.isArray())) {
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
148 return resolvedMethod;
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
149 }
22531
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
150
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19134
diff changeset
151 Assumptions assumptions = receiver.graph().getAssumptions();
22531
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
152 AssumptionResult<ResolvedJavaType> leafConcreteSubtype = type.findLeafConcreteSubtype();
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
153 if (leafConcreteSubtype != null && leafConcreteSubtype.canRecordTo(assumptions)) {
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
154 ResolvedJavaMethod methodFromUniqueType = leafConcreteSubtype.getResult().resolveConcreteMethod(targetMethod, contextType);
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
155 if (methodFromUniqueType != null) {
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
156 leafConcreteSubtype.recordTo(assumptions);
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
157 return methodFromUniqueType;
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
158 }
22531
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
159 }
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
160
22531
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
161 AssumptionResult<ResolvedJavaMethod> uniqueConcreteMethod = type.findUniqueConcreteMethod(targetMethod);
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
162 if (uniqueConcreteMethod != null && uniqueConcreteMethod.canRecordTo(assumptions)) {
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
163 uniqueConcreteMethod.recordTo(assumptions);
ce2b71115ade Invert logic for recording the assumptions of an AssumptionResult to Assumptions; this allows using assumption-free AssumptionResults when compiling without speculative optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22169
diff changeset
164 return uniqueConcreteMethod.getResult();
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
165 }
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
166 }
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
167
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
168 return null;
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
169 }
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
170
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 @Override
18184
49898cb251d8 Make MethodCallTargetNode Simplifiable (instead of Canonicalizable).
Josef Eisl <josef.eisl@jku.at>
parents: 17450
diff changeset
172 public void simplify(SimplifierTool tool) {
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
173 // attempt to devirtualize the call
21155
754f2b20d8bc Skip invokes with a placeholder framestate in MethodCallTargetNode.simplify
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19801
diff changeset
174 if (invoke().getContextMethod() == null) {
754f2b20d8bc Skip invokes with a placeholder framestate in MethodCallTargetNode.simplify
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19801
diff changeset
175 // avoid invokes that have placeholder bcis: they do not have a valid contextType
754f2b20d8bc Skip invokes with a placeholder framestate in MethodCallTargetNode.simplify
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19801
diff changeset
176 assert (invoke().stateAfter() != null && BytecodeFrame.isPlaceholderBci(invoke().stateAfter().bci)) || BytecodeFrame.isPlaceholderBci(invoke().stateDuring().bci);
754f2b20d8bc Skip invokes with a placeholder framestate in MethodCallTargetNode.simplify
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19801
diff changeset
177 return;
754f2b20d8bc Skip invokes with a placeholder framestate in MethodCallTargetNode.simplify
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19801
diff changeset
178 }
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
179 ResolvedJavaType contextType = (invoke().stateAfter() == null && invoke().stateDuring() == null) ? null : invoke().getContextType();
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19134
diff changeset
180 ResolvedJavaMethod specialCallTarget = findSpecialCallTarget(invokeKind, receiver(), targetMethod, contextType);
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
181 if (specialCallTarget != null) {
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
182 this.setTargetMethod(specialCallTarget);
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
183 setInvokeKind(InvokeKind.Special);
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
184 return;
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
185 }
14746
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
186
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
187 if (invokeKind().isIndirect() && invokeKind().isInterface()) {
14746
7544068e1a91 Perform de-virtualization of calls only in canonicalizer and not in graph builder
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14158
diff changeset
188
15102
175111728365 improve canBeStaticallyBound
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14908
diff changeset
189 // check if the type of the receiver can narrow the result
18687
2885aafd812f Backout useless changeset c2b23f6e4603
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18504
diff changeset
190 ValueNode receiver = receiver();
15727
fa66540676ce Try to devirtualize using unique concrete method and subtype in MethodCallTargetNode.canonical
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15722
diff changeset
191
18687
2885aafd812f Backout useless changeset c2b23f6e4603
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18504
diff changeset
192 // try to turn a interface call into a virtual call
18257
4a41f32ed552 MethodCallTargetNode: better variable names.
Josef Eisl <josef.eisl@jku.at>
parents: 18250
diff changeset
193 ResolvedJavaType declaredReceiverType = targetMethod().getDeclaringClass();
18313
6b8bceeecb30 MethodCallTargetNode: also simplify default method calls to virtual calls if possible.
Josef Eisl <josef.eisl@jku.at>
parents: 18257
diff changeset
194 /*
18314
3cc813ce3cea MethodCallTargetNode: document the single implementor optimization.
Josef Eisl <josef.eisl@jku.at>
parents: 18313
diff changeset
195 * We need to check the invoke kind to avoid recursive simplification for virtual
3cc813ce3cea MethodCallTargetNode: document the single implementor optimization.
Josef Eisl <josef.eisl@jku.at>
parents: 18313
diff changeset
196 * interface methods calls.
18313
6b8bceeecb30 MethodCallTargetNode: also simplify default method calls to virtual calls if possible.
Josef Eisl <josef.eisl@jku.at>
parents: 18257
diff changeset
197 */
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
198 if (declaredReceiverType.isInterface()) {
21381
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
199 tryCheckCastSingleImplementor(graph().getAssumptions(), receiver, declaredReceiverType);
18467
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
200 }
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
201
19134
0b05bd821399 Factor the findSpecialCallTarget logic when canonicalizing MethodCallTarget nodes into a static method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
202 if (receiver instanceof UncheckedInterfaceProvider) {
18467
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
203 UncheckedInterfaceProvider uncheckedInterfaceProvider = (UncheckedInterfaceProvider) receiver;
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
204 Stamp uncheckedStamp = uncheckedInterfaceProvider.uncheckedStamp();
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
205 if (uncheckedStamp != null) {
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
206 ResolvedJavaType uncheckedReceiverType = StampTool.typeOrNull(uncheckedStamp);
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
207 if (uncheckedReceiverType.isInterface()) {
21381
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
208 tryCheckCastSingleImplementor(graph().getAssumptions(), receiver, uncheckedReceiverType);
15727
fa66540676ce Try to devirtualize using unique concrete method and subtype in MethodCallTargetNode.canonical
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15722
diff changeset
209 }
fa66540676ce Try to devirtualize using unique concrete method and subtype in MethodCallTargetNode.canonical
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15722
diff changeset
210 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214
21381
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
215 private void tryCheckCastSingleImplementor(Assumptions assumptions, ValueNode receiver, ResolvedJavaType declaredReceiverType) {
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
216 if (assumptions == null) {
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
217 /*
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
218 * Even though we are not registering an assumption (see comment below), the
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
219 * optimization is only valid when speculative optimizations are enabled.
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
220 */
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
221 return;
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
222 }
d339bcb65015 Single-implementer optimization is an optimistic optimization, even though it does not register an assumption
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21155
diff changeset
223
18467
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
224 ResolvedJavaType singleImplementor = declaredReceiverType.getSingleImplementor();
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
225 if (singleImplementor != null && !singleImplementor.equals(declaredReceiverType)) {
22169
af6cc957bf04 Remove dummy parameter `includeAbstract` from `ResolvedJavaType#resolveMethod()`;
Josef Eisl <josef.eisl@jku.at>
parents: 22054
diff changeset
226 ResolvedJavaMethod singleImplementorMethod = singleImplementor.resolveMethod(targetMethod(), invoke().getContextType());
18467
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
227 if (singleImplementorMethod != null) {
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
228 /**
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
229 * We have an invoke on an interface with a single implementor. We can replace this
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
230 * with an invoke virtual.
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
231 *
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
232 * To do so we need to ensure two properties: 1) the receiver must implement the
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
233 * interface (declaredReceiverType). The verifier does not prove this so we need a
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
234 * dynamic check. 2) we need to ensure that there is still only one implementor of
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
235 * this interface, i.e. that we are calling the right method. We could do this with
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
236 * an assumption but as we need an instanceof check anyway we can verify both
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
237 * properties by checking of the receiver is an instance of the single implementor.
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
238 */
21765
a7a1b9b65bce Small improvement and clean up of InstanceOfNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21556
diff changeset
239 LogicNode condition = graph().unique(InstanceOfNode.create(singleImplementor, receiver, getProfile()));
19707
d57ca11a6883 Use FixedGuard in tryCheckcastSingleImplementor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19529
diff changeset
240 FixedGuardNode guard = graph().add(new FixedGuardNode(condition, DeoptimizationReason.OptimizedTypeCheckViolated, DeoptimizationAction.InvalidateRecompile, false));
d57ca11a6883 Use FixedGuard in tryCheckcastSingleImplementor
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19529
diff changeset
241 graph().addBeforeFixed(invoke().asNode(), guard);
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18823
diff changeset
242 PiNode piNode = graph().unique(new PiNode(receiver, StampFactory.declaredNonNull(singleImplementor), guard));
18467
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
243 arguments().set(0, piNode);
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
244 setInvokeKind(InvokeKind.Virtual);
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
245 setTargetMethod(singleImplementorMethod);
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
246 }
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
247 }
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
248 }
1d2e382d8259 Add UncheckedInterfaceProvider interface for nodes that can give an unchecked hint about the interface type they are likely to return.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 18315
diff changeset
249
22037
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
250 public JavaTypeProfile getProfile() {
0571d4a8d7cc Remove type profile proxy node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 21765
diff changeset
251 return profile;
18250
34cb95edfc97 MethodCallTargetNode: get profile from TypeProfileProxy if available.
Josef Eisl <josef.eisl@jku.at>
parents: 18244
diff changeset
252 }
34cb95edfc97 MethodCallTargetNode: get profile from TypeProfileProxy if available.
Josef Eisl <josef.eisl@jku.at>
parents: 18244
diff changeset
253
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
254 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 public Stamp returnStamp() {
22604
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22531
diff changeset
256 JavaKind returnKind = targetMethod().getSignature().getReturnKind();
b00cc0475f31 Update jvmci import: Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 22531
diff changeset
257 if (returnKind == JavaKind.Object && returnType instanceof ResolvedJavaType) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
258 return StampFactory.declared((ResolvedJavaType) returnType);
5283
8dd6165d7b73 compute returnStamp on demand in MethodCallTargetNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
259 } else {
8dd6165d7b73 compute returnStamp on demand in MethodCallTargetNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
260 return StampFactory.forKind(returnKind);
8dd6165d7b73 compute returnStamp on demand in MethodCallTargetNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
261 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 }
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
263
7684
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
264 public JavaType returnType() {
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
265 return returnType;
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
266 }
bbf97d6688d3 cleanup for the inlining policies
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7310
diff changeset
267
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
268 @Override
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
269 public String targetName() {
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
270 if (targetMethod() == null) {
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
271 return "??Invalid!";
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
272 }
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 16174
diff changeset
273 return targetMethod().format("%h.%n");
6409
823a2978e7ba Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5541
diff changeset
274 }
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
275
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
276 public static MethodCallTargetNode find(StructuredGraph graph, ResolvedJavaMethod method) {
19410
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
277 for (MethodCallTargetNode target : graph.getNodes(MethodCallTargetNode.TYPE)) {
16564
688f84e397a3 Move the target method from MethodCallTargetNode and LoweredCallTargetNode to their superclass CallTargetNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16563
diff changeset
278 if (target.targetMethod().equals(method)) {
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
279 return target;
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
280 }
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
281 }
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
282 return null;
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7123
diff changeset
283 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 }