Mercurial > hg > truffle
annotate graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java @ 10730:f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 12 Jul 2013 22:52:05 +0200 |
parents | 2a4ad6ab345e |
children | c483912aaf70 |
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) 2009, 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.nodes.java; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
25 import static com.oracle.graal.api.code.DeoptimizationAction.*; |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
26 import static com.oracle.graal.api.meta.DeoptimizationReason.*; |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
27 |
10730
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
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:
5504
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
10730
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
30 import com.oracle.graal.api.meta.ProfilingInfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
33 import com.oracle.graal.nodes.calc.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
34 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.nodes.type.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 /** |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
38 * Implements a type check against a compile-time known type. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 */ |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
40 public final class CheckCastNode extends FixedWithNextNode implements Canonicalizable, Lowerable, Node.IterableNodeType, Virtualizable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
5370 | 42 @Input private ValueNode object; |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
43 private final ResolvedJavaType type; |
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
|
44 private final JavaTypeProfile profile; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 /** |
9478
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
47 * Determines the exception thrown by this node if the check fails: {@link ClassCastException} |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
48 * if false; {@link ArrayStoreException} if true. |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
49 */ |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
50 private final boolean forStoreCheck; |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
51 |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
52 /** |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 * Creates a new CheckCast instruction. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7394
diff
changeset
|
54 * |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
55 * @param type the type being cast to |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 * @param object the instruction producing the object |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 */ |
9478
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
58 public CheckCastNode(ResolvedJavaType type, ValueNode object, JavaTypeProfile profile, boolean forStoreCheck) { |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
59 super(StampFactory.declared(type)); |
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
60 assert type != null; |
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
61 this.type = type; |
5370 | 62 this.object = object; |
63 this.profile = profile; | |
9478
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
64 this.forStoreCheck = forStoreCheck; |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
65 } |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
66 |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
67 public boolean isForStoreCheck() { |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
68 return forStoreCheck; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 |
10729
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
71 // TODO (ds) remove once performance regression in compiler.sunflow (and other benchmarks) |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
72 // caused by new lowering is fixed |
10730
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
73 private static final boolean useNewLowering = true; // Boolean.getBoolean("graal.checkcast.useNewLowering"); |
10729
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
74 |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
75 /** |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
76 * Lowers a {@link CheckCastNode} to a {@link GuardingPiNode}. That is: |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
77 * |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
78 * <pre> |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
79 * 1: A a = ... |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
80 * 2: B b = (B) a; |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
81 * </pre> |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
82 * |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
83 * is lowered to: |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
84 * |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
85 * <pre> |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
86 * 1: A a = ... |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
87 * 2: B b = guardingPi(a == null || a instanceof B, a, stamp(B)) |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
88 * </pre> |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
89 * |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
90 * or if a is known to be non-null: |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
91 * |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
92 * <pre> |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
93 * 1: A a = ... |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
94 * 2: B b = guardingPi(a instanceof B, a, stamp(B, non-null)) |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
95 * </pre> |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
96 * |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
97 * Note: we use {@link Graph#add} as opposed to {@link Graph#unique} for the new |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
98 * {@link InstanceOfNode} to maintain the invariant checked by |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
99 * {@code LoweringPhase.checkUsagesAreScheduled()}. |
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
100 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 @Override |
9251
435bb9425124
added enum to Lowerable interface (before/after guard lowering)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9197
diff
changeset
|
102 public void lower(LoweringTool tool, LoweringType loweringType) { |
10729
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
103 if (useNewLowering) { |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
104 InstanceOfNode typeTest = graph().add(new InstanceOfNode(type, object, profile)); |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
105 Stamp stamp = StampFactory.declared(type).join(object.stamp()); |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
106 ValueNode condition; |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
107 if (stamp == null) { |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
108 // This is a check cast that will always fail |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
109 condition = LogicConstantNode.contradiction(graph()); |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
110 stamp = StampFactory.declared(type); |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
111 } else if (object.stamp().nonNull()) { |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
112 condition = typeTest; |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
113 } else { |
10730
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
114 if (profile != null && profile.getNullSeen() == TriState.FALSE) { |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
115 FixedGuardNode nullGuard = graph().add(new FixedGuardNode(graph().unique(new IsNullNode(object)), UnreachedCode, DeoptimizationAction.InvalidateReprofile, true)); |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
116 graph().addBeforeFixed(this, nullGuard); |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
117 condition = typeTest; |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
118 stamp = stamp.join(StampFactory.objectNonNull()); |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
119 } else { |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
120 condition = graph().unique(new LogicDisjunctionNode(graph().unique(new IsNullNode(object)), typeTest)); |
f1904749e4fe
re-enabled new lowering of checkcast with addition of a null-check guard where the profile has nullSeen=FALSE
Doug Simon <doug.simon@oracle.com>
parents:
10729
diff
changeset
|
121 } |
10729
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
122 } |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
123 GuardingPiNode checkedObject = graph().add(new GuardingPiNode(object, condition, false, forStoreCheck ? ArrayStoreException : ClassCastException, InvalidateReprofile, stamp)); |
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
124 graph().replaceFixedWithFixed(this, checkedObject); |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
125 } else { |
10729
2a4ad6ab345e
disabled new lowering of checkcast until performance regression is fixed
Doug Simon <doug.simon@oracle.com>
parents:
10712
diff
changeset
|
126 tool.getRuntime().lower(this, tool); |
10693
f8adf47cc05e
checkcast is lowered to instanceof (GRAAL-248)
Doug Simon <doug.simon@oracle.com>
parents:
9786
diff
changeset
|
127 } |
5379
c862951e769d
moved checkcast lowering into LoweringPhase and added -G:HIRLowerCheckcast option to enable it (disabled by default) as it is not yet stable
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
128 } |
c862951e769d
moved checkcast lowering into LoweringPhase and added -G:HIRLowerCheckcast option to enable it (disabled by default) as it is not yet stable
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
129 |
c862951e769d
moved checkcast lowering into LoweringPhase and added -G:HIRLowerCheckcast option to enable it (disabled by default) as it is not yet stable
Doug Simon <doug.simon@oracle.com>
parents:
5372
diff
changeset
|
130 @Override |
5831
ed08c40d67de
Add a alwaysNull property to ObjectStamp (Phi(null, a! A) get a "a A" stamp and not just "a -")
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5720
diff
changeset
|
131 public boolean inferStamp() { |
7337
c1a5c3bc5656
more accurate inferStamp for UnsafeCastNode and CheckCastNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7097
diff
changeset
|
132 return updateStamp(stamp().join(object().stamp())); |
5831
ed08c40d67de
Add a alwaysNull property to ObjectStamp (Phi(null, a! A) get a "a A" stamp and not just "a -")
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5720
diff
changeset
|
133 } |
ed08c40d67de
Add a alwaysNull property to ObjectStamp (Phi(null, a! A) get a "a A" stamp and not just "a -")
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5720
diff
changeset
|
134 |
ed08c40d67de
Add a alwaysNull property to ObjectStamp (Phi(null, a! A) get a "a A" stamp and not just "a -")
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5720
diff
changeset
|
135 @Override |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4199
diff
changeset
|
136 public ValueNode canonical(CanonicalizerTool tool) { |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5299
diff
changeset
|
137 assert object() != null : this; |
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5299
diff
changeset
|
138 |
9478
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
139 ResolvedJavaType objectType = object().objectStamp().type(); |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
140 if (objectType != null && type.isAssignableFrom(objectType)) { |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
141 // we don't have to check for null types here because they will also pass the |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
142 // checkcast. |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
143 return object(); |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
144 } |
9543
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
145 |
9493
38b07e59dcbb
CheckCastNode: better attempt to combine checkcasts
Bernhard Urban <bernhard.urban@jku.at>
parents:
9478
diff
changeset
|
146 // remove checkcast if next node is a more specific checkcast |
9543
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
147 if (predecessor() instanceof CheckCastNode) { |
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
148 CheckCastNode ccn = (CheckCastNode) predecessor(); |
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
149 if (ccn != null && ccn.type != null && ccn == object && ccn.forStoreCheck == forStoreCheck && ccn.type.isAssignableFrom(type)) { |
9602
19c5a07c7843
Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9543
diff
changeset
|
150 StructuredGraph graph = ccn.graph(); |
9543
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
151 CheckCastNode newccn = graph.add(new CheckCastNode(type, ccn.object, ccn.profile, ccn.forStoreCheck)); |
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
152 graph.replaceFixedWithFixed(ccn, newccn); |
f8a5f7f7d0bd
CheckCastNode: eliminate the other way around
Bernhard Urban <bernhard.urban@jku.at>
parents:
9494
diff
changeset
|
153 return newccn; |
5417
791eb4f85b29
Use exact type for check cast canonicalization if available
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5379
diff
changeset
|
154 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 } |
5339
e8f80481326d
use PiNodes instead of CheckCastNodes to pin inlining receivers, remove emitCode flag
Lukas Stadler <lukas.stadler@jku.at>
parents:
5299
diff
changeset
|
156 |
5831
ed08c40d67de
Add a alwaysNull property to ObjectStamp (Phi(null, a! A) get a "a A" stamp and not just "a -")
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5720
diff
changeset
|
157 if (object().objectStamp().alwaysNull()) { |
ed08c40d67de
Add a alwaysNull property to ObjectStamp (Phi(null, a! A) get a "a A" stamp and not just "a -")
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5720
diff
changeset
|
158 return object(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 } |
9478
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
160 if (tool.assumptions().useOptimisticAssumptions()) { |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
161 ResolvedJavaType exactType = type.findUniqueConcreteSubtype(); |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
162 if (exactType != null && exactType != type) { |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
163 // Propagate more precise type information to usages of the checkcast. |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
164 tool.assumptions().recordConcreteSubtype(type, exactType); |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
165 return graph().add(new CheckCastNode(exactType, object, profile, forStoreCheck)); |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
166 } |
fb22b4d5f475
Allow distinction between ClassCastException and ArrayStoreException. Add more canonicalizations for check casts.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9251
diff
changeset
|
167 } |
9197
9b455ec15820
canonicalizer: eliminate nested checkcasts
Bernhard Urban <bernhard.urban@jku.at>
parents:
8961
diff
changeset
|
168 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 return this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 |
5370 | 172 public ValueNode object() { |
173 return object; | |
174 } | |
175 | |
176 /** | |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
177 * Gets the type being cast to. |
5370 | 178 */ |
6648
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
179 public ResolvedJavaType type() { |
7bf5a6c42db7
factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
180 return type; |
5370 | 181 } |
182 | |
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
|
183 public JavaTypeProfile profile() { |
5370 | 184 return profile; |
185 } | |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
186 |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
187 @Override |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
188 public void virtualize(VirtualizerTool tool) { |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7337
diff
changeset
|
189 State state = tool.getObjectState(object); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7337
diff
changeset
|
190 if (state != null && state.getState() == EscapeState.Virtual) { |
8961
1b5eeb50e690
PEA: fix virtualization of CheckCastNode (check type)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
191 if (type.isAssignableFrom(state.getVirtualObject().type())) { |
1b5eeb50e690
PEA: fix virtualization of CheckCastNode (check type)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
192 tool.replaceWithVirtual(state.getVirtualObject()); |
1b5eeb50e690
PEA: fix virtualization of CheckCastNode (check type)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
193 } |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
194 } |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6648
diff
changeset
|
195 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 } |