annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/HIRFrameStateBuilder.java @ 21343:ce95a5e36927

removed unnecessary Intrinsic interface
author Doug Simon <doug.simon@oracle.com>
date Tue, 12 May 2015 15:57:40 +0200
parents 710fc7216c56
children 6d5a198d23e6
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 /*
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
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.*;
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
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.*;
19821
87736c089259 refactored graph builder plugins to be top level interfaces
Doug Simon <doug.simon@oracle.com>
parents: 19820
diff changeset
34 import com.oracle.graal.graphbuilderconf.*;
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
35 import com.oracle.graal.graphbuilderconf.IntrinsicContext.*;
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
36 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: 19636
diff changeset
37 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
38 import com.oracle.graal.nodeinfo.*;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.nodes.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.nodes.calc.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.nodes.java.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.nodes.util.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
43
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
44 public final class HIRFrameStateBuilder implements SideEffectsState {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
45
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
46 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
47 static final MonitorIdNode[] EMPTY_MONITOR_ARRAY = new MonitorIdNode[0];
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
48
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
49 protected final BytecodeParser parser;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
50 protected final ResolvedJavaMethod method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
51 protected int stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
52 protected final ValueNode[] locals;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
53 protected final ValueNode[] stack;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
54 protected ValueNode[] lockedObjects;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
55
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
56 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
57 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
58 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
59 protected boolean rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
60
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
61 private MonitorIdNode[] monitorIds;
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
62 private final StructuredGraph graph;
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
63 private FrameState outerFrameState;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
64
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
65 /**
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
66 * The closest {@link StateSplit#hasSideEffect() side-effect} predecessors. There will be more
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
67 * than one when the current block contains no side-effects but merging predecessor blocks do.
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
68 */
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
69 protected List<StateSplit> sideEffects;
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
70
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
71 /**
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
72 * 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
73 *
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
74 * @param method the method whose frame is simulated
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
75 * @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
76 */
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
77 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: 19636
diff changeset
78 this.parser = parser;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
79 this.method = method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
80 this.locals = allocateArray(method.getMaxLocals());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
81 this.stack = allocateArray(Math.max(1, method.getMaxStackSize()));
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
82 this.lockedObjects = allocateArray(0);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
83
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
84 assert graph != null;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
85
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
86 this.monitorIds = EMPTY_MONITOR_ARRAY;
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
87 this.graph = graph;
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
88 }
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
89
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
90 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
91
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
92 int javaIndex = 0;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
93 int index = 0;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
94 if (!method.isStatic()) {
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
95 // 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
96 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
97 javaIndex = 1;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
98 index = 1;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
99 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
100 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
101 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
102 for (int i = 0; i < max; i++) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
103 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
104 locals[javaIndex] = arguments[index];
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
105 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
106 index++;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
107 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
108 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
109
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
110 public void initializeForMethodStart(boolean eagerResolve, ParameterPlugin parameterPlugin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
111
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
112 int javaIndex = 0;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
113 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
114 if (!method.isStatic()) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
115 // add the receiver
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
116 FloatingNode receiver = null;
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
117 Stamp receiverStamp = StampFactory.declaredNonNull(method.getDeclaringClass());
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
118 if (parameterPlugin != null) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
119 receiver = parameterPlugin.interceptParameter(parser, index, receiverStamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
120 }
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
121 if (receiver == null) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
122 receiver = new ParameterNode(javaIndex, receiverStamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
123 }
19386
664b396dbe64 Do not use store local in HIRFrameStateBuilder as a simple write to the local array is sufficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19175
diff changeset
124 locals[javaIndex] = graph.unique(receiver);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
125 javaIndex = 1;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
126 index = 1;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
127 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
128 Signature sig = method.getSignature();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
129 int max = sig.getParameterCount(false);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
130 ResolvedJavaType accessingClass = method.getDeclaringClass();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
131 for (int i = 0; i < max; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
132 JavaType type = sig.getParameterType(i, accessingClass);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
133 if (eagerResolve) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
134 type = type.resolve(accessingClass);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
135 }
15022
bceb077143ae Preserve value range in stamp of ParameterNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 14978
diff changeset
136 Kind kind = type.getKind();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
137 Stamp stamp;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
138 if (kind == Kind.Object && type instanceof ResolvedJavaType) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
139 stamp = StampFactory.declared((ResolvedJavaType) type);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
140 } else {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
141 stamp = StampFactory.forKind(kind);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
142 }
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
143 FloatingNode param = null;
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
144 if (parameterPlugin != null) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
145 param = parameterPlugin.interceptParameter(parser, index, stamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
146 }
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
147 if (param == null) {
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
148 param = new ParameterNode(index, stamp);
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
149 }
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
150 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
151 javaIndex += kind.getSlotCount();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
152 index++;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
153 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
154 }
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 private HIRFrameStateBuilder(HIRFrameStateBuilder other) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
157 this.parser = other.parser;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
158 this.method = other.method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
159 this.stackSize = other.stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
160 this.locals = other.locals.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
161 this.stack = other.stack.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
162 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: 19494
diff changeset
163 this.rethrowException = other.rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
164
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
165 assert locals.length == method.getMaxLocals();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
166 assert stack.length == Math.max(1, method.getMaxStackSize());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
167
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
168 assert other.graph != null;
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
169 graph = other.graph;
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18230
diff changeset
170 monitorIds = other.monitorIds.length == 0 ? other.monitorIds : other.monitorIds.clone();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
171
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
172 assert locals.length == method.getMaxLocals();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
173 assert stack.length == Math.max(1, method.getMaxStackSize());
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
174 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
175 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
176
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
177 private static ValueNode[] allocateArray(int length) {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18230
diff changeset
178 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
179 }
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 @Override
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
182 public String toString() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
183 StringBuilder sb = new StringBuilder();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
184 sb.append("[locals: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
185 for (int i = 0; i < locals.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
186 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
187 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
188 sb.append("] stack: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
189 for (int i = 0; i < stackSize; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
190 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
191 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
192 sb.append("] locks: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
193 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
194 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
195 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
196 sb.append("]");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
197 if (rethrowException) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
198 sb.append(" rethrowException");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
199 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
200 sb.append("]");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
201 return sb.toString();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
202 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
203
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
204 public FrameState create(int bci, StateSplit forStateSplit) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
205 if (parser.parsingIntrinsic()) {
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
206 return parser.intrinsicContext.createFrameState(parser.getGraph(), this, forStateSplit);
18927
8da21b779982 Initialize FrameState with less copying.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18923
diff changeset
207 }
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
208
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
209 // Skip intrinsic frames
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
210 BytecodeParser parent = (BytecodeParser) parser.getNonReplacementAncestor();
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
211 return create(bci, parent, false);
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
212 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
213
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
214 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: 19636
diff changeset
215 if (outerFrameState == null && parent != null) {
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
216 outerFrameState = parent.getFrameState().create(parent.bci(), null);
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
217 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
218 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: 19636
diff changeset
219 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: 19636
diff changeset
220 return newFrameState;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
221 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
222 if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
223 throw GraalInternalError.shouldNotReachHere();
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
224 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
225 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
226 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
227
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
228 public BytecodePosition createBytecodePosition(int bci) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
229 BytecodeParser parent = parser.getParent();
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
230 if (AbstractBytecodeParser.Options.HideSubstitutionStates.getValue()) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
231 if (parser.parsingIntrinsic()) {
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
232 // Attribute to the method being replaced
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
233 return new BytecodePosition(parent.getFrameState().createBytecodePosition(parent.bci()), parser.intrinsicContext.getOriginalMethod(), -1);
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
234 }
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
235 // Skip intrinsic frames
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
236 parent = (BytecodeParser) parser.getNonReplacementAncestor();
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
237 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
238 return create(null, bci, parent);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
239 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
240
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
241 private BytecodePosition create(BytecodePosition o, int bci, BytecodeParser parent) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
242 BytecodePosition outer = o;
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
243 if (outer == null && parent != null) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
244 outer = parent.getFrameState().createBytecodePosition(parent.bci());
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
245 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
246 if (bci == BytecodeFrame.AFTER_EXCEPTION_BCI && parent != null) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
247 return FrameState.toBytecodePosition(outerFrameState);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
248 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
249 if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
250 throw GraalInternalError.shouldNotReachHere();
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
251 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
252 return new BytecodePosition(outer, method, bci);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
253 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
254
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
255 public HIRFrameStateBuilder copy() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
256 return new HIRFrameStateBuilder(this);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
257 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
258
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
259 public boolean isCompatibleWith(HIRFrameStateBuilder other) {
14803
Josef Eisl <josef.eisl@jku.at>
parents: 14793
diff changeset
260 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
261 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
262
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
263 if (stackSize() != other.stackSize()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
264 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
265 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
266 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
267 ValueNode x = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
268 ValueNode y = other.stackAt(i);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
269 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
270 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
271 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
272 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
273 if (lockedObjects.length != other.lockedObjects.length) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
274 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
275 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
276 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
277 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
278 throw new BailoutException("unbalanced monitors");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
279 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
280 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
281 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
282 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
283
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
284 public void merge(AbstractMergeNode block, HIRFrameStateBuilder other) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
285 assert isCompatibleWith(other);
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 for (int i = 0; i < localsSize(); i++) {
19539
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
288 ValueNode curLocal = localAt(i);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
289 ValueNode mergedLocal = merge(curLocal, other.localAt(i), block);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
290 if (curLocal != mergedLocal) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
291 storeLocal(i, mergedLocal);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
292 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
293 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
294 for (int i = 0; i < stackSize(); i++) {
19539
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
295 ValueNode curStack = stackAt(i);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
296 ValueNode mergedStack = merge(curStack, other.stackAt(i), block);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
297 if (curStack != mergedStack) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
298 storeStack(i, mergedStack);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
299 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
300 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
301 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
302 lockedObjects[i] = merge(lockedObjects[i], other.lockedObjects[i], block);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
303 assert monitorIds[i] == other.monitorIds[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
304 }
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
305
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
306 if (sideEffects == null) {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
307 sideEffects = other.sideEffects;
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
308 } else {
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
309 if (other.sideEffects != null) {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
310 sideEffects.addAll(other.sideEffects);
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
311 }
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
312 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
313 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
314
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
315 private ValueNode merge(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
316 if (currentValue == null || currentValue.isDeleted()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
317 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
318 } else if (block.isPhiAtMerge(currentValue)) {
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
319 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
320 propagateDelete((ValuePhiNode) currentValue);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
321 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
322 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
323 ((PhiNode) currentValue).addInput(otherValue);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
324 return currentValue;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
325 } 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: 19821
diff changeset
326 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
327 if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
328 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
329 }
19539
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
330 return createValuePhi(currentValue, otherValue, block);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
331 } else {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
332 return currentValue;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
333 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
334 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
335
19539
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
336 private ValuePhiNode createValuePhi(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
337 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(currentValue.stamp().unrestricted(), block));
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
338 for (int i = 0; i < block.phiPredecessorCount(); i++) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
339 phi.addInput(currentValue);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
340 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
341 phi.addInput(otherValue);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
342 assert phi.valueCount() == block.phiPredecessorCount() + 1;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
343 return phi;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
344 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
345
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
346 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
347 assert node instanceof ValuePhiNode || node instanceof ProxyNode;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
348 if (node.isDeleted()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
349 return;
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 // 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
352 // 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
353 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
354
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
355 // 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
356 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
357 node.replaceAtUsages(null);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
358 node.safeDelete();
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 (FloatingNode phiUsage : propagateUsages) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
361 propagateDelete(phiUsage);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
362 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
363 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
364
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
365 public void insertLoopPhis(LocalLiveness liveness, int loopId, LoopBeginNode loopBegin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
366 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
367 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
368 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
369 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
370 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
371 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
372 storeStack(i, createLoopPhi(loopBegin, stackAt(i)));
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 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
375 lockedObjects[i] = createLoopPhi(loopBegin, lockedObjects[i]);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
376 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
377 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
378
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
379 public void insertLoopProxies(LoopExitNode loopExit, HIRFrameStateBuilder loopEntryState) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
380 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
381 ValueNode value = localAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
382 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
383 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
384 storeLocal(i, ProxyNode.forValue(value, loopExit, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
385 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
386 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
387 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
388 ValueNode value = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
389 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
390 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
391 storeStack(i, ProxyNode.forValue(value, loopExit, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
392 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
393 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
394 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
395 ValueNode value = lockedObjects[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
396 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
397 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
398 lockedObjects[i] = ProxyNode.forValue(value, loopExit, graph);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
399 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
400 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
401 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
402
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18934
diff changeset
403 public void insertProxies(AbstractBeginNode begin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
404 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
405 ValueNode value = localAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
406 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
407 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
408 storeLocal(i, ProxyNode.forValue(value, begin, graph));
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 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
412 ValueNode value = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
413 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
414 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
415 storeStack(i, ProxyNode.forValue(value, begin, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
416 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
417 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
418 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
419 ValueNode value = lockedObjects[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
420 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
421 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
422 lockedObjects[i] = ProxyNode.forValue(value, begin, graph);
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
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
427 private ValuePhiNode createLoopPhi(AbstractMergeNode block, ValueNode value) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
428 if (value == null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
429 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
430 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
431 assert !block.isPhiAtMerge(value) : "phi function for this block already created";
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
432
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18374
diff changeset
433 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(value.stamp().unrestricted(), block));
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
434 phi.addInput(value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
435 return phi;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
436 }
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 * 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
440 *
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
441 * @param object the object whose monitor will be locked.
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 public void pushLock(ValueNode object, MonitorIdNode monitorId) {
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
444 assert object.isAlive() && object.getKind() == Kind.Object : "unexpected value: " + object;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
445 lockedObjects = Arrays.copyOf(lockedObjects, lockedObjects.length + 1);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
446 monitorIds = Arrays.copyOf(monitorIds, monitorIds.length + 1);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
447 lockedObjects[lockedObjects.length - 1] = object;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
448 monitorIds[monitorIds.length - 1] = monitorId;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
449 assert lockedObjects.length == monitorIds.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 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
453 * 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
454 *
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
455 * @return the object whose monitor was removed from the locks list.
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 public ValueNode popLock() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
458 try {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
459 return lockedObjects[lockedObjects.length - 1];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
460 } finally {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
461 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
462 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
463 assert lockedObjects.length == monitorIds.length;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
464 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
465 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
466
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
467 public MonitorIdNode peekMonitorId() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
468 return monitorIds[monitorIds.length - 1];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
469 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
470
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
471 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
472 * @return the current lock depth
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
473 */
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
474 public int lockDepth() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
475 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
476 return lockedObjects.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
477 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
478
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
479 public boolean contains(ValueNode value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
480 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
481 if (localAt(i) == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
482 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
483 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
484 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
485 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
486 if (stackAt(i) == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
487 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
488 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
489 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
490 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
491 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
492 if (lockedObjects[i] == value || monitorIds[i] == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
493 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
494 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
495 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
496 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
497 }
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
498
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
499 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: 19494
diff changeset
500 /*
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
501 * (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: 19494
diff changeset
502 * 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: 19494
diff changeset
503 * 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: 19494
diff changeset
504 * 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: 19494
diff changeset
505 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
506 if (liveness == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
507 return;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
508 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
509 if (liveIn) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
510 for (int i = 0; i < locals.length; i++) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
511 if (!liveness.localIsLiveIn(block, i)) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
512 locals[i] = null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
513 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
514 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
515 } else {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
516 for (int i = 0; i < locals.length; i++) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
517 if (!liveness.localIsLiveOut(block, i)) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
518 locals[i] = null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
519 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
520 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
521 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
522 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
523
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
524 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
525 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
526 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
527 public boolean rethrowException() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
528 return rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
529 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
530
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
531 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
532 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
533 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
534 public void setRethrowException(boolean b) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
535 rethrowException = b;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
536 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
537
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
538 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
539 * Returns the size of the local variables.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
540 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
541 * @return the size of the local variables
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
542 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
543 public int localsSize() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
544 return locals.length;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
545 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
546
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
547 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
548 * Gets the current size (height) of the stack.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
549 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
550 public int stackSize() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
551 return stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
552 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
553
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
554 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
555 * 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: 19494
diff changeset
556 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
557 * @param i the index into the locals
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
558 * @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: 19494
diff changeset
559 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
560 public ValueNode localAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
561 return locals[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
562 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
563
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
564 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
565 * 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: 19494
diff changeset
566 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
567 * @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: 19494
diff changeset
568 * @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: 19494
diff changeset
569 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
570 public ValueNode stackAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
571 return stack[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
572 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
573
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
574 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
575 * 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: 19494
diff changeset
576 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
577 * @param i the index into the lock
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
578 * @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: 19494
diff changeset
579 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
580 public ValueNode lockAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
581 return lockedObjects[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
582 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
583
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
584 public void storeLock(int i, ValueNode lock) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
585 lockedObjects[i] = lock;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
586 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
587
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
588 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
589 * 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: 19494
diff changeset
590 * and that two-stack values are properly handled.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
591 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
592 * @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: 19494
diff changeset
593 * @return the instruction that produced the specified local
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
594 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
595 public ValueNode loadLocal(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
596 ValueNode x = locals[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
597 assert assertLoadLocal(i, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
598 return x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
599 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
600
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
601 private boolean assertLoadLocal(int i, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
602 assert x != null : i;
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
603 assert parser.parsingIntrinsic() || (x.getKind().getSlotCount() == 1 || locals[i + 1] == null);
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
604 assert parser.parsingIntrinsic() || (i == 0 || locals[i - 1] == null || locals[i - 1].getKind().getSlotCount() == 1);
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
605 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
606 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
607
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
608 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: 19636
diff changeset
609 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: 19636
diff changeset
610 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
611
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
612 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
613 * 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: 19494
diff changeset
614 * the next local variable index is also overwritten.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
615 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
616 * @param i the index at which to store
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
617 * @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: 19494
diff changeset
618 */
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
619 public void storeLocal(int i, ValueNode x, Kind kind) {
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
620 assert assertStoreLocal(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
621 locals[i] = x;
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
622 if (x != null) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
623 if (kind.needsTwoSlots() && !parser.parsingIntrinsic()) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
624 // 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: 19636
diff changeset
625 locals[i + 1] = null;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
626 }
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
627 if (i > 0 && !parser.parsingIntrinsic()) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
628 ValueNode p = locals[i - 1];
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
629 if (p != null && p.getKind().needsTwoSlots()) {
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
630 // 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: 19636
diff changeset
631 locals[i - 1] = null;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
632 }
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
633 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
634 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
635 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
636
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
637 private boolean assertStoreLocal(ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
638 assert x == null || parser.parsingIntrinsic() || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal) : "unexpected value: " + x;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
639 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
640 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
641
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
642 public void storeStack(int i, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
643 assert assertStoreStack(i, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
644 stack[i] = x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
645 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
646
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
647 private boolean assertStoreStack(int i, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
648 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: 19494
diff changeset
649 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
650 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
651
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
652 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
653 * 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: 19494
diff changeset
654 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
655 * @param kind the type expected for this instruction
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
656 * @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: 19494
diff changeset
657 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
658 public void push(Kind kind, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
659 assert assertPush(kind, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
660 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
661 if (kind.needsTwoSlots()) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
662 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
663 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
664 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
665
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
666 private boolean assertPush(Kind kind, ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
667 assert parser.parsingIntrinsic() || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal);
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
668 assert x != null && (parser.parsingIntrinsic() || x.getKind() == kind);
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
669 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
670 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
671
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
672 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
673 * 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: 19494
diff changeset
674 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
675 * @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: 19494
diff changeset
676 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
677 public void xpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
678 assert assertXpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
679 stack[stackSize++] = x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
680 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
681
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
682 private boolean assertXpush(ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
683 assert parser.parsingIntrinsic() || (x == null || (x.getKind() != Kind.Void && x.getKind() != Kind.Illegal));
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
684 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
685 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
686
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
687 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
688 * 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: 19494
diff changeset
689 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
690 * @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: 19494
diff changeset
691 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
692 public void ipush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
693 assert assertInt(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
694 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
695 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
696
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
697 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
698 * 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: 19494
diff changeset
699 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
700 * @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: 19494
diff changeset
701 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
702 public void fpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
703 assert assertFloat(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
704 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
705 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
706
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
707 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
708 * 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: 19494
diff changeset
709 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
710 * @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: 19494
diff changeset
711 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
712 public void apush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
713 assert assertObject(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
714 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
715 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
716
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
717 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
718 * 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: 19494
diff changeset
719 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
720 * @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: 19494
diff changeset
721 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
722 public void lpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
723 assert assertLong(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
724 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
725 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
726 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
727
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
728 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
729 * 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: 19494
diff changeset
730 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
731 * @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: 19494
diff changeset
732 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
733 public void dpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
734 assert assertDouble(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
735 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
736 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
737 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
738
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
739 public void pushReturn(Kind kind, ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
740 if (kind != Kind.Void) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
741 push(kind.getStackKind(), x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
742 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
743 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
744
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
745 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
746 * 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: 19494
diff changeset
747 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
748 * @param kind the expected type
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
749 * @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: 19494
diff changeset
750 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
751 public ValueNode pop(Kind kind) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
752 if (kind.needsTwoSlots()) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
753 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
754 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
755 assert assertPop(kind);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
756 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
757 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
758
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
759 private boolean assertPop(Kind kind) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
760 assert kind != Kind.Void;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
761 ValueNode x = xpeek();
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
762 assert x != null && (parser.parsingIntrinsic() || x.getKind() == kind);
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
763 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
764 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
765
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
766 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
767 * 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: 19494
diff changeset
768 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
769 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
770 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
771 public ValueNode xpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
772 return stack[--stackSize];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
773 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
774
19553
0362d64c0cd4 Small refactoring of DUP/POP bytecode processing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19539
diff changeset
775 public ValueNode xpeek() {
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
776 return stack[stackSize - 1];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
777 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
778
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
779 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
780 * 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: 19494
diff changeset
781 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
782 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
783 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
784 public ValueNode ipop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
785 assert assertIntPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
786 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
787 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
788
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
789 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
790 * 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: 19494
diff changeset
791 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
792 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
793 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
794 public ValueNode fpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
795 assert assertFloatPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
796 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
797 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
798
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
799 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
800 * 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: 19494
diff changeset
801 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
802 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
803 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
804 public ValueNode apop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
805 assert assertObjectPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
806 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
807 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
808
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
809 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
810 * 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: 19494
diff changeset
811 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
812 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
813 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
814 public ValueNode lpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
815 assert assertHighPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
816 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
817 assert assertLongPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
818 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
819 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
820
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
821 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
822 * 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: 19494
diff changeset
823 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
824 * @return x the instruction popped off the stack
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
825 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
826 public ValueNode dpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
827 assert assertHighPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
828 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
829 assert assertDoublePeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
830 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
831 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
832
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
833 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
834 * 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: 19494
diff changeset
835 * instructions.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
836 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
837 * @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: 19494
diff changeset
838 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
839 public ValueNode[] popArguments(int argSize) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
840 ValueNode[] result = allocateArray(argSize);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
841 int newStackSize = stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
842 for (int i = argSize - 1; i >= 0; i--) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
843 newStackSize--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
844 if (stack[newStackSize] == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
845 /* Two-slot value. */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
846 newStackSize--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
847 assert stack[newStackSize].getKind().needsTwoSlots();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
848 } else {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
849 assert parser.parsingIntrinsic() || (stack[newStackSize].getKind().getSlotCount() == 1);
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
850 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
851 result[i] = stack[newStackSize];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
852 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
853 stackSize = newStackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
854 return result;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
855 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
856
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
857 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
858 * Peeks an element from the operand stack.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
859 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
860 * @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: 19494
diff changeset
861 * 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: 19494
diff changeset
862 * ignored.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
863 * @return The peeked argument.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
864 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
865 public ValueNode peek(int argumentNumber) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
866 int idx = stackSize() - 1;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
867 for (int i = 0; i < argumentNumber; i++) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
868 if (stackAt(idx) == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
869 idx--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
870 assert stackAt(idx).getKind().needsTwoSlots();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
871 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
872 idx--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
873 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
874 return stackAt(idx);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
875 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
876
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
877 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
878 * Clears all values on this stack.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
879 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
880 public void clearStack() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
881 stackSize = 0;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
882 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
883
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
884 private boolean assertLongPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
885 return assertLong(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
886 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
887
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
888 private static boolean assertLong(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
889 assert x != null && (x.getKind() == Kind.Long);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
890 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
891 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
892
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
893 private boolean assertIntPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
894 return assertInt(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
895 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
896
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
897 private static boolean assertInt(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
898 assert x != null && (x.getKind() == Kind.Int);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
899 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
900 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
901
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
902 private boolean assertFloatPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
903 return assertFloat(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
904 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
905
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
906 private static boolean assertFloat(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
907 assert x != null && (x.getKind() == Kind.Float);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
908 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
909 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
910
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
911 private boolean assertObjectPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
912 return assertObject(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
913 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
914
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
915 private boolean assertObject(ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
916 assert x != null && (parser.parsingIntrinsic() || (x.getKind() == Kind.Object));
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
917 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
918 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
919
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
920 private boolean assertDoublePeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
921 return assertDouble(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
922 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
923
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
924 private static boolean assertDouble(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
925 assert x != null && (x.getKind() == Kind.Double);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
926 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
927 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
928
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
929 private boolean assertHighPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
930 assert xpeek() == null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
931 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
932 }
19630
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
933
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
934 @Override
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
935 public int hashCode() {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
936 int result = hashCode(locals, locals.length);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
937 result *= 13;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
938 result += hashCode(stack, this.stackSize);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
939 return result;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
940 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
941
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
942 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: 19592
diff changeset
943 int result = 1;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
944 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: 19592
diff changeset
945 Object element = a[i];
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
946 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: 19592
diff changeset
947 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
948 return result;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
949 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
950
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
951 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: 19592
diff changeset
952 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: 19592
diff changeset
953 if (a[i] != b[i]) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
954 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
955 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
956 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
957 return true;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
958 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
959
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
960 @Override
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
961 public boolean equals(Object otherObject) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
962 if (otherObject instanceof HIRFrameStateBuilder) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
963 HIRFrameStateBuilder other = (HIRFrameStateBuilder) otherObject;
19636
5762e1d007b6 Fix issue found by CheckGraalInvariants.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19630
diff changeset
964 if (!other.method.equals(method)) {
19630
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
965 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
966 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
967 if (other.stackSize != stackSize) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
968 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
969 }
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
970 if (other.parser != parser) {
19630
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
971 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
972 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
973 if (other.rethrowException != rethrowException) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
974 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
975 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
976 if (other.graph != graph) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
977 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
978 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
979 if (other.locals.length != locals.length) {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
980 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
981 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
982 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: 19592
diff changeset
983 equals(other.monitorIds, monitorIds, monitorIds.length);
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
984 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
985 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
986 }
19962
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19821
diff changeset
987
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19821
diff changeset
988 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: 19821
diff changeset
989 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: 19821
diff changeset
990 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: 19821
diff changeset
991 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: 19821
diff changeset
992 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19821
diff changeset
993 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19821
diff changeset
994 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: 19821
diff changeset
995 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: 19821
diff changeset
996 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: 19821
diff changeset
997 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19821
diff changeset
998 }
9b669776bf8a added null checking for the receiver when inlining or applying an InvocationPlugin during graph parsing
Doug Simon <doug.simon@oracle.com>
parents: 19821
diff changeset
999 }
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
1000
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1001 @Override
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1002 public boolean isAfterSideEffect() {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1003 return sideEffects != null;
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1004 }
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1005
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1006 @Override
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1007 public Iterable<StateSplit> sideEffects() {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1008 return sideEffects;
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1009 }
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1010
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1011 @Override
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1012 public void addSideEffect(StateSplit sideEffect) {
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
1013 assert sideEffect != null;
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
1014 assert sideEffect.hasSideEffect();
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1015 if (sideEffects == null) {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1016 sideEffects = new ArrayList<>(4);
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
1017 }
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1018 sideEffects.add(sideEffect);
21289
3b5ec1a2b3b5 consolidate frame state creation and processing for intrinsics into graph parsing, removing need for CollapseFrameForSingleSideEffectPhase
Doug Simon <doug.simon@oracle.com>
parents: 20885
diff changeset
1019 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
1020 }