Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java @ 6500:8fd4201ce98c
moved TTY and LogStream to com.oracle.graal.debug
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Oct 2012 18:34:46 +0200 |
parents | 16d1411409b4 |
children | 2a0c9f20baa1 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
4181
319860ae697a
Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4173
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.compiler.gen; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
25 import static com.oracle.graal.api.code.CallingConvention.Type.*; |
5658
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
26 import static com.oracle.graal.api.code.ValueUtil.*; |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
27 import static com.oracle.graal.api.meta.Value.*; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
28 import static com.oracle.graal.lir.LIRValueUtil.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import java.util.*; |
5199
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
31 import java.util.Map.Entry; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
33 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
34 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.compiler.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.compiler.util.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
38 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 import com.oracle.graal.lir.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
40 import com.oracle.graal.lir.StandardOp.JumpOp; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.lir.StandardOp.LabelOp; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.lir.StandardOp.ParametersOp; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
43 import com.oracle.graal.lir.cfg.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
44 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
45 import com.oracle.graal.nodes.PhiNode.PhiType; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
46 import com.oracle.graal.nodes.calc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
47 import com.oracle.graal.nodes.extended.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
48 import com.oracle.graal.nodes.java.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
49 import com.oracle.graal.nodes.spi.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
50 import com.oracle.graal.nodes.virtual.*; |
5167
591f8231aa82
removed XIR & LIR code for nodes that are completely lowered in HotspotRuntime.lower()
Doug Simon <doug.simon@oracle.com>
parents:
5160
diff
changeset
|
51 import com.oracle.max.asm.*; |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 * This class traverses the HIR instructions and generates LIR instructions from them. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 public abstract class LIRGenerator extends LIRGeneratorTool { |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
57 protected final Graph graph; |
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
|
58 protected final CodeCacheProvider runtime; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
59 protected final TargetDescription target; |
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
|
60 protected final ResolvedJavaMethod method; |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
61 protected final FrameMap frameMap; |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
62 public final NodeMap<Value> nodeOperands; |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
63 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 protected final LIR lir; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 private final DebugInfoBuilder debugInfoBuilder; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
67 private Block currentBlock; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 private ValueNode currentInstruction; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 private ValueNode lastInstructionPrinted; // Debugging only |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 private FrameState lastState; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
72 /** |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
73 * Mapping from blocks to the last encountered frame state at the end of the block. |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
74 */ |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
75 private final BlockMap<FrameState> blockLastState; |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
76 |
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
77 /** |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
78 * The number of currently locked monitors. |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
79 */ |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
80 private int currentLockCount; |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
81 |
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
82 /** |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
83 * Mapping from blocks to the number of locked monitors at the end of the block. |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
84 */ |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
85 private final BlockMap<Integer> blockLastLockCount; |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
86 |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
87 /** |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
88 * Contains the lock data slot for each lock depth (so these may be reused within a compiled method). |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
89 */ |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
90 private final ArrayList<StackSlot> lockDataSlots; |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
91 |
6462 | 92 public LIRGenerator(Graph graph, CodeCacheProvider runtime, TargetDescription target, FrameMap frameMap, ResolvedJavaMethod method, LIR lir) { |
4265
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
93 this.graph = graph; |
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
94 this.runtime = runtime; |
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
95 this.target = target; |
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
96 this.frameMap = frameMap; |
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
97 this.method = method; |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
98 this.nodeOperands = graph.createNodeMap(); |
4265
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
99 this.lir = lir; |
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
100 this.debugInfoBuilder = new DebugInfoBuilder(nodeOperands); |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
101 this.blockLastLockCount = new BlockMap<>(lir.cfg); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
102 this.lockDataSlots = new ArrayList<>(); |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
103 this.blockLastState = new BlockMap<>(lir.cfg); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 @Override |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
107 public TargetDescription target() { |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
108 return target; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 |
6455
c4d21bd7653b
made position calculation for VMErrorNode more robust when debug info is not available
Doug Simon <doug.simon@oracle.com>
parents:
6443
diff
changeset
|
111 public ResolvedJavaMethod method() { |
c4d21bd7653b
made position calculation for VMErrorNode more robust when debug info is not available
Doug Simon <doug.simon@oracle.com>
parents:
6443
diff
changeset
|
112 return method; |
c4d21bd7653b
made position calculation for VMErrorNode more robust when debug info is not available
Doug Simon <doug.simon@oracle.com>
parents:
6443
diff
changeset
|
113 } |
c4d21bd7653b
made position calculation for VMErrorNode more robust when debug info is not available
Doug Simon <doug.simon@oracle.com>
parents:
6443
diff
changeset
|
114 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 /** |
5711
4d7175cf3526
enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents:
5698
diff
changeset
|
116 * Returns the operand that has been previously initialized by {@link #setResult(ValueNode, Value)} |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 * with the result of an instruction. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 * @param node A node that produces a result value. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
121 public Value operand(ValueNode node) { |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
122 if (nodeOperands == null) { |
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
123 return null; |
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
124 } |
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
125 return nodeOperands.get(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
128 public ValueNode valueForOperand(Value value) { |
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
129 for (Entry<Node, Value> entry : nodeOperands.entries()) { |
5199
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
130 if (entry.getValue() == value) { |
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
131 return (ValueNode) entry.getKey(); |
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
132 } |
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
133 } |
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
134 return null; |
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
135 } |
b968b71e22a4
Allow tracking nodes responsible for a non-empty liveIn in LinearScan
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5167
diff
changeset
|
136 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 /** |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
138 * Creates a new {@linkplain Variable variable}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 * @param kind The kind of the new variable. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 * @return a new variable |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 @Override |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
143 public Variable newVariable(Kind kind) { |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
144 Kind stackKind = kind.stackKind(); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
145 switch (stackKind) { |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
146 case Jsr: |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
147 case Int: |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
148 case Long: |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
149 case Object: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
150 return new Variable(stackKind, lir.nextVariable(), Register.RegisterFlag.CPU); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
151 case Float: |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
152 case Double: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
153 return new Variable(stackKind, lir.nextVariable(), Register.RegisterFlag.FPU); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
154 default: |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
155 throw GraalInternalError.shouldNotReachHere(); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
156 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 @Override |
5658
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
160 public RegisterAttributes attributes(Register register) { |
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
161 return frameMap.registerConfig.getAttributesMap()[register.number]; |
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
162 } |
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
163 |
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
164 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
165 public Value setResult(ValueNode x, Value operand) { |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
166 assert (isVariable(operand) && x.kind() == operand.getKind()) || |
5658
297f30d8d610
allowed RegisterNode to directly use a register not used by the register allocator
Doug Simon <doug.simon@oracle.com>
parents:
5645
diff
changeset
|
167 (isRegister(operand) && !attributes(asRegister(operand)).isAllocatable()) || |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
168 (isConstant(operand) && x.kind() == operand.getKind().stackKind()) : operand.getKind() + " for node " + x; |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
169 assert operand(x) == null : "operand cannot be set twice"; |
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
170 assert operand != null && isLegal(operand) : "operand must be legal"; |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
171 assert operand.getKind().stackKind() == x.kind(); |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
172 assert !(x instanceof VirtualObjectNode); |
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
173 nodeOperands.set(x, operand); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 return operand; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
177 @Override |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
178 public abstract Variable emitMove(Value input); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
180 public Variable load(Value value) { |
4183
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4181
diff
changeset
|
181 if (!isVariable(value)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 return emitMove(value); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 } |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
184 return (Variable) value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
187 public Value loadNonConst(Value value) { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
188 if (isConstant(value) && !canInlineConstant((Constant) value)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 return emitMove(value); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 return value; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
194 public Value loadForStore(Value value, Kind storeKind) { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
195 if (isConstant(value) && canStoreConstant((Constant) value)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 return value; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 } |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
198 if (storeKind == Kind.Byte || storeKind == Kind.Boolean) { |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
199 Variable tempVar = new Variable(value.getKind(), lir.nextVariable(), Register.RegisterFlag.Byte); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4205
diff
changeset
|
200 emitMove(value, tempVar); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 return tempVar; |
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 return load(value); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 protected LabelRef getLIRBlock(FixedNode b) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
207 Block result = lir.cfg.blockFor(b); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 int suxIndex = currentBlock.getSuccessors().indexOf(result); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 assert suxIndex != -1 : "Block not in successor list of current block"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
211 return LabelRef.forSuccessor(lir, currentBlock, suxIndex); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
214 public LIRFrameState state() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 assert lastState != null : "must have state before instruction"; |
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
|
216 return stateFor(lastState, -1); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
219 public LIRFrameState state(long leafGraphId) { |
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
|
220 assert lastState != null : "must have state before instruction"; |
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
|
221 return stateFor(lastState, leafGraphId); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
224 public LIRFrameState stateFor(FrameState state, long leafGraphId) { |
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
|
225 return stateFor(state, null, null, leafGraphId); |
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
|
226 } |
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
|
227 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
228 public LIRFrameState stateFor(FrameState state, List<StackSlot> pointerSlots, LabelRef exceptionEdge, long leafGraphId) { |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
229 return debugInfoBuilder.build(state, lockDataSlots.subList(0, currentLockCount), pointerSlots, exceptionEdge, leafGraphId); |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 * Gets the ABI specific operand used to return a value of a given kind from a method. |
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 * @param kind the kind of value being returned |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 * @return the operand representing the ABI defined location used return a value of kind {@code kind} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 */ |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
238 public Value resultOperandFor(Kind kind) { |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
239 if (kind == Kind.Void) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 return IllegalValue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 } |
4265
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
242 return frameMap.registerConfig.getReturnRegister(kind).asValue(kind); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 public void append(LIRInstruction op) { |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4233
diff
changeset
|
247 assert LIRVerifier.verify(op); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 if (GraalOptions.PrintIRWithLIR && !TTY.isSuppressed()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 if (currentInstruction != null && lastInstructionPrinted != currentInstruction) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 lastInstructionPrinted = currentInstruction; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 InstructionPrinter ip = new InstructionPrinter(TTY.out()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 ip.printInstructionListing(currentInstruction); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
253 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 TTY.println(op.toStringWithIdPrefix()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 TTY.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 } |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
257 lir.lir(currentBlock).add(op); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
260 public void doBlock(Block block) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 if (GraalOptions.PrintIRWithLIR) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 TTY.print(block.toString()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 currentBlock = block; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 // set up the list of LIR instructions |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
267 assert lir.lir(block) == null : "LIR list already computed for this block"; |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
268 lir.setLir(block, new ArrayList<LIRInstruction>()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 |
6316
2e25b9c14b84
Temporarily remove experimental register allocators.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5798
diff
changeset
|
270 append(new LabelOp(new Label(), block.align)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 if (GraalOptions.TraceLIRGeneratorLevel >= 1) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
273 TTY.println("BEGIN Generating LIR for block B" + block.getId()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
276 if (block == lir.cfg.getStartBlock()) { |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
277 assert block.getPredecessors().size() == 0; |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
278 currentLockCount = 0; |
4212
f282e35ea829
Define incoming parameters in a PARAMS instruction. This simplifies register allocation because the initial register state does not have to be inferred from the calling convention.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4206
diff
changeset
|
279 emitPrologue(); |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
280 |
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
281 } else { |
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
282 assert block.getPredecessors().size() > 0; |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
283 |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
284 currentLockCount = -1; |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
285 for (Block pred : block.getPredecessors()) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
286 Integer predLocks = blockLastLockCount.get(pred); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
287 if (currentLockCount == -1) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
288 currentLockCount = predLocks; |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
289 } else { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
290 assert (predLocks == null && pred.isLoopEnd()) || currentLockCount == predLocks; |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
291 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
292 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
293 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 FrameState fs = null; |
4233
fa53d5e4aa35
Remove lock information from frame states, and compute it instead when LIR is generated.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4212
diff
changeset
|
295 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
296 for (Block pred : block.getPredecessors()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 if (fs == null) { |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
298 fs = blockLastState.get(pred); |
5462
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
299 } else { |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
300 if (blockLastState.get(pred) == null) { |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
301 // Only a back edge can have a null state for its enclosing block. |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
302 assert pred.getEndNode() instanceof LoopEndNode; |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
303 |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
304 if (block.getBeginNode().stateAfter() == null) { |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
305 // We'll assert later that the begin and end of a framestate-less loop |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
306 // share the frame state that flowed into the loop |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
307 blockLastState.put(pred, fs); |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
308 } |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
309 } else if (fs != blockLastState.get(pred)) { |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
310 fs = null; |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
311 break; |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
312 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 } |
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 if (GraalOptions.TraceLIRGeneratorLevel >= 2) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 if (fs == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 TTY.println("STATE RESET"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 TTY.println("STATE CHANGE (singlePred)"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 if (GraalOptions.TraceLIRGeneratorLevel >= 3) { |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
321 TTY.println(fs.toString(Node.Verbosity.Debugger)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 lastState = fs; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5547
diff
changeset
|
328 List<ScheduledNode> nodes = lir.nodesFor(block); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
329 for (int i = 0; i < nodes.size(); i++) { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
330 Node instr = nodes.get(i); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 if (GraalOptions.OptImplicitNullChecks) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 Node nextInstr = null; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
334 if (i < nodes.size() - 1) { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
335 nextInstr = nodes.get(i + 1); |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 if (instr instanceof GuardNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 GuardNode guardNode = (GuardNode) instr; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
340 if (guardNode.condition() instanceof IsNullNode && guardNode.negated()) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
341 IsNullNode isNullNode = (IsNullNode) guardNode.condition(); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
342 if (nextInstr instanceof Access) { |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4268
diff
changeset
|
343 Access access = (Access) nextInstr; |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
344 if (isNullNode.object() == access.object() && canBeNullCheck(access.location())) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 //TTY.println("implicit null check"); |
4309
4a609a685fa4
changes to Node structures:
Lukas Stadler <lukas.stadler@jku.at>
parents:
4268
diff
changeset
|
346 access.setNullCheck(true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 continue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 if (GraalOptions.TraceLIRGeneratorLevel >= 3) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 TTY.println("LIRGen for " + instr); |
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 FrameState stateAfter = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 if (instr instanceof StateSplit) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 stateAfter = ((StateSplit) instr).stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 if (instr instanceof ValueNode) { |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
361 try { |
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
362 doRoot((ValueNode) instr); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
363 } catch (GraalInternalError e) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
364 throw e.addContext(instr); |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
365 } catch (Throwable e) { |
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
366 throw new GraalInternalError(e).addContext(instr); |
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
367 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
368 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
369 if (stateAfter != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
370 lastState = stateAfter; |
4628
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
371 assert checkStateReady(lastState); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 if (GraalOptions.TraceLIRGeneratorLevel >= 2) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
373 TTY.println("STATE CHANGE"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 if (GraalOptions.TraceLIRGeneratorLevel >= 3) { |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
375 TTY.println(stateAfter.toString(Node.Verbosity.Debugger)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
377 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
378 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
379 } |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
380 if (block.numberOfSux() >= 1 && !endsWithJump(block)) { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
381 NodeSuccessorsIterable successors = block.getEndNode().successors(); |
4619
a09b44a28e7f
clenup unused floating nodes on killCFG
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4614
diff
changeset
|
382 assert successors.isNotEmpty() : "should have at least one successor : " + block.getEndNode(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
383 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 emitJump(getLIRBlock((FixedNode) successors.first()), null); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 if (GraalOptions.TraceLIRGeneratorLevel >= 1) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
388 TTY.println("END Generating LIR for block B" + block.getId()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 |
5462
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
391 // Check that the begin and end of a framestate-less loop |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
392 // share the frame state that flowed into the loop |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
393 assert blockLastState.get(block) == null || blockLastState.get(block) == lastState; |
fc58f934f9a1
allow a framestate to flow though a framestate-less loop
Doug Simon <doug.simon@oracle.com>
parents:
5460
diff
changeset
|
394 |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
395 blockLastLockCount.put(currentBlock, currentLockCount); |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
396 blockLastState.put(block, lastState); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
397 currentBlock = null; |
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 if (GraalOptions.PrintIRWithLIR) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
400 TTY.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 |
4628
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
404 private boolean checkStateReady(FrameState state) { |
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
405 FrameState fs = state; |
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
406 while (fs != null) { |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
407 for (ValueNode v : fs.values()) { |
4628
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
408 if (v != null && !(v instanceof VirtualObjectNode)) { |
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
409 assert operand(v) != null : "Value " + v + " in " + fs + " is not ready!"; |
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
410 } |
4625
73f935f28920
in esa mode, check that values in stateAfter are all ready after LIRGen of a ValudeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4619
diff
changeset
|
411 } |
4628
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
412 fs = fs.outerFrameState(); |
4625
73f935f28920
in esa mode, check that values in stateAfter are all ready after LIRGen of a ValudeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4619
diff
changeset
|
413 } |
4628
d882b9baea6e
check all framestates in LIRGen assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4625
diff
changeset
|
414 return true; |
4625
73f935f28920
in esa mode, check that values in stateAfter are all ready after LIRGen of a ValudeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4619
diff
changeset
|
415 } |
73f935f28920
in esa mode, check that values in stateAfter are all ready after LIRGen of a ValudeNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4619
diff
changeset
|
416 |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
417 private boolean endsWithJump(Block block) { |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
418 List<LIRInstruction> instructions = lir.lir(block); |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
419 if (instructions.size() == 0) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
420 return false; |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
421 } |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6409
diff
changeset
|
422 LIRInstruction lirInstruction = instructions.get(instructions.size() - 1); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
423 return lirInstruction instanceof StandardOp.JumpOp; |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
424 } |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4432
diff
changeset
|
425 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 private void doRoot(ValueNode instr) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 if (GraalOptions.TraceLIRGeneratorLevel >= 2) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
428 TTY.println("Emitting LIR for instruction " + instr); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
429 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
430 currentInstruction = instr; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 |
4404
aa4347c72887
Remove TraceLIRVisit
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
432 Debug.log("Visiting %s", instr); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 emitNode(instr); |
4404
aa4347c72887
Remove TraceLIRVisit
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4387
diff
changeset
|
434 Debug.log("Operand for %s = %s", instr, operand(instr)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 protected void emitNode(ValueNode node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 ((LIRLowerable) node).generate(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
439 } |
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 private static boolean canBeNullCheck(LocationNode location) { |
5774
a1db0ea58b53
Removed left over Ci* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
442 // TODO: Make this part of TargetDescription |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 return !(location instanceof IndexedLocationNode) && location.displacement() < 4096; |
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 |
5318
b5cd7bc05695
Method entry counters: Enable the flag to collect an execution profile of compiled methods and their callers. This allows to, e.g., detect methods that should be inlined because they are called frequently.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5251
diff
changeset
|
446 protected void emitPrologue() { |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
447 CallingConvention incomingArguments = frameMap.registerConfig.getCallingConvention(JavaCallee, method.signature().returnKind(), MetaUtil.signatureToKinds(method), target, false); |
4212
f282e35ea829
Define incoming parameters in a PARAMS instruction. This simplifies register allocation because the initial register state does not have to be inferred from the calling convention.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4206
diff
changeset
|
448 |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
449 Value[] params = new Value[incomingArguments.getArgumentCount()]; |
4212
f282e35ea829
Define incoming parameters in a PARAMS instruction. This simplifies register allocation because the initial register state does not have to be inferred from the calling convention.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4206
diff
changeset
|
450 for (int i = 0; i < params.length; i++) { |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
451 params[i] = toStackKind(incomingArguments.getArgument(i)); |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
452 if (ValueUtil.isStackSlot(params[i])) { |
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
453 StackSlot slot = ValueUtil.asStackSlot(params[i]); |
5251
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5247
diff
changeset
|
454 if (slot.inCallerFrame() && !lir.hasArgInCallerFrame()) { |
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5247
diff
changeset
|
455 lir.setHasArgInCallerFrame(); |
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5247
diff
changeset
|
456 } |
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5247
diff
changeset
|
457 } |
4212
f282e35ea829
Define incoming parameters in a PARAMS instruction. This simplifies register allocation because the initial register state does not have to be inferred from the calling convention.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4206
diff
changeset
|
458 } |
5251
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5247
diff
changeset
|
459 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4309
diff
changeset
|
460 append(new ParametersOp(params)); |
4212
f282e35ea829
Define incoming parameters in a PARAMS instruction. This simplifies register allocation because the initial register state does not have to be inferred from the calling convention.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4206
diff
changeset
|
461 |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4245
diff
changeset
|
462 for (LocalNode local : graph.getNodes(LocalNode.class)) { |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
463 Value param = params[local.index()]; |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
464 assert param.getKind() == local.kind().stackKind(); |
4212
f282e35ea829
Define incoming parameters in a PARAMS instruction. This simplifies register allocation because the initial register state does not have to be inferred from the calling convention.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4206
diff
changeset
|
465 setResult(local, emitMove(param)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 } |
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 |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
469 /** |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
470 * Increases the number of currently locked monitors and makes sure that a lock data slot is available for the new lock. |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
471 */ |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
472 public void lock() { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
473 if (lockDataSlots.size() == currentLockCount) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
474 lockDataSlots.add(frameMap.allocateStackBlock(runtime.sizeOfLockData(), false)); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
475 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
476 currentLockCount++; |
6382
9b6b8626983a
factored out access to LIRGenerator lock scope for external use in LIR lowering
Doug Simon <doug.simon@oracle.com>
parents:
6329
diff
changeset
|
477 } |
9b6b8626983a
factored out access to LIRGenerator lock scope for external use in LIR lowering
Doug Simon <doug.simon@oracle.com>
parents:
6329
diff
changeset
|
478 |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
479 /** |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
480 * Decreases the number of currently locked monitors. |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
481 * |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
482 * @throws GraalInternalError if the number of currently locked monitors is already zero. |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
483 */ |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
484 public void unlock() { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
485 if (currentLockCount == 0) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
486 throw new GraalInternalError("unmatched locks"); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
487 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
488 currentLockCount--; |
6382
9b6b8626983a
factored out access to LIRGenerator lock scope for external use in LIR lowering
Doug Simon <doug.simon@oracle.com>
parents:
6329
diff
changeset
|
489 } |
9b6b8626983a
factored out access to LIRGenerator lock scope for external use in LIR lowering
Doug Simon <doug.simon@oracle.com>
parents:
6329
diff
changeset
|
490 |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
491 /** |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
492 * @return The lock data slot for the topmost locked monitor. |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
493 */ |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
494 public StackSlot peekLock() { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6411
diff
changeset
|
495 return lockDataSlots.get(currentLockCount - 1); |
6382
9b6b8626983a
factored out access to LIRGenerator lock scope for external use in LIR lowering
Doug Simon <doug.simon@oracle.com>
parents:
6329
diff
changeset
|
496 } |
9b6b8626983a
factored out access to LIRGenerator lock scope for external use in LIR lowering
Doug Simon <doug.simon@oracle.com>
parents:
6329
diff
changeset
|
497 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 public void visitReturn(ReturnNode x) { |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
500 Value operand = Value.IllegalValue; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 if (!x.kind().isVoid()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 operand = resultOperandFor(x.kind()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 emitMove(operand(x.result()), operand); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 } |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
5199
diff
changeset
|
505 emitReturn(operand); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
508 protected abstract void emitReturn(Value input); |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4309
diff
changeset
|
509 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 public void visitMerge(MergeNode x) { |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 public void visitEndNode(EndNode end) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 moveToPhi(end.merge(), end); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 |
5236
f9aae727d035
removed XIR safepoint operation
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
519 /** |
f9aae727d035
removed XIR safepoint operation
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
520 * Runtime specific classes can override this to insert a safepoint at the end of a loop. |
f9aae727d035
removed XIR safepoint operation
Doug Simon <doug.simon@oracle.com>
parents:
5233
diff
changeset
|
521 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 public void visitLoopEnd(LoopEndNode x) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4550
diff
changeset
|
526 private void moveToPhi(MergeNode merge, EndNode pred) { |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
527 if (GraalOptions.TraceLIRGeneratorLevel >= 1) { |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
528 TTY.println("MOVE TO PHI from " + pred + " to " + merge); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
529 } |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
530 PhiResolver resolver = new PhiResolver(this); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
531 for (PhiNode phi : merge.phis()) { |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
532 if (phi.type() == PhiType.Value) { |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
533 ValueNode curVal = phi.valueAt(pred); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
534 resolver.move(operand(curVal), operandForPhi(phi)); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
535 } |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
536 } |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
537 resolver.dispose(); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
538 |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
539 append(new JumpOp(getLIRBlock(merge), null)); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
540 } |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
541 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
542 private Value operandForPhi(PhiNode phi) { |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
543 assert phi.type() == PhiType.Value : "wrong phi type: " + phi; |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
544 Value result = operand(phi); |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
545 if (result == null) { |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
546 // allocate a variable for this phi |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
547 Variable newOperand = newVariable(phi.kind()); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
548 setResult(phi, newOperand); |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
549 return newOperand; |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
550 } else { |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
551 return result; |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
552 } |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
553 } |
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4469
diff
changeset
|
554 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 public void emitIf(IfNode x) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 emitBranch(x.compare(), getLIRBlock(x.trueSuccessor()), getLIRBlock(x.falseSuccessor()), null); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
560 @Override |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5546
diff
changeset
|
561 public void emitGuardCheck(BooleanNode comp, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated, long leafGraphId) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
562 if (comp instanceof IsNullNode && negated) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
563 emitNullCheckGuard(((IsNullNode) comp).object(), leafGraphId); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
564 } else if (comp instanceof ConstantNode && (comp.asConstant().asBoolean() != negated)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
565 // True constant, nothing to emit. |
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
|
566 // False constants are handled within emitBranch. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
567 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
568 // Fall back to a normal branch. |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
569 LIRFrameState info = state(leafGraphId); |
5160
6e385457d6fc
Add a RiDeoptAction to Guards and FixedGuards
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5130
diff
changeset
|
570 LabelRef stubEntry = createDeoptStub(action, deoptReason, info, comp); |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
571 if (negated) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
572 emitBranch(comp, stubEntry, null, info); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
573 } else { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
574 emitBranch(comp, null, stubEntry, info); |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
575 } |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
578 |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
579 protected abstract void emitNullCheckGuard(ValueNode object, long leafGraphId); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
580 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
581 public void emitBranch(BooleanNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, LIRFrameState info) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
582 if (node instanceof IsNullNode) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
583 emitNullCheckBranch((IsNullNode) node, trueSuccessor, falseSuccessor, info); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
584 } else if (node instanceof CompareNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
585 emitCompareBranch((CompareNode) node, trueSuccessor, falseSuccessor, info); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
586 } else if (node instanceof ConstantNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
587 emitConstantBranch(((ConstantNode) node).asConstant().asBoolean(), trueSuccessor, falseSuccessor, info); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
588 } else { |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
589 throw GraalInternalError.unimplemented(node.toString()); |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
592 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
593 private void emitNullCheckBranch(IsNullNode node, LabelRef trueSuccessor, LabelRef falseSuccessor, LIRFrameState info) { |
5460
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
594 if (falseSuccessor != null) { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
595 emitBranch(operand(node.object()), Constant.NULL_OBJECT, Condition.NE, false, falseSuccessor, info); |
5460
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
596 if (trueSuccessor != null) { |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
597 emitJump(trueSuccessor, null); |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
598 } |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
599 } else { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
600 emitBranch(operand(node.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueSuccessor, info); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
601 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
602 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
603 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
604 public void emitCompareBranch(CompareNode compare, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock, LIRFrameState info) { |
5460
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
605 if (falseSuccessorBlock != null) { |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
606 emitBranch(operand(compare.x()), operand(compare.y()), compare.condition().negate(), !compare.unorderedIsTrue(), falseSuccessorBlock, info); |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
607 if (trueSuccessorBlock != null) { |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
608 emitJump(trueSuccessorBlock, null); |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
609 } |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
610 } else { |
4ea62e26643e
fix for branches that have only a true successor (as emitted for negated guards).
Andreas Woess <andreas.woess@jku.at>
parents:
5443
diff
changeset
|
611 emitBranch(operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueSuccessorBlock, info); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
612 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
613 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
614 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
615 public void emitConstantBranch(boolean value, LabelRef trueSuccessorBlock, LabelRef falseSuccessorBlock, LIRFrameState info) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 LabelRef block = value ? trueSuccessorBlock : falseSuccessorBlock; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
617 if (block != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
618 emitJump(block, info); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
619 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
620 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
621 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
622 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
623 public void emitConditional(ConditionalNode conditional) { |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
624 Value tVal = operand(conditional.trueValue()); |
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
625 Value fVal = operand(conditional.falseValue()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
626 setResult(conditional, emitConditional(conditional.condition(), tVal, fVal)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
627 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
629 public Variable emitConditional(BooleanNode node, Value trueValue, Value falseValue) { |
5425
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
630 if (node instanceof IsNullNode) { |
0364a2a874b8
changes towards a canonical representation of comparisons:
Lukas Stadler <lukas.stadler@jku.at>
parents:
5374
diff
changeset
|
631 return emitNullCheckConditional((IsNullNode) node, trueValue, falseValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 } else if (node instanceof CompareNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
633 return emitCompareConditional((CompareNode) node, trueValue, falseValue); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
634 } else if (node instanceof ConstantNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
635 return emitConstantConditional(((ConstantNode) node).asConstant().asBoolean(), trueValue, falseValue); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
636 } else { |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
637 throw GraalInternalError.unimplemented(node.toString()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
638 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
639 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
640 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
641 private Variable emitNullCheckConditional(IsNullNode node, Value trueValue, Value falseValue) { |
5538
e18ba36bfebc
Renamed RiConstant => Constant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5531
diff
changeset
|
642 return emitCMove(operand(node.object()), Constant.NULL_OBJECT, Condition.EQ, false, trueValue, falseValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
643 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
645 private Variable emitConstantConditional(boolean value, Value trueValue, Value falseValue) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 return emitMove(value ? trueValue : falseValue); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
649 private Variable emitCompareConditional(CompareNode compare, Value trueValue, Value falseValue) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 return emitCMove(operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueValue, falseValue); |
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 public abstract void emitLabel(Label label, boolean align); |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
655 public abstract void emitJump(LabelRef label, LIRFrameState info); |
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
656 public abstract void emitBranch(Value left, Value right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRFrameState info); |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
657 public abstract Variable emitCMove(Value leftVal, Value right, Condition cond, boolean unorderedIsTrue, Value trueValue, Value falseValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
659 protected FrameState stateBeforeCallWithArguments(FrameState stateAfter, MethodCallTargetNode call, int bci) { |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
660 return stateAfter.duplicateModified(bci, stateAfter.rethrowException(), call.returnStamp().kind(), toJVMArgumentStack(call.targetMethod().signature(), call.isStatic(), call.arguments())); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
661 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
662 |
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
|
663 private static ValueNode[] toJVMArgumentStack(Signature signature, boolean isStatic, NodeInputList<ValueNode> arguments) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
664 int slotCount = signature.argumentSlots(!isStatic); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
665 ValueNode[] stack = new ValueNode[slotCount]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
666 int stackIndex = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
667 int argumentIndex = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
668 for (ValueNode arg : arguments) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
669 stack[stackIndex] = arg; |
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 if (stackIndex == 0 && !isStatic) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 // Current argument is receiver. |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
673 stackIndex += stackSlots(Kind.Object); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 } else { |
5531
816fb2492760
Remove architecture boolean from Ri* interfaces.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5510
diff
changeset
|
675 stackIndex += stackSlots(signature.argumentKindAt(argumentIndex)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
676 argumentIndex++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
677 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
679 return stack; |
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 |
4205
2af849af1723
moved graphbuilder into the graal.java project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
682 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
683 public static int stackSlots(Kind kind) { |
4205
2af849af1723
moved graphbuilder into the graal.java project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
684 return isTwoSlot(kind) ? 2 : 1; |
2af849af1723
moved graphbuilder into the graal.java project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
685 } |
2af849af1723
moved graphbuilder into the graal.java project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
686 |
5540
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
687 public static boolean isTwoSlot(Kind kind) { |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
688 assert kind != Kind.Void && kind != Kind.Illegal; |
a891c53a295b
Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5539
diff
changeset
|
689 return kind == Kind.Long || kind == Kind.Double; |
4205
2af849af1723
moved graphbuilder into the graal.java project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
690 } |
2af849af1723
moved graphbuilder into the graal.java project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4200
diff
changeset
|
691 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 public void emitInvoke(Invoke x) { |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
694 AbstractCallTargetNode callTarget = (AbstractCallTargetNode) x.callTarget(); |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
695 Kind[] signature = callTarget.signature(); |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
696 CallingConvention cc = frameMap.registerConfig.getCallingConvention(callTarget.callType(), x.node().kind(), signature, target(), false); |
6472
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
697 frameMap.callsMethod(cc); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
698 |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
699 Value[] parameters = visitInvokeArguments(cc, callTarget.arguments()); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
700 |
6438
bbf47e2d519f
Allow calls without a FrameState in the backend
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6436
diff
changeset
|
701 LIRFrameState callState = null; |
bbf47e2d519f
Allow calls without a FrameState in the backend
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6436
diff
changeset
|
702 if (x.stateAfter() != null) { |
bbf47e2d519f
Allow calls without a FrameState in the backend
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6436
diff
changeset
|
703 callState = stateFor(x.stateDuring(), null, x instanceof InvokeWithExceptionNode ? getLIRBlock(((InvokeWithExceptionNode) x).exceptionEdge()) : null, x.leafGraphId()); |
bbf47e2d519f
Allow calls without a FrameState in the backend
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6436
diff
changeset
|
704 } |
bbf47e2d519f
Allow calls without a FrameState in the backend
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6436
diff
changeset
|
705 |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
706 Value result = cc.getReturn(); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
707 |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
708 if (callTarget instanceof DirectCallTargetNode) { |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
709 emitDirectCall((DirectCallTargetNode) callTarget, result, parameters, cc.getTemporaries(), callState); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
710 } else if (callTarget instanceof IndirectCallTargetNode) { |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
711 emitIndirectCall((IndirectCallTargetNode) callTarget, result, parameters, cc.getTemporaries(), callState); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
712 } else { |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
713 throw GraalInternalError.shouldNotReachHere(); |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
714 } |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
715 |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
716 if (isLegal(result)) { |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
717 setResult(x.node(), emitMove(result)); |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
718 } |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
719 } |
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
720 |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
721 protected abstract void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
722 |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
723 protected abstract void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState); |
6409
823a2978e7ba
Lowering of call targets to direct / indirect call targets
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6382
diff
changeset
|
724 |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
725 protected abstract void emitCall(Object targetMethod, Value result, Value[] arguments, Value[] temps, Value targetAddress, LIRFrameState info); |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4309
diff
changeset
|
726 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
727 private static Value toStackKind(Value value) { |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
728 if (value.getKind().stackKind() != value.getKind()) { |
4173
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
729 // We only have stack-kinds in the LIR, so convert the operand kind for values from the calling convention. |
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
730 if (isRegister(value)) { |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
731 return asRegister(value).asValue(value.getKind().stackKind()); |
4173
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
732 } else if (isStackSlot(value)) { |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
733 return StackSlot.get(value.getKind().stackKind(), asStackSlot(value).rawOffset(), asStackSlot(value).rawAddFrameSize()); |
4173
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
734 } else { |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
735 throw GraalInternalError.shouldNotReachHere(); |
4173
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
736 } |
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
737 } |
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
738 return value; |
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
739 } |
15b9402dc018
Canonicalize the incoming and outgoing parameters to stack-kinds
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
740 |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
741 public Value[] visitInvokeArguments(CallingConvention cc, Collection<ValueNode> arguments) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
742 // for each argument, load it into the correct location |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
743 Value[] result = new Value[arguments.size()]; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 int j = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 for (ValueNode arg : arguments) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 if (arg != null) { |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
747 Value operand = toStackKind(cc.getArgument(j)); |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
748 emitMove(operand(arg), operand); |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
749 result[j] = operand; |
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
750 j++; |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
751 } else { |
4524
dcc8f5c6f394
Refactorings to prepare for LIR project splitting
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4522
diff
changeset
|
752 throw GraalInternalError.shouldNotReachHere("I thought we no longer have null entries for two-slot types..."); |
3733
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 } |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
755 return result; |
3733
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
758 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
759 protected abstract LabelRef createDeoptStub(DeoptimizationAction action, DeoptimizationReason reason, LIRFrameState info, Object deoptInfo); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
760 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
761 @Override |
6472
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
762 public Variable emitCall(@SuppressWarnings("hiding") Object target, CallingConvention cc, boolean canTrap, Value... args) { |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
763 LIRFrameState info = canTrap ? state() : null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
764 |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
765 // move the arguments into the correct location |
6472
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
766 frameMap.callsMethod(cc); |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
767 assert cc.getArgumentCount() == args.length : "argument count mismatch"; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
768 Value[] argLocations = new Value[args.length]; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
769 for (int i = 0; i < args.length; i++) { |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
770 Value arg = args[i]; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
771 Value loc = cc.getArgument(i); |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
772 emitMove(arg, loc); |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
773 argLocations[i] = loc; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
774 } |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
775 emitCall(target, cc.getReturn(), argLocations, cc.getTemporaries(), Constant.forLong(0), info); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
777 if (isLegal(cc.getReturn())) { |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
778 return emitMove(cc.getReturn()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
780 return null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
781 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
783 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
784 @Override |
6472
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
785 public Value emitCall(RuntimeCall runtimeCall, boolean canTrap, Value... args) { |
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
786 CallingConvention cc = frameMap.registerConfig.getCallingConvention(RuntimeCall, runtimeCall.getResultKind(), runtimeCall.getArgumentKinds(), target, false); |
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
787 return emitCall(runtimeCall, cc, canTrap, args); |
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
788 } |
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
789 |
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
790 @Override |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
791 public void emitRuntimeCall(RuntimeCallNode x) { |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
792 CallingConvention cc = frameMap.registerConfig.getCallingConvention(RuntimeCall, x.kind(), x.call().getArgumentKinds(), target(), false); |
6472
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
793 frameMap.callsMethod(cc); |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
794 Value resultOperand = cc.getReturn(); |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
795 Value[] args = visitInvokeArguments(cc, x.arguments()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
797 LIRFrameState info = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 FrameState stateAfter = x.stateAfter(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 if (stateAfter != null) { |
5056
2f2c6347fce4
comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5029
diff
changeset
|
800 // (cwimmer) I made the code that modifies the operand stack conditional. My scenario: runtime calls to, e.g., |
2f2c6347fce4
comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5029
diff
changeset
|
801 // CreateNullPointerException have no equivalent in the bytecodes, so there is no invoke bytecode. |
5026
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
802 // Therefore, the result of the runtime call was never pushed to the stack, and we cannot pop it here. |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
803 FrameState stateBeforeReturn = stateAfter; |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
804 if ((stateAfter.stackSize() > 0 && stateAfter.stackAt(stateAfter.stackSize() - 1) == x) || |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
805 (stateAfter.stackSize() > 1 && stateAfter.stackAt(stateAfter.stackSize() - 2) == x)) { |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
806 |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
807 stateBeforeReturn = stateAfter.duplicateModified(stateAfter.bci, stateAfter.rethrowException(), x.kind()); |
b11561111585
Remove FrameStateAccess: Make FrameState immutable and move all modification logic into FrameStateBuilder
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
5003
diff
changeset
|
808 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
809 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 // TODO is it correct here that the pointerSlots are not passed to the oop map generation? |
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
|
811 info = stateFor(stateBeforeReturn, -1); |
5601
e1aa23322006
ensure that every runtime call has debug info associated with it
Doug Simon <doug.simon@oracle.com>
parents:
5591
diff
changeset
|
812 } else { |
e1aa23322006
ensure that every runtime call has debug info associated with it
Doug Simon <doug.simon@oracle.com>
parents:
5591
diff
changeset
|
813 // Every runtime call needs an info |
e1aa23322006
ensure that every runtime call has debug info associated with it
Doug Simon <doug.simon@oracle.com>
parents:
5591
diff
changeset
|
814 // TODO This is conservative. It's not needed for RuntimeCalls that are implemented purely in a stub |
e1aa23322006
ensure that every runtime call has debug info associated with it
Doug Simon <doug.simon@oracle.com>
parents:
5591
diff
changeset
|
815 // that does not trash any registers and does not call into the runtime. |
e1aa23322006
ensure that every runtime call has debug info associated with it
Doug Simon <doug.simon@oracle.com>
parents:
5591
diff
changeset
|
816 info = state(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
819 emitCall(x.call(), resultOperand, args, cc.getTemporaries(), Constant.forLong(0), info); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 |
4183
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4181
diff
changeset
|
821 if (isLegal(resultOperand)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 setResult(x, emitMove(resultOperand)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
823 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
826 /** |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
827 * This method tries to create a switch implementation that is optimal for the given switch. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
828 * It will either generate a sequential if/then/else cascade, a set of range tests or a table switch. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
829 * |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
830 * If the given switch does not contain int keys, it will always create a sequential implementation. |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
831 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
832 @Override |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
833 public void emitSwitch(SwitchNode x) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
834 int keyCount = x.keyCount(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
835 if (keyCount == 0) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
836 emitJump(getLIRBlock(x.defaultSuccessor()), null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
837 } else { |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
838 Variable value = load(operand(x.value())); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
839 LabelRef defaultTarget = x.defaultSuccessor() == null ? null : getLIRBlock(x.defaultSuccessor()); |
6329
92bc58dc5b5e
More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6316
diff
changeset
|
840 if (value.getKind() == Kind.Object || keyCount < GraalOptions.SequentialSwitchLimit) { |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
841 // only a few entries |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
842 emitSequentialSwitch(x, value, defaultTarget); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 } else { |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
844 long valueRange = x.keyAt(keyCount - 1).asLong() - x.keyAt(0).asLong() + 1; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
845 int switchRangeCount = switchRangeCount(x); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
846 int rangeDensity = keyCount / switchRangeCount; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
847 if (rangeDensity >= GraalOptions.RangeTestsSwitchDensity) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
848 emitSwitchRanges(x, switchRangeCount, value, defaultTarget); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
849 } else if (keyCount / (double) valueRange >= GraalOptions.MinTableSwitchDensity) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
850 int minValue = x.keyAt(0).asInt(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
851 assert valueRange < Integer.MAX_VALUE; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
852 LabelRef[] targets = new LabelRef[(int) valueRange]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
853 for (int i = 0; i < valueRange; i++) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
854 targets[i] = defaultTarget; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
855 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
856 for (int i = 0; i < keyCount; i++) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
857 targets[x.keyAt(i).asInt() - minValue] = getLIRBlock(x.keySuccessor(i)); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
858 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
859 emitTableSwitch(minValue, defaultTarget, targets, value); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
860 } else { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
861 emitSequentialSwitch(x, value, defaultTarget); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
862 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
863 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
864 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
865 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
867 private void emitSequentialSwitch(final SwitchNode x, Variable key, LabelRef defaultTarget) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
868 int keyCount = x.keyCount(); |
5784
182d5b57967e
order successors by probability in ComputeLinearScanOrder
Lukas Stadler <lukas.stadler@jku.at>
parents:
5775
diff
changeset
|
869 Integer[] indexes = Util.createSortedPermutation(keyCount, new Comparator<Integer>() { |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
870 @Override |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
871 public int compare(Integer o1, Integer o2) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
872 return x.keyProbability(o1) < x.keyProbability(o2) ? 1 : x.keyProbability(o1) > x.keyProbability(o2) ? -1 : 0; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
873 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
874 }); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
875 LabelRef[] keyTargets = new LabelRef[keyCount]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
876 Constant[] keyConstants = new Constant[keyCount]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
877 for (int i = 0; i < keyCount; i++) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
878 keyTargets[i] = getLIRBlock(x.keySuccessor(indexes[i])); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
879 keyConstants[i] = x.keyAt(indexes[i]); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
880 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
881 emitSequentialSwitch(keyConstants, keyTargets, defaultTarget, key); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
882 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
883 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
884 protected abstract void emitSequentialSwitch(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
885 protected abstract void emitSwitchRanges(int[] lowKeys, int[] highKeys, LabelRef[] targets, LabelRef defaultTarget, Value key); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
886 protected abstract void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
887 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
888 private static int switchRangeCount(SwitchNode x) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
889 int keyCount = x.keyCount(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
890 int i = 0; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
891 while (i < keyCount && x.keySuccessorIndex(i) == x.defaultSuccessorIndex()) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
892 i++; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
893 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
894 if (i == keyCount) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
895 return 0; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
896 } else { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
897 int switchRangeCount = 1; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
898 i++; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
899 for (; i < keyCount; i++) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
900 if (x.keySuccessorIndex(i) != x.defaultSuccessorIndex()) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
901 if (x.keyAt(i).asInt() != x.keyAt(i - 1).asInt() + 1 || x.keySuccessorIndex(i) != x.keySuccessorIndex(i - 1)) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
902 switchRangeCount++; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
903 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
904 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
905 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
906 return switchRangeCount; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
907 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
908 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
909 |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
910 private void emitSwitchRanges(SwitchNode x, int switchRangeCount, Variable keyValue, LabelRef defaultTarget) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
911 int[] lowKeys = new int[switchRangeCount]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
912 int[] highKeys = new int[switchRangeCount]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
913 LabelRef[] targets = new LabelRef[switchRangeCount]; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
914 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
915 int keyCount = x.keyCount(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
916 int defaultSuccessor = x.defaultSuccessorIndex(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
917 |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
918 int current = 0; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
919 int i = 0; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
920 while (i < keyCount && x.keySuccessorIndex(i) == x.defaultSuccessorIndex()) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
921 i++; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
922 } |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
923 if (i == keyCount) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
924 emitJump(defaultTarget, null); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
925 } else { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
926 int key = x.keyAt(i).asInt(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
927 int successor = x.keySuccessorIndex(i); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
928 lowKeys[current] = key; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
929 highKeys[current] = key; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
930 targets[current] = getLIRBlock(x.blockSuccessor(successor)); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
931 i++; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
932 for (; i < keyCount; i++) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
933 int newSuccessor = x.keySuccessorIndex(i); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
934 if (newSuccessor != defaultSuccessor) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
935 int newKey = x.keyAt(i).asInt(); |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
936 if (key + 1 == newKey && successor == newSuccessor) { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
937 // still in same range |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
938 highKeys[current] = newKey; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
939 } else { |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
940 current++; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
941 lowKeys[current] = newKey; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
942 highKeys[current] = newKey; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
943 targets[current] = getLIRBlock(x.blockSuccessor(newSuccessor)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
944 } |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
945 key = newKey; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
946 } |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
947 successor = newSuccessor; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
948 } |
5698
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
949 assert current == switchRangeCount - 1; |
764db9ada24f
rework of switch operations: unify lookup- and tableswitch, introduce switch lir instructions
Lukas Stadler <lukas.stadler@jku.at>
parents:
5662
diff
changeset
|
950 emitSwitchRanges(lowKeys, highKeys, targets, defaultTarget, keyValue); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
951 } |
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 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
954 protected final Value callRuntime(RuntimeCall runtimeCall, LIRFrameState info, Value... args) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
955 // get a result register |
6443
5b419d76b406
Make RuntimeCall more extensible by changing it from an enum to a class
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6438
diff
changeset
|
956 Kind[] arguments = runtimeCall.getArgumentKinds(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
957 |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
958 // move the arguments into the correct location |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
959 CallingConvention cc = frameMap.registerConfig.getCallingConvention(RuntimeCall, runtimeCall.getResultKind(), arguments, target(), false); |
6472
7548c1248bb3
pushed CallingConvention further into LIR API for emitting calls
Doug Simon <doug.simon@oracle.com>
parents:
6470
diff
changeset
|
960 frameMap.callsMethod(cc); |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
961 assert cc.getArgumentCount() == args.length : "argument count mismatch"; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
962 Value[] argLocations = new Value[args.length]; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
963 for (int i = 0; i < args.length; i++) { |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
964 Value arg = args[i]; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
965 Value loc = cc.getArgument(i); |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
966 emitMove(arg, loc); |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
967 argLocations[i] = loc; |
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
968 } |
6478
62878ae057a5
added support for temps in LIR call instructions
Doug Simon <doug.simon@oracle.com>
parents:
6476
diff
changeset
|
969 emitCall(runtimeCall, cc.getReturn(), argLocations, cc.getTemporaries(), Constant.forLong(0), info); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
970 |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
971 return cc.getReturn(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
972 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
973 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
974 protected final Variable callRuntimeWithResult(RuntimeCall runtimeCall, LIRFrameState info, Value... args) { |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5538
diff
changeset
|
975 Value location = callRuntime(runtimeCall, info, args); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
976 return emitMove(location); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
977 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
978 |
4268
3e5c18a41c25
Add frameMap getter to LIRGenerator. Add compileMethod overload with input graph parameter.
Andreas Woess <andreas.woess@jku.at>
parents:
4265
diff
changeset
|
979 public FrameMap frameMap() { |
3e5c18a41c25
Add frameMap getter to LIRGenerator. Add compileMethod overload with input graph parameter.
Andreas Woess <andreas.woess@jku.at>
parents:
4265
diff
changeset
|
980 return frameMap; |
3e5c18a41c25
Add frameMap getter to LIRGenerator. Add compileMethod overload with input graph parameter.
Andreas Woess <andreas.woess@jku.at>
parents:
4265
diff
changeset
|
981 } |
6496
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
982 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
983 public abstract void emitBitScanForward(Variable result, Value operand); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
984 public abstract void emitBitScanReverse(Variable result, Value operand); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
985 |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
986 public abstract void emitMathAbs(Variable result, Variable input); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
987 public abstract void emitMathSqrt(Variable result, Variable input); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
988 public abstract void emitMathLog(Variable result, Variable input, boolean base10); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
989 public abstract void emitMathCos(Variable result, Variable input); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
990 public abstract void emitMathSin(Variable result, Variable input); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
991 public abstract void emitMathTan(Variable result, Variable input); |
16d1411409b4
moved AMD64 specific code into com.oracle.graal.compiler.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6478
diff
changeset
|
992 public abstract void emitByteSwap(Variable result, Value operand); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
993 } |