annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents b1530a6cce8c
children 47bebae7454f
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
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
25 import com.oracle.jvmci.code.BailoutException;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
26 import com.oracle.jvmci.code.BytecodeFrame;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
27 import com.oracle.jvmci.code.BytecodePosition;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
28 import com.oracle.jvmci.meta.ResolvedJavaType;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
29 import com.oracle.jvmci.meta.Signature;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
30 import com.oracle.jvmci.meta.ResolvedJavaMethod;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
31 import com.oracle.jvmci.meta.Kind;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
32 import com.oracle.jvmci.meta.JavaType;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
33 import static com.oracle.graal.graph.iterators.NodePredicates.*;
21352
6d5a198d23e6 consolidated AbstractBytecodeParser into BytecodeParser
Doug Simon <doug.simon@oracle.com>
parents: 21343
diff changeset
34 import static com.oracle.graal.java.GraphBuilderPhase.Options.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 15558
diff changeset
35
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
36 import java.util.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
37
15198
2c0cfbf454b5 Move LIRTypeTool and Stamp to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15145
diff changeset
38 import com.oracle.graal.compiler.common.type.*;
21352
6d5a198d23e6 consolidated AbstractBytecodeParser into BytecodeParser
Doug Simon <doug.simon@oracle.com>
parents: 21343
diff changeset
39 import com.oracle.graal.graphbuilderconf.IntrinsicContext.SideEffectsState;
19821
87736c089259 refactored graph builder plugins to be top level interfaces
Doug Simon <doug.simon@oracle.com>
parents: 19820
diff changeset
40 import com.oracle.graal.graphbuilderconf.*;
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
41 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
42 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
43 import com.oracle.graal.nodeinfo.*;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.nodes.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
45 import com.oracle.graal.nodes.calc.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.nodes.java.*;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
47 import com.oracle.graal.nodes.util.*;
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21388
diff changeset
48 import com.oracle.jvmci.common.*;
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21543
diff changeset
49 import com.oracle.jvmci.debug.*;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
50
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
51 public final class FrameStateBuilder implements SideEffectsState {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
52
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
53 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
54 static final MonitorIdNode[] EMPTY_MONITOR_ARRAY = new MonitorIdNode[0];
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
55
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
56 protected final BytecodeParser parser;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
57 protected final ResolvedJavaMethod method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
58 protected int stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
59 protected final ValueNode[] locals;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
60 protected final ValueNode[] stack;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
61 protected ValueNode[] lockedObjects;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
62
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
63 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
64 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
65 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
66 protected boolean rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
67
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
68 private MonitorIdNode[] monitorIds;
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
69 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
70 private FrameState outerFrameState;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
71
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
72 /**
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
73 * 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
74 * 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
75 */
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
76 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
77
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
78 /**
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
79 * 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
80 *
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
81 * @param method the method whose frame is simulated
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
82 * @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
83 */
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
84 public FrameStateBuilder(BytecodeParser parser, ResolvedJavaMethod method, StructuredGraph graph) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
85 this.parser = parser;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
86 this.method = method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
87 this.locals = allocateArray(method.getMaxLocals());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
88 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
89 this.lockedObjects = allocateArray(0);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
90
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
91 assert graph != null;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
92
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
93 this.monitorIds = EMPTY_MONITOR_ARRAY;
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
94 this.graph = graph;
18918
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
95 }
e8fd0342d9c4 GraphBuilder simplifications.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18913
diff changeset
96
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
97 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
98
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
99 int javaIndex = 0;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
100 int index = 0;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
101 if (!method.isStatic()) {
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
102 // 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
103 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
104 javaIndex = 1;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
105 index = 1;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
106 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
107 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
108 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
109 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
110 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
111 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
112 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
113 index++;
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
114 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
115 }
13e43d2a413e Initialize frame state builder created for parse time inlining correctly.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18918
diff changeset
116
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
117 public void initializeForMethodStart(boolean eagerResolve, ParameterPlugin parameterPlugin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
118
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
119 int javaIndex = 0;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
120 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
121 if (!method.isStatic()) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
122 // add the receiver
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
123 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
124 Stamp receiverStamp = StampFactory.declaredNonNull(method.getDeclaringClass());
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
125 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
126 receiver = parameterPlugin.interceptParameter(parser, index, receiverStamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
127 }
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
128 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
129 receiver = new ParameterNode(javaIndex, receiverStamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
130 }
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
131 locals[javaIndex] = graph.unique(receiver);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
132 javaIndex = 1;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
133 index = 1;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
134 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
135 Signature sig = method.getSignature();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
136 int max = sig.getParameterCount(false);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
137 ResolvedJavaType accessingClass = method.getDeclaringClass();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
138 for (int i = 0; i < max; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
139 JavaType type = sig.getParameterType(i, accessingClass);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
140 if (eagerResolve) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
141 type = type.resolve(accessingClass);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
142 }
15022
bceb077143ae Preserve value range in stamp of ParameterNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 14978
diff changeset
143 Kind kind = type.getKind();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
144 Stamp stamp;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
145 if (kind == Kind.Object && type instanceof ResolvedJavaType) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
146 stamp = StampFactory.declared((ResolvedJavaType) type);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
147 } else {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
148 stamp = StampFactory.forKind(kind);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
149 }
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
150 FloatingNode param = null;
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
151 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
152 param = parameterPlugin.interceptParameter(parser, index, stamp);
19112
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
153 }
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
154 if (param == null) {
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
155 param = new ParameterNode(index, stamp);
c2019f6e821b Draft for ParameterPlugin.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18995
diff changeset
156 }
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
157 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
158 javaIndex += kind.getSlotCount();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
159 index++;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
160 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
161 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
162
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
163 private FrameStateBuilder(FrameStateBuilder other) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
164 this.parser = other.parser;
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
165 this.method = other.method;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
166 this.stackSize = other.stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
167 this.locals = other.locals.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
168 this.stack = other.stack.clone();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
169 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
170 this.rethrowException = other.rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
171
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
172 assert locals.length == method.getMaxLocals();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
173 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
174
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
175 assert other.graph != null;
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
176 graph = other.graph;
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18230
diff changeset
177 monitorIds = other.monitorIds.length == 0 ? other.monitorIds : other.monitorIds.clone();
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
178
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
179 assert locals.length == method.getMaxLocals();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
180 assert stack.length == Math.max(1, method.getMaxStackSize());
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
181 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
182 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
183
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
184 private static ValueNode[] allocateArray(int length) {
18374
8971259db8ed Eliminated the need for Signature.getParameterSlots()
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18230
diff changeset
185 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
186 }
14e542e27076 Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents: 15022
diff changeset
187
14e542e27076 Lift implementation from HIRFrameStateBuilder up to AbstractFrameStateBuilder if possible.
Josef Eisl <josef.eisl@jku.at>
parents: 15022
diff changeset
188 @Override
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
189 public String toString() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
190 StringBuilder sb = new StringBuilder();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
191 sb.append("[locals: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
192 for (int i = 0; i < locals.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
193 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
194 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
195 sb.append("] stack: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
196 for (int i = 0; i < stackSize; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
197 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
198 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
199 sb.append("] locks: [");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
200 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
201 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
202 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
203 sb.append("]");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
204 if (rethrowException) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
205 sb.append(" rethrowException");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
206 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
207 sb.append("]");
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
208 return sb.toString();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
209 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
210
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
211 public FrameState create(int bci, StateSplit forStateSplit) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
212 if (parser.parsingIntrinsic()) {
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
213 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
214 }
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
215
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 // Skip intrinsic frames
21364
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
217 return create(bci, parser.getNonIntrinsicAncestor(), false, (ValueNode[]) null);
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
218 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
219
21364
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
220 /**
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
221 * @param pushedValues if non-null, values to {@link #push(Kind, ValueNode)} to the stack before
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
222 * creating the {@link FrameState}
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
223 */
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
224 public FrameState create(int bci, BytecodeParser parent, boolean duringCall, ValueNode... pushedValues) {
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
225 if (outerFrameState == null && parent != null) {
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
226 outerFrameState = parent.getFrameStateBuilder().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
227 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
228 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
229 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
230 return newFrameState;
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
231 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
232 if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21388
diff changeset
233 throw JVMCIError.shouldNotReachHere();
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
234 }
21364
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
235
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
236 if (pushedValues != null) {
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
237 int stackSizeToRestore = stackSize;
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
238 for (ValueNode arg : pushedValues) {
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
239 push(arg.getKind(), arg);
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
240 }
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
241 FrameState res = graph.add(new FrameState(outerFrameState, method, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
242 stackSize = stackSizeToRestore;
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
243 return res;
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
244 } else {
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
245 return graph.add(new FrameState(outerFrameState, method, bci, locals, stack, stackSize, lockedObjects, Arrays.asList(monitorIds), rethrowException, duringCall));
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
246 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
247 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
248
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
249 public BytecodePosition createBytecodePosition(int bci) {
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
250 BytecodeParser parent = parser.getParent();
21352
6d5a198d23e6 consolidated AbstractBytecodeParser into BytecodeParser
Doug Simon <doug.simon@oracle.com>
parents: 21343
diff changeset
251 if (HideSubstitutionStates.getValue()) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
252 if (parser.parsingIntrinsic()) {
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
253 // Attribute to the method being replaced
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
254 return new BytecodePosition(parent.getFrameStateBuilder().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
255 }
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
256 // Skip intrinsic frames
21364
600d37d28494 cleaned up and improved documentation for IntrinsicScope
Doug Simon <doug.simon@oracle.com>
parents: 21363
diff changeset
257 parent = parser.getNonIntrinsicAncestor();
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
258 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
259 return create(null, bci, parent);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
260 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
261
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
262 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
263 BytecodePosition outer = o;
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
264 if (outer == null && parent != null) {
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
265 outer = parent.getFrameStateBuilder().createBytecodePosition(parent.bci());
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
266 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
267 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
268 return FrameState.toBytecodePosition(outerFrameState);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
269 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
270 if (bci == BytecodeFrame.INVALID_FRAMESTATE_BCI) {
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21388
diff changeset
271 throw JVMCIError.shouldNotReachHere();
21294
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
272 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
273 return new BytecodePosition(outer, method, bci);
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
274 }
d5ee8f60459d Improve accuracy of info point states
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20885
diff changeset
275
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
276 public FrameStateBuilder copy() {
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
277 return new FrameStateBuilder(this);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
278 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
279
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
280 public boolean isCompatibleWith(FrameStateBuilder other) {
14803
Josef Eisl <josef.eisl@jku.at>
parents: 14793
diff changeset
281 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
282 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
283
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
284 if (stackSize() != other.stackSize()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
285 return false;
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 < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
288 ValueNode x = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
289 ValueNode y = other.stackAt(i);
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
290 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
291 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
292 }
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 if (lockedObjects.length != other.lockedObjects.length) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
295 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
296 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
297 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
298 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
299 throw new BailoutException("unbalanced monitors");
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 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
302 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
303 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
304
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
305 public void merge(AbstractMergeNode block, FrameStateBuilder other) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
306 assert isCompatibleWith(other);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
307
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
308 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
309 ValueNode curLocal = localAt(i);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
310 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
311 if (curLocal != mergedLocal) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
312 storeLocal(i, mergedLocal);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
313 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
314 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
315 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
316 ValueNode curStack = stackAt(i);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
317 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
318 if (curStack != mergedStack) {
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
319 storeStack(i, mergedStack);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
320 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
321 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
322 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
323 lockedObjects[i] = merge(lockedObjects[i], other.lockedObjects[i], block);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
324 assert monitorIds[i] == other.monitorIds[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
325 }
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
326
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
327 if (sideEffects == null) {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
328 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
329 } else {
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
330 if (other.sideEffects != null) {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
331 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
332 }
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
333 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
334 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
335
18995
a2cb19764970 Rename MergeNode to AbstractMergeNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18993
diff changeset
336 private ValueNode merge(ValueNode currentValue, ValueNode otherValue, AbstractMergeNode block) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
337 if (currentValue == null || currentValue.isDeleted()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
338 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
339 } else if (block.isPhiAtMerge(currentValue)) {
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
340 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
341 propagateDelete((ValuePhiNode) currentValue);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
342 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
343 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
344 ((PhiNode) currentValue).addInput(otherValue);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
345 return currentValue;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
346 } 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
347 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
348 if (otherValue == null || otherValue.isDeleted() || currentValue.getKind() != otherValue.getKind()) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
349 return null;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
350 }
19539
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
351 return createValuePhi(currentValue, otherValue, block);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
352 } else {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
353 return currentValue;
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 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
356
19539
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
357 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
358 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
359 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
360 phi.addInput(currentValue);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
361 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
362 phi.addInput(otherValue);
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
363 assert phi.valueCount() == block.phiPredecessorCount() + 1;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
364 return phi;
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
365 }
2c3ea61e8b65 Small clean up for graph building.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19538
diff changeset
366
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
367 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
368 assert node instanceof ValuePhiNode || node instanceof ProxyNode;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
369 if (node.isDeleted()) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
370 return;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
371 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
372 // 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
373 // 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
374 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
375
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
376 // 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
377 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
378 node.replaceAtUsages(null);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
379 node.safeDelete();
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
380
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
381 for (FloatingNode phiUsage : propagateUsages) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
382 propagateDelete(phiUsage);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
383 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
384 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
385
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
386 public void insertLoopPhis(LocalLiveness liveness, int loopId, LoopBeginNode loopBegin, boolean forcePhis) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
387 for (int i = 0; i < localsSize(); i++) {
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
388 boolean changedInLoop = liveness.localIsChangedInLoop(loopId, i);
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
389 if (changedInLoop || forcePhis) {
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
390 storeLocal(i, createLoopPhi(loopBegin, localAt(i), !changedInLoop));
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
391 }
14793
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 for (int i = 0; i < stackSize(); i++) {
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
394 storeStack(i, createLoopPhi(loopBegin, stackAt(i), false));
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
395 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
396 for (int i = 0; i < lockedObjects.length; i++) {
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
397 lockedObjects[i] = createLoopPhi(loopBegin, lockedObjects[i], false);
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
398 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
399 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
400
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
401 public void insertLoopProxies(LoopExitNode loopExit, FrameStateBuilder loopEntryState) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
402 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
403 ValueNode value = localAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
404 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
405 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
406 storeLocal(i, ProxyNode.forValue(value, loopExit, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
407 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
408 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
409 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
410 ValueNode value = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
411 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
412 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
413 storeStack(i, ProxyNode.forValue(value, loopExit, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
414 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
415 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
416 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
417 ValueNode value = lockedObjects[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
418 if (value != null && (!loopEntryState.contains(value) || loopExit.loopBegin().isPhiAtMerge(value))) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
419 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
420 lockedObjects[i] = ProxyNode.forValue(value, loopExit, graph);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
421 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
422 }
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
18993
480bd3b1adcd Rename BeginNode => AbstractBeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18934
diff changeset
425 public void insertProxies(AbstractBeginNode begin) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
426 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
427 ValueNode value = localAt(i);
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 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
430 storeLocal(i, ProxyNode.forValue(value, begin, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
431 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
432 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
433 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
434 ValueNode value = stackAt(i);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
435 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
436 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
437 storeStack(i, ProxyNode.forValue(value, begin, graph));
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
438 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
439 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
440 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
441 ValueNode value = lockedObjects[i];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
442 if (value != null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
443 Debug.log(" inserting proxy for %s", value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
444 lockedObjects[i] = ProxyNode.forValue(value, begin, graph);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
445 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
446 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
447 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
448
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
449 private ValuePhiNode createLoopPhi(AbstractMergeNode block, ValueNode value, boolean stampFromValue) {
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
450 if (value == null) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
451 return null;
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 assert !block.isPhiAtMerge(value) : "phi function for this block already created";
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
454
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
455 ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(stampFromValue ? value.stamp() : value.stamp().unrestricted(), block));
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
456 phi.addInput(value);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
457 return phi;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
458 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
459
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
460 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
461 * 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
462 *
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
463 * @param object the object whose monitor will be locked.
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 public void pushLock(ValueNode object, MonitorIdNode monitorId) {
14817
80147dac0d6e LIRFrameStateBuilder added
Niclas Adlertz <niclas.adlertz@oracle.com>
parents: 14803
diff changeset
466 assert object.isAlive() && object.getKind() == Kind.Object : "unexpected value: " + object;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
467 lockedObjects = Arrays.copyOf(lockedObjects, lockedObjects.length + 1);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
468 monitorIds = Arrays.copyOf(monitorIds, monitorIds.length + 1);
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
469 lockedObjects[lockedObjects.length - 1] = object;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
470 monitorIds[monitorIds.length - 1] = monitorId;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
471 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
472 }
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 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
475 * 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
476 *
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
477 * @return the object whose monitor was removed from the locks list.
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 ValueNode popLock() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
480 try {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
481 return lockedObjects[lockedObjects.length - 1];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
482 } finally {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
483 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
484 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
485 assert lockedObjects.length == monitorIds.length;
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
486 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
487 }
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 public MonitorIdNode peekMonitorId() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
490 return monitorIds[monitorIds.length - 1];
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
491 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
492
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
493 /**
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
494 * @return the current lock depth
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 public int lockDepth() {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
497 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
498 return lockedObjects.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
499 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
500
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
501 public boolean contains(ValueNode value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
502 for (int i = 0; i < localsSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
503 if (localAt(i) == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
504 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
505 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
506 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
507 for (int i = 0; i < stackSize(); i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
508 if (stackAt(i) == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
509 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
510 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
511 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
512 assert lockedObjects.length == monitorIds.length;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
513 for (int i = 0; i < lockedObjects.length; i++) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
514 if (lockedObjects[i] == value || monitorIds[i] == value) {
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
515 return true;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
516 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
517 }
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
518 return false;
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
519 }
19538
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 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
522 /*
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
523 * (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
524 * 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
525 * 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
526 * 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
527 */
21388
e4eae0fb72d0 Always do liveness analysis, but allow non-clearing of local variables; centralize omitAssertion code in bytecode parser
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21364
diff changeset
528 if (!parser.graphBuilderConfig.clearNonLiveLocals()) {
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
529 return;
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 if (liveIn) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
532 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
533 if (!liveness.localIsLiveIn(block, i)) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
534 locals[i] = null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
535 }
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 } else {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
538 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
539 if (!liveness.localIsLiveOut(block, i)) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
540 locals[i] = null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
541 }
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 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
544 }
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 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
548 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
549 public boolean rethrowException() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
550 return rethrowException;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
551 }
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 * @see BytecodeFrame#rethrowException
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
555 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
556 public void setRethrowException(boolean b) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
557 rethrowException = b;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
558 }
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 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
561 * 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
562 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
563 * @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
564 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
565 public int localsSize() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
566 return locals.length;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
567 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
568
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 * 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
571 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
572 public int stackSize() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
573 return stackSize;
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
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 * 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
578 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
579 * @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
580 * @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
581 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
582 public ValueNode localAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
583 return locals[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
584 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
585
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 * 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
588 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
589 * @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
590 * @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
591 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
592 public ValueNode stackAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
593 return stack[i];
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
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
596 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
597 * 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
598 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
599 * @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
600 * @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
601 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
602 public ValueNode lockAt(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
603 return lockedObjects[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
604 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
605
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
606 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
607 lockedObjects[i] = lock;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
608 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
609
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
610 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
611 * 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
612 * 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
613 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
614 * @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
615 * @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
616 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
617 public ValueNode loadLocal(int i) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
618 ValueNode x = locals[i];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
619 assert assertLoadLocal(i, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
620 return x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
621 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
622
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
623 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
624 assert x != null : i;
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
625 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
626 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
627 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
628 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
629
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
630 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
631 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
632 }
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
633
19538
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 * 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
636 * 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
637 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
638 * @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
639 * @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
640 */
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
641 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
642 assert assertStoreLocal(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
643 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
644 if (x != null) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
645 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
646 // 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
647 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
648 }
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
649 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
650 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
651 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
652 // 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
653 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
654 }
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
655 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
656 }
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
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
659 private boolean assertStoreLocal(ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
660 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
661 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
662 }
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 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
665 assert assertStoreStack(i, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
666 stack[i] = x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
667 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
668
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
669 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
670 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
671 return true;
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
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 * 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
676 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
677 * @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
678 * @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
679 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
680 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
681 assert assertPush(kind, x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
682 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
683 if (kind.needsTwoSlots()) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
684 xpush(null);
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 private boolean assertPush(Kind kind, ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
689 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
690 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
691 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
692 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
693
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
694 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
695 * 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
696 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
697 * @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
698 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
699 public void xpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
700 assert assertXpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
701 stack[stackSize++] = x;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
702 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
703
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
704 private boolean assertXpush(ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
705 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
706 return true;
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
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 * 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
711 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
712 * @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
713 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
714 public void ipush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
715 assert assertInt(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
716 xpush(x);
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
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 * 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
721 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
722 * @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
723 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
724 public void fpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
725 assert assertFloat(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
726 xpush(x);
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 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
730 * 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
731 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
732 * @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
733 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
734 public void apush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
735 assert assertObject(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
736 xpush(x);
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 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
740 * 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
741 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
742 * @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
743 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
744 public void lpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
745 assert assertLong(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
746 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
747 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
748 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
749
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 * 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
752 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
753 * @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
754 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
755 public void dpush(ValueNode x) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
756 assert assertDouble(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
757 xpush(x);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
758 xpush(null);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
759 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
760
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
761 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
762 if (kind != Kind.Void) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
763 push(kind.getStackKind(), x);
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 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
768 * 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
769 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
770 * @param kind the expected type
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
771 * @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
772 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
773 public ValueNode pop(Kind kind) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
774 if (kind.needsTwoSlots()) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
775 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
776 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
777 assert assertPop(kind);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
778 return xpop();
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
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
781 private boolean assertPop(Kind kind) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
782 assert kind != Kind.Void;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
783 ValueNode x = xpeek();
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
784 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
785 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
786 }
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 * 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
790 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
791 * @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
792 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
793 public ValueNode xpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
794 return stack[--stackSize];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
795 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
796
19553
0362d64c0cd4 Small refactoring of DUP/POP bytecode processing.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19539
diff changeset
797 public ValueNode xpeek() {
19538
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
798 return stack[stackSize - 1];
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
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 * 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
803 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
804 * @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
805 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
806 public ValueNode ipop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
807 assert assertIntPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
808 return xpop();
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
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 * 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
813 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
814 * @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
815 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
816 public ValueNode fpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
817 assert assertFloatPeek();
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 an object.
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 apop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
827 assert assertObjectPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
828 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
829 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
830
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 * 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
833 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
834 * @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
835 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
836 public ValueNode lpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
837 assert assertHighPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
838 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
839 assert assertLongPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
840 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
841 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
842
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
843 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
844 * 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
845 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
846 * @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
847 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
848 public ValueNode dpop() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
849 assert assertHighPeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
850 xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
851 assert assertDoublePeek();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
852 return xpop();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
853 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
854
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 * 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
857 * instructions.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
858 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
859 * @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
860 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
861 public ValueNode[] popArguments(int argSize) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
862 ValueNode[] result = allocateArray(argSize);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
863 int newStackSize = stackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
864 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
865 newStackSize--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
866 if (stack[newStackSize] == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
867 /* Two-slot value. */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
868 newStackSize--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
869 assert stack[newStackSize].getKind().needsTwoSlots();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
870 } else {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
871 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
872 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
873 result[i] = stack[newStackSize];
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
874 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
875 stackSize = newStackSize;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
876 return result;
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
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 * 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
881 *
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
882 * @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
883 * 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
884 * ignored.
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
885 * @return The peeked argument.
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 public ValueNode peek(int argumentNumber) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
888 int idx = stackSize() - 1;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
889 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
890 if (stackAt(idx) == null) {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
891 idx--;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
892 assert stackAt(idx).getKind().needsTwoSlots();
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
893 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
894 idx--;
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 return stackAt(idx);
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
897 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
898
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
899 /**
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
900 * 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
901 */
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
902 public void clearStack() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
903 stackSize = 0;
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 boolean assertLongPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
907 return assertLong(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
908 }
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 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
911 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
912 return true;
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 assertIntPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
916 return assertInt(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
917 }
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 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
920 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
921 return true;
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 boolean assertFloatPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
925 return assertFloat(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
926 }
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 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
929 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
930 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
931 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
932
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
933 private boolean assertObjectPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
934 return assertObject(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
935 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
936
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
937 private boolean assertObject(ValueNode x) {
21311
710fc7216c56 consolidated ReplacementContext and IntrinsicContext
Doug Simon <doug.simon@oracle.com>
parents: 21299
diff changeset
938 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
939 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
940 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
941
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
942 private boolean assertDoublePeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
943 return assertDouble(xpeek());
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
944 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
945
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
946 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
947 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
948 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
949 }
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
950
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
951 private boolean assertHighPeek() {
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
952 assert xpeek() == null;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
953 return true;
97b35083d49d Reduce casting in AbstractBytecodeParser. Consolidate asserts in HIRFrameStateBuilder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19494
diff changeset
954 }
19630
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 @Override
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
957 public int hashCode() {
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
958 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
959 result *= 13;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
960 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
961 return result;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
962 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
963
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
964 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
965 int result = 1;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
966 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
967 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
968 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
969 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
970 return result;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
971 }
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 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
974 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
975 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
976 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
977 }
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 return true;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
980 }
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 @Override
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
983 public boolean equals(Object otherObject) {
21363
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
984 if (otherObject instanceof FrameStateBuilder) {
ead75077228b rename GraphBuilderPhase.getFrameState to getFrameStateBuilder
Doug Simon <doug.simon@oracle.com>
parents: 21352
diff changeset
985 FrameStateBuilder other = (FrameStateBuilder) otherObject;
19636
5762e1d007b6 Fix issue found by CheckGraalInvariants.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19630
diff changeset
986 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
987 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
988 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
989 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
990 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
991 }
19775
14e703edb2ab use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents: 19636
diff changeset
992 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
993 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
994 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
995 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
996 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
997 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
998 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
999 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
1000 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
1001 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
1002 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
1003 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
1004 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
1005 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
1006 }
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
1007 return false;
490f2c54c28a Support for creating merges during partial evaluation of bytecode interpreters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19592
diff changeset
1008 }
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
1009
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
1010 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
1011 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
1012 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
1013 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
1014 }
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
1015 }
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
1016 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
1017 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
1018 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
1019 }
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
1020 }
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
1021 }
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
1022
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1023 @Override
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1024 public boolean isAfterSideEffect() {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1025 return sideEffects != null;
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1026 }
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1027
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1028 @Override
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1029 public Iterable<StateSplit> sideEffects() {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1030 return sideEffects;
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1031 }
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1032
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1033 @Override
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1034 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
1035 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
1036 assert sideEffect.hasSideEffect();
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1037 if (sideEffects == null) {
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1038 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
1039 }
21343
ce95a5e36927 removed unnecessary Intrinsic interface
Doug Simon <doug.simon@oracle.com>
parents: 21311
diff changeset
1040 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
1041 }
14793
c4e65d48887c Added the HIRAbstractFrameStateBuilder
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
diff changeset
1042 }