annotate graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java @ 7041:d730d8febfcf

Avoid call to MetaUtil.format in GraphBuilder if it is not necessary
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 27 Nov 2012 11:29:06 +0100
parents e35077f6d2a2
children 4cef3dfcaedc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
4233
fa53d5e4aa35 Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4205
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.java;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
5568
fdf19fa15ce4 Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
25 import static com.oracle.graal.bytecode.Bytecodes.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import static java.lang.reflect.Modifier.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.lang.reflect.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
31 import com.oracle.graal.api.code.*;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
32 import com.oracle.graal.api.code.RuntimeCall.Descriptor;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
33 import com.oracle.graal.api.meta.*;
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
34 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
35 import com.oracle.graal.api.meta.ProfilingInfo.ExceptionSeen;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
36 import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
5568
fdf19fa15ce4 Split bytecode utilities into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
37 import com.oracle.graal.bytecode.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.debug.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
40 import com.oracle.graal.java.BciBlockMapping.Block;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
41 import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
43 import com.oracle.graal.nodes.calc.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
44 import com.oracle.graal.nodes.extended.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
45 import com.oracle.graal.nodes.java.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
46 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
47 import com.oracle.graal.nodes.type.*;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
48 import com.oracle.graal.nodes.util.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6521
diff changeset
49 import com.oracle.graal.phases.*;
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6521
diff changeset
50 import com.oracle.graal.phases.util.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 public final class GraphBuilderPhase extends Phase {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
6534
feb579677b58 SnippetTemplate must not depend on CodeCacheProvider (only on MetaAccessProvider). This means that the hasSideEffect flag of a RuntimeCall must be already fixed in the RuntimeCall.Descriptor to avoid a lookup of the actual RuntimeCall using the CodeCacheProvider.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
57 public static final Descriptor CREATE_NULL_POINTER_EXCEPTION = new Descriptor("createNullPointerException", true, Kind.Object);
feb579677b58 SnippetTemplate must not depend on CodeCacheProvider (only on MetaAccessProvider). This means that the hasSideEffect flag of a RuntimeCall must be already fixed in the RuntimeCall.Descriptor to avoid a lookup of the actual RuntimeCall using the CodeCacheProvider.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6526
diff changeset
58 public static final Descriptor CREATE_OUT_OF_BOUNDS_EXCEPTION = new Descriptor("createOutOfBoundsException", true, Kind.Object, Kind.Int);
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6511
diff changeset
59
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6511
diff changeset
60
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 * The minimum value to which {@link GraalOptions#TraceBytecodeParserLevel} must be set to trace
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 * the bytecode instructions as they are parsed.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 public static final int TRACELEVEL_INSTRUCTIONS = 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 * The minimum value to which {@link GraalOptions#TraceBytecodeParserLevel} must be set to trace
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 * the frame state before each bytecode instruction as it is parsed.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 public static final int TRACELEVEL_STATE = 2;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
73 private StructuredGraph currentGraph;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
5629
26a060cc58ca Initial implementation of closed world analysis by iteratively expanding the universe starting at method entry points.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5572
diff changeset
75 private final MetaAccessProvider runtime;
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
76 private ConstantPool constantPool;
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
77 private ResolvedJavaMethod method;
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
78 private int entryBCI;
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
79 private ProfilingInfo profilingInfo;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80
4203
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
81 private BytecodeStream stream; // the bytecode stream
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 private FrameStateBuilder frameState; // the current execution state
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 private Block currentBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 private ValueNode methodSynchronizedObject;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
87 private ExceptionDispatchBlock unwindBlock;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 private Block returnBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 private FixedWithNextNode lastInstr; // the last instruction added
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
92 private final GraphBuilderConfiguration graphBuilderConfig;
5114
dad1ac9dba7d finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5110
diff changeset
93 private final OptimisticOptimizations optimisticOpts;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94
5129
51111665eda6 Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
95 private long graphId;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
96
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
97 /**
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
98 * Node that marks the begin of block during bytecode parsing. When a block is identified the first
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
99 * time as a jump target, the placeholder is created and used as the successor for the jump. When the
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
100 * block is seen the second time, a MergeNode is created to correctly merge the now two different
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
101 * predecessor states.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
102 */
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
103 private static class BlockPlaceholderNode extends FixedWithNextNode implements Node.IterableNodeType {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
104 public BlockPlaceholderNode() {
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5425
diff changeset
105 super(StampFactory.forVoid());
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
106 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
107 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
108
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
109 private Block[] loopHeaders;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
110
5629
26a060cc58ca Initial implementation of closed world analysis by iteratively expanding the universe starting at method entry points.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5572
diff changeset
111 public GraphBuilderPhase(MetaAccessProvider runtime, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts) {
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
112 this.graphBuilderConfig = graphBuilderConfig;
5114
dad1ac9dba7d finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5110
diff changeset
113 this.optimisticOpts = optimisticOpts;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 this.runtime = runtime;
5629
26a060cc58ca Initial implementation of closed world analysis by iteratively expanding the universe starting at method entry points.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5572
diff changeset
115 assert runtime != null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 protected void run(StructuredGraph graph) {
4203
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
120 method = graph.method();
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
121 entryBCI = graph.getEntryBCI();
5129
51111665eda6 Support for recording a leaf graph id for each deoptimization point in the debug info.
Lukas Stadler <lukas.stadler@jku.at>
parents: 5061
diff changeset
122 graphId = graph.graphId();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
123 profilingInfo = method.getProfilingInfo();
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
124 assert method.getCode() != null : "method must contain bytecodes: " + method;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
125 this.stream = new BytecodeStream(method.getCode());
4203
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
126 this.constantPool = method.getConstantPool();
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
127 unwindBlock = null;
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
128 returnBlock = null;
847e9dcb4980 Add graph builder to the phase plan.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4199
diff changeset
129 methodSynchronizedObject = null;
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
130 this.currentGraph = graph;
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
131 this.frameState = new FrameStateBuilder(method, graph, graphBuilderConfig.eagerResolving());
6992
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
132 TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method);
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
133 try {
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
134 build();
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
135 } finally {
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
136 filter.remove();
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
137 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 protected String getDetailedName() {
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5704
diff changeset
142 return getName() + " " + MetaUtil.format("%H.%n(%p):%r", method);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
145 private BciBlockMapping createBlockMap() {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
146 BciBlockMapping map = new BciBlockMapping(method);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 map.build();
7041
d730d8febfcf Avoid call to MetaUtil.format in GraphBuilder if it is not necessary
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6992
diff changeset
148 if (Debug.isDumpEnabled()) {
d730d8febfcf Avoid call to MetaUtil.format in GraphBuilder if it is not necessary
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6992
diff changeset
149 Debug.dump(map, MetaUtil.format("After block building %f %R %H.%n(%P)", method));
d730d8febfcf Avoid call to MetaUtil.format in GraphBuilder if it is not necessary
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6992
diff changeset
150 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 return map;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 private void build() {
5040
4d6e5ddf70e5 added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4997
diff changeset
156 if (GraalOptions.PrintProfilingInformation) {
5344
f47c770756e6 moved RiResolvedMethod.dumpProfile() to CiUtil.profileAsString()
Doug Simon <doug.simon@oracle.com>
parents: 5343
diff changeset
157 TTY.println("Profiling info for " + method);
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5704
diff changeset
158 TTY.println(MetaUtil.indent(MetaUtil.profileToString(profilingInfo, method, CodeUtil.NEW_LINE), " "));
5040
4d6e5ddf70e5 added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4997
diff changeset
159 }
4d6e5ddf70e5 added option to print the profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4997
diff changeset
160
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161 // compute the block map, setup exception handlers and get the entrypoint(s)
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
162 BciBlockMapping blockMap = createBlockMap();
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
163 loopHeaders = blockMap.loopHeaders;
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4233
diff changeset
164
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
165 lastInstr = currentGraph.start();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
166 if (isSynchronized(method.getModifiers())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 // add a monitor enter to the start block
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
168 currentGraph.start().setStateAfter(frameState.create(FrameState.BEFORE_BCI));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 methodSynchronizedObject = synchronizedObject(frameState, method);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 lastInstr = genMonitorEnter(methodSynchronizedObject);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
172 frameState.clearNonLiveLocals(blockMap.startBlock.localsLiveIn);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 // finish the start block
5373
53cc37c27b04 used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents: 5372
diff changeset
175 ((StateSplit) lastInstr).setStateAfter(frameState.create(0));
6692
349127dc59de fix for bug in GraphBuilderPhase (which caused a NPE in insertLoopProxies)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6681
diff changeset
176
349127dc59de fix for bug in GraphBuilderPhase (which caused a NPE in insertLoopProxies)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6681
diff changeset
177 currentBlock = blockMap.startBlock;
349127dc59de fix for bug in GraphBuilderPhase (which caused a NPE in insertLoopProxies)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6681
diff changeset
178 blockMap.startBlock.entryState = frameState;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 if (blockMap.startBlock.isLoopHeader) {
6692
349127dc59de fix for bug in GraphBuilderPhase (which caused a NPE in insertLoopProxies)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6681
diff changeset
180 // TODO(lstadler,gduboscq) createTarget might not be safe at this position, since it expects currentBlock,
349127dc59de fix for bug in GraphBuilderPhase (which caused a NPE in insertLoopProxies)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6681
diff changeset
181 // etc. to be set up correctly. A better solution to this problem of start blocks that are loop headers
349127dc59de fix for bug in GraphBuilderPhase (which caused a NPE in insertLoopProxies)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6681
diff changeset
182 // would be to create a dummy block in BciBlockMapping.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 appendGoto(createTarget(blockMap.startBlock, frameState));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 blockMap.startBlock.firstInstruction = lastInstr;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
188 for (Block block : blockMap.blocks) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
189 processBlock(block);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
190 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
191 processBlock(returnBlock);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
192 processBlock(unwindBlock);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
193
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
194 Debug.dump(currentGraph, "After bytecode parsing");
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
195
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 connectLoopEndToBegin();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197
5097
5d0925455be1 Canonicalize some filter usages. Fix for graph printer's escape (escape invalid control chars). Small comment fixes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
198 // remove Placeholders
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
199 for (BlockPlaceholderNode n : currentGraph.getNodes(BlockPlaceholderNode.class)) {
4309
4a609a685fa4 changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4307
diff changeset
200 currentGraph.removeFixed(n);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 // remove dead FrameStates
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
204 for (Node n : currentGraph.getNodes(FrameState.class)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 if (n.usages().size() == 0 && n.predecessor() == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 n.safeDelete();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 private Block unwindBlock(int bci) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 if (unwindBlock == null) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
213 unwindBlock = new ExceptionDispatchBlock();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214 unwindBlock.startBci = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 unwindBlock.endBci = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 unwindBlock.deoptBci = bci;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
217 unwindBlock.blockID = Integer.MAX_VALUE;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 return unwindBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 private Block returnBlock(int bci) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 if (returnBlock == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 returnBlock = new Block();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 returnBlock.startBci = bci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 returnBlock.endBci = bci;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
227 returnBlock.blockID = Integer.MAX_VALUE;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 return returnBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 public BytecodeStream stream() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 return stream;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 public int bci() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 return stream.currentBCI();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
240 private void loadLocal(int index, Kind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 frameState.push(kind, frameState.loadLocal(index));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
244 private void storeLocal(Kind kind, int index) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 frameState.storeLocal(index, frameState.pop(kind));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
248 public static boolean covers(ExceptionHandler handler, int bci) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
249 return handler.getStartBCI() <= bci && bci < handler.getEndBCI();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
252 public static boolean isCatchAll(ExceptionHandler handler) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 return handler.catchTypeCPI() == 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255
5373
53cc37c27b04 used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents: 5372
diff changeset
256 private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 assert bci == FrameState.BEFORE_BCI || bci == bci() : "invalid bci";
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
258 Debug.log("Creating exception dispatch edges at %d, exception object=%s, exception seen=%s", bci, exceptionObject, profilingInfo.getExceptionSeen(bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
260 Block dispatchBlock = currentBlock.exceptionDispatchBlock();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
261 // The exception dispatch block is always for the last bytecode of a block, so if we are not at the endBci yet,
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
262 // there is no exception handler for this bci and we can unwind immediately.
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
263 if (bci != currentBlock.endBci || dispatchBlock == null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
264 dispatchBlock = unwindBlock(bci);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
267 FrameStateBuilder dispatchState = frameState.copy();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
268 dispatchState.clearStack();
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
269
5373
53cc37c27b04 used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents: 5372
diff changeset
270 DispatchBeginNode dispatchBegin = currentGraph.add(new DispatchBeginNode());
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
271 dispatchBegin.setStateAfter(dispatchState.create(bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
273 if (exceptionObject == null) {
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5425
diff changeset
274 ExceptionObjectNode newExceptionObject = currentGraph.add(new ExceptionObjectNode(runtime));
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
275 dispatchState.apush(newExceptionObject);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
276 dispatchState.setRethrowException(true);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
277 newExceptionObject.setStateAfter(dispatchState.create(bci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
279 FixedNode target = createTarget(dispatchBlock, dispatchState);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
280 dispatchBegin.setNext(newExceptionObject);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
281 newExceptionObject.setNext(target);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 } else {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
283 dispatchState.apush(exceptionObject);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
284 dispatchState.setRethrowException(true);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
285
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
286 FixedNode target = createTarget(dispatchBlock, dispatchState);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
287 dispatchBegin.setNext(target);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
289 return dispatchBegin;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291
4315
4c223446c28e Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents: 4310
diff changeset
292 private void genLoadConstant(int cpi, int opcode) {
4316
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
293 Object con = lookupConstant(cpi, opcode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
295 if (con instanceof JavaType) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 // this is a load of class constant which might be unresolved
5719
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5704
diff changeset
297 JavaType type = (JavaType) con;
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5704
diff changeset
298 if (type instanceof ResolvedJavaType) {
429accae15aa moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents: 5704
diff changeset
299 frameState.push(Kind.Object, append(ConstantNode.forConstant(((ResolvedJavaType) type).getEncoding(Representation.JavaClass), runtime, currentGraph)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
301 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
302 frameState.push(Kind.Object, append(ConstantNode.forObject(null, runtime, currentGraph)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 }
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
304 } else if (con instanceof Constant) {
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
305 Constant constant = (Constant) con;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
306 frameState.push(constant.getKind().getStackKind(), appendConstant(constant));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 throw new Error("lookupConstant returned an object of incorrect type");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
312 private void genLoadIndexed(Kind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 emitExplicitExceptions(frameState.peek(1), frameState.peek(0));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 ValueNode index = frameState.ipop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 ValueNode array = frameState.apop();
5401
332a3c0d7b3b remove array length input from LoadIndexedNode and StoreIndexedNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5375
diff changeset
317 ValueNode v = append(currentGraph.add(new LoadIndexedNode(array, index, kind, graphId)));
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
318 frameState.push(kind.getStackKind(), v);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
321 private void genStoreIndexed(Kind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 emitExplicitExceptions(frameState.peek(2), frameState.peek(1));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
324 ValueNode value = frameState.pop(kind.getStackKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 ValueNode index = frameState.ipop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326 ValueNode array = frameState.apop();
5401
332a3c0d7b3b remove array length input from LoadIndexedNode and StoreIndexedNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 5375
diff changeset
327 StoreIndexedNode result = currentGraph.add(new StoreIndexedNode(array, index, kind, value, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328 append(result);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
330
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331 private void stackOp(int opcode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 switch (opcode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 case POP: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
335 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 case POP2: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 case DUP: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 ValueNode w = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 frameState.xpush(w);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 frameState.xpush(w);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 case DUP_X1: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 ValueNode w1 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 ValueNode w2 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 case DUP_X2: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 ValueNode w1 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358 ValueNode w2 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 ValueNode w3 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
361 frameState.xpush(w3);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
362 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 case DUP2: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 ValueNode w1 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 ValueNode w2 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 case DUP2_X1: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 ValueNode w1 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 ValueNode w2 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 ValueNode w3 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 frameState.xpush(w3);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 case DUP2_X2: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 ValueNode w1 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 ValueNode w2 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 ValueNode w3 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 ValueNode w4 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 frameState.xpush(w4);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 frameState.xpush(w3);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 case SWAP: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 ValueNode w1 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 ValueNode w2 = frameState.xpop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402 frameState.xpush(w1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 frameState.xpush(w2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 default:
4524
dcc8f5c6f394 Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4484
diff changeset
407 throw GraalInternalError.shouldNotReachHere();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
412 private void genArithmeticOp(Kind result, int opcode, boolean canTrap) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 ValueNode y = frameState.pop(result);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 ValueNode x = frameState.pop(result);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
415 boolean isStrictFP = isStrict(method.getModifiers());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 ArithmeticNode v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 switch(opcode){
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 case IADD:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 case LADD: v = new IntegerAddNode(result, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 case FADD:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 case DADD: v = new FloatAddNode(result, x, y, isStrictFP); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 case ISUB:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 case LSUB: v = new IntegerSubNode(result, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 case FSUB:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 case DSUB: v = new FloatSubNode(result, x, y, isStrictFP); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 case IMUL:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 case LMUL: v = new IntegerMulNode(result, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 case FMUL:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 case DMUL: v = new FloatMulNode(result, x, y, isStrictFP); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 case IDIV:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431 case LDIV: v = new IntegerDivNode(result, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 case FDIV:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 case DDIV: v = new FloatDivNode(result, x, y, isStrictFP); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 case IREM:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 case LREM: v = new IntegerRemNode(result, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 case FREM:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 case DREM: v = new FloatRemNode(result, x, y, isStrictFP); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 default:
4616
53168434d0df Transform some CiBailout into GraalInternalError
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4614
diff changeset
439 throw new GraalInternalError("should not reach");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 }
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
441 ValueNode result1 = append(currentGraph.unique(v));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 if (canTrap) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
443 append(currentGraph.add(new ValueAnchorNode(result1)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 frameState.push(result, result1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
448 private void genNegateOp(Kind kind) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
449 frameState.push(kind, append(currentGraph.unique(new NegateNode(frameState.pop(kind)))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
452 private void genShiftOp(Kind kind, int opcode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 ValueNode s = frameState.ipop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 ValueNode x = frameState.pop(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 ShiftNode v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 switch(opcode){
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 case ISHL:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 case LSHL: v = new LeftShiftNode(kind, x, s); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 case ISHR:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460 case LSHR: v = new RightShiftNode(kind, x, s); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 case IUSHR:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 case LUSHR: v = new UnsignedRightShiftNode(kind, x, s); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463 default:
4616
53168434d0df Transform some CiBailout into GraalInternalError
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4614
diff changeset
464 throw new GraalInternalError("should not reach");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 }
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
466 frameState.push(kind, append(currentGraph.unique(v)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
469 private void genLogicOp(Kind kind, int opcode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 ValueNode y = frameState.pop(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 ValueNode x = frameState.pop(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 LogicNode v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 switch(opcode){
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 case IAND:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 case LAND: v = new AndNode(kind, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 case IOR:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 case LOR: v = new OrNode(kind, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 case IXOR:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 case LXOR: v = new XorNode(kind, x, y); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 default:
4616
53168434d0df Transform some CiBailout into GraalInternalError
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4614
diff changeset
481 throw new GraalInternalError("should not reach");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 }
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
483 frameState.push(kind, append(currentGraph.unique(v)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
486 private void genCompareOp(Kind kind, boolean isUnorderedLess) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 ValueNode y = frameState.pop(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 ValueNode x = frameState.pop(kind);
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
489 frameState.ipush(append(currentGraph.unique(new NormalizeCompareNode(x, y, isUnorderedLess))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 private void genConvert(ConvertNode.Op opcode) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
493 ValueNode input = frameState.pop(opcode.from.getStackKind());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
494 frameState.push(opcode.to.getStackKind(), append(currentGraph.unique(new ConvertNode(opcode, input))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 private void genIncrement() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 int index = stream().readLocalIndex();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 int delta = stream().readIncrement();
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
500 ValueNode x = frameState.loadLocal(index);
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
501 ValueNode y = append(ConstantNode.forInt(delta, currentGraph));
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
502 frameState.storeLocal(index, append(currentGraph.unique(new IntegerAddNode(Kind.Int, x, y))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
505 private void genGoto() {
5050
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5049
diff changeset
506 double probability = profilingInfo.getBranchTakenProbability(bci());
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5049
diff changeset
507 if (probability < 0) {
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5049
diff changeset
508 probability = 1;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5049
diff changeset
509 }
5051
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
510 appendGoto(createTarget(probability, currentBlock.successors.get(0), frameState));
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
511 assert currentBlock.numNormalSuccessors() == 1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 private void ifNode(ValueNode x, Condition cond, ValueNode y) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 assert !x.isDeleted() && !y.isDeleted();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
516 assert currentBlock.numNormalSuccessors() == 2;
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
517 Block trueBlock = currentBlock.successors.get(0);
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
518 Block falseBlock = currentBlock.successors.get(1);
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
519 if (trueBlock == falseBlock) {
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
520 appendGoto(createTarget(trueBlock, frameState));
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
521 return;
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
522 }
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
523
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4266
diff changeset
524 double probability = profilingInfo.getBranchTakenProbability(bci());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 if (probability < 0) {
4997
0c9196f57172 use profiling information whenever possible
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4692
diff changeset
526 assert probability == -1 : "invalid probability";
4399
a74fd31c017e Remove TraceProbability flag.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4370
diff changeset
527 Debug.log("missing probability in %s at bci %d", method, bci());
5043
879ac08596b8 fix after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5042
diff changeset
528 probability = 0.5;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
531 // the mirroring and negation operations get the condition into canonical form
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
532 boolean mirror = cond.canonicalMirror();
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
533 boolean negate = cond.canonicalNegate();
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
534
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
535 ValueNode a = mirror ? y : x;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
536 ValueNode b = mirror ? x : y;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
537
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
538 CompareNode condition;
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
539 assert !a.kind().isFloatOrDouble();
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
540 if (cond == Condition.EQ || cond == Condition.NE) {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
541 if (a.kind() == Kind.Object) {
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
542 condition = new ObjectEqualsNode(a, b);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
543 } else {
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
544 condition = new IntegerEqualsNode(a, b);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
545 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
546 } else {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
547 assert a.kind() != Kind.Object && !cond.isUnsigned();
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
548 condition = new IntegerLessThanNode(a, b);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
549 }
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
550 condition = currentGraph.unique(condition);
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
551
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
552 BeginNode trueSuccessor = createBlockTarget(probability, trueBlock, frameState);
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
553 BeginNode falseSuccessor = createBlockTarget(1 - probability, falseBlock, frameState);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
554
5695
a63ed5993987 Add leadGraphID to IfNOde so that we can convert them to deopts
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5648
diff changeset
555 IfNode ifNode = negate ? new IfNode(condition, falseSuccessor, trueSuccessor, 1 - probability, graphId) : new IfNode(condition, trueSuccessor, falseSuccessor, probability, graphId);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
556 append(currentGraph.add(ifNode));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
557 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
558
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559 private void genIfZero(Condition cond) {
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
560 ValueNode y = appendConstant(Constant.INT_0);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
561 ValueNode x = frameState.ipop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562 ifNode(x, cond, y);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
563 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
564
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
565 private void genIfNull(Condition cond) {
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
566 ValueNode y = appendConstant(Constant.NULL_OBJECT);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
567 ValueNode x = frameState.apop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
568 ifNode(x, cond, y);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
569 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
570
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
571 private void genIfSame(Kind kind, Condition cond) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572 ValueNode y = frameState.pop(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
573 ValueNode x = frameState.pop(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
574 assert !x.isDeleted() && !y.isDeleted();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
575 ifNode(x, cond, y);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
576 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
578 private void genThrow() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
579 ValueNode exception = frameState.apop();
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
580 FixedGuardNode node = currentGraph.add(new FixedGuardNode(currentGraph.unique(new IsNullNode(exception)), DeoptimizationReason.NullCheckException, DeoptimizationAction.InvalidateReprofile, true, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 append(node);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
582 append(handleException(exception, bci()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
583 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
584
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
585 private JavaType lookupType(int cpi, int bytecode) {
4315
4c223446c28e Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents: 4310
diff changeset
586 eagerResolvingForSnippets(cpi, bytecode);
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
587 JavaType result = constantPool.lookupType(cpi, bytecode);
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
588 assert !graphBuilderConfig.eagerResolvingForSnippets() || result instanceof ResolvedJavaType;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
591
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
592 private JavaMethod lookupMethod(int cpi, int opcode) {
4315
4c223446c28e Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents: 4310
diff changeset
593 eagerResolvingForSnippets(cpi, opcode);
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
594 JavaMethod result = constantPool.lookupMethod(cpi, opcode);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
595 assert !graphBuilderConfig.eagerResolvingForSnippets() || ((result instanceof ResolvedJavaMethod) && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
597 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
598
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
599 private JavaField lookupField(int cpi, int opcode) {
4315
4c223446c28e Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents: 4310
diff changeset
600 eagerResolvingForSnippets(cpi, opcode);
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
601 JavaField result = constantPool.lookupField(cpi, opcode);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
602 assert !graphBuilderConfig.eagerResolvingForSnippets() || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
605
4316
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
606 private Object lookupConstant(int cpi, int opcode) {
5562
4ffc061dc71a commented out use of non-snippet eager resolving in GraphBuilder
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
607 eagerResolvingForSnippets(cpi, opcode);
4316
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
608 Object result = constantPool.lookupConstant(cpi);
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
609 assert !graphBuilderConfig.eagerResolving() || !(result instanceof JavaType) || (result instanceof ResolvedJavaType);
4316
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
610 return result;
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
611 }
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
612
5562
4ffc061dc71a commented out use of non-snippet eager resolving in GraphBuilder
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
613 // private void eagerResolving(int cpi, int bytecode) {
4ffc061dc71a commented out use of non-snippet eager resolving in GraphBuilder
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
614 // if (graphBuilderConfig.eagerResolving()) {
4ffc061dc71a commented out use of non-snippet eager resolving in GraphBuilder
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
615 // constantPool.loadReferencedType(cpi, bytecode);
4ffc061dc71a commented out use of non-snippet eager resolving in GraphBuilder
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
616 // }
4ffc061dc71a commented out use of non-snippet eager resolving in GraphBuilder
Doug Simon <doug.simon@oracle.com>
parents: 5547
diff changeset
617 // }
4316
b4b16e4e043f Fix eager resolving for class constants
Peter Hofer <peter.hofer@jku.at>
parents: 4315
diff changeset
618
4315
4c223446c28e Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents: 4310
diff changeset
619 private void eagerResolvingForSnippets(int cpi, int bytecode) {
5109
6766253384bf more preparations for disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5105
diff changeset
620 if (graphBuilderConfig.eagerResolvingForSnippets()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
621 constantPool.loadReferencedType(cpi, bytecode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
622 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
624
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
625 private JavaTypeProfile getProfileForTypeCheck(ResolvedJavaType type) {
5369
2e9a5365dfb0 moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
626 if (!optimisticOpts.useTypeCheckHints() || TypeCheckHints.isFinalClass(type)) {
2e9a5365dfb0 moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
627 return null;
4433
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
628 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
629 ResolvedJavaType uniqueSubtype = type.findUniqueConcreteSubtype();
4433
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
630 if (uniqueSubtype != null) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
631 return new JavaTypeProfile(0.0D, new ProfiledType(uniqueSubtype, 1.0D));
4433
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
632 } else {
5369
2e9a5365dfb0 moved conversion of type profiles into hints for type check instructions from front end to lowering phase
Doug Simon <doug.simon@oracle.com>
parents: 5362
diff changeset
633 return profilingInfo.getTypeProfile(bci());
4433
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
634 }
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
635 }
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
636 }
b494d6f329a3 some more checkcast opts
Lukas Stadler <lukas.stadler@jku.at>
parents: 4432
diff changeset
637
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
638 private void genCheckCast() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
639 int cpi = stream().readCPI();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
640 JavaType type = lookupType(cpi, CHECKCAST);
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
641 boolean initialized = type instanceof ResolvedJavaType;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
642 if (initialized) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
643 ValueNode object = frameState.apop();
6648
7bf5a6c42db7 factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
644 CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) type, object, getProfileForTypeCheck((ResolvedJavaType) type)));
5372
4485e0edd1af made CheckCastNode be a FixedNode instead of a BooleanNode
Doug Simon <doug.simon@oracle.com>
parents: 5371
diff changeset
645 append(checkCast);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
646 frameState.apush(checkCast);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
647 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
648 ValueNode object = frameState.apop();
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
649 append(currentGraph.add(new FixedGuardNode(currentGraph.unique(new IsNullNode(object)), DeoptimizationReason.Unresolved, DeoptimizationAction.InvalidateRecompile, graphId)));
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
650 frameState.apush(appendConstant(Constant.NULL_OBJECT));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
651 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
652 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
653
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 private void genInstanceOf() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
655 int cpi = stream().readCPI();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
656 JavaType type = lookupType(cpi, INSTANCEOF);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657 ValueNode object = frameState.apop();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
658 if (type instanceof ResolvedJavaType) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
659 ResolvedJavaType resolvedType = (ResolvedJavaType) type;
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6552
diff changeset
660 InstanceOfNode instanceOfNode = new InstanceOfNode((ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType));
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5760
diff changeset
661 frameState.ipush(append(MaterializeNode.create(currentGraph.unique(instanceOfNode))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 } else {
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
663 BlockPlaceholderNode successor = currentGraph.add(new BlockPlaceholderNode());
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
664 DeoptimizeNode deopt = currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId));
5703
05c5f68e23d5 Fix some If probabilities in graph builder
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5695
diff changeset
665 IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new IsNullNode(object)), successor, deopt, 1, graphId));
4326
2b7474c492a9 Generate if(!=null){Deopt}else{...} In the unresolved case for instanceof instead of always deopting
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4316
diff changeset
666 append(ifNode);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
667 lastInstr = successor;
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
668 frameState.ipush(appendConstant(Constant.INT_0));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
670 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
671
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
672 void genNewInstance(int cpi) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
673 JavaType type = lookupType(cpi, NEW);
5648
1cfa35d467de removed support for compiling allocation of instances of non-initialized classes
Doug Simon <doug.simon@oracle.com>
parents: 5630
diff changeset
674 if (type instanceof ResolvedJavaType && ((ResolvedJavaType) type).isInitialized()) {
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6500
diff changeset
675 NewInstanceNode n = currentGraph.add(new NewInstanceNode((ResolvedJavaType) type, true, false));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
676 frameState.apush(append(n));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
677 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
678 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
679 frameState.apush(appendConstant(Constant.NULL_OBJECT));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
680 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
681 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
682
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 * Gets the kind of array elements for the array type code that appears
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685 * in a {@link Bytecodes#NEWARRAY} bytecode.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686 * @param code the array type code
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
687 * @return the kind from the array type code
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
688 */
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
689 public static Class< ? > arrayTypeCodeToClass(int code) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
690 // Checkstyle: stop
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
691 switch (code) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
692 case 4: return boolean.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
693 case 5: return char.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
694 case 6: return float.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
695 case 7: return double.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
696 case 8: return byte.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
697 case 9: return short.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
698 case 10: return int.class;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
699 case 11: return long.class;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
700 default: throw new IllegalArgumentException("unknown array type code: " + code);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
701 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
702 // Checkstyle: resume
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
703 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
705 private void genNewPrimitiveArray(int typeCode) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
706 Class< ? > clazz = arrayTypeCodeToClass(typeCode);
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
707 ResolvedJavaType elementType = runtime.lookupJavaType(clazz);
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6500
diff changeset
708 NewPrimitiveArrayNode nta = currentGraph.add(new NewPrimitiveArrayNode(elementType, frameState.ipop(), true, false));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 frameState.apush(append(nta));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
710 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
711
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
712 private void genNewObjectArray(int cpi) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
713 JavaType type = lookupType(cpi, ANEWARRAY);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714 ValueNode length = frameState.ipop();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
715 if (type instanceof ResolvedJavaType) {
6511
0b62a9d44c21 add infrastructure for creating locked objects
Lukas Stadler <lukas.stadler@jku.at>
parents: 6500
diff changeset
716 NewArrayNode n = currentGraph.add(new NewObjectArrayNode((ResolvedJavaType) type, length, true, false));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 frameState.apush(append(n));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
718 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
719 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
720 frameState.apush(appendConstant(Constant.NULL_OBJECT));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
722
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
723 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
725 private void genNewMultiArray(int cpi) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
726 JavaType type = lookupType(cpi, MULTIANEWARRAY);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 int rank = stream().readUByte(bci() + 3);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 ValueNode[] dims = new ValueNode[rank];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
729 for (int i = rank - 1; i >= 0; i--) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
730 dims[i] = frameState.ipop();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731 }
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
732 if (type instanceof ResolvedJavaType) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
733 FixedWithNextNode n = currentGraph.add(new NewMultiArrayNode((ResolvedJavaType) type, dims));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
734 frameState.apush(append(n));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
736 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
737 frameState.apush(appendConstant(Constant.NULL_OBJECT));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
738 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
739 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
741 private void genGetField(JavaField field) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
742 emitExplicitExceptions(frameState.peek(0), null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
743
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
744 Kind kind = field.getKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
745 ValueNode receiver = frameState.apop();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
746 if ((field instanceof ResolvedJavaField) && ((ResolvedJavaField) field).getDeclaringClass().isInitialized()) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
747 LoadFieldNode load = currentGraph.add(new LoadFieldNode(receiver, (ResolvedJavaField) field, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748 appendOptimizedLoadField(kind, load);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
749 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
750 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
751 frameState.push(kind.getStackKind(), append(ConstantNode.defaultForKind(kind, currentGraph)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 public static class ExceptionInfo {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
757 public final FixedWithNextNode exceptionEdge;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758 public final ValueNode exception;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
759
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
760 public ExceptionInfo(FixedWithNextNode exceptionEdge, ValueNode exception) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
761 this.exceptionEdge = exceptionEdge;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
762 this.exception = exception;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
763 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
764 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
765
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
766 private void emitNullCheck(ValueNode receiver) {
6552
3cd6c6743a6a Do not generate null check for values already proven to be non-null.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
767 if (receiver.stamp().nonNull()) {
3cd6c6743a6a Do not generate null check for values already proven to be non-null.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
768 return;
3cd6c6743a6a Do not generate null check for values already proven to be non-null.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
769 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
770 BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode());
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
771 BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode());
5703
05c5f68e23d5 Fix some If probabilities in graph builder
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5695
diff changeset
772 IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new IsNullNode(receiver)), trueSucc, falseSucc, 0.5, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
774 append(ifNode);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
775 lastInstr = falseSucc;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
776
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
777 if (GraalOptions.OmitHotExceptionStacktrace) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
778 ValueNode exception = ConstantNode.forObject(new NullPointerException(), runtime, currentGraph);
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
779 trueSucc.setNext(handleException(exception, bci()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
780 } else {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6511
diff changeset
781 RuntimeCallNode call = currentGraph.add(new RuntimeCallNode(CREATE_NULL_POINTER_EXCEPTION));
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
782 call.setStateAfter(frameState.create(bci()));
5425
0364a2a874b8 changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5401
diff changeset
783 trueSucc.setNext(call);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
784 call.setNext(handleException(call, bci()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
786 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
788 private void emitBoundsCheck(ValueNode index, ValueNode length) {
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
789 BlockPlaceholderNode trueSucc = currentGraph.add(new BlockPlaceholderNode());
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
790 BlockPlaceholderNode falseSucc = currentGraph.add(new BlockPlaceholderNode());
5703
05c5f68e23d5 Fix some If probabilities in graph builder
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5695
diff changeset
791 IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new IntegerBelowThanNode(index, length)), trueSucc, falseSucc, 0.5, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
792
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 append(ifNode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
794 lastInstr = trueSucc;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
795
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
796 if (GraalOptions.OmitHotExceptionStacktrace) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
797 ValueNode exception = ConstantNode.forObject(new ArrayIndexOutOfBoundsException(), runtime, currentGraph);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
798 falseSucc.setNext(handleException(exception, bci()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
799 } else {
6521
2a0c9f20baa1 consolidated framework for runtime and stub calls and moved declaration of descriptors for such calls to the source file in which they are used
Doug Simon <doug.simon@oracle.com>
parents: 6511
diff changeset
800 RuntimeCallNode call = currentGraph.add(new RuntimeCallNode(CREATE_OUT_OF_BOUNDS_EXCEPTION, index));
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
801 call.setStateAfter(frameState.create(bci()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 falseSucc.setNext(call);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
803 call.setNext(handleException(call, bci()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
806
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 private void emitExplicitExceptions(ValueNode receiver, ValueNode outOfBoundsIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808 assert receiver != null;
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
809 if (!GraalOptions.AllowExplicitExceptionChecks || (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == ExceptionSeen.FALSE)) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
810 return;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
811 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
813 emitNullCheck(receiver);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
814 if (outOfBoundsIndex != null) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
815 ValueNode length = append(currentGraph.add(new ArrayLengthNode(receiver)));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
816 emitBoundsCheck(outOfBoundsIndex, length);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
817 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
818 Debug.metric("ExplicitExceptions").increment();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
819 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
820
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
821 private void genPutField(JavaField field) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
822 emitExplicitExceptions(frameState.peek(1), null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
823
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
824 ValueNode value = frameState.pop(field.getKind().getStackKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
825 ValueNode receiver = frameState.apop();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
826 if (field instanceof ResolvedJavaField && ((ResolvedJavaField) field).getDeclaringClass().isInitialized()) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
827 StoreFieldNode store = currentGraph.add(new StoreFieldNode(receiver, (ResolvedJavaField) field, value, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
828 appendOptimizedStoreField(store);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
829 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
830 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
831 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
832 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
833
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
834 private void genGetStatic(JavaField field) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
835 JavaType holder = field.getDeclaringClass();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
836 boolean isInitialized = (field instanceof ResolvedJavaField) && ((ResolvedJavaType) holder).isInitialized();
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
837 Constant constantValue = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
838 if (isInitialized) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
839 constantValue = ((ResolvedJavaField) field).readConstantValue(null);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
840 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
841 if (constantValue != null) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
842 frameState.push(constantValue.getKind().getStackKind(), appendConstant(constantValue));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
843 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
844 ValueNode container = genTypeOrDeopt(field.getKind() == Kind.Object ? Representation.StaticObjectFields : Representation.StaticPrimitiveFields, holder, isInitialized);
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
845 Kind kind = field.getKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
846 if (container != null) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
847 LoadFieldNode load = currentGraph.add(new LoadFieldNode(container, (ResolvedJavaField) field, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
848 appendOptimizedLoadField(kind, load);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
849 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
850 // deopt will be generated by genTypeOrDeopt, not needed here
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
851 frameState.push(kind.getStackKind(), append(ConstantNode.defaultForKind(kind, currentGraph)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
852 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
853 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
854 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
855
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
856 private void genPutStatic(JavaField field) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
857 JavaType holder = field.getDeclaringClass();
6401
3b3af8fc32a7 Distinguish between the Representation of primitive and Object fields so that Object fields can be stored in a different place.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6354
diff changeset
858 boolean isInitialized = (field instanceof ResolvedJavaField) && ((ResolvedJavaType) holder).isInitialized();
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
859 ValueNode container = genTypeOrDeopt(field.getKind() == Kind.Object ? Representation.StaticObjectFields : Representation.StaticPrimitiveFields, holder, isInitialized);
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
860 ValueNode value = frameState.pop(field.getKind().getStackKind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861 if (container != null) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
862 StoreFieldNode store = currentGraph.add(new StoreFieldNode(container, (ResolvedJavaField) field, value, graphId));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
863 appendOptimizedStoreField(store);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
865 // deopt will be generated by genTypeOrDeopt, not needed here
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
867 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
868
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
869 private ConstantNode genTypeOrDeopt(Representation representation, JavaType holder, boolean initialized) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
870 if (initialized) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
871 return appendConstant(((ResolvedJavaType) holder).getEncoding(representation));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
872 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
873 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
874 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
875 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
876 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
877
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
878 private void appendOptimizedStoreField(StoreFieldNode store) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
879 append(store);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
880 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
881
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
882 private void appendOptimizedLoadField(Kind kind, LoadFieldNode load) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
883 // append the load to the instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
884 ValueNode optimized = append(load);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
885 frameState.push(kind.getStackKind(), optimized);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
886 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
887
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
888 private void genInvokeStatic(JavaMethod target) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
889 if (target instanceof ResolvedJavaMethod) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
890 ResolvedJavaMethod resolvedTarget = (ResolvedJavaMethod) target;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
891 ResolvedJavaType holder = resolvedTarget.getDeclaringClass();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
892 if (!holder.isInitialized() && GraalOptions.ResolveClassBeforeStaticInvoke) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
893 genInvokeDeopt(target, false);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
894 } else {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
895 ValueNode[] args = frameState.popArguments(resolvedTarget.getSignature().getParameterSlots(false), resolvedTarget.getSignature().getParameterCount(false));
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
896 appendInvoke(InvokeKind.Static, resolvedTarget, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
897 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
898 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
899 genInvokeDeopt(target, false);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
900 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
901 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
902
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
903 private void genInvokeInterface(JavaMethod target) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
904 if (target instanceof ResolvedJavaMethod) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
905 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(true), target.getSignature().getParameterCount(true));
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
906 genInvokeIndirect(InvokeKind.Interface, (ResolvedJavaMethod) target, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
907 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
908 genInvokeDeopt(target, true);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
909 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
910 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
911
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
912 private void genInvokeVirtual(JavaMethod target) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
913 if (target instanceof ResolvedJavaMethod) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
914 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(true), target.getSignature().getParameterCount(true));
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
915 genInvokeIndirect(InvokeKind.Virtual, (ResolvedJavaMethod) target, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
916 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917 genInvokeDeopt(target, true);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
918 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
919
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
920 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
921
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
922 private void genInvokeSpecial(JavaMethod target) {
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
923 if (target instanceof ResolvedJavaMethod) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
924 assert target != null;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
925 assert target.getSignature() != null;
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
926 ValueNode[] args = frameState.popArguments(target.getSignature().getParameterSlots(true), target.getSignature().getParameterCount(true));
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
927 invokeDirect((ResolvedJavaMethod) target, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
928 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929 genInvokeDeopt(target, true);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
930 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
931 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
932
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
933 private void genInvokeDeopt(JavaMethod unresolvedTarget, boolean withReceiver) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
934 append(currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.Unresolved, graphId)));
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
935 frameState.popArguments(unresolvedTarget.getSignature().getParameterSlots(withReceiver), unresolvedTarget.getSignature().getParameterCount(withReceiver));
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
936 Kind kind = unresolvedTarget.getSignature().getReturnKind();
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
937 if (kind != Kind.Void) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
938 frameState.push(kind.getStackKind(), append(ConstantNode.defaultForKind(kind, currentGraph)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
942 private void genInvokeIndirect(InvokeKind invokeKind, ResolvedJavaMethod target, ValueNode[] args) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
943 ValueNode receiver = args[0];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
944 // attempt to devirtualize the call
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
945 ResolvedJavaType klass = target.getDeclaringClass();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
946
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
947 // 0. check for trivial cases
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
948 if (target.canBeStaticallyBound()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
949 // check for trivial cases (e.g. final methods, nonvirtual methods)
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
950 invokeDirect(target, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
951 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
952 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
953 // 1. check if the exact type of the receiver can be determined
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6699
diff changeset
954 ResolvedJavaType exact = klass.asExactType();
5443
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5425
diff changeset
955 if (exact == null && receiver.objectStamp().isExactType()) {
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5425
diff changeset
956 exact = receiver.objectStamp().type();
141817e206d4 changes to the dependencies and stamp system:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5425
diff changeset
957 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
958 if (exact != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
959 // either the holder class is exact, or the receiver object has an exact type
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
960 invokeDirect(exact.resolveMethod(target), args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
961 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
962 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
963 // devirtualization failed, produce an actual invokevirtual
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
964 appendInvoke(invokeKind, target, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
965 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
966
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
967 private void invokeDirect(ResolvedJavaMethod target, ValueNode[] args) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
968 appendInvoke(InvokeKind.Special, target, args);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
969 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
970
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
971 private void appendInvoke(InvokeKind invokeKind, ResolvedJavaMethod targetMethod, ValueNode[] args) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
972 Kind resultType = targetMethod.getSignature().getReturnKind();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
973 if (GraalOptions.DeoptALot) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
974 DeoptimizeNode deoptimize = currentGraph.add(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.RuntimeConstraint, graphId));
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
975 deoptimize.setMessage("invoke " + targetMethod.getName());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
976 append(deoptimize);
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
977 frameState.pushReturn(resultType, ConstantNode.defaultForKind(resultType, currentGraph));
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
978 return;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
979 }
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
980
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
981 JavaType returnType = targetMethod.getSignature().getReturnType(method.getDeclaringClass());
5752
6e9c7af8ce5d Fixed propagation of return type into call sites. Eager resolve return type when specified in the graph builder. Added new test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5648
diff changeset
982 if (graphBuilderConfig.eagerResolvingForSnippets()) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
983 returnType = returnType.resolve(targetMethod.getDeclaringClass());
5752
6e9c7af8ce5d Fixed propagation of return type into call sites. Eager resolve return type when specified in the graph builder. Added new test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5648
diff changeset
984 }
6e9c7af8ce5d Fixed propagation of return type into call sites. Eager resolve return type when specified in the graph builder. Added new test case.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5648
diff changeset
985 MethodCallTargetNode callTarget = currentGraph.add(new MethodCallTargetNode(invokeKind, targetMethod, args, returnType));
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
986 // be conservative if information was not recorded (could result in endless recompiles otherwise)
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
987 if (optimisticOpts.useExceptionProbability() && profilingInfo.getExceptionSeen(bci()) == ExceptionSeen.FALSE) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
988 ValueNode result = appendWithBCI(currentGraph.add(new InvokeNode(callTarget, bci(), graphId)));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
989 frameState.pushReturn(resultType, result);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
990
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
991 } else {
5373
53cc37c27b04 used more specific BeginNode subclass where appropriate
Doug Simon <doug.simon@oracle.com>
parents: 5372
diff changeset
992 DispatchBeginNode exceptionEdge = handleException(null, bci());
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
993 InvokeWithExceptionNode invoke = currentGraph.add(new InvokeWithExceptionNode(callTarget, exceptionEdge, bci(), graphId));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
994 ValueNode result = append(invoke);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
995 frameState.pushReturn(resultType, result);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
996 Block nextBlock = currentBlock.successors.get(0);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
997
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
998 assert bci() == currentBlock.endBci;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
999 frameState.clearNonLiveLocals(currentBlock.localsLiveOut);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1000
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1001 invoke.setNext(createTarget(nextBlock, frameState));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1002 invoke.setStateAfter(frameState.create(nextBlock.startBci));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1003 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1004 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1005
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1006 private void callRegisterFinalizer() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1007 // append a call to the finalizer registration
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1008 append(currentGraph.add(new RegisterFinalizerNode(frameState.loadLocal(0))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1009 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1010
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1011 private void genReturn(ValueNode x) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1012 frameState.clearStack();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1013 if (x != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1014 frameState.push(x.kind(), x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1015 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1016 appendGoto(createTarget(returnBlock(bci()), frameState));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1017 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1018
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1019 private MonitorEnterNode genMonitorEnter(ValueNode x) {
6444
5ebe3e5a892b fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 6436
diff changeset
1020 frameState.pushLock(x);
4233
fa53d5e4aa35 Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4205
diff changeset
1021 MonitorEnterNode monitorEnter = currentGraph.add(new MonitorEnterNode(x));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1022 appendWithBCI(monitorEnter);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1023 return monitorEnter;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1024 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1025
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1026 private MonitorExitNode genMonitorExit(ValueNode x) {
6436
5395ecdfce8a move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6401
diff changeset
1027 ValueNode lockedObject = frameState.popLock();
6444
5ebe3e5a892b fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 6436
diff changeset
1028 if (GraphUtil.originalValue(lockedObject) != GraphUtil.originalValue(x)) {
5ebe3e5a892b fix bailouts due to insufficient balanced monitor checks
Lukas Stadler <lukas.stadler@jku.at>
parents: 6436
diff changeset
1029 throw new BailoutException("unbalanced monitors: mismatch at monitorexit, %s != %s", GraphUtil.originalValue(x), GraphUtil.originalValue(lockedObject));
6436
5395ecdfce8a move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6401
diff changeset
1030 }
4233
fa53d5e4aa35 Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4205
diff changeset
1031 MonitorExitNode monitorExit = currentGraph.add(new MonitorExitNode(x));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 appendWithBCI(monitorExit);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1033 return monitorExit;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1034 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1035
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 private void genJsr(int dest) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1037 Block successor = currentBlock.jsrSuccessor;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1038 assert successor.startBci == dest : successor.startBci + " != " + dest + " @" + bci();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1039 JsrScope scope = currentBlock.jsrScope;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1040 if (!successor.jsrScope.pop().equals(scope)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1041 throw new JsrNotSupportedBailout("unstructured control flow (internal limitation)");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1042 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1043 if (successor.jsrScope.nextReturnAddress() != stream().nextBCI()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1044 throw new JsrNotSupportedBailout("unstructured control flow (internal limitation)");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1045 }
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1046 frameState.push(Kind.Jsr, ConstantNode.forJsr(stream().nextBCI(), currentGraph));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1047 appendGoto(createTarget(successor, frameState));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1048 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1049
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1050 private void genRet(int localIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1051 Block successor = currentBlock.retSuccessor;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1052 ValueNode local = frameState.loadLocal(localIndex);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1053 JsrScope scope = currentBlock.jsrScope;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1054 int retAddress = scope.nextReturnAddress();
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
1055 append(currentGraph.add(new FixedGuardNode(currentGraph.unique(new IntegerEqualsNode(local, ConstantNode.forJsr(retAddress, currentGraph))), DeoptimizationReason.JavaSubroutineMismatch, DeoptimizationAction.InvalidateReprofile, graphId)));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1056 if (!successor.jsrScope.equals(scope.pop())) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1057 throw new JsrNotSupportedBailout("unstructured control flow (ret leaves more than one scope)");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1058 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1059 appendGoto(createTarget(successor, frameState));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1060 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1061
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1062 private double[] switchProbability(int numberOfCases, int bci) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4266
diff changeset
1063 double[] prob = profilingInfo.getSwitchProbabilities(bci);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1064 if (prob != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1065 assert prob.length == numberOfCases;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1066 } else {
4399
a74fd31c017e Remove TraceProbability flag.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4370
diff changeset
1067 Debug.log("Missing probability (switch) in %s at bci %d", method, bci);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1068 prob = new double[numberOfCases];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1069 for (int i = 0; i < numberOfCases; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1070 prob[i] = 1.0d / numberOfCases;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1071 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1072 }
5146
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1073 assert allPositive(prob);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1074 return prob;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1075 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1076
5146
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1077 private static boolean allPositive(double[] a) {
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1078 for (double d : a) {
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1079 if (d < 0) {
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1080 return false;
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1081 }
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1082 }
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1083 return true;
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1084 }
25903e52af48 Add assertion around probabilities, and fix potential problem in ComputeProbabilityPhase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5130
diff changeset
1085
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1086 private void genSwitch(BytecodeSwitch bs) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1087 int bci = bci();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1088 ValueNode value = frameState.ipop();
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1089
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1090 int nofCases = bs.numberOfCases();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1091
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1092 Map<Integer, Integer> bciToSuccessorIndex = new HashMap<>();
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1093 int successorCount = currentBlock.successors.size();
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1094 for (int i = 0; i < successorCount; i++) {
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1095 assert !bciToSuccessorIndex.containsKey(currentBlock.successors.get(i).startBci);
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1096 if (!bciToSuccessorIndex.containsKey(currentBlock.successors.get(i).startBci)) {
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1097 bciToSuccessorIndex.put(currentBlock.successors.get(i).startBci, i);
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1098 }
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1099 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1100
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1101 double[] keyProbabilities = switchProbability(nofCases + 1, bci);
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1102
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1103 int[] keys = new int[nofCases];
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1104 int[] keySuccessors = new int[nofCases + 1];
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1105 for (int i = 0; i < nofCases; i++) {
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1106 keys[i] = bs.keyAt(i);
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1107 keySuccessors[i] = bciToSuccessorIndex.get(bs.targetAt(i));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1108 }
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1109 keySuccessors[nofCases] = bciToSuccessorIndex.get(bs.defaultTarget());
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1110
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1111 double[] successorProbabilities = IntegerSwitchNode.successorProbabilites(successorCount, keySuccessors, keyProbabilities);
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1112 IntegerSwitchNode lookupSwitch = currentGraph.add(new IntegerSwitchNode(value, successorCount, keys, keyProbabilities, keySuccessors));
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1113 for (int i = 0; i < successorCount; i++) {
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1114 lookupSwitch.setBlockSuccessor(i, createBlockTarget(successorProbabilities[i], currentBlock.successors.get(i), frameState));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1115 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1116 append(lookupSwitch);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1118
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1119 private ConstantNode appendConstant(Constant constant) {
5629
26a060cc58ca Initial implementation of closed world analysis by iteratively expanding the universe starting at method entry points.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5572
diff changeset
1120 assert constant != null;
5572
8f9c9d372e31 small renaming and doc fixes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5571
diff changeset
1121 return ConstantNode.forConstant(constant, runtime, currentGraph);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1122 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1123
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1124 private ValueNode append(FixedNode fixed) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1125 lastInstr.setNext(fixed);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1126 lastInstr = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1127 return fixed;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1128 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1129
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1130 private ValueNode append(FixedWithNextNode x) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1131 return appendWithBCI(x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1132 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1133
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1134 private static ValueNode append(ValueNode v) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1135 return v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1136 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1137
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1138 private ValueNode appendWithBCI(FixedWithNextNode x) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1139 assert x.predecessor() == null : "instruction should not have been appended yet";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1140 assert lastInstr.next() == null : "cannot append instruction to instruction which isn't end (" + lastInstr + "->" + lastInstr.next() + ")";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1141 lastInstr.setNext(x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1142 lastInstr = x;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1143 return x;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1144 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1145
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1146 private static class Target {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1147 FixedNode fixed;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1148 FrameStateBuilder state;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1149 public Target(FixedNode fixed, FrameStateBuilder state) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1150 this.fixed = fixed;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1151 this.state = state;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1152 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1153 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1154
5255
38feba3e8526 separated safepoints out of LoopEndNodes into SafepointNodes
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
1155 private Target checkLoopExit(FixedNode target, Block targetBlock, FrameStateBuilder state) {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1156 if (currentBlock != null) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1157 long exits = currentBlock.loops & ~targetBlock.loops;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1158 if (exits != 0) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1159 LoopExitNode firstLoopExit = null;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1160 LoopExitNode lastLoopExit = null;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1161
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1162 int pos = 0;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1163 ArrayList<Block> exitLoops = new ArrayList<>(Long.bitCount(exits));
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1164 do {
5767
5967805da8f5 fix bug in BciBlockMapping that leads to bailouts on methods with more than 32 loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 5719
diff changeset
1165 long lMask = 1L << pos;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1166 if ((exits & lMask) != 0) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1167 exitLoops.add(loopHeaders[pos]);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1168 exits &= ~lMask;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1169 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1170 pos++;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1171 } while (exits != 0);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1172
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1173 Collections.sort(exitLoops, new Comparator<Block>() {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1174 @Override
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1175 public int compare(Block o1, Block o2) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1176 return Long.bitCount(o2.loops) - Long.bitCount(o1.loops);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1177 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1178 });
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1179
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1180 int bci = targetBlock.startBci;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1181 if (targetBlock instanceof ExceptionDispatchBlock) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1182 bci = ((ExceptionDispatchBlock) targetBlock).deoptBci;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1183 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1184 FrameStateBuilder newState = state.copy();
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1185 for (Block loop : exitLoops) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1186 LoopBeginNode loopBegin = (LoopBeginNode) loop.firstInstruction;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1187 LoopExitNode loopExit = currentGraph.add(new LoopExitNode(loopBegin));
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1188 if (lastLoopExit != null) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1189 lastLoopExit.setNext(loopExit);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1190 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1191 if (firstLoopExit == null) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1192 firstLoopExit = loopExit;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1193 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1194 lastLoopExit = loopExit;
5255
38feba3e8526 separated safepoints out of LoopEndNodes into SafepointNodes
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
1195 Debug.log("Target %s (%s) Exits %s, scanning framestates...", targetBlock, target, loop);
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1196 newState.insertLoopProxies(loopExit, loop.entryState);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1197 loopExit.setStateAfter(newState.create(bci));
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1198 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1199
5255
38feba3e8526 separated safepoints out of LoopEndNodes into SafepointNodes
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
1200 lastLoopExit.setNext(target);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1201 return new Target(firstLoopExit, newState);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1202 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1203 }
5255
38feba3e8526 separated safepoints out of LoopEndNodes into SafepointNodes
Doug Simon <doug.simon@oracle.com>
parents: 5210
diff changeset
1204 return new Target(target, state);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1205 }
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1206
5051
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1207 private FixedNode createTarget(double probability, Block block, FrameStateBuilder stateAfter) {
5786
f69a406355b2 new tail duplication phase
Lukas Stadler <lukas.stadler@jku.at>
parents: 5768
diff changeset
1208 assert probability >= 0 && probability <= 1.01 : probability;
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1209 if (probability == 0 && optimisticOpts.removeNeverExecutedCode() && entryBCI == StructuredGraph.INVOCATION_ENTRY_BCI) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
1210 return currentGraph.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.UnreachedCode, graphId));
5051
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1211 } else {
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1212 return createTarget(block, stateAfter);
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1213 }
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1214 }
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1215
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1216 private FixedNode createTarget(Block block, FrameStateBuilder state) {
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1217 assert block != null && state != null;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1218 assert !block.isExceptionEntry || state.stackSize() == 1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1219
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1220 if (block.firstInstruction == null) {
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1221 // This is the first time we see this block as a branch target.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1222 // Create and return a placeholder that later can be replaced with a MergeNode when we see this block again.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1223 block.firstInstruction = currentGraph.add(new BlockPlaceholderNode());
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1224 Target target = checkLoopExit(block.firstInstruction, block, state);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1225 FixedNode result = target.fixed;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1226 block.entryState = target.state == state ? state.copy() : target.state;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1227 block.entryState.clearNonLiveLocals(block.localsLiveIn);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1228
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1229 Debug.log("createTarget %s: first visit, result: %s", block, block.firstInstruction);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1230 return result;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1231 }
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1232
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1233 // We already saw this block before, so we have to merge states.
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1234 if (!block.entryState.isCompatibleWith(state)) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
1235 throw new BailoutException("stacks do not match; bytecodes would not verify");
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1236 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1237
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1238 if (block.firstInstruction instanceof LoopBeginNode) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1239 assert block.isLoopHeader && currentBlock.blockID >= block.blockID : "must be backward branch";
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1240 // Backward loop edge. We need to create a special LoopEndNode and merge with the loop begin node created before.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1241 LoopBeginNode loopBegin = (LoopBeginNode) block.firstInstruction;
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1242 Target target = checkLoopExit(currentGraph.add(new LoopEndNode(loopBegin)), block, state);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1243 FixedNode result = target.fixed;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1244 block.entryState.merge(loopBegin, target.state);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1245
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1246 Debug.log("createTarget %s: merging backward branch to loop header %s, result: %s", block, loopBegin, result);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1247 return result;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1248 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1249 assert currentBlock == null || currentBlock.blockID < block.blockID : "must not be backward branch";
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1250 assert block.firstInstruction.next() == null : "bytecodes already parsed for block";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1251
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1252 if (block.firstInstruction instanceof BlockPlaceholderNode) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1253 // This is the second time we see this block. Create the actual MergeNode and the End Node for the already existing edge.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1254 // For simplicity, we leave the placeholder in the graph and just append the new nodes after the placeholder.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1255 BlockPlaceholderNode placeholder = (BlockPlaceholderNode) block.firstInstruction;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1256
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1257 // The EndNode for the already existing edge.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1258 EndNode end = currentGraph.add(new EndNode());
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1259 // The MergeNode that replaces the placeholder.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1260 MergeNode mergeNode = currentGraph.add(new MergeNode());
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1261 FixedNode next = placeholder.next();
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1262
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1263 placeholder.setNext(end);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1264 mergeNode.addForwardEnd(end);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1265 mergeNode.setNext(next);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1266
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1267 block.firstInstruction = mergeNode;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1268 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1269
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1270 MergeNode mergeNode = (MergeNode) block.firstInstruction;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1271
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1272 // The EndNode for the newly merged edge.
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1273 EndNode newEnd = currentGraph.add(new EndNode());
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1274 Target target = checkLoopExit(newEnd, block, state);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1275 FixedNode result = target.fixed;
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1276 block.entryState.merge(mergeNode, target.state);
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1277 mergeNode.addForwardEnd(newEnd);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1278
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1279 Debug.log("createTarget %s: merging state, result: %s", block, result);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1280 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1281 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1282
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1283 /**
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1284 * Returns a block begin node with the specified state. If the specified probability is 0, the block
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1285 * deoptimizes immediately.
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1286 */
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1287 private BeginNode createBlockTarget(double probability, Block block, FrameStateBuilder stateAfter) {
5051
2ab527c53dba another fix for goto's deopt case
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5050
diff changeset
1288 FixedNode target = createTarget(probability, block, stateAfter);
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1289 BeginNode begin = BeginNode.begin(target);
5053
c53115427ff9 added assertion
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5051
diff changeset
1290
5375
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1291 assert !(target instanceof DeoptimizeNode && begin.stateAfter() != null) :
5053
c53115427ff9 added assertion
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5051
diff changeset
1292 "We are not allowed to set the stateAfter of the begin node, because we have to deoptimize to a bci _before_ the actual if, so that the interpreter can update the profiling information.";
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1293 return begin;
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1294 }
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5026
diff changeset
1295
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
1296 private ValueNode synchronizedObject(FrameStateBuilder state, ResolvedJavaMethod target) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
1297 if (isStatic(target.getModifiers())) {
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
1298 return append(ConstantNode.forConstant(target.getDeclaringClass().getEncoding(Representation.JavaClass), runtime, currentGraph));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1299 } else {
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1300 return state.loadLocal(0);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1301 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1302 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1303
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1304 private void processBlock(Block block) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1305 // Ignore blocks that have no predecessors by the time it their bytecodes are parsed
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1306 if (block == null || block.firstInstruction == null) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1307 Debug.log("Ignoring block %s", block);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1308 return;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1309 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1310 Debug.log("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1311
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1312 lastInstr = block.firstInstruction;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1313 frameState = block.entryState;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1314 currentBlock = block;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1315
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1316 frameState.cleanupDeletedPhis();
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1317 if (lastInstr instanceof MergeNode) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1318 int bci = block.startBci;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1319 if (block instanceof ExceptionDispatchBlock) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1320 bci = ((ExceptionDispatchBlock) block).deoptBci;
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1321 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1322 ((MergeNode) lastInstr).setStateAfter(frameState.create(bci));
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1323 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1324
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1325 if (block == returnBlock) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1326 frameState.setRethrowException(false);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1327 createReturn();
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1328 } else if (block == unwindBlock) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1329 frameState.setRethrowException(false);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1330 createUnwind();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1331 } else if (block instanceof ExceptionDispatchBlock) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1332 createExceptionDispatch((ExceptionDispatchBlock) block);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1333 } else {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1334 frameState.setRethrowException(false);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1335 iterateBytecodesForBlock(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1336 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1337 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1338
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1339 private void connectLoopEndToBegin() {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1340 for (LoopBeginNode begin : currentGraph.getNodes(LoopBeginNode.class)) {
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1341 if (begin.loopEnds().isEmpty()) {
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1342 // Remove loop header without loop ends.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1343 // This can happen with degenerated loops like this one:
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1344 // for (;;) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1345 // try {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1346 // break;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1347 // } catch (UnresolvedException iioe) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1348 // }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1349 // }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1350 assert begin.forwardEndCount() == 1;
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1351 currentGraph.reduceDegenerateLoopBegin(begin);
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4554
diff changeset
1352 } else {
5210
e3e7542d78b7 Loop-closed form GraphBuidling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5160
diff changeset
1353 GraphUtil.normalizeLoopBegin(begin);
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1354 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1355 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1356 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1357
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1358 private void createUnwind() {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1359 assert frameState.stackSize() == 1 : frameState;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1360 synchronizedEpilogue(FrameState.AFTER_EXCEPTION_BCI);
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1361 UnwindNode unwindNode = currentGraph.add(new UnwindNode(frameState.apop()));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1362 append(unwindNode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1363 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1364
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1365 private void createReturn() {
6699
d79098b9db3b Support for interfaces in the Graal API: Make interfaces implemented by a ResolvedJavaType available; change semantics of ResolvedJavaType.getSuperclass to return null for interfaces (to conform with java.lang.Class); change semantics of ResolvedJavaType.isInstanceClass to return false for interfaces.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6692
diff changeset
1366 if (method.isConstructor() && MetaUtil.isJavaLangObject(method.getDeclaringClass())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1367 callRegisterFinalizer();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1368 }
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
1369 Kind returnKind = method.getSignature().getReturnKind().getStackKind();
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1370 ValueNode x = returnKind == Kind.Void ? null : frameState.pop(returnKind);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1371 assert frameState.stackSize() == 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1372
5056
2f2c6347fce4 comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5053
diff changeset
1373 // TODO (gdub) remove this when FloatingRead can handle this case
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
1374 if (Modifier.isSynchronized(method.getModifiers())) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1375 append(currentGraph.add(new ValueAnchorNode(x)));
4689
15849962252d Make sure rethrowException flag is cleared also when return/unwind blocks are entered, they could use the framestate for the synchronization epilogue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4618
diff changeset
1376 assert !frameState.rethrowException();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1377 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1378
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1379 synchronizedEpilogue(FrameState.AFTER_BCI);
6436
5395ecdfce8a move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6401
diff changeset
1380 if (!frameState.locksEmpty()) {
5395ecdfce8a move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6401
diff changeset
1381 throw new BailoutException("unbalanced monitors");
5395ecdfce8a move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6401
diff changeset
1382 }
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1383 ReturnNode returnNode = currentGraph.add(new ReturnNode(x));
6436
5395ecdfce8a move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents: 6401
diff changeset
1384
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1385 append(returnNode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1386 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1387
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1388 private void synchronizedEpilogue(int bci) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
1389 if (Modifier.isSynchronized(method.getModifiers())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1390 MonitorExitNode monitorExit = genMonitorExit(methodSynchronizedObject);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1391 monitorExit.setStateAfter(frameState.create(bci));
4689
15849962252d Make sure rethrowException flag is cleared also when return/unwind blocks are entered, they could use the framestate for the synchronization epilogue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4618
diff changeset
1392 assert !frameState.rethrowException();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1393 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1394 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1395
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1396 private void createExceptionDispatch(ExceptionDispatchBlock block) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1397 assert frameState.stackSize() == 1 : frameState;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1398 if (block.handler.isCatchAll()) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1399 assert block.successors.size() == 1;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1400 appendGoto(createTarget(block.successors.get(0), frameState));
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1401 return;
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1402 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1403
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6534
diff changeset
1404 JavaType catchType = block.handler.getCatchType();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1405 if (graphBuilderConfig.eagerResolving()) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1406 catchType = lookupType(block.handler.catchTypeCPI(), INSTANCEOF);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1407 }
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
1408 boolean initialized = (catchType instanceof ResolvedJavaType);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1409 if (initialized && graphBuilderConfig.getSkippedExceptionTypes() != null) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
1410 ResolvedJavaType resolvedCatchType = (ResolvedJavaType) catchType;
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
1411 for (ResolvedJavaType skippedType : graphBuilderConfig.getSkippedExceptionTypes()) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1412 initialized &= !resolvedCatchType.isSubtypeOf(skippedType);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1413 if (!initialized) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1414 break;
4548
f55914bc1d67 Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4541
diff changeset
1415 }
f55914bc1d67 Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4541
diff changeset
1416 }
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1417 }
4548
f55914bc1d67 Added experimental ConvertDeoptimizeToGuardPhase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4541
diff changeset
1418
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6699
diff changeset
1419 ConstantNode typeInstruction = genTypeOrDeopt(Representation.ObjectHub, catchType, initialized);
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6699
diff changeset
1420 if (typeInstruction != null) {
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1421 Block nextBlock = block.successors.size() == 1 ? unwindBlock(block.deoptBci) : block.successors.get(1);
5630
b60a368c8104 Add correct checkcast node to entry of catch block after exception dispatch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5629
diff changeset
1422 ValueNode exception = frameState.stackAt(0);
6648
7bf5a6c42db7 factored CheckCastDynamicNode out of CheckCastNode
Doug Simon <doug.simon@oracle.com>
parents: 6647
diff changeset
1423 CheckCastNode checkCast = currentGraph.add(new CheckCastNode((ResolvedJavaType) catchType, exception, null));
5630
b60a368c8104 Add correct checkcast node to entry of catch block after exception dispatch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5629
diff changeset
1424 frameState.apop();
b60a368c8104 Add correct checkcast node to entry of catch block after exception dispatch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5629
diff changeset
1425 frameState.push(Kind.Object, checkCast);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1426 FixedNode catchSuccessor = createTarget(block.successors.get(0), frameState);
5630
b60a368c8104 Add correct checkcast node to entry of catch block after exception dispatch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5629
diff changeset
1427 frameState.apop();
b60a368c8104 Add correct checkcast node to entry of catch block after exception dispatch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5629
diff changeset
1428 frameState.push(Kind.Object, exception);
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1429 FixedNode nextDispatch = createTarget(nextBlock, frameState);
5630
b60a368c8104 Add correct checkcast node to entry of catch block after exception dispatch.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5629
diff changeset
1430 checkCast.setNext(catchSuccessor);
6647
0b8410de1365 removed targetClassInstruction from InstanceOfNode
Doug Simon <doug.simon@oracle.com>
parents: 6552
diff changeset
1431 IfNode ifNode = currentGraph.add(new IfNode(currentGraph.unique(new InstanceOfNode((ResolvedJavaType) catchType, exception, null)), checkCast, nextDispatch, 0.5, graphId));
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1432 append(ifNode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1433 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1434 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1435
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1436 private void appendGoto(FixedNode target) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1437 if (lastInstr != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1438 lastInstr.setNext(target);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1439 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1440 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1441
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1442 private static boolean isBlockEnd(Node n) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1443 return trueSuccessorCount(n) > 1 || n instanceof ReturnNode || n instanceof UnwindNode || n instanceof DeoptimizeNode;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1444 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1445
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1446 private static int trueSuccessorCount(Node n) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1447 if (n == null) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1448 return 0;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1449 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1450 int i = 0;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1451 for (Node s : n.successors()) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1452 if (Util.isFixed(s)) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1453 i++;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1454 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1455 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1456 return i;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1457 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1458
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1459 private void iterateBytecodesForBlock(Block block) {
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1460 if (block.isLoopHeader) {
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1461 // Create the loop header block, which later will merge the backward branches of the loop.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1462 EndNode preLoopEnd = currentGraph.add(new EndNode());
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1463 LoopBeginNode loopBegin = currentGraph.add(new LoopBeginNode());
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1464 lastInstr.setNext(preLoopEnd);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1465 // Add the single non-loop predecessor of the loop header.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1466 loopBegin.addForwardEnd(preLoopEnd);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1467 lastInstr = loopBegin;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1468
5026
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1469 // Create phi functions for all local variables and operand stack slots.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1470 frameState.insertLoopPhis(loopBegin);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1471 loopBegin.setStateAfter(frameState.create(block.startBci));
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1472
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1473 // We have seen all forward branches. All subsequent backward branches will merge to the loop header.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1474 // This ensures that the loop header has exactly one non-loop predecessor.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1475 block.firstInstruction = loopBegin;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1476 // We need to preserve the frame state builder of the loop header so that we can merge values for
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1477 // phi functions, so make a copy of it.
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1478 block.entryState = frameState.copy();
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1479
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1480 Debug.log(" created loop header %s", loopBegin);
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1481 }
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1482 assert lastInstr.next() == null : "instructions already appended at block " + block;
b11561111585 Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4997
diff changeset
1483 Debug.log(" frameState: %s", frameState);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1484
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1485 int endBCI = stream.endBCI();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1486
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1487 stream.setBCI(block.startBci);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1488 int bci = block.startBci;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1489 while (bci < endBCI) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1490 // read the opcode
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1491 int opcode = stream.currentBC();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1492 traceState();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1493 traceInstruction(bci, opcode, bci == block.startBci);
6676
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1494 if (bci == entryBCI) {
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1495 EntryMarkerNode x = currentGraph.add(new EntryMarkerNode());
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1496 append(x);
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1497 frameState.insertProxies(x);
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1498 x.setStateAfter(frameState.create(bci));
090868cbcda6 Graal infrastructure for OnStackReplacement
Lukas Stadler <lukas.stadler@jku.at>
parents: 6648
diff changeset
1499 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1500 processBytecode(bci, opcode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1501
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4433
diff changeset
1502 if (lastInstr == null || isBlockEnd(lastInstr) || lastInstr.next() != null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1503 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1504 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1505
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1506 stream.next();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1507 bci = stream.currentBCI();
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1508
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1509 if (bci > block.endBci) {
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1510 frameState.clearNonLiveLocals(currentBlock.localsLiveOut);
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1511 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1512 if (lastInstr instanceof StateSplit) {
5375
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1513 if (lastInstr.getClass() == BeginNode.class) {
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1514 // BeginNodes do not need a frame state
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1515 } else {
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1516 StateSplit stateSplit = (StateSplit) lastInstr;
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1517 if (stateSplit.stateAfter() == null) {
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1518 stateSplit.setStateAfter(frameState.create(bci));
3035b6b881d9 removed stateAfter field from FixedWithNextNode - now only StateSplit implementations have this field
Doug Simon <doug.simon@oracle.com>
parents: 5373
diff changeset
1519 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1520 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1521 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1522 if (bci < endBCI) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1523 if (bci > block.endBci) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1524 assert !block.successors.get(0).isExceptionEntry;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1525 assert block.numNormalSuccessors() == 1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1526 // we fell through to the next block, add a goto and break
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1527 appendGoto(createTarget(block.successors.get(0), frameState));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1528 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1529 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1530 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1531 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1532 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1533
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1534 private void traceState() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1535 if (GraalOptions.TraceBytecodeParserLevel >= TRACELEVEL_STATE && !TTY.isSuppressed()) {
6992
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
1536 TTY.println(String.format("| state [nr locals = %d, stack depth = %d, method = %s]", frameState.localsSize(), frameState.stackSize(), method));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1537 for (int i = 0; i < frameState.localsSize(); ++i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1538 ValueNode value = frameState.localAt(i);
6992
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
1539 TTY.println(String.format("| local[%d] = %-8s : %s", i, value == null ? "bogus" : value.kind().getJavaName(), value));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1540 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1541 for (int i = 0; i < frameState.stackSize(); ++i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1542 ValueNode value = frameState.stackAt(i);
6992
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
1543 TTY.println(String.format("| stack[%d] = %-8s : %s", i, value == null ? "bogus" : value.kind().getJavaName(), value));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1544 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1545 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1546 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1547
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1548 private void processBytecode(int bci, int opcode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1549 int cpi;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1550
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1551 // Checkstyle: stop
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1552 switch (opcode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1553 case NOP : /* nothing to do */ break;
5538
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1554 case ACONST_NULL : frameState.apush(appendConstant(Constant.NULL_OBJECT)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1555 case ICONST_M1 : frameState.ipush(appendConstant(Constant.INT_MINUS_1)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1556 case ICONST_0 : frameState.ipush(appendConstant(Constant.INT_0)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1557 case ICONST_1 : frameState.ipush(appendConstant(Constant.INT_1)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1558 case ICONST_2 : frameState.ipush(appendConstant(Constant.INT_2)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1559 case ICONST_3 : frameState.ipush(appendConstant(Constant.INT_3)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1560 case ICONST_4 : frameState.ipush(appendConstant(Constant.INT_4)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1561 case ICONST_5 : frameState.ipush(appendConstant(Constant.INT_5)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1562 case LCONST_0 : frameState.lpush(appendConstant(Constant.LONG_0)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1563 case LCONST_1 : frameState.lpush(appendConstant(Constant.LONG_1)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1564 case FCONST_0 : frameState.fpush(appendConstant(Constant.FLOAT_0)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1565 case FCONST_1 : frameState.fpush(appendConstant(Constant.FLOAT_1)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1566 case FCONST_2 : frameState.fpush(appendConstant(Constant.FLOAT_2)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1567 case DCONST_0 : frameState.dpush(appendConstant(Constant.DOUBLE_0)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1568 case DCONST_1 : frameState.dpush(appendConstant(Constant.DOUBLE_1)); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1569 case BIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readByte()))); break;
e18ba36bfebc Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5531
diff changeset
1570 case SIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readShort()))); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1571 case LDC : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1572 case LDC_W : // fall through
4315
4c223446c28e Replace the eagerResolving option of GraphBuilderConfiguration with three resolve policies: Default, EagerForSnippets (previously eagerResolving), and Eager (resolves exceptions and types of constants as well)
Peter Hofer <peter.hofer@jku.at>
parents: 4310
diff changeset
1573 case LDC2_W : genLoadConstant(stream.readCPI(), opcode); break;
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1574 case ILOAD : loadLocal(stream.readLocalIndex(), Kind.Int); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1575 case LLOAD : loadLocal(stream.readLocalIndex(), Kind.Long); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1576 case FLOAD : loadLocal(stream.readLocalIndex(), Kind.Float); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1577 case DLOAD : loadLocal(stream.readLocalIndex(), Kind.Double); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1578 case ALOAD : loadLocal(stream.readLocalIndex(), Kind.Object); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1579 case ILOAD_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1580 case ILOAD_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1581 case ILOAD_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1582 case ILOAD_3 : loadLocal(opcode - ILOAD_0, Kind.Int); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1583 case LLOAD_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1584 case LLOAD_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1585 case LLOAD_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1586 case LLOAD_3 : loadLocal(opcode - LLOAD_0, Kind.Long); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1587 case FLOAD_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1588 case FLOAD_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1589 case FLOAD_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1590 case FLOAD_3 : loadLocal(opcode - FLOAD_0, Kind.Float); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1591 case DLOAD_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1592 case DLOAD_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1593 case DLOAD_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1594 case DLOAD_3 : loadLocal(opcode - DLOAD_0, Kind.Double); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1595 case ALOAD_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1596 case ALOAD_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1597 case ALOAD_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1598 case ALOAD_3 : loadLocal(opcode - ALOAD_0, Kind.Object); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1599 case IALOAD : genLoadIndexed(Kind.Int ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1600 case LALOAD : genLoadIndexed(Kind.Long ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1601 case FALOAD : genLoadIndexed(Kind.Float ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1602 case DALOAD : genLoadIndexed(Kind.Double); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1603 case AALOAD : genLoadIndexed(Kind.Object); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1604 case BALOAD : genLoadIndexed(Kind.Byte ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1605 case CALOAD : genLoadIndexed(Kind.Char ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1606 case SALOAD : genLoadIndexed(Kind.Short ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1607 case ISTORE : storeLocal(Kind.Int, stream.readLocalIndex()); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1608 case LSTORE : storeLocal(Kind.Long, stream.readLocalIndex()); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1609 case FSTORE : storeLocal(Kind.Float, stream.readLocalIndex()); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1610 case DSTORE : storeLocal(Kind.Double, stream.readLocalIndex()); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1611 case ASTORE : storeLocal(Kind.Object, stream.readLocalIndex()); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1612 case ISTORE_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1613 case ISTORE_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1614 case ISTORE_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1615 case ISTORE_3 : storeLocal(Kind.Int, opcode - ISTORE_0); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1616 case LSTORE_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1617 case LSTORE_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1618 case LSTORE_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1619 case LSTORE_3 : storeLocal(Kind.Long, opcode - LSTORE_0); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1620 case FSTORE_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1621 case FSTORE_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1622 case FSTORE_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1623 case FSTORE_3 : storeLocal(Kind.Float, opcode - FSTORE_0); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1624 case DSTORE_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1625 case DSTORE_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1626 case DSTORE_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1627 case DSTORE_3 : storeLocal(Kind.Double, opcode - DSTORE_0); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1628 case ASTORE_0 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1629 case ASTORE_1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1630 case ASTORE_2 : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1631 case ASTORE_3 : storeLocal(Kind.Object, opcode - ASTORE_0); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1632 case IASTORE : genStoreIndexed(Kind.Int ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1633 case LASTORE : genStoreIndexed(Kind.Long ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1634 case FASTORE : genStoreIndexed(Kind.Float ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1635 case DASTORE : genStoreIndexed(Kind.Double); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1636 case AASTORE : genStoreIndexed(Kind.Object); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1637 case BASTORE : genStoreIndexed(Kind.Byte ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1638 case CASTORE : genStoreIndexed(Kind.Char ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1639 case SASTORE : genStoreIndexed(Kind.Short ); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1640 case POP : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1641 case POP2 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1642 case DUP : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1643 case DUP_X1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1644 case DUP_X2 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1645 case DUP2 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1646 case DUP2_X1 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1647 case DUP2_X2 : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1648 case SWAP : stackOp(opcode); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1649 case IADD : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1650 case ISUB : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1651 case IMUL : genArithmeticOp(Kind.Int, opcode, false); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1652 case IDIV : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1653 case IREM : genArithmeticOp(Kind.Int, opcode, true); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1654 case LADD : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1655 case LSUB : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1656 case LMUL : genArithmeticOp(Kind.Long, opcode, false); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1657 case LDIV : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1658 case LREM : genArithmeticOp(Kind.Long, opcode, true); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1659 case FADD : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1660 case FSUB : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1661 case FMUL : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1662 case FDIV : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1663 case FREM : genArithmeticOp(Kind.Float, opcode, false); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1664 case DADD : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1665 case DSUB : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1666 case DMUL : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1667 case DDIV : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1668 case DREM : genArithmeticOp(Kind.Double, opcode, false); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1669 case INEG : genNegateOp(Kind.Int); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1670 case LNEG : genNegateOp(Kind.Long); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1671 case FNEG : genNegateOp(Kind.Float); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1672 case DNEG : genNegateOp(Kind.Double); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1673 case ISHL : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1674 case ISHR : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1675 case IUSHR : genShiftOp(Kind.Int, opcode); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1676 case IAND : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1677 case IOR : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1678 case IXOR : genLogicOp(Kind.Int, opcode); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1679 case LSHL : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1680 case LSHR : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1681 case LUSHR : genShiftOp(Kind.Long, opcode); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1682 case LAND : // fall through
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1683 case LOR : // fall through
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1684 case LXOR : genLogicOp(Kind.Long, opcode); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1685 case IINC : genIncrement(); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1686 case I2L : genConvert(ConvertNode.Op.I2L); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1687 case I2F : genConvert(ConvertNode.Op.I2F); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1688 case I2D : genConvert(ConvertNode.Op.I2D); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1689 case L2I : genConvert(ConvertNode.Op.L2I); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1690 case L2F : genConvert(ConvertNode.Op.L2F); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1691 case L2D : genConvert(ConvertNode.Op.L2D); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1692 case F2I : genConvert(ConvertNode.Op.F2I); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1693 case F2L : genConvert(ConvertNode.Op.F2L); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1694 case F2D : genConvert(ConvertNode.Op.F2D); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1695 case D2I : genConvert(ConvertNode.Op.D2I); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1696 case D2L : genConvert(ConvertNode.Op.D2L); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1697 case D2F : genConvert(ConvertNode.Op.D2F); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1698 case I2B : genConvert(ConvertNode.Op.I2B); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1699 case I2C : genConvert(ConvertNode.Op.I2C); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1700 case I2S : genConvert(ConvertNode.Op.I2S); break;
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1701 case LCMP : genCompareOp(Kind.Long, false); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1702 case FCMPL : genCompareOp(Kind.Float, true); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1703 case FCMPG : genCompareOp(Kind.Float, false); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1704 case DCMPL : genCompareOp(Kind.Double, true); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1705 case DCMPG : genCompareOp(Kind.Double, false); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1706 case IFEQ : genIfZero(Condition.EQ); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1707 case IFNE : genIfZero(Condition.NE); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1708 case IFLT : genIfZero(Condition.LT); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1709 case IFGE : genIfZero(Condition.GE); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1710 case IFGT : genIfZero(Condition.GT); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1711 case IFLE : genIfZero(Condition.LE); break;
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1712 case IF_ICMPEQ : genIfSame(Kind.Int, Condition.EQ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1713 case IF_ICMPNE : genIfSame(Kind.Int, Condition.NE); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1714 case IF_ICMPLT : genIfSame(Kind.Int, Condition.LT); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1715 case IF_ICMPGE : genIfSame(Kind.Int, Condition.GE); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1716 case IF_ICMPGT : genIfSame(Kind.Int, Condition.GT); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1717 case IF_ICMPLE : genIfSame(Kind.Int, Condition.LE); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1718 case IF_ACMPEQ : genIfSame(Kind.Object, Condition.EQ); break;
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5538
diff changeset
1719 case IF_ACMPNE : genIfSame(Kind.Object, Condition.NE); break;
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1720 case GOTO : genGoto(); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1721 case JSR : genJsr(stream.readBranchDest()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1722 case RET : genRet(stream.readLocalIndex()); break;
5698
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1723 case TABLESWITCH : genSwitch(new BytecodeTableSwitch(stream(), bci())); break;
764db9ada24f rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 5695
diff changeset
1724 case LOOKUPSWITCH : genSwitch(new BytecodeLookupSwitch(stream(), bci())); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1725 case IRETURN : genReturn(frameState.ipop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1726 case LRETURN : genReturn(frameState.lpop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1727 case FRETURN : genReturn(frameState.fpop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1728 case DRETURN : genReturn(frameState.dpop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1729 case ARETURN : genReturn(frameState.apop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1730 case RETURN : genReturn(null); break;
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1731 case GETSTATIC : cpi = stream.readCPI(); genGetStatic(lookupField(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1732 case PUTSTATIC : cpi = stream.readCPI(); genPutStatic(lookupField(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1733 case GETFIELD : cpi = stream.readCPI(); genGetField(lookupField(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1734 case PUTFIELD : cpi = stream.readCPI(); genPutField(lookupField(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1735 case INVOKEVIRTUAL : cpi = stream.readCPI(); genInvokeVirtual(lookupMethod(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1736 case INVOKESPECIAL : cpi = stream.readCPI(); genInvokeSpecial(lookupMethod(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1737 case INVOKESTATIC : cpi = stream.readCPI(); genInvokeStatic(lookupMethod(cpi, opcode)); break;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1738 case INVOKEINTERFACE: cpi = stream.readCPI(); genInvokeInterface(lookupMethod(cpi, opcode)); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1739 case NEW : genNewInstance(stream.readCPI()); break;
5760
87e8baf5447c added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents: 5719
diff changeset
1740 case NEWARRAY : genNewPrimitiveArray(stream.readLocalIndex()); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1741 case ANEWARRAY : genNewObjectArray(stream.readCPI()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1742 case ARRAYLENGTH : genArrayLength(); break;
5256
1e153fdac9fb Fix and simplify exception handling in the bytecode parser
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5255
diff changeset
1743 case ATHROW : genThrow(); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1744 case CHECKCAST : genCheckCast(); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1745 case INSTANCEOF : genInstanceOf(); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1746 case MONITORENTER : genMonitorEnter(frameState.apop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1747 case MONITOREXIT : genMonitorExit(frameState.apop()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1748 case MULTIANEWARRAY : genNewMultiArray(stream.readCPI()); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1749 case IFNULL : genIfNull(Condition.EQ); break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1750 case IFNONNULL : genIfNull(Condition.NE); break;
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1751 case GOTO_W : genGoto(); break;
5031
4d152e5e34ba Use BytecodeStream in BciBlockMapping instead of hand-crafted byte-array accesses
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5030
diff changeset
1752 case JSR_W : genJsr(stream.readBranchDest()); break;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1753 case BREAKPOINT:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
1754 throw new BailoutException("concurrent setting of breakpoint");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1755 default:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
1756 throw new BailoutException("Unsupported opcode " + opcode + " (" + nameOf(opcode) + ") [bci=" + bci + "]");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1757 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1758 // Checkstyle: resume
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1759 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1760
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1761 private void traceInstruction(int bci, int opcode, boolean blockStart) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1762 if (GraalOptions.TraceBytecodeParserLevel >= TRACELEVEL_INSTRUCTIONS && !TTY.isSuppressed()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1763 StringBuilder sb = new StringBuilder(40);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1764 sb.append(blockStart ? '+' : '|');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1765 if (bci < 10) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1766 sb.append(" ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1767 } else if (bci < 100) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1768 sb.append(' ');
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1769 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1770 sb.append(bci).append(": ").append(Bytecodes.nameOf(opcode));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1771 for (int i = bci + 1; i < stream.nextBCI(); ++i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1772 sb.append(' ').append(stream.readUByte(i));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1773 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1774 if (!currentBlock.jsrScope.isEmpty()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1775 sb.append(' ').append(currentBlock.jsrScope);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1776 }
6992
e35077f6d2a2 removed cached LogStream in GraphBuilderPhase
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
1777 TTY.println(sb.toString());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1778 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1779 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1780
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1781 private void genArrayLength() {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1782 frameState.ipush(append(currentGraph.add(new ArrayLengthNode(frameState.apop()))));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1783 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1784 }