Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/SnippetIntrinsificationPhase.java @ 5531:816fb2492760
Remove architecture boolean from Ri* interfaces.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 08 Jun 2012 22:00:05 +0200 |
parents | 426c605c9d3c |
children | e18ba36bfebc |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
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.compiler.phases; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.lang.reflect.*; |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
26 import java.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
28 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5503
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
30 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.graph.Node.ConstantNodeParameter; |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
32 import com.oracle.graal.graph.Node.Fold; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.graph.Node.NodeIntrinsic; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.nodes.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 public class SnippetIntrinsificationPhase extends Phase { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 private final RiRuntime runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 private final BoxingMethodPool pool; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 public SnippetIntrinsificationPhase(RiRuntime runtime, BoxingMethodPool pool) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 this.runtime = runtime; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 this.pool = pool; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 protected void run(StructuredGraph graph) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 for (Invoke i : graph.getInvokes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 tryIntrinsify(i); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 private void tryIntrinsify(Invoke invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 RiResolvedMethod target = invoke.callTarget().targetMethod(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 if (intrinsic != null) { |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
60 assert target.getAnnotation(Node.Fold.class) == null; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
61 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 Class< ? >[] parameterTypes = CiUtil.signatureToTypes(target.signature(), target.holder()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 // Prepare the arguments for the reflective constructor call on the node class. |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
65 Object[] nodeConstructorArguments = prepareArguments(invoke, parameterTypes, target, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 // Create the new node instance. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 Class< ? > c = getNodeClass(target, intrinsic); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 Node newInstance = createNodeInstance(c, parameterTypes, nodeConstructorArguments); |
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 // Replace the invoke with the new node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 invoke.node().graph().add(newInstance); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 invoke.intrinsify(newInstance); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 // Clean up checkcast instructions inserted by javac if the return type is generic. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 cleanUpReturnCheckCast(newInstance); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
77 } else if (target.getAnnotation(Node.Fold.class) != null) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
78 Class< ? >[] parameterTypes = CiUtil.signatureToTypes(target.signature(), target.holder()); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
79 |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
80 // Prepare the arguments for the reflective method call |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
81 Object[] arguments = prepareArguments(invoke, parameterTypes, target, true); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
82 Object receiver = null; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
83 if (!invoke.callTarget().isStatic()) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
84 receiver = arguments[0]; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
85 arguments = Arrays.asList(arguments).subList(1, arguments.length).toArray(); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
86 } |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
87 |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
88 // Call the method |
5531
816fb2492760
Remove architecture boolean from Ri* interfaces.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
89 RiConstant constant = callMethod(target.signature().returnKind(), target.holder().toJava(), target.name(), parameterTypes, receiver, arguments); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
90 |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
91 if (constant != null) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
92 // Replace the invoke with the result of the call |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
93 ConstantNode node = ConstantNode.forCiConstant(constant, runtime, invoke.node().graph()); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
94 invoke.intrinsify(node); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
95 |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
96 // Clean up checkcast instructions inserted by javac if the return type is generic. |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
97 cleanUpReturnCheckCast(node); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
98 } else { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
99 // Remove the invoke |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
100 invoke.intrinsify(null); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
101 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
105 /** |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
106 * Converts the arguments of an invoke node to object values suitable for use as the arguments |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
107 * to a reflective invocation of a Java constructor or method. |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
108 * |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
109 * @param folding specifies if the invocation is for handling a {@link Fold} annotation |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
110 */ |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
111 private Object[] prepareArguments(Invoke invoke, Class< ? >[] parameterTypes, RiResolvedMethod target, boolean folding) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 NodeInputList<ValueNode> arguments = invoke.callTarget().arguments(); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
113 Object[] reflectionCallArguments = new Object[arguments.size()]; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
114 for (int i = 0; i < reflectionCallArguments.length; ++i) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 int parameterIndex = i; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 if (!invoke.callTarget().isStatic()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 parameterIndex--; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 ValueNode argument = tryBoxingElimination(parameterIndex, target, arguments.get(i)); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
120 if (folding || CiUtil.getParameterAnnotation(ConstantNodeParameter.class, parameterIndex, target) != null) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
121 assert argument instanceof ConstantNode : "parameter " + parameterIndex + " must be a compile time constant for calling " + invoke.callTarget().targetMethod() + ": " + argument; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 ConstantNode constantNode = (ConstantNode) argument; |
5501
d89b20486d87
Renaming CiConstant => RiConstant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
123 RiConstant constant = constantNode.asConstant(); |
5463
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
124 Object o = constant.boxedValue(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 if (o instanceof Class< ? >) { |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
126 reflectionCallArguments[i] = runtime.getType((Class< ? >) o); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 parameterTypes[i] = RiResolvedType.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 } else { |
5463
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
129 if (parameterTypes[i] == boolean.class) { |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
130 reflectionCallArguments[i] = Boolean.valueOf(constant.asInt() != 0); |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
131 } else if (parameterTypes[i] == byte.class) { |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
132 reflectionCallArguments[i] = Byte.valueOf((byte) constant.asInt()); |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
133 } else if (parameterTypes[i] == short.class) { |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
134 reflectionCallArguments[i] = Short.valueOf((short) constant.asInt()); |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
135 } else if (parameterTypes[i] == char.class) { |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
136 reflectionCallArguments[i] = Character.valueOf((char) constant.asInt()); |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
137 } else { |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
138 reflectionCallArguments[i] = o; |
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
139 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 } else { |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
142 reflectionCallArguments[i] = argument; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 parameterTypes[i] = ValueNode.class; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 } |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
146 return reflectionCallArguments; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
149 private static Class< ? > getNodeClass(RiResolvedMethod target, NodeIntrinsic intrinsic) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 Class< ? > result = intrinsic.value(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 if (result == NodeIntrinsic.class) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 result = target.holder().toJava(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 assert Node.class.isAssignableFrom(result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 private ValueNode tryBoxingElimination(int parameterIndex, RiResolvedMethod target, ValueNode node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 if (parameterIndex >= 0) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 Type type = target.getGenericParameterTypes()[parameterIndex]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 if (type instanceof TypeVariable) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 TypeVariable typeVariable = (TypeVariable) type; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 if (typeVariable.getBounds().length == 1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 Type boundType = typeVariable.getBounds()[0]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 if (boundType instanceof Class && ((Class) boundType).getSuperclass() == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 // Unbound generic => try boxing elimination |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 if (node.usages().size() == 2) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 if (node instanceof Invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 Invoke invokeNode = (Invoke) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 MethodCallTargetNode callTarget = invokeNode.callTarget(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 if (pool.isBoxingMethod(callTarget.targetMethod())) { |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
172 FrameState stateAfter = invokeNode.stateAfter(); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
173 assert stateAfter.usages().size() == 1; |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
174 invokeNode.node().replaceAtUsages(null); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
175 ValueNode result = callTarget.arguments().get(0); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
176 StructuredGraph graph = (StructuredGraph) node.graph(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 if (invokeNode instanceof InvokeWithExceptionNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 // Destroy exception edge & clear stateAfter. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invokeNode; |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
180 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 invokeWithExceptionNode.killExceptionEdge(); |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
182 graph.removeSplit(invokeWithExceptionNode, InvokeWithExceptionNode.NORMAL_EDGE); |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
183 } else { |
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
184 graph.removeFixed((InvokeNode) invokeNode); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 } |
4310
72d099e5be61
more CanonicalizerPhase simplifications, added Simplifiable interface
Lukas Stadler <lukas.stadler@jku.at>
parents:
4309
diff
changeset
|
186 stateAfter.safeDelete(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 GraphUtil.propagateKill(callTarget); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 return node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
199 private static Node createNodeInstance(Class< ? > nodeClass, Class< ? >[] parameterTypes, Object[] nodeConstructorArguments) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 Constructor< ? > constructor; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 constructor = nodeClass.getDeclaredConstructor(parameterTypes); |
4423
e8ce691d7923
Move Array copy, Unsafe and System snippets to hotspot specific project since they are hotspot specific.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
203 constructor.setAccessible(true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } catch (Exception e) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 throw new RuntimeException(e); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 return (ValueNode) constructor.newInstance(nodeConstructorArguments); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 } catch (Exception e) { |
5463
b6311d367bd6
support use of boolean, byte, char and short constant arguments in @NodeIntrinsic methods
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
210 throw new RuntimeException(constructor + Arrays.toString(nodeConstructorArguments), e); |
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 |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
214 /** |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
215 * Calls a Java method via reflection. |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
216 */ |
5503
438ab53efdd0
Renaming CiKind => RiKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5501
diff
changeset
|
217 private static RiConstant callMethod(RiKind returnKind, Class< ? > holder, String name, Class< ? >[] parameterTypes, Object receiver, Object[] arguments) { |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
218 Method method; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
219 try { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
220 method = holder.getDeclaredMethod(name, parameterTypes); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
221 method.setAccessible(true); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
222 } catch (Exception e) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
223 throw new RuntimeException(e); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
224 } |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
225 try { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
226 Object result = method.invoke(receiver, arguments); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
227 if (result == null) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
228 return null; |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
229 } |
5501
d89b20486d87
Renaming CiConstant => RiConstant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5487
diff
changeset
|
230 return RiConstant.forBoxed(returnKind, result); |
5175
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
231 } catch (Exception e) { |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
232 throw new RuntimeException(e); |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
233 } |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
234 } |
a8c5283a835c
added @Fold to folding methods during snippet intrinsification; replaced CardTableStartNode and CardTableShiftNode with @Fold methods
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
235 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 public void cleanUpReturnCheckCast(Node newInstance) { |
5503
438ab53efdd0
Renaming CiKind => RiKind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5501
diff
changeset
|
237 if (newInstance instanceof ValueNode && ((ValueNode) newInstance).kind() != RiKind.Object) { |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4199
diff
changeset
|
238 StructuredGraph graph = (StructuredGraph) newInstance.graph(); |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
239 for (CheckCastNode checkCastNode : newInstance.usages().filter(CheckCastNode.class).snapshot()) { |
5210
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5175
diff
changeset
|
240 for (ValueProxyNode vpn : checkCastNode.usages().filter(ValueProxyNode.class).snapshot()) { |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5175
diff
changeset
|
241 graph.replaceFloating(vpn, checkCastNode); |
e3e7542d78b7
Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5175
diff
changeset
|
242 } |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
243 for (Node checkCastUsage : checkCastNode.usages().snapshot()) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
244 if (checkCastUsage instanceof ValueAnchorNode) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
245 ValueAnchorNode valueAnchorNode = (ValueAnchorNode) checkCastUsage; |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
246 graph.removeFixed(valueAnchorNode); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
247 } else if (checkCastUsage instanceof MethodCallTargetNode) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
248 MethodCallTargetNode checkCastCallTarget = (MethodCallTargetNode) checkCastUsage; |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
249 assert pool.isUnboxingMethod(checkCastCallTarget.targetMethod()); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
250 Invoke invokeNode = checkCastCallTarget.invoke(); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
251 invokeNode.node().replaceAtUsages(newInstance); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
252 if (invokeNode instanceof InvokeWithExceptionNode) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
253 // Destroy exception edge & clear stateAfter. |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
254 InvokeWithExceptionNode invokeWithExceptionNode = (InvokeWithExceptionNode) invokeNode; |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4199
diff
changeset
|
255 |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
256 invokeWithExceptionNode.killExceptionEdge(); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
257 graph.removeSplit(invokeWithExceptionNode, InvokeWithExceptionNode.NORMAL_EDGE); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 } else { |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
259 graph.removeFixed((InvokeNode) invokeNode); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 } |
4411
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
261 checkCastCallTarget.safeDelete(); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
262 } else if (checkCastUsage instanceof FrameState) { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
263 checkCastUsage.replaceFirstInput(checkCastNode, null); |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
264 } else { |
cd2b68ef8e23
cleanup around filter and predicates :
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4310
diff
changeset
|
265 assert false : "unexpected checkcast usage: " + checkCastUsage; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 } |
5372
4485e0edd1af
made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
268 FixedNode next = checkCastNode.next(); |
4485e0edd1af
made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
269 checkCastNode.setNext(null); |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5463
diff
changeset
|
270 checkCastNode.replaceAtPredecessor(next); |
5372
4485e0edd1af
made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
271 GraphUtil.killCFG(checkCastNode); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 } |