Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java @ 19494:9525e4d5b385
disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
added GraphBuilderContext.getCurrentBlockGuard()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 11:16:19 +0100 |
parents | 7837f7aab5ed |
children | 97b35083d49d |
rev | line source |
---|---|
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
1 /* |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
4 * |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
8 * |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
14 * |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
18 * |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
22 */ |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.java; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
24 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.graph.iterators.NodePredicates.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
15558
diff
changeset
|
26 |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
27 import java.util.*; |
18922
fede93375dcb
Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18921
diff
changeset
|
28 import java.util.function.*; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
29 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
15198
2c0cfbf454b5
Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15145
diff
changeset
|
32 import com.oracle.graal.compiler.common.type.*; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.debug.*; |
19390
7f4201b633e7
renamed GraphBuilderPlugins to InvocationPlugins and consolidated it into GraphBuilderConfiguration; moved declaration of GraphBuilderPlugin sub-interfaces into GraphBuilderPlugin
Doug Simon <doug.simon@oracle.com>
parents:
19386
diff
changeset
|
34 import com.oracle.graal.java.GraphBuilderPlugin.ParameterPlugin; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
15558
diff
changeset
|
35 import com.oracle.graal.nodeinfo.*; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.*; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.calc.*; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.graal.nodes.java.*; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.graal.nodes.util.*; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
40 |
15031
14e542e27076
Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents:
15022
diff
changeset
|
41 public class HIRFrameStateBuilder extends AbstractFrameStateBuilder<ValueNode, HIRFrameStateBuilder> { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
42 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
43 private static final ValueNode[] EMPTY_ARRAY = new ValueNode[0]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
44 private static final MonitorIdNode[] EMPTY_MONITOR_ARRAY = new MonitorIdNode[0]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
45 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
46 private MonitorIdNode[] monitorIds; |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
47 private final StructuredGraph graph; |
18922
fede93375dcb
Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18921
diff
changeset
|
48 private final Supplier<FrameState> outerFrameStateSupplier; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
49 |
18918
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
50 /** |
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
51 * Creates a new frame state builder for the given method and the given target graph. |
18921
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
52 * |
18918
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
53 * @param method the method whose frame is simulated |
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
54 * @param graph the target graph of Graal nodes created by the builder |
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
55 */ |
19494
9525e4d5b385
disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents:
19479
diff
changeset
|
56 public HIRFrameStateBuilder(ResolvedJavaMethod method, StructuredGraph graph, boolean checkTypes, Supplier<FrameState> outerFrameStateSupplier) { |
9525e4d5b385
disable (asserting) type checks in the FrameStateBuilder when parsing a replacement
Doug Simon <doug.simon@oracle.com>
parents:
19479
diff
changeset
|
57 super(method, checkTypes); |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
58 |
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
59 assert graph != null; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
60 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
61 this.monitorIds = EMPTY_MONITOR_ARRAY; |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
62 this.graph = graph; |
18922
fede93375dcb
Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18921
diff
changeset
|
63 this.outerFrameStateSupplier = outerFrameStateSupplier; |
18918
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
64 } |
e8fd0342d9c4
GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18913
diff
changeset
|
65 |
18921
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
66 public final void initializeFromArgumentsArray(ValueNode[] arguments) { |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
67 |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
68 int javaIndex = 0; |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
69 int index = 0; |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
70 if (!method.isStatic()) { |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
71 // set the receiver |
19386
664b396dbe64
Do not use store local in HIRFrameStateBuilder as a simple write to the local array is sufficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19175
diff
changeset
|
72 locals[javaIndex] = arguments[index]; |
18921
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
73 javaIndex = 1; |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
74 index = 1; |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
75 } |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
76 Signature sig = method.getSignature(); |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
77 int max = sig.getParameterCount(false); |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
78 for (int i = 0; i < max; i++) { |
19386
664b396dbe64
Do not use store local in HIRFrameStateBuilder as a simple write to the local array is sufficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19175
diff
changeset
|
79 locals[javaIndex] = arguments[index]; |
18921
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
80 javaIndex += arguments[index].getKind().getSlotCount(); |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
81 index++; |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
82 } |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
83 } |
13e43d2a413e
Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18918
diff
changeset
|
84 |
19112
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
85 public final void initializeForMethodStart(boolean eagerResolve, ParameterPlugin parameterPlugin) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
86 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
87 int javaIndex = 0; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
88 int index = 0; |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15261
diff
changeset
|
89 if (!method.isStatic()) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
90 // add the receiver |
19112
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
91 FloatingNode receiver = null; |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
92 if (parameterPlugin != null) { |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
93 receiver = parameterPlugin.interceptParameter(index); |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
94 } |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
95 if (receiver == null) { |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
96 receiver = new ParameterNode(javaIndex, StampFactory.declaredNonNull(method.getDeclaringClass())); |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
97 } |
19386
664b396dbe64
Do not use store local in HIRFrameStateBuilder as a simple write to the local array is sufficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19175
diff
changeset
|
98 locals[javaIndex] = graph.unique(receiver); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
99 javaIndex = 1; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
100 index = 1; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
101 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
102 Signature sig = method.getSignature(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
103 int max = sig.getParameterCount(false); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
104 ResolvedJavaType accessingClass = method.getDeclaringClass(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
105 for (int i = 0; i < max; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
106 JavaType type = sig.getParameterType(i, accessingClass); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
107 if (eagerResolve) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
108 type = type.resolve(accessingClass); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
109 } |
15022
bceb077143ae
Preserve value range in stamp of ParameterNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
14978
diff
changeset
|
110 Kind kind = type.getKind(); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
111 Stamp stamp; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
112 if (kind == Kind.Object && type instanceof ResolvedJavaType) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
113 stamp = StampFactory.declared((ResolvedJavaType) type); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
114 } else { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
115 stamp = StampFactory.forKind(kind); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
116 } |
19112
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
117 FloatingNode param = null; |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
118 if (parameterPlugin != null) { |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
119 param = parameterPlugin.interceptParameter(index); |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
120 } |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
121 if (param == null) { |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
122 param = new ParameterNode(index, stamp); |
c2019f6e821b
Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18995
diff
changeset
|
123 } |
19386
664b396dbe64
Do not use store local in HIRFrameStateBuilder as a simple write to the local array is sufficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19175
diff
changeset
|
124 locals[javaIndex] = graph.unique(param); |
18913
51680f58e681
Clean up in Kind class. Introduce Kind#getSlotCount and Kind#needsTwoSlots methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18845
diff
changeset
|
125 javaIndex += kind.getSlotCount(); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
126 index++; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
127 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
128 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
129 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
130 private HIRFrameStateBuilder(HIRFrameStateBuilder other) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
131 super(other); |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
132 assert other.graph != null; |
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
133 graph = other.graph; |
18374
8971259db8ed
Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18230
diff
changeset
|
134 monitorIds = other.monitorIds.length == 0 ? other.monitorIds : other.monitorIds.clone(); |
18922
fede93375dcb
Initial version of inlining during parsing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18921
diff
changeset
|
135 this.outerFrameStateSupplier = other.outerFrameStateSupplier; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
136 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
137 assert locals.length == method.getMaxLocals(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
138 assert stack.length == Math.max(1, method.getMaxStackSize()); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
139 assert lockedObjects.length == monitorIds.length; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
140 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
141 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
142 @Override |
18374
8971259db8ed
Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18230
diff
changeset
|
143 protected ValueNode[] allocateArray(int length) { |
8971259db8ed
Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18230
diff
changeset
|
144 return length == 0 ? EMPTY_ARRAY : new ValueNode[length]; |
15031
14e542e27076
Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents:
15022
diff
changeset
|
145 } |
14e542e27076
Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents:
15022
diff
changeset
|
146 |
14e542e27076
Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents:
15022
diff
changeset
|
147 @Override |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
148 public String toString() { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
149 StringBuilder sb = new StringBuilder(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
150 sb.append("[locals: ["); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
151 for (int i = 0; i < locals.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
152 sb.append(i == 0 ? "" : ",").append(locals[i] == null ? "_" : locals[i].toString(Verbosity.Id)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
153 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
154 sb.append("] stack: ["); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
155 for (int i = 0; i < stackSize; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
156 sb.append(i == 0 ? "" : ",").append(stack[i] == null ? "_" : stack[i].toString(Verbosity.Id)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
157 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
158 sb.append("] locks: ["); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
159 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
160 sb.append(i == 0 ? "" : ",").append(lockedObjects[i].toString(Verbosity.Id)).append(" / ").append(monitorIds[i].toString(Verbosity.Id)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
161 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
162 sb.append("]"); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
163 if (rethrowException) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
164 sb.append(" rethrowException"); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
165 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
166 sb.append("]"); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
167 return sb.toString(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
168 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
169 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
170 public FrameState create(int bci) { |
18927
8da21b779982
Initialize FrameState with less copying.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18923
diff
changeset
|
171 FrameState outerFrameState = null; |
8da21b779982
Initialize FrameState with less copying.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18923
diff
changeset
|
172 if (outerFrameStateSupplier != null) { |
8da21b779982
Initialize FrameState with less copying.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18923
diff
changeset
|
173 outerFrameState = outerFrameStateSupplier.get(); |
8da21b779982
Initialize FrameState with less copying.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18923
diff
changeset
|
174 } |
18934
f7c940b59147
Avoid double copy of monitorIds list.
Roland Schatz <roland.schatz@oracle.com>
parents:
18927
diff
changeset
|
175 return graph.add(new FrameState(outerFrameState, method, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, false)); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
176 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
177 |
15031
14e542e27076
Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents:
15022
diff
changeset
|
178 @Override |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
179 public HIRFrameStateBuilder copy() { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
180 return new HIRFrameStateBuilder(this); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
181 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
182 |
15031
14e542e27076
Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents:
15022
diff
changeset
|
183 @Override |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
184 public boolean isCompatibleWith(HIRFrameStateBuilder other) { |
14803 | 185 assert method.equals(other.method) && graph == other.graph && localsSize() == other.localsSize() : "Can only compare frame states of the same method"; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
186 assert lockedObjects.length == monitorIds.length && other.lockedObjects.length == other.monitorIds.length : "mismatch between lockedObjects and monitorIds"; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
187 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
188 if (stackSize() != other.stackSize()) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
189 return false; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
190 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
191 for (int i = 0; i < stackSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
192 ValueNode x = stackAt(i); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
193 ValueNode y = other.stackAt(i); |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
194 if (x != y && (x == null || x.isDeleted() || y == null || y.isDeleted() || x.getKind() != y.getKind())) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
195 return false; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
196 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
197 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
198 if (lockedObjects.length != other.lockedObjects.length) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
199 return false; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
200 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
201 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
202 if (GraphUtil.originalValue(lockedObjects[i]) != GraphUtil.originalValue(other.lockedObjects[i]) || monitorIds[i] != other.monitorIds[i]) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
203 throw new BailoutException("unbalanced monitors"); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
204 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
205 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
206 return true; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
207 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
208 |
18995
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
209 public void merge(AbstractMergeNode block, HIRFrameStateBuilder other) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
210 assert isCompatibleWith(other); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
211 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
212 for (int i = 0; i < localsSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
213 storeLocal(i, merge(localAt(i), other.localAt(i), block)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
214 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
215 for (int i = 0; i < stackSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
216 storeStack(i, merge(stackAt(i), other.stackAt(i), block)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
217 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
218 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
219 lockedObjects[i] = merge(lockedObjects[i], other.lockedObjects[i], block); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
220 assert monitorIds[i] == other.monitorIds[i]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
221 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
222 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
223 |
18995
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
224 private ValueNode merge(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
225 if (currentValue == null || currentValue.isDeleted()) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
226 return null; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
227 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
228 } else if (block.isPhiAtMerge(currentValue)) { |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
229 if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) { |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14827
diff
changeset
|
230 propagateDelete((ValuePhiNode) currentValue); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
231 return null; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
232 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
233 ((PhiNode) currentValue).addInput(otherValue); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
234 return currentValue; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
235 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
236 } else if (currentValue != otherValue) { |
19173
396ca3a22ee8
Perform analysis for locals changed in the loop and avoid creating phis for loop invariant locals.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
237 assert !(block instanceof LoopBeginNode) : "Phi functions for loop headers are create eagerly for changed locals and all stack slots"; |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
238 if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
239 return null; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
240 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
241 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
242 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(currentValue.stamp().unrestricted(), block)); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
243 for (int i = 0; i < block.phiPredecessorCount(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
244 phi.addInput(currentValue); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
245 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
246 phi.addInput(otherValue); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
247 assert phi.valueCount() == block.phiPredecessorCount() + 1 : "valueCount=" + phi.valueCount() + " predSize= " + block.phiPredecessorCount(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
248 return phi; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
249 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
250 } else { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
251 return currentValue; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
252 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
253 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
254 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
255 private void propagateDelete(FloatingNode node) { |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14827
diff
changeset
|
256 assert node instanceof ValuePhiNode || node instanceof ProxyNode; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
257 if (node.isDeleted()) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
258 return; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
259 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
260 // Collect all phi functions that use this phi so that we can delete them recursively (after |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
261 // we delete ourselves to avoid circles). |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14827
diff
changeset
|
262 List<FloatingNode> propagateUsages = node.usages().filter(FloatingNode.class).filter(isA(ValuePhiNode.class).or(ProxyNode.class)).snapshot(); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
263 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
264 // Remove the phi function from all FrameStates where it is used and then delete it. |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14827
diff
changeset
|
265 assert node.usages().filter(isNotA(FrameState.class).nor(ValuePhiNode.class).nor(ProxyNode.class)).isEmpty() : "phi function that gets deletes must only be used in frame states"; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
266 node.replaceAtUsages(null); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
267 node.safeDelete(); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
268 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
269 for (FloatingNode phiUsage : propagateUsages) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
270 propagateDelete(phiUsage); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
271 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
272 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
273 |
19173
396ca3a22ee8
Perform analysis for locals changed in the loop and avoid creating phis for loop invariant locals.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
274 public void insertLoopPhis(LocalLiveness liveness, int loopId, LoopBeginNode loopBegin) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
275 for (int i = 0; i < localsSize(); i++) { |
19175
4cee43cd1315
Avoid creating loop phis only for non-OSR graphs.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19173
diff
changeset
|
276 if (loopBegin.graph().isOSR() || liveness.localIsChangedInLoop(loopId, i)) { |
19173
396ca3a22ee8
Perform analysis for locals changed in the loop and avoid creating phis for loop invariant locals.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
277 storeLocal(i, createLoopPhi(loopBegin, localAt(i))); |
396ca3a22ee8
Perform analysis for locals changed in the loop and avoid creating phis for loop invariant locals.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19112
diff
changeset
|
278 } |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
279 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
280 for (int i = 0; i < stackSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
281 storeStack(i, createLoopPhi(loopBegin, stackAt(i))); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
282 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
283 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
284 lockedObjects[i] = createLoopPhi(loopBegin, lockedObjects[i]); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
285 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
286 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
287 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
288 public void insertLoopProxies(LoopExitNode loopExit, HIRFrameStateBuilder loopEntryState) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
289 for (int i = 0; i < localsSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
290 ValueNode value = localAt(i); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
291 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
292 Debug.log(" inserting proxy for %s", value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
293 storeLocal(i, ProxyNode.forValue(value, loopExit, graph)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
294 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
295 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
296 for (int i = 0; i < stackSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
297 ValueNode value = stackAt(i); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
298 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
299 Debug.log(" inserting proxy for %s", value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
300 storeStack(i, ProxyNode.forValue(value, loopExit, graph)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
301 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
302 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
303 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
304 ValueNode value = lockedObjects[i]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
305 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
306 Debug.log(" inserting proxy for %s", value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
307 lockedObjects[i] = ProxyNode.forValue(value, loopExit, graph); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
308 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
309 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
310 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
311 |
18993
480bd3b1adcd
Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18934
diff
changeset
|
312 public void insertProxies(AbstractBeginNode begin) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
313 for (int i = 0; i < localsSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
314 ValueNode value = localAt(i); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
315 if (value != null) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
316 Debug.log(" inserting proxy for %s", value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
317 storeLocal(i, ProxyNode.forValue(value, begin, graph)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
318 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
319 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
320 for (int i = 0; i < stackSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
321 ValueNode value = stackAt(i); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
322 if (value != null) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
323 Debug.log(" inserting proxy for %s", value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
324 storeStack(i, ProxyNode.forValue(value, begin, graph)); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
325 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
326 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
327 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
328 ValueNode value = lockedObjects[i]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
329 if (value != null) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
330 Debug.log(" inserting proxy for %s", value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
331 lockedObjects[i] = ProxyNode.forValue(value, begin, graph); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
332 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
333 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
334 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
335 |
18995
a2cb19764970
Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18993
diff
changeset
|
336 private ValuePhiNode createLoopPhi(AbstractMergeNode block, ValueNode value) { |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
337 if (value == null) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
338 return null; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
339 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
340 assert !block.isPhiAtMerge(value) : "phi function for this block already created"; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
341 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18374
diff
changeset
|
342 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(value.stamp().unrestricted(), block)); |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
343 phi.addInput(value); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
344 return phi; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
345 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
346 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
347 /** |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
348 * Adds a locked monitor to this frame state. |
15022
bceb077143ae
Preserve value range in stamp of ParameterNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
14978
diff
changeset
|
349 * |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
350 * @param object the object whose monitor will be locked. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
351 */ |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
352 public void pushLock(ValueNode object, MonitorIdNode monitorId) { |
14817
80147dac0d6e
LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14803
diff
changeset
|
353 assert object.isAlive() && object.getKind() == Kind.Object : "unexpected value: " + object; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
354 lockedObjects = Arrays.copyOf(lockedObjects, lockedObjects.length + 1); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
355 monitorIds = Arrays.copyOf(monitorIds, monitorIds.length + 1); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
356 lockedObjects[lockedObjects.length - 1] = object; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
357 monitorIds[monitorIds.length - 1] = monitorId; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
358 assert lockedObjects.length == monitorIds.length; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
359 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
360 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
361 /** |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
362 * Removes a locked monitor from this frame state. |
15022
bceb077143ae
Preserve value range in stamp of ParameterNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
14978
diff
changeset
|
363 * |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
364 * @return the object whose monitor was removed from the locks list. |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
365 */ |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
366 public ValueNode popLock() { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
367 try { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
368 return lockedObjects[lockedObjects.length - 1]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
369 } finally { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
370 lockedObjects = lockedObjects.length == 1 ? EMPTY_ARRAY : Arrays.copyOf(lockedObjects, lockedObjects.length - 1); |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
371 monitorIds = monitorIds.length == 1 ? EMPTY_MONITOR_ARRAY : Arrays.copyOf(monitorIds, monitorIds.length - 1); |
15361
2682747f7108
Refactoring in InliningUtil.processFrameStates, add some bci/monitor related asserts
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15311
diff
changeset
|
372 assert lockedObjects.length == monitorIds.length; |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
373 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
374 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
375 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
376 public MonitorIdNode peekMonitorId() { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
377 return monitorIds[monitorIds.length - 1]; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
378 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
379 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
380 /** |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
381 * @return the current lock depth |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
382 */ |
15558
b8bb78808495
AbstractFrameStateBuilder enable access to locks.
Josef Eisl <josef.eisl@jku.at>
parents:
15361
diff
changeset
|
383 @Override |
14793
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
384 public int lockDepth() { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
385 assert lockedObjects.length == monitorIds.length; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
386 return lockedObjects.length; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
387 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
388 |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
389 public boolean contains(ValueNode value) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
390 for (int i = 0; i < localsSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
391 if (localAt(i) == value) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
392 return true; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
393 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
394 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
395 for (int i = 0; i < stackSize(); i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
396 if (stackAt(i) == value) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
397 return true; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
398 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
399 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
400 assert lockedObjects.length == monitorIds.length; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
401 for (int i = 0; i < lockedObjects.length; i++) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
402 if (lockedObjects[i] == value || monitorIds[i] == value) { |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
403 return true; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
404 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
405 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
406 return false; |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
407 } |
c4e65d48887c
Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff
changeset
|
408 } |