annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java @ 20901:c4691265275a

made ReplacementContext and IntrinsicContext top level classes
author Doug Simon <doug.simon@oracle.com>
date Fri, 10 Apr 2015 13:21:33 +0200
parents aaf5039e56d7
children 3b5ec1a2b3b5 d5ee8f60459d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
1 /*
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
14793
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.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
28
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.code.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.meta.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
31 import com.oracle.graal.compiler.common.*;
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.*;
19884
87736c089259 refactored graph builder plugins to be top level interfaces
Doug Simon <doug.simon@oracle.com>
parents: 19883
diff changeset
34 import com.oracle.graal.graphbuilderconf.*;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
35 import com.oracle.graal.java.BciBlockMapping.BciBlock;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
36 import com.oracle.graal.java.GraphBuilderPhase.Instance.BytecodeParser;
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
37 import com.oracle.graal.nodeinfo.*;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.nodes.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.nodes.calc.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.nodes.java.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.nodes.util.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
42
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
43 public final class HIRFrameStateBuilder {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
44
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
45 static final ValueNode[] EMPTY_ARRAY = new ValueNode[0];
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
46 static final MonitorIdNode[] EMPTY_MONITOR_ARRAY = new MonitorIdNode[0];
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
47
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
48 protected final BytecodeParser parser;
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
49 protected final ResolvedJavaMethod method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
50 protected int stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
51 protected final ValueNode[] locals;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
52 protected final ValueNode[] stack;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
53 protected ValueNode[] lockedObjects;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
54
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
55 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
56 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
57 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
58 protected boolean rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
59
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
60 private MonitorIdNode[] monitorIds;
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
61 private final StructuredGraph graph;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
62 private FrameState outerFrameState;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
63
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 * 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
66 *
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
67 * @param method the method whose frame is simulated
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
68 * @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
69 */
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
70 public HIRFrameStateBuilder(BytecodeParser parser, ResolvedJavaMethod method, StructuredGraph graph) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
71 this.parser = parser;
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
72 this.method = method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
73 this.locals = allocateArray(method.getMaxLocals());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
74 this.stack = allocateArray(Math.max(1, method.getMaxStackSize()));
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
75 this.lockedObjects = allocateArray(0);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
76
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
77 assert graph != null;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
78
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
79 this.monitorIds = EMPTY_MONITOR_ARRAY;
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
80 this.graph = graph;
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
81 }
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
82
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
83 public void initializeFromArgumentsArray(ValueNode[] arguments) {
18921
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
84
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
85 int javaIndex = 0;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
86 int index = 0;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
87 if (!method.isStatic()) {
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
88 // 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
89 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
90 javaIndex = 1;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
91 index = 1;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
92 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
93 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
94 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
95 for (int i = 0; i < max; i++) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
96 Kind kind = sig.getParameterKind(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
97 locals[javaIndex] = arguments[index];
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
98 javaIndex += kind.getSlotCount();
18921
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
99 index++;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
100 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
101 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
102
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
103 public void initializeForMethodStart(boolean eagerResolve, ParameterPlugin parameterPlugin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
104
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
105 int javaIndex = 0;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
106 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
107 if (!method.isStatic()) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
108 // add the receiver
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
109 FloatingNode receiver = null;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
110 Stamp receiverStamp = StampFactory.declaredNonNull(method.getDeclaringClass());
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
111 if (parameterPlugin != null) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
112 receiver = parameterPlugin.interceptParameter(parser, index, receiverStamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
113 }
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
114 if (receiver == null) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
115 receiver = new ParameterNode(javaIndex, receiverStamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
116 }
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
117 locals[javaIndex] = graph.unique(receiver);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
118 javaIndex = 1;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
119 index = 1;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
120 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
121 Signature sig = method.getSignature();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
122 int max = sig.getParameterCount(false);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
123 ResolvedJavaType accessingClass = method.getDeclaringClass();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
124 for (int i = 0; i < max; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
125 JavaType type = sig.getParameterType(i, accessingClass);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
126 if (eagerResolve) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
127 type = type.resolve(accessingClass);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
128 }
15022
bceb077143ae Preserve value range in stamp of ParameterNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 14978
diff changeset
129 Kind kind = type.getKind();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
130 Stamp stamp;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
131 if (kind == Kind.Object && type instanceof ResolvedJavaType) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
132 stamp = StampFactory.declared((ResolvedJavaType) type);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
133 } else {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
134 stamp = StampFactory.forKind(kind);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
135 }
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
136 FloatingNode param = null;
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
137 if (parameterPlugin != null) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
138 param = parameterPlugin.interceptParameter(parser, index, stamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
139 }
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
140 if (param == null) {
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
141 param = new ParameterNode(index, stamp);
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
142 }
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
143 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
144 javaIndex += kind.getSlotCount();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
145 index++;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
146 }
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
147
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
148 if (parser.replacementContext instanceof IntrinsicContext) {
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
149 IntrinsicContext intrinsic = (IntrinsicContext) parser.replacementContext;
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
150 if (intrinsic.isCompilationRoot()) {
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
151 // Records the parameters to an root compiled intrinsic
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
152 intrinsic.args = locals.clone();
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
153 }
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
154 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
155 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
156
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
157 private HIRFrameStateBuilder(HIRFrameStateBuilder other) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
158 this.parser = other.parser;
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
159 this.method = other.method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
160 this.stackSize = other.stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
161 this.locals = other.locals.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
162 this.stack = other.stack.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
163 this.lockedObjects = other.lockedObjects.length == 0 ? other.lockedObjects : other.lockedObjects.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
164 this.rethrowException = other.rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
165
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
166 assert locals.length == method.getMaxLocals();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
167 assert stack.length == Math.max(1, method.getMaxStackSize());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
168
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
169 assert other.graph != null;
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
170 graph = other.graph;
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18230
diff changeset
171 monitorIds = other.monitorIds.length == 0 ? other.monitorIds : other.monitorIds.clone();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
172
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
173 assert locals.length == method.getMaxLocals();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
174 assert stack.length == Math.max(1, method.getMaxStackSize());
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
175 assert lockedObjects.length == monitorIds.length;
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
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
178 private static ValueNode[] allocateArray(int length) {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18230
diff changeset
179 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
180 }
14e542e27076 Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents: 15022
diff changeset
181
14e542e27076 Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents: 15022
diff changeset
182 @Override
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
183 public String toString() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
184 StringBuilder sb = new StringBuilder();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
185 sb.append("[locals: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
186 for (int i = 0; i < locals.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
187 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
188 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
189 sb.append("] stack: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
190 for (int i = 0; i < stackSize; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
191 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
192 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
193 sb.append("] locks: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
194 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
195 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
196 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
197 sb.append("]");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
198 if (rethrowException) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
199 sb.append(" rethrowException");
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 sb.append("]");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
202 return sb.toString();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
203 }
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 public FrameState create(int bci) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
206 BytecodeParser parent = parser.getParent();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
207 if (parser.parsingReplacement()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
208 IntrinsicContext intrinsic = parser.replacementContext.asIntrinsic();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
209 if (intrinsic != null) {
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
210 return intrinsic.getInvokeStateBefore(parser.getGraph(), parent);
19585
d28482893f28 Fix construction of unwind BEFORE_EXCEPTION_BCI frame states when inlining in the graph builder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19546
diff changeset
211 }
18927
8da21b779982 Initialize FrameState with less copying.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18923
diff changeset
212 }
19994
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
213 // If this is the recursive call in a partial intrinsification
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
214 // the frame(s) of the intrinsic method are omitted
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
215 while (parent != null && parent.parsingReplacement() && parent.replacementContext.asIntrinsic() != null) {
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
216 parent = parent.getParent();
aaf5039e56d7 made partial intrinsification work (i.e., intrinsics that call the original method to handle slow/uncommon paths)
Doug Simon <doug.simon@oracle.com>
parents: 19962
diff changeset
217 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
218 return create(bci, parent, false);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
219 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
220
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
221 public FrameState create(int bci, BytecodeParser parent, boolean duringCall) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
222 if (outerFrameState == null && parent != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
223 outerFrameState = parent.getFrameState().create(parent.bci());
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
224 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
225 if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI && parent != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
226 FrameState newFrameState = outerFrameState.duplicateModified(outerFrameState.bci, true, Kind.Void, this.peek(0));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
227 return newFrameState;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
228 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
229 if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
230 throw GraalInternalError.shouldNotReachHere();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
231 // return graph.add(new FrameState(bci));
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
232 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
233 return graph.add(new FrameState(outerFrameState, method, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
234 }
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 public HIRFrameStateBuilder copy() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
237 return new HIRFrameStateBuilder(this);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
238 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
239
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
240 public boolean isCompatibleWith(HIRFrameStateBuilder other) {
14803
Josef Eisl <josef.eisl@jku.at>
parents: 14793
diff changeset
241 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
242 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
243
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
244 if (stackSize() != other.stackSize()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
245 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
246 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
247 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
248 ValueNode x = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
249 ValueNode y = other.stackAt(i);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
250 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
251 return false;
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 if (lockedObjects.length != other.lockedObjects.length) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
255 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
256 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
257 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
258 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
259 throw new BailoutException("unbalanced monitors");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
260 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
261 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
262 return true;
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
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
265 public void merge(AbstractMergeNode block, HIRFrameStateBuilder other) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
266 assert isCompatibleWith(other);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
267
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
268 for (int i = 0; i < localsSize(); i++) {
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
269 ValueNode curLocal = localAt(i);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
270 ValueNode mergedLocal = merge(curLocal, other.localAt(i), block);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
271 if (curLocal != mergedLocal) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
272 storeLocal(i, mergedLocal);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
273 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
274 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
275 for (int i = 0; i < stackSize(); i++) {
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
276 ValueNode curStack = stackAt(i);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
277 ValueNode mergedStack = merge(curStack, other.stackAt(i), block);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
278 if (curStack != mergedStack) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
279 storeStack(i, mergedStack);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
280 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
281 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
282 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
283 lockedObjects[i] = merge(lockedObjects[i], other.lockedObjects[i], block);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
284 assert monitorIds[i] == other.monitorIds[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
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
288 private ValueNode merge(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
289 if (currentValue == null || currentValue.isDeleted()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
290 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
291 } else if (block.isPhiAtMerge(currentValue)) {
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
292 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
293 propagateDelete((ValuePhiNode) currentValue);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
294 return null;
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 ((PhiNode) currentValue).addInput(otherValue);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
297 return currentValue;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
298 } else if (currentValue != otherValue) {
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
299 assert !(block instanceof LoopBeginNode) : String.format("Phi functions for loop headers are create eagerly for changed locals and all stack slots: %s != %s", currentValue, otherValue);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
300 if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
301 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
302 }
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
303 return createValuePhi(currentValue, otherValue, block);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
304 } else {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
305 return currentValue;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
306 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
307 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
308
19536
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
309 private ValuePhiNode createValuePhi(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
310 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(currentValue.stamp().unrestricted(), block));
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
311 for (int i = 0; i < block.phiPredecessorCount(); i++) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
312 phi.addInput(currentValue);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
313 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
314 phi.addInput(otherValue);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
315 assert phi.valueCount() == block.phiPredecessorCount() + 1;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
316 return phi;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
317 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19535
diff changeset
318
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
319 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
320 assert node instanceof ValuePhiNode || node instanceof ProxyNode;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
321 if (node.isDeleted()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
322 return;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
323 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
324 // 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
325 // 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
326 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
327
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
328 // 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
329 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
330 node.replaceAtUsages(null);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
331 node.safeDelete();
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 for (FloatingNode phiUsage : propagateUsages) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
334 propagateDelete(phiUsage);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
335 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
336 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
337
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
338 public void insertLoopPhis(LocalLiveness liveness, int loopId, LoopBeginNode loopBegin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
339 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
340 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
341 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
342 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
343 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
344 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
345 storeStack(i, createLoopPhi(loopBegin, stackAt(i)));
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 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
348 lockedObjects[i] = createLoopPhi(loopBegin, lockedObjects[i]);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
349 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
350 }
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 insertLoopProxies(LoopExitNode loopExit, HIRFrameStateBuilder loopEntryState) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
353 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
354 ValueNode value = localAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
355 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
356 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
357 storeLocal(i, ProxyNode.forValue(value, loopExit, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
358 }
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 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
361 ValueNode value = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
362 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
363 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
364 storeStack(i, ProxyNode.forValue(value, loopExit, graph));
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 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
367 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
368 ValueNode value = lockedObjects[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
369 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
370 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
371 lockedObjects[i] = ProxyNode.forValue(value, loopExit, graph);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
372 }
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
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18934
diff changeset
376 public void insertProxies(AbstractBeginNode begin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
377 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
378 ValueNode value = localAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
379 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
380 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
381 storeLocal(i, ProxyNode.forValue(value, begin, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
382 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
383 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
384 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
385 ValueNode value = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
386 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
387 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
388 storeStack(i, ProxyNode.forValue(value, begin, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
389 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
390 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
391 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
392 ValueNode value = lockedObjects[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
393 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
394 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
395 lockedObjects[i] = ProxyNode.forValue(value, begin, graph);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
396 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
397 }
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
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
400 private ValuePhiNode createLoopPhi(AbstractMergeNode block, ValueNode value) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
401 if (value == null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
402 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
403 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
404 assert !block.isPhiAtMerge(value) : "phi function for this block already created";
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
405
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
406 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(value.stamp().unrestricted(), block));
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
407 phi.addInput(value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
408 return phi;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
409 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
410
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
411 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
412 * 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
413 *
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
414 * @param object the object whose monitor will be locked.
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
415 */
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
416 public void pushLock(ValueNode object, MonitorIdNode monitorId) {
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
417 assert object.isAlive() && object.getKind() == Kind.Object : "unexpected value: " + object;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
418 lockedObjects = Arrays.copyOf(lockedObjects, lockedObjects.length + 1);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
419 monitorIds = Arrays.copyOf(monitorIds, monitorIds.length + 1);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
420 lockedObjects[lockedObjects.length - 1] = object;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
421 monitorIds[monitorIds.length - 1] = monitorId;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
422 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
423 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
424
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
425 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
426 * 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
427 *
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
428 * @return the object whose monitor was removed from the locks list.
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
429 */
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
430 public ValueNode popLock() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
431 try {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
432 return lockedObjects[lockedObjects.length - 1];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
433 } finally {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
434 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
435 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
436 assert lockedObjects.length == monitorIds.length;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
437 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
438 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
439
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
440 public MonitorIdNode peekMonitorId() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
441 return monitorIds[monitorIds.length - 1];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
442 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
443
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
444 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
445 * @return the current lock depth
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
446 */
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
447 public int lockDepth() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
448 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
449 return lockedObjects.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
450 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
451
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
452 public boolean contains(ValueNode value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
453 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
454 if (localAt(i) == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
455 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
456 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
457 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
458 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
459 if (stackAt(i) == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
460 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
461 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
462 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
463 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
464 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
465 if (lockedObjects[i] == value || monitorIds[i] == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
466 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
467 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
468 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
469 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
470 }
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
471
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
472 public void clearNonLiveLocals(BciBlock block, LocalLiveness liveness, boolean liveIn) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
473 /*
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
474 * (lstadler) if somebody is tempted to remove/disable this clearing code: it's possible to
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
475 * remove it for normal compilations, but not for OSR compilations - otherwise dead object
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
476 * slots at the OSR entry aren't cleared. it is also not enough to rely on PiNodes with
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
477 * Kind.Illegal, because the conflicting branch might not have been parsed.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
478 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
479 if (liveness == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
480 return;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
481 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
482 if (liveIn) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
483 for (int i = 0; i < locals.length; i++) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
484 if (!liveness.localIsLiveIn(block, i)) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
485 locals[i] = null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
486 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
487 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
488 } else {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
489 for (int i = 0; i < locals.length; i++) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
490 if (!liveness.localIsLiveOut(block, i)) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
491 locals[i] = null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
492 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
493 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
494 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
495 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
496
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
497 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
498 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
499 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
500 public boolean rethrowException() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
501 return rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
502 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
503
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
504 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
505 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
506 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
507 public void setRethrowException(boolean b) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
508 rethrowException = b;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
509 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
510
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
511 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
512 * Returns the size of the local variables.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
513 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
514 * @return the size of the local variables
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
515 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
516 public int localsSize() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
517 return locals.length;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
518 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
519
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
520 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
521 * Gets the current size (height) of the stack.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
522 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
523 public int stackSize() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
524 return stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
525 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
526
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
527 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
528 * Gets the value in the local variables at the specified index, without any sanity checking.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
529 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
530 * @param i the index into the locals
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
531 * @return the instruction that produced the value for the specified local
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
532 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
533 public ValueNode localAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
534 return locals[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
535 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
536
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
537 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
538 * Get the value on the stack at the specified stack index.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
539 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
540 * @param i the index into the stack, with {@code 0} being the bottom of the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
541 * @return the instruction at the specified position in the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
542 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
543 public ValueNode stackAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
544 return stack[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
545 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
546
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
547 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
548 * Gets the value in the lock at the specified index, without any sanity checking.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
549 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
550 * @param i the index into the lock
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
551 * @return the instruction that produced the value for the specified lock
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
552 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
553 public ValueNode lockAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
554 return lockedObjects[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
555 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
556
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
557 public void storeLock(int i, ValueNode lock) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
558 lockedObjects[i] = lock;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
559 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
560
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
561 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
562 * Loads the local variable at the specified index, checking that the returned value is non-null
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
563 * and that two-stack values are properly handled.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
564 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
565 * @param i the index of the local variable to load
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
566 * @return the instruction that produced the specified local
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
567 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
568 public ValueNode loadLocal(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
569 ValueNode x = locals[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
570 assert assertLoadLocal(i, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
571 return x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
572 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
573
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
574 private boolean assertLoadLocal(int i, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
575 assert x != null : i;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
576 assert parser.parsingReplacement() || (x.getKind().getSlotCount() == 1 || locals[i + 1] == null);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
577 assert parser.parsingReplacement() || (i == 0 || locals[i - 1] == null || locals[i - 1].getKind().getSlotCount() == 1);
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
578 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
579 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
580
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
581 public void storeLocal(int i, ValueNode x) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
582 storeLocal(i, x, x == null ? null : x.getKind());
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
583 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
584
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
585 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
586 * Stores a given local variable at the specified index. If the value occupies two slots, then
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
587 * the next local variable index is also overwritten.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
588 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
589 * @param i the index at which to store
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
590 * @param x the instruction which produces the value for the local
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
591 */
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
592 public void storeLocal(int i, ValueNode x, Kind kind) {
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
593 assert assertStoreLocal(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
594 locals[i] = x;
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
595 if (x != null) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
596 if (kind.needsTwoSlots() && !parser.parsingReplacement()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
597 // if this is a double word, then kill i+1
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
598 locals[i + 1] = null;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
599 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
600 if (i > 0 && !parser.parsingReplacement()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
601 ValueNode p = locals[i - 1];
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
602 if (p != null && p.getKind().needsTwoSlots()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
603 // if there was a double word at i - 1, then kill it
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
604 locals[i - 1] = null;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
605 }
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
606 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
607 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
608 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
609
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
610 private boolean assertStoreLocal(ValueNode x) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
611 assert x == null || parser.parsingReplacement() || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal) : "unexpected value: " + x;
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
612 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
613 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
614
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
615 public void storeStack(int i, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
616 assert assertStoreStack(i, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
617 stack[i] = x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
618 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
619
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
620 private boolean assertStoreStack(int i, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
621 assert x == null || (stack[i] == null || x.getKind() == stack[i].getKind()) : "Method does not handle changes from one-slot to two-slot values or non-alive values";
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
622 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
623 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
624
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
625 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
626 * Pushes an instruction onto the stack with the expected type.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
627 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
628 * @param kind the type expected for this instruction
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
629 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
630 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
631 public void push(Kind kind, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
632 assert assertPush(kind, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
633 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
634 if (kind.needsTwoSlots()) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
635 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
636 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
637 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
638
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
639 private boolean assertPush(Kind kind, ValueNode x) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
640 assert parser.parsingReplacement() || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
641 assert x != null && (parser.parsingReplacement() || x.getKind() == kind);
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
642 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
643 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
644
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
645 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
646 * Pushes a value onto the stack without checking the type.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
647 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
648 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
649 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
650 public void xpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
651 assert assertXpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
652 stack[stackSize++] = x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
653 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
654
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
655 private boolean assertXpush(ValueNode x) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
656 assert parser.parsingReplacement() || (x == null || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal));
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
657 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
658 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
659
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
660 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
661 * Pushes a value onto the stack and checks that it is an int.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
662 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
663 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
664 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
665 public void ipush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
666 assert assertInt(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
667 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
668 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
669
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
670 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
671 * Pushes a value onto the stack and checks that it is a float.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
672 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
673 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
674 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
675 public void fpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
676 assert assertFloat(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
677 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
678 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
679
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
680 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
681 * Pushes a value onto the stack and checks that it is an object.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
682 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
683 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
684 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
685 public void apush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
686 assert assertObject(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
687 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
688 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
689
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
690 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
691 * Pushes a value onto the stack and checks that it is a long.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
692 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
693 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
694 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
695 public void lpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
696 assert assertLong(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
697 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
698 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
699 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
700
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
701 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
702 * Pushes a value onto the stack and checks that it is a double.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
703 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
704 * @param x the instruction to push onto the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
705 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
706 public void dpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
707 assert assertDouble(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
708 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
709 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
710 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
711
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
712 public void pushReturn(Kind kind, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
713 if (kind != Kind.Void) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
714 push(kind.getStackKind(), x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
715 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
716 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
717
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
718 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
719 * Pops an instruction off the stack with the expected type.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
720 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
721 * @param kind the expected type
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
722 * @return the instruction on the top of the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
723 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
724 public ValueNode pop(Kind kind) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
725 if (kind.needsTwoSlots()) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
726 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
727 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
728 assert assertPop(kind);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
729 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
730 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
731
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
732 private boolean assertPop(Kind kind) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
733 assert kind != Kind.Void;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
734 ValueNode x = xpeek();
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
735 assert x != null && (parser.parsingReplacement() || x.getKind() == kind);
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
736 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
737 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
738
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
739 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
740 * Pops a value off of the stack without checking the type.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
741 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
742 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
743 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
744 public ValueNode xpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
745 return stack[--stackSize];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
746 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
747
19546
0362d64c0cd4 Small refactoring of DUP/POP bytecode processing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19536
diff changeset
748 public ValueNode xpeek() {
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
749 return stack[stackSize - 1];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
750 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
751
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
752 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
753 * Pops a value off of the stack and checks that it is an int.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
754 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
755 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
756 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
757 public ValueNode ipop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
758 assert assertIntPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
759 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
760 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
761
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
762 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
763 * Pops a value off of the stack and checks that it is a float.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
764 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
765 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
766 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
767 public ValueNode fpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
768 assert assertFloatPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
769 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
770 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
771
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
772 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
773 * Pops a value off of the stack and checks that it is an object.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
774 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
775 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
776 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
777 public ValueNode apop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
778 assert assertObjectPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
779 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
780 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
781
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
782 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
783 * Pops a value off of the stack and checks that it is a long.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
784 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
785 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
786 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
787 public ValueNode lpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
788 assert assertHighPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
789 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
790 assert assertLongPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
791 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
792 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
793
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
794 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
795 * Pops a value off of the stack and checks that it is a double.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
796 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
797 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
798 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
799 public ValueNode dpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
800 assert assertHighPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
801 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
802 assert assertDoublePeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
803 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
804 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
805
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
806 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
807 * Pop the specified number of slots off of this stack and return them as an array of
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
808 * instructions.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
809 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
810 * @return an array containing the arguments off of the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
811 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
812 public ValueNode[] popArguments(int argSize) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
813 ValueNode[] result = allocateArray(argSize);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
814 int newStackSize = stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
815 for (int i = argSize - 1; i >= 0; i--) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
816 newStackSize--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
817 if (stack[newStackSize] == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
818 /* Two-slot value. */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
819 newStackSize--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
820 assert stack[newStackSize].getKind().needsTwoSlots();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
821 } else {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
822 assert parser.parsingReplacement() || (stack[newStackSize].getKind().getSlotCount() == 1);
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
823 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
824 result[i] = stack[newStackSize];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
825 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
826 stackSize = newStackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
827 return result;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
828 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
829
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
830 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
831 * Peeks an element from the operand stack.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
832 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
833 * @param argumentNumber The number of the argument, relative from the top of the stack (0 =
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
834 * top). Long and double arguments only count as one argument, i.e., null-slots are
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
835 * ignored.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
836 * @return The peeked argument.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
837 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
838 public ValueNode peek(int argumentNumber) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
839 int idx = stackSize() - 1;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
840 for (int i = 0; i < argumentNumber; i++) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
841 if (stackAt(idx) == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
842 idx--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
843 assert stackAt(idx).getKind().needsTwoSlots();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
844 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
845 idx--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
846 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
847 return stackAt(idx);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
848 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
849
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
850 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
851 * Clears all values on this stack.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
852 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
853 public void clearStack() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
854 stackSize = 0;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
855 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
856
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
857 private boolean assertLongPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
858 return assertLong(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
859 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
860
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
861 private static boolean assertLong(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
862 assert x != null && (x.getKind() == Kind.Long);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
863 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
864 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
865
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
866 private boolean assertIntPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
867 return assertInt(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
868 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
869
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
870 private static boolean assertInt(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
871 assert x != null && (x.getKind() == Kind.Int);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
872 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
873 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
874
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
875 private boolean assertFloatPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
876 return assertFloat(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
877 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
878
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
879 private static boolean assertFloat(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
880 assert x != null && (x.getKind() == Kind.Float);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
881 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
882 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
883
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
884 private boolean assertObjectPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
885 return assertObject(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
886 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
887
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
888 private boolean assertObject(ValueNode x) {
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
889 assert x != null && (parser.parsingReplacement() || (x.getKind() == Kind.Object));
19535
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
890 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
891 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
892
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
893 private boolean assertDoublePeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
894 return assertDouble(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
895 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
896
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
897 private static boolean assertDouble(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
898 assert x != null && (x.getKind() == Kind.Double);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
899 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
900 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
901
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
902 private boolean assertHighPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
903 assert xpeek() == null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
904 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19496
diff changeset
905 }
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
906
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
907 @Override
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
908 public int hashCode() {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
909 int result = hashCode(locals, locals.length);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
910 result *= 13;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
911 result += hashCode(stack, this.stackSize);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
912 return result;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
913 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
914
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
915 private static int hashCode(Object[] a, int length) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
916 int result = 1;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
917 for (int i = 0; i < length; ++i) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
918 Object element = a[i];
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
919 result = 31 * result + (element == null ? 0 : System.identityHashCode(element));
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
920 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
921 return result;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
922 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
923
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
924 private static boolean equals(ValueNode[] a, ValueNode[] b, int length) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
925 for (int i = 0; i < length; ++i) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
926 if (a[i] != b[i]) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
927 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
928 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
929 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
930 return true;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
931 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
932
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
933 @Override
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
934 public boolean equals(Object otherObject) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
935 if (otherObject instanceof HIRFrameStateBuilder) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
936 HIRFrameStateBuilder other = (HIRFrameStateBuilder) otherObject;
19629
5762e1d007b6 Fix issue found by CheckGraalInvariants.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19623
diff changeset
937 if (!other.method.equals(method)) {
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
938 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
939 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
940 if (other.stackSize != stackSize) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
941 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
942 }
19791
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19629
diff changeset
943 if (other.parser != parser) {
19623
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
944 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
945 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
946 if (other.rethrowException != rethrowException) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
947 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
948 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
949 if (other.graph != graph) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
950 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
951 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
952 if (other.locals.length != locals.length) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
953 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
954 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
955 return equals(other.locals, locals, locals.length) && equals(other.stack, stack, stackSize) && equals(other.lockedObjects, lockedObjects, lockedObjects.length) &&
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
956 equals(other.monitorIds, monitorIds, monitorIds.length);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
957 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
958 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19585
diff changeset
959 }
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
960
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
961 public void replace(ValueNode oldValue, ValueNode newValue) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
962 for (int i = 0; i < locals.length; i++) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
963 if (locals[i] == oldValue) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
964 locals[i] = newValue;
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
965 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
966 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
967 for (int i = 0; i < stackSize; i++) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
968 if (stack[i] == oldValue) {
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
969 stack[i] = newValue;
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
970 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
971 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19884
diff changeset
972 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
973 }