annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java @ 21319:9ddb5a749eab

LinearScan: use multiline comments.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 12 May 2015 10:16:43 +0200
parents 88f8bbed600f
children 26beac81ab2f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 15927
diff changeset
2 * Copyright (c) 2009, 2014, 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 */
19166
39e99cf01468 Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents: 19165
diff changeset
23 package com.oracle.graal.lir.alloc.lsra;
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: 5542
diff changeset
25 import static com.oracle.graal.api.code.CodeUtil.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
26 import static com.oracle.graal.api.code.ValueUtil.*;
19163
0751ebc54c13 Move DetailedAsserts Option to GraalOptions.
Josef Eisl <josef.eisl@jku.at>
parents: 19162
diff changeset
27 import static com.oracle.graal.compiler.common.GraalOptions.*;
16505
45f92700119f Move AbstractBlock.{dominates, isDominatedBy} to AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 16380
diff changeset
28 import static com.oracle.graal.compiler.common.cfg.AbstractControlFlowGraph.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
29 import static com.oracle.graal.lir.LIRValueUtil.*;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
30
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import java.util.*;
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.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
35 import com.oracle.graal.compiler.common.*;
19165
b3b81dfff200 Move ComputeBlockOrder to compiler.common and delete c.o.g.alloc project.
Josef Eisl <josef.eisl@jku.at>
parents: 19164
diff changeset
36 import com.oracle.graal.compiler.common.alloc.*;
15192
644dfe49c0f4 Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents: 15157
diff changeset
37 import com.oracle.graal.compiler.common.cfg.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.debug.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.lir.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
40 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
41 import com.oracle.graal.lir.LIRInstruction.OperandMode;
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
42 import com.oracle.graal.lir.StandardOp.LabelOp;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
43 import com.oracle.graal.lir.StandardOp.MoveOp;
19166
39e99cf01468 Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents: 19165
diff changeset
44 import com.oracle.graal.lir.alloc.lsra.Interval.RegisterBinding;
39e99cf01468 Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents: 19165
diff changeset
45 import com.oracle.graal.lir.alloc.lsra.Interval.RegisterPriority;
39e99cf01468 Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents: 19165
diff changeset
46 import com.oracle.graal.lir.alloc.lsra.Interval.SpillState;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 18441
diff changeset
47 import com.oracle.graal.lir.framemap.*;
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
48 import com.oracle.graal.lir.gen.*;
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
49 import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory;
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
50 import com.oracle.graal.lir.phases.*;
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
51 import com.oracle.graal.lir.phases.AllocationPhase.AllocationContext;
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
52 import com.oracle.graal.options.*;
3733
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
55 * An implementation of the linear scan register allocator algorithm described in <a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
56 * href="http://doi.acm.org/10.1145/1064979.1064998"
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
57 * >"Optimized Interval Splitting in a Linear Scan Register Allocator"</a> by Christian Wimmer and
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
58 * Hanspeter Moessenboeck.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 */
21240
1e9242c9735e Introduce SSALinearScan and SSAMoveResolver.
Josef Eisl <josef.eisl@jku.at>
parents: 21236
diff changeset
60 class LinearScan {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
62 final LIRGenerationResult res;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 final LIR ir;
18150
22f2e42923de Use FrameMapBuilder in LinearScan (except for location marking).
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
64 final FrameMapBuilder frameMapBuilder;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
65 final RegisterAttributes[] registerAttributes;
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
66 final Register[] registers;
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
67 final RegisterAllocationConfig regAllocConfig;
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
68 private final SpillMoveFactory moveFactory;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69
18512
bcf66634c55c Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents: 18446
diff changeset
70 final boolean callKillsRegisters;
10961
d0c9278fe471 move callKillsRegisters to LinearScan
twisti
parents: 9966
diff changeset
71
16380
8057279ec60e LSRA spill optimization: use DOMINATOR_SPILL_MOVE_ID to mark moves.
Josef Eisl <josef.eisl@jku.at>
parents: 16379
diff changeset
72 public static final int DOMINATOR_SPILL_MOVE_ID = -2;
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
73 static final int SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT = 1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
75 public static class Options {
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
76 // @formatter:off
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18610
diff changeset
77 @Option(help = "Enable spill position optimization", type = OptionType.Debug)
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
78 public static final OptionValue<Boolean> LSRAOptimizeSpillPosition = new OptionValue<>(true);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
79 // @formatter:on
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
80 }
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
81
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
82 public static class BlockData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
83
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
84 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
85 * Bit map specifying which operands are live upon entry to this block. These are values
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
86 * used in this block or any of its successors where such value are not defined in this
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
87 * block. The bit index of an operand is its {@linkplain LinearScan#operandNumber(Value)
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
88 * operand number}.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
89 */
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
90 public BitSet liveIn;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
91
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
92 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
93 * Bit map specifying which operands are live upon exit from this block. These are values
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
94 * used in a successor block that are either defined in this block or were live upon entry
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
95 * to this block. The bit index of an operand is its
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
96 * {@linkplain LinearScan#operandNumber(Value) operand number}.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
97 */
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
98 public BitSet liveOut;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
99
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
100 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
101 * Bit map specifying which operands are used (before being defined) in this block. That is,
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
102 * these are the values that are live upon entry to the block. The bit index of an operand
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
103 * is its {@linkplain LinearScan#operandNumber(Value) operand number}.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
104 */
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
105 public BitSet liveGen;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
106
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
107 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
108 * Bit map specifying which operands are defined/overwritten in this block. The bit index of
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
109 * an operand is its {@linkplain LinearScan#operandNumber(Value) operand number}.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
110 */
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
111 public BitSet liveKill;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
112 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
113
19212
95a7954ea155 Add LinearScanPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19166
diff changeset
114 final BlockMap<BlockData> blockData;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
115
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 * List of blocks in linear-scan order. This is only correct as long as the CFG does not change.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
119 final List<? extends AbstractBlockBase<?>> sortedBlocks;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 /**
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
122 * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 Interval[] intervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125
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 * The number of valid entries in {@link #intervals}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 int intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
132 * The index of the first entry in {@link #intervals} for a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
133 * {@linkplain #createDerivedInterval(Interval) derived interval}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 int firstDerivedIntervalIndex = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 * Intervals sorted by {@link Interval#from()}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 Interval[] sortedIntervals;
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
143 * Map from an instruction {@linkplain LIRInstruction#id id} to the instruction. Entries should
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
144 * be retrieved with {@link #instructionForId(int)} as the id is not simply an index into this
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
145 * array.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 LIRInstruction[] opIdToInstructionMap;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 /**
19565
9bb45bec2b1f Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19563
diff changeset
150 * Map from an instruction {@linkplain LIRInstruction#id id} to the
9bb45bec2b1f Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19563
diff changeset
151 * {@linkplain AbstractBlockBase block} containing the instruction. Entries should be retrieved
9bb45bec2b1f Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19563
diff changeset
152 * with {@link #blockForId(int)} as the id is not simply an index into this array.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
154 AbstractBlockBase<?>[] opIdToBlockMap;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 /**
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5552
diff changeset
157 * The {@linkplain #operandNumber(Value) number} of the first variable operand allocated.
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
158 */
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
159 private final int firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
160
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
161 LinearScan(TargetDescription target, LIRGenerationResult res, SpillMoveFactory spillMoveFactory, RegisterAllocationConfig regAllocConfig) {
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
162 this.res = res;
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
163 this.ir = res.getLIR();
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
164 this.moveFactory = spillMoveFactory;
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
165 this.frameMapBuilder = res.getFrameMapBuilder();
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
166 this.sortedBlocks = ir.linearScanOrder();
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
167 this.registerAttributes = regAllocConfig.getRegisterConfig().getAttributesMap();
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
168 this.regAllocConfig = regAllocConfig;
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
169
6582
cc32ce37eddc deleted Architecture.twoOperandMode() and encapsulated all public fields in Architecture with getters
Doug Simon <doug.simon@oracle.com>
parents: 6581
diff changeset
170 this.registers = target.arch.getRegisters();
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
171 this.firstVariableNumber = registers.length;
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14142
diff changeset
172 this.blockData = new BlockMap<>(ir.getControlFlowGraph());
18512
bcf66634c55c Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents: 18446
diff changeset
173
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
174 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
175 * If all allocatable registers are caller saved, then no registers are live across a call
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
176 * site. The register allocator can save time not trying to find a register at a call site.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
177 */
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
178 this.callKillsRegisters = regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
181 int getFirstLirInstructionId(AbstractBlockBase<?> block) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
182 int result = ir.getLIRforBlock(block).get(0).id();
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
183 assert result >= 0;
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
184 return result;
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
185 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
186
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
187 int getLastLirInstructionId(AbstractBlockBase<?> block) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
188 List<LIRInstruction> instructions = ir.getLIRforBlock(block);
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
189 int result = instructions.get(instructions.size() - 1).id();
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
190 assert result >= 0;
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
191 return result;
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
192 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
193
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
194 SpillMoveFactory getSpillMoveFactory() {
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
195 return moveFactory;
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
196 }
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
197
21203
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
198 protected MoveResolver createMoveResolver() {
21246
b2b3c514a391 MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents: 21240
diff changeset
199 MoveResolver moveResolver = new MoveResolver(this);
b2b3c514a391 MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents: 21240
diff changeset
200 assert moveResolver.checkEmpty();
b2b3c514a391 MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents: 21240
diff changeset
201 return moveResolver;
21203
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
202 }
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
203
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
204 public static boolean isVariableOrRegister(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
205 return isVariable(value) || isRegister(value);
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
206 }
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
207
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
209 * Converts an operand (variable or register) to an index in a flat address space covering all
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
210 * the {@linkplain Variable variables} and {@linkplain RegisterValue registers} being processed
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
211 * by this allocator.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 */
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
213 int operandNumber(Value operand) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
214 if (isRegister(operand)) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
215 int number = asRegister(operand).number;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
216 assert number < firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
217 return number;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
218 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
219 assert isVariable(operand) : operand;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
220 return firstVariableNumber + ((Variable) operand).index;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
223 /**
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
224 * Gets the number of operands. This value will increase by 1 for new variable.
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
225 */
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
226 int operandSize() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
227 return firstVariableNumber + ir.numVariables();
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
228 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
229
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
230 /**
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
231 * Gets the highest operand number for a register operand. This value will never change.
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
232 */
19212
95a7954ea155 Add LinearScanPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19166
diff changeset
233 int maxRegisterNumber() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
234 return firstVariableNumber - 1;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
235 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
236
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
237 static final IntervalPredicate IS_PRECOLORED_INTERVAL = new IntervalPredicate() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
238
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 public boolean apply(Interval i) {
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
241 return isRegister(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 };
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 static final IntervalPredicate IS_VARIABLE_INTERVAL = new IntervalPredicate() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
246
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 public boolean apply(Interval i) {
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
249 return isVariable(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
253 static final IntervalPredicate IS_STACK_INTERVAL = new IntervalPredicate() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
254
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 public boolean apply(Interval i) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
257 return !isRegister(i.operand);
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 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
262 * Gets an object describing the attributes of a given register according to this register
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
263 * configuration.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 */
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
265 RegisterAttributes attributes(Register reg) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 return registerAttributes[reg.number];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 void assignSpillSlot(Interval interval) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
270 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
271 * Assign the canonical spill slot of the parent (if a part of the interval is already
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
272 * spilled) or allocate a new spill slot.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
273 */
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
274 if (interval.canMaterialize()) {
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
275 interval.assignLocation(Value.ILLEGAL);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
276 } else if (interval.spillSlot() != null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 interval.assignLocation(interval.spillSlot());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 } else {
18425
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18420
diff changeset
279 VirtualStackSlot slot = frameMapBuilder.allocateSpillSlot(interval.kind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 interval.setSpillSlot(slot);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 interval.assignLocation(slot);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 * Creates a new interval.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
287 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 * @param operand the operand for the interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 * @return the created interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 */
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
291 Interval createInterval(AllocatableValue operand) {
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
292 assert isLegal(operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 int operandNumber = operandNumber(operand);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4350
diff changeset
294 Interval interval = new Interval(operand, operandNumber);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 assert operandNumber < intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 assert intervals[operandNumber] == null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 intervals[operandNumber] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298 return interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 * Creates an interval as a result of splitting or spilling another interval.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
303 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 * @param source an interval being split of spilled
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 * @return a new interval derived from {@code source}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 Interval createDerivedInterval(Interval source) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 if (firstDerivedIntervalIndex == -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 firstDerivedIntervalIndex = intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 if (intervalsSize == intervals.length) {
15885
4d18c6bb6b3a LinearScan: Improve initialization and resizing of intervals array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15884
diff changeset
312 intervals = Arrays.copyOf(intervals, intervals.length + (intervals.length >> SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT));
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 intervalsSize++;
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9422
diff changeset
315 Variable variable = new Variable(source.kind(), ir.nextVariable());
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
316
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
317 Interval interval = createInterval(variable);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 assert intervals[intervalsSize - 1] == interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 return interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 // access to block list (sorted in linear scan order)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 int blockCount() {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
324 return sortedBlocks.size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
327 AbstractBlockBase<?> blockAt(int index) {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
328 return sortedBlocks.get(index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
330
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
332 * Gets the size of the {@link BlockData#liveIn} and {@link BlockData#liveOut} sets for a basic
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
333 * block. These sets do not include any operands allocated as a result of creating
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
334 * {@linkplain #createDerivedInterval(Interval) derived intervals}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
335 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 int liveSetSize() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
337 return firstDerivedIntervalIndex == -1 ? operandSize() : firstDerivedIntervalIndex;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 int numLoops() {
15107
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 15026
diff changeset
341 return ir.getControlFlowGraph().getLoops().size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343
15884
0e6f83eeb0ab Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15850
diff changeset
344 Interval intervalFor(int operandNumber) {
0e6f83eeb0ab Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15850
diff changeset
345 return intervals[operandNumber];
0e6f83eeb0ab Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15850
diff changeset
346 }
0e6f83eeb0ab Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15850
diff changeset
347
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
348 Interval intervalFor(Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 int operandNumber = operandNumber(operand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 assert operandNumber < intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 return intervals[operandNumber];
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
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
354 Interval getOrCreateInterval(AllocatableValue operand) {
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
355 Interval ret = intervalFor(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
356 if (ret == null) {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
357 return createInterval(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
358 } else {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
359 return ret;
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
360 }
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
361 }
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
362
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 * Gets the highest instruction id allocated by this object.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 int maxOpId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 assert opIdToInstructionMap.length > 0 : "no operations";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 return (opIdToInstructionMap.length - 1) << 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
372 * Converts an {@linkplain LIRInstruction#id instruction id} to an instruction index. All LIR
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
373 * instructions in a method have an index one greater than their linear-scan order predecesor
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 * with the first instruction having an index of 0.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 static int opIdToIndex(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 return opId >> 1;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 * Retrieves the {@link LIRInstruction} based on its {@linkplain LIRInstruction#id id}.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
382 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 * @param opId an instruction {@linkplain LIRInstruction#id id}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 * @return the instruction whose {@linkplain LIRInstruction#id} {@code == id}
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 LIRInstruction instructionForId(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 assert isEven(opId) : "opId not even";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 LIRInstruction instr = opIdToInstructionMap[opIdToIndex(opId)];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 assert instr.id() == opId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 return instr;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 * Gets the block containing a given instruction.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
395 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 * @param opId an instruction {@linkplain LIRInstruction#id id}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 * @return the block containing the instruction denoted by {@code opId}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
399 AbstractBlockBase<?> blockForId(int opId) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 assert opIdToBlockMap.length > 0 && opId >= 0 && opId <= maxOpId() + 1 : "opId out of range";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 return opIdToBlockMap[opIdToIndex(opId)];
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 boolean isBlockBegin(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 return opId == 0 || blockForId(opId) != blockForId(opId - 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 boolean coversBlockBegin(int opId1, int opId2) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 return blockForId(opId1) != blockForId(opId2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 * Determines if an {@link LIRInstruction} destroys all caller saved registers.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
414 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 * @param opId an instruction {@linkplain LIRInstruction#id id}
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
416 * @return {@code true} if the instruction denoted by {@code id} destroys all caller saved
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
417 * registers.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 boolean hasCall(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 assert isEven(opId) : "opId not even";
9454
85a836bcd796 renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents: 9425
diff changeset
421 return instructionForId(opId).destroysCallerSavedRegisters();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 * Eliminates moves from register to stack if the stack slot is known to be correct.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 void changeSpillDefinitionPos(Interval interval, int defPos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 assert interval.isSplitParent() : "can only be called for split parents";
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 switch (interval.spillState()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431 case NoDefinitionFound:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 assert interval.spillDefinitionPos() == -1 : "must no be set before";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 interval.setSpillDefinitionPos(defPos);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 interval.setSpillState(SpillState.NoSpillStore);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 break;
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 case NoSpillStore:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 assert defPos <= interval.spillDefinitionPos() : "positions are processed in reverse order when intervals are created";
6462
b3f5dc099f9d removed XIR
Doug Simon <doug.simon@oracle.com>
parents: 6411
diff changeset
439 if (defPos < interval.spillDefinitionPos() - 2) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 // second definition found, so no spill optimization possible for this interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 interval.setSpillState(SpillState.NoOptimization);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 // two consecutive definitions (because of two-operand LIR form)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 assert blockForId(defPos) == blockForId(interval.spillDefinitionPos()) : "block must be equal";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 case NoOptimization:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 // nothing to do
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 default:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
453 throw new BailoutException("other states not allowed at this time");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 // called during register allocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 void changeSpillState(Interval interval, int spillPos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 switch (interval.spillState()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460 case NoSpillStore: {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
461 int defLoopDepth = blockForId(interval.spillDefinitionPos()).getLoopDepth();
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
462 int spillLoopDepth = blockForId(spillPos).getLoopDepth();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 if (defLoopDepth < spillLoopDepth) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
465 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
466 * The loop depth of the spilling position is higher then the loop depth at the
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
467 * definition of the interval. Move write to memory out of loop.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
468 */
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
469 if (Options.LSRAOptimizeSpillPosition.getValue()) {
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
470 // find best spill position in dominator the tree
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
471 interval.setSpillState(SpillState.SpillInDominator);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
472 } else {
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
473 // store at definition of the interval
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
474 interval.setSpillState(SpillState.StoreAtDefinition);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
475 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 } else {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
477 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
478 * The interval is currently spilled only once, so for now there is no reason to
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
479 * store the interval at the definition.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
480 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 interval.setSpillState(SpillState.OneSpillStore);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486 case OneSpillStore: {
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
487 if (Options.LSRAOptimizeSpillPosition.getValue()) {
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
488 // the interval is spilled more then once
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
489 interval.setSpillState(SpillState.SpillInDominator);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
490 } else {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
491 // It is better to store it to memory at the definition.
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
492 interval.setSpillState(SpillState.StoreAtDefinition);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
493 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496
16359
f686fae77383 LSRA spill optimization: rename SpillInDominator.MultipleSpills to SpillState.SpillInDominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16358
diff changeset
497 case SpillInDominator:
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 case StoreAtDefinition:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 case StartInMemory:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 case NoOptimization:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501 case NoDefinitionFound:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
502 // nothing to do
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 default:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
506 throw new BailoutException("other states not allowed at this time");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
509
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 abstract static class IntervalPredicate {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
511
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 abstract boolean apply(Interval i);
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
16379
c5257d58b71a LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents: 16378
diff changeset
515 private static final IntervalPredicate mustStoreAtDefinition = new IntervalPredicate() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
516
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 public boolean apply(Interval i) {
16379
c5257d58b71a LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents: 16378
diff changeset
519 return i.isSplitParent() && i.spillState() == SpillState.StoreAtDefinition;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
523 /**
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
524 * @return the index of the first instruction that is of interest for
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
525 * {@link #eliminateSpillMoves()}
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
526 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
527 protected int firstInstructionOfInterest() {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
528 // skip the first because it is always a label
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
529 return 1;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
530 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
531
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
532 // called once before assignment of register numbers
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 void eliminateSpillMoves() {
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
534 try (Indent indent = Debug.logAndIndent("Eliminating unnecessary spill moves")) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
535
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
536 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
537 * collect all intervals that must be stored after their definition. The list is sorted
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
538 * by Interval.spillDefinitionPos.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
539 */
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
540 Interval interval;
16379
c5257d58b71a LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents: 16378
diff changeset
541 interval = createUnhandledLists(mustStoreAtDefinition, null).first;
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
542 if (DetailedAsserts.getValue()) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
543 checkIntervals(interval);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
544 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
545
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
546 LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer();
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
547 for (AbstractBlockBase<?> block : sortedBlocks) {
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
548 try (Indent indent1 = Debug.logAndIndent("Handle %s", block)) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
549 List<LIRInstruction> instructions = ir.getLIRforBlock(block);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
550 int numInst = instructions.size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
552 // iterate all instructions of the block.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
553 for (int j = firstInstructionOfInterest(); j < numInst; j++) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
554 LIRInstruction op = instructions.get(j);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
555 int opId = op.id();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
557 if (opId == -1) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
558 MoveOp move = (MoveOp) op;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
559 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
560 * Remove move from register to stack if the stack slot is guaranteed to
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
561 * be correct. Only moves that have been inserted by LinearScan can be
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
562 * removed.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
563 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
564 if (canEliminateSpillMove(block, move)) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
565 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
566 * Move target is a stack slot that is always correct, so eliminate
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
567 * instruction.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
568 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
569 if (Debug.isLogEnabled()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
570 Debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", operandNumber(move.getInput()), move.getInput(), operandNumber(move.getResult()),
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
571 move.getResult(), block);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
572 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
573
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
574 // null-instructions are deleted by assignRegNum
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
575 instructions.set(j, null);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
576 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
577
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
578 } else {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
579 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
580 * Insert move from register to stack just after the beginning of the
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
581 * interval.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
582 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
583 assert interval == Interval.EndMarker || interval.spillDefinitionPos() >= opId : "invalid order";
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
584 assert interval == Interval.EndMarker || (interval.isSplitParent() && interval.spillState() == SpillState.StoreAtDefinition) : "invalid interval";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
585
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
586 while (interval != Interval.EndMarker && interval.spillDefinitionPos() == opId) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
587 if (!interval.canMaterialize()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
588 if (!insertionBuffer.initialized()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
589 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
590 * prepare insertion buffer (appended when all instructions
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
591 * in the block are processed)
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
592 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
593 insertionBuffer.init(instructions);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
594 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
595
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
596 AllocatableValue fromLocation = interval.location();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
597 AllocatableValue toLocation = canonicalSpillOpr(interval);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
598 if (!fromLocation.equals(toLocation)) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
599
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
600 assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" +
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
601 interval.spillState();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
602 assert isStackSlotValue(toLocation) : "to operand must be a stack slot";
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
603
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
604 LIRInstruction move = getSpillMoveFactory().createMove(toLocation, fromLocation);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
605 insertionBuffer.append(j + 1, move);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
606
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
607 if (Debug.isLogEnabled()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
608 Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
609 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
610 }
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
611 }
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
612 interval = interval.next;
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
613 }
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
614 }
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
615 } // end of instruction iteration
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
616
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
617 if (insertionBuffer.initialized()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
618 insertionBuffer.finish();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
619 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
620 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
621 } // end of block iteration
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
622
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
623 assert interval == Interval.EndMarker : "missed an interval";
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
624 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
625 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
626
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
627 /**
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
628 * @param block The block {@code move} is located in.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
629 * @param move Spill move.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
630 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
631 protected boolean canEliminateSpillMove(AbstractBlockBase<?> block, MoveOp move) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
632 assert isVariable(move.getResult()) : "LinearScan inserts only moves to variables: " + move;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
633
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
634 Interval curInterval = intervalFor(move.getResult());
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
635
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
636 if (!isRegister(curInterval.location()) && curInterval.alwaysInMemory()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
637 assert isStackSlotValue(curInterval.location()) : "Not a stack slot: " + curInterval.location();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
638 return true;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
639 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
640 return false;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
641 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
642
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
643 private static void checkIntervals(Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
644 Interval prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
645 Interval temp = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
646 while (temp != Interval.EndMarker) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
647 assert temp.spillDefinitionPos() > 0 : "invalid spill definition pos";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
648 if (prev != null) {
16379
c5257d58b71a LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents: 16378
diff changeset
649 assert temp.from() >= prev.from() : "intervals not sorted";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
650 assert temp.spillDefinitionPos() >= prev.spillDefinitionPos() : "when intervals are sorted by from : then they must also be sorted by spillDefinitionPos";
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
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
653 assert temp.spillSlot() != null || temp.canMaterialize() : "interval has no spill slot assigned";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 assert temp.spillDefinitionPos() >= temp.from() : "invalid order";
16379
c5257d58b71a LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents: 16378
diff changeset
655 assert temp.spillDefinitionPos() <= temp.from() + 2 : "only intervals defined once at their start-pos can be optimized";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
656
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
657 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
658 Debug.log("interval %d (from %d to %d) must be stored at %d", temp.operandNumber, temp.from(), temp.to(), temp.spillDefinitionPos());
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
659 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
660
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
661 prev = temp;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 temp = temp.next;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
663 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
664 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
665
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
666 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
667 * Determines the register priority for an instruction's output/result operand.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
668 */
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
669 static RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
670 if (op instanceof MoveOp) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
671 MoveOp move = (MoveOp) op;
8353
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
672 if (optimizeMethodArgument(move.getInput())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
673 return RegisterPriority.None;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
674 }
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
675 } else if (op instanceof LabelOp) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
676 LabelOp label = (LabelOp) op;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
677 if (label.isPhiIn()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
678 return RegisterPriority.None;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
679 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
680 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
681
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
682 // all other operands require a register
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683 return RegisterPriority.MustHaveRegister;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
687 * Determines the priority which with an instruction's input operand will be allocated a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
688 * register.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
689 */
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
690 static RegisterPriority registerPriorityOfInputOperand(EnumSet<OperandFlag> flags) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
691 if (flags.contains(OperandFlag.STACK)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
692 return RegisterPriority.ShouldHaveRegister;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
693 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
694 // all other operands require a register
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
695 return RegisterPriority.MustHaveRegister;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
697
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
698 static boolean optimizeMethodArgument(Value value) {
8402
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
699 /*
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
700 * Object method arguments that are passed on the stack are currently not optimized because
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
701 * this requires that the runtime visits method arguments during stack walking.
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
702 */
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
703 return isStackSlot(value) && asStackSlot(value).isInCallerFrame() && value.getKind() != Kind.Object;
8353
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
704 }
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
705
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
706 boolean isProcessed(Value operand) {
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
707 return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
708 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
710 // * Phase 5: actual register allocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
711
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
712 private static boolean isSorted(Interval[] intervals) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 int from = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715 assert interval != null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
716 assert from <= interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 from = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
718 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
719 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
720 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
722 static Interval addToList(Interval first, Interval prev, Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
723 Interval newFirst = first;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724 if (prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
725 prev.next = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 newFirst = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
729 return newFirst;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
730 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
732 Interval.Pair createUnhandledLists(IntervalPredicate isList1, IntervalPredicate isList2) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
733 assert isSorted(sortedIntervals) : "interval list is not sorted";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
734
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735 Interval list1 = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
736 Interval list2 = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
737
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
738 Interval list1Prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
739 Interval list2Prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740 Interval v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
741
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
742 int n = sortedIntervals.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
743 for (int i = 0; i < n; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
744 v = sortedIntervals[i];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
745 if (v == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
746 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
749 if (isList1.apply(v)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
750 list1 = addToList(list1, list1Prev, v);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
751 list1Prev = v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 } else if (isList2 == null || isList2.apply(v)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753 list2 = addToList(list2, list2Prev, v);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 list2Prev = v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 }
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 if (list1Prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
759 list1Prev.next = Interval.EndMarker;
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 if (list2Prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
762 list2Prev.next = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
763 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
764
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
765 assert list1Prev == null || list1Prev.next == Interval.EndMarker : "linear list ends not with sentinel";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 assert list2Prev == null || list2Prev.next == Interval.EndMarker : "linear list ends not with sentinel";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
768 return new Interval.Pair(list1, list2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
769 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
771 void sortIntervalsBeforeAllocation() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
772 int sortedLen = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
774 if (interval != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
775 sortedLen++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
776 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
777 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
778
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
779 Interval[] sortedList = new Interval[sortedLen];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
780 int sortedIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
781 int sortedFromMax = -1;
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 // special sorting algorithm: the original interval-list is almost sorted,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
784 // only some intervals are swapped. So this is much faster than a complete QuickSort
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
786 if (interval != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787 int from = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
788
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
789 if (sortedFromMax <= from) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
790 sortedList[sortedIdx++] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
791 sortedFromMax = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
792 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 // the assumption that the intervals are already sorted failed,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
794 // so this interval must be sorted in manually
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
795 int j;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
796 for (j = sortedIdx - 1; j >= 0 && from < sortedList[j].from(); j--) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
797 sortedList[j + 1] = sortedList[j];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
798 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
799 sortedList[j + 1] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800 sortedIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
801 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804 sortedIntervals = sortedList;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
806
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 void sortIntervalsAfterAllocation() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808 if (firstDerivedIntervalIndex == -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 // no intervals have been added during allocation, so sorted list is already up to date
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
810 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
811 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
813 Interval[] oldList = sortedIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
814 Interval[] newList = Arrays.copyOfRange(intervals, firstDerivedIntervalIndex, intervalsSize);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
815 int oldLen = oldList.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
816 int newLen = newList.length;
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 // conventional sort-algorithm for new intervals
15886
e5e7d9dfff1a LinearScan: Clean up interval comparator and replace with lambda form.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15885
diff changeset
819 Arrays.sort(newList, (Interval a, Interval b) -> a.from() - b.from());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
820
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
821 // merge old and new list (both already sorted) into one combined list
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
822 Interval[] combinedList = new Interval[oldLen + newLen];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
823 int oldIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
824 int newIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
825
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
826 while (oldIdx + newIdx < combinedList.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
827 if (newIdx >= newLen || (oldIdx < oldLen && oldList[oldIdx].from() <= newList[newIdx].from())) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
828 combinedList[oldIdx + newIdx] = oldList[oldIdx];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
829 oldIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
830 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
831 combinedList[oldIdx + newIdx] = newList[newIdx];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
832 newIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
833 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
834 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
835
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
836 sortedIntervals = combinedList;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
837 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
838
19212
95a7954ea155 Add LinearScanPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19166
diff changeset
839 void allocateRegisters() {
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
840 try (Indent indent = Debug.logAndIndent("allocate registers")) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
841 Interval precoloredIntervals;
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
842 Interval notPrecoloredIntervals;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
843
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
844 Interval.Pair result = createUnhandledLists(IS_PRECOLORED_INTERVAL, IS_VARIABLE_INTERVAL);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
845 precoloredIntervals = result.first;
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
846 notPrecoloredIntervals = result.second;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
847
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
848 // allocate cpu registers
15927
96229f219351 LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents: 15920
diff changeset
849 LinearScanWalker lsw;
96229f219351 LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents: 15920
diff changeset
850 if (OptimizingLinearScanWalker.Options.LSRAOptimization.getValue()) {
96229f219351 LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents: 15920
diff changeset
851 lsw = new OptimizingLinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals);
96229f219351 LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents: 15920
diff changeset
852 } else {
96229f219351 LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents: 15920
diff changeset
853 lsw = new LinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals);
96229f219351 LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents: 15920
diff changeset
854 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
855 lsw.walk();
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
856 lsw.finishAllocation();
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
857 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
858 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
859
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860 // * Phase 6: resolve data flow
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861 // (insert moves at edges between blocks if intervals have been split)
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 // wrapper for Interval.splitChildAtOpId that performs a bailout in product mode
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 // instead of returning null
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
865 Interval splitChildAtOpId(Interval interval, int opId, LIRInstruction.OperandMode mode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 Interval result = interval.getSplitChildAtOpId(opId, mode, this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
867
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
868 if (result != null) {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
869 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
870 Debug.log("Split child at pos %d of interval %s is %s", opId, interval, result);
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
871 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
872 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
873 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
874
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
875 throw new BailoutException("LinearScan: interval is null");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
876 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
877
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
878 void resolveCollectMappings(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, AbstractBlockBase<?> midBlock, MoveResolver moveResolver) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
879 assert moveResolver.checkEmpty();
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
880 assert midBlock == null ||
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
881 (midBlock.getPredecessorCount() == 1 && midBlock.getSuccessorCount() == 1 && midBlock.getPredecessors().get(0).equals(fromBlock) && midBlock.getSuccessors().get(0).equals(
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
882 toBlock));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
883
20979
65d8d305f9c0 Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20915
diff changeset
884 int toBlockFirstInstructionId = getFirstLirInstructionId(toBlock);
65d8d305f9c0 Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20915
diff changeset
885 int fromBlockLastInstructionId = getLastLirInstructionId(fromBlock) + 1;
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
886 int numOperands = operandSize();
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
887 BitSet liveAtEdge = blockData.get(toBlock).liveIn;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
888
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
889 // visit all variables for which the liveAtEdge bit is set
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
890 for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 1)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
891 assert operandNum < numOperands : "live information set for not exisiting interval";
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
892 assert blockData.get(fromBlock).liveOut.get(operandNum) && blockData.get(toBlock).liveIn.get(operandNum) : "interval not live at this edge";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
893
20979
65d8d305f9c0 Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20915
diff changeset
894 Interval fromInterval = splitChildAtOpId(intervalFor(operandNum), fromBlockLastInstructionId, LIRInstruction.OperandMode.DEF);
65d8d305f9c0 Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20915
diff changeset
895 Interval toInterval = splitChildAtOpId(intervalFor(operandNum), toBlockFirstInstructionId, LIRInstruction.OperandMode.DEF);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
896
9632
97db51025787 Value: use `equals()' instead of object equality
Bernhard Urban <bernhard.urban@jku.at>
parents: 9628
diff changeset
897 if (fromInterval != toInterval && !fromInterval.location().equals(toInterval.location())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
898 // need to insert move instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
899 moveResolver.addMapping(fromInterval, toInterval);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
900 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
901 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
902 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
903
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
904 void resolveFindInsertPos(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, MoveResolver moveResolver) {
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
905 if (fromBlock.getSuccessorCount() <= 1) {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
906 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
907 Debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId());
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
908 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
909
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
910 List<LIRInstruction> instructions = ir.getLIRforBlock(fromBlock);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
911 LIRInstruction instr = instructions.get(instructions.size() - 1);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
912 if (instr instanceof StandardOp.JumpOp) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
913 // insert moves before branch
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
914 moveResolver.setInsertPosition(instructions, instructions.size() - 1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
915 } else {
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
916 moveResolver.setInsertPosition(instructions, instructions.size());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
918
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
919 } else {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
920 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
921 Debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId());
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
922 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
923
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
924 if (DetailedAsserts.getValue()) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
925 assert ir.getLIRforBlock(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
926
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
927 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
928 * Because the number of predecessor edges matches the number of successor edges,
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
929 * blocks which are reached by switch statements may have be more than one
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
930 * predecessor but it will be guaranteed that all predecessors will be the same.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
931 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
932 for (AbstractBlockBase<?> predecessor : toBlock.getPredecessors()) {
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
933 assert fromBlock == predecessor : "all critical edges must be broken";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
934 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
935 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
937 moveResolver.setInsertPosition(ir.getLIRforBlock(toBlock), 1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
938 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
942 * Inserts necessary moves (spilling or reloading) at edges between blocks for intervals that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
943 * have been split.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
944 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
945 void resolveDataFlow() {
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
946 try (Indent indent = Debug.logAndIndent("resolve data flow")) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
947
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
948 int numBlocks = blockCount();
21203
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
949 MoveResolver moveResolver = createMoveResolver();
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
950 BitSet blockCompleted = new BitSet(numBlocks);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
951 BitSet alreadyResolved = new BitSet(numBlocks);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
952
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
953 for (AbstractBlockBase<?> block : sortedBlocks) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
954
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
955 // check if block has only one predecessor and only one successor
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
956 if (block.getPredecessorCount() == 1 && block.getSuccessorCount() == 1) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
957 List<LIRInstruction> instructions = ir.getLIRforBlock(block);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
958 assert instructions.get(0) instanceof StandardOp.LabelOp : "block must start with label";
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
959 assert instructions.get(instructions.size() - 1) instanceof StandardOp.JumpOp : "block with successor must end with unconditional jump";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
960
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
961 // check if block is empty (only label and branch)
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
962 if (instructions.size() == 2) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
963 AbstractBlockBase<?> pred = block.getPredecessors().iterator().next();
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
964 AbstractBlockBase<?> sux = block.getSuccessors().iterator().next();
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
965
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
966 // prevent optimization of two consecutive blocks
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
967 if (!blockCompleted.get(pred.getLinearScanNumber()) && !blockCompleted.get(sux.getLinearScanNumber())) {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
968 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
969 Debug.log(" optimizing empty block B%d (pred: B%d, sux: B%d)", block.getId(), pred.getId(), sux.getId());
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
970 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
971
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
972 blockCompleted.set(block.getLinearScanNumber());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
973
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
974 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
975 * Directly resolve between pred and sux (without looking at the empty
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
976 * block between).
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
977 */
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
978 resolveCollectMappings(pred, sux, block, moveResolver);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
979 if (moveResolver.hasMappings()) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
980 moveResolver.setInsertPosition(instructions, 1);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
981 moveResolver.resolveAndAppendMoves();
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
982 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
983 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
984 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
985 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
986 }
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
987
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
988 for (AbstractBlockBase<?> fromBlock : sortedBlocks) {
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
989 if (!blockCompleted.get(fromBlock.getLinearScanNumber())) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
990 alreadyResolved.clear();
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
991 alreadyResolved.or(blockCompleted);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
992
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
993 for (AbstractBlockBase<?> toBlock : fromBlock.getSuccessors()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
994
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
995 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
996 * Check for duplicate edges between the same blocks (can happen with switch
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
997 * blocks).
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
998 */
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
999 if (!alreadyResolved.get(toBlock.getLinearScanNumber())) {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1000 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1001 Debug.log("processing edge between B%d and B%d", fromBlock.getId(), toBlock.getId());
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1002 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1003
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1004 alreadyResolved.set(toBlock.getLinearScanNumber());
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1005
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1006 // collect all intervals that have been split between
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1007 // fromBlock and toBlock
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
1008 resolveCollectMappings(fromBlock, toBlock, null, moveResolver);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1009 if (moveResolver.hasMappings()) {
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1010 resolveFindInsertPos(fromBlock, toBlock, moveResolver);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1011 moveResolver.resolveAndAppendMoves();
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1012 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1013 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1014 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1015 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1016 }
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
1017
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1018 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1019 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1020
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1021 // * Phase 7: assign register numbers back to LIR
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1022 // (includes computation of debug information and oop maps)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1023
18425
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18420
diff changeset
1024 static StackSlotValue canonicalSpillOpr(Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1025 assert interval.spillSlot() != null : "canonical spill slot not set";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1026 return interval.spillSlot();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1027 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1028
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1029 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1030 * Assigns the allocated location for an LIR instruction operand back into the instruction.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1031 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 * @param operand an LIR instruction operand
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1033 * @param opId the id of the LIR instruction using {@code operand}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1034 * @param mode the usage mode for {@code operand} by the instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1035 * @return the location assigned for the operand
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 */
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1037 private Value colorLirOperand(Variable operand, int opId, OperandMode mode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1038 Interval interval = intervalFor(operand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1039 assert interval != null : "interval must exist";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1040
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1041 if (opId != -1) {
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
1042 if (DetailedAsserts.getValue()) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1043 AbstractBlockBase<?> block = blockForId(opId);
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1044 if (block.getSuccessorCount() <= 1 && opId == getLastLirInstructionId(block)) {
21192
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1045 /*
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1046 * Check if spill moves could have been appended at the end of this block, but
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1047 * before the branch instruction. So the split child information for this branch
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1048 * would be incorrect.
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1049 */
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
1050 LIRInstruction instr = ir.getLIRforBlock(block).get(ir.getLIRforBlock(block).size() - 1);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1051 if (instr instanceof StandardOp.JumpOp) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1052 if (blockData.get(block).liveOut.get(operandNumber(operand))) {
21192
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1053 assert false : String.format(
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1054 "can't get split child for the last branch of a block because the information would be incorrect (moves are inserted before the branch in resolveDataFlow) block=%s, instruction=%s, operand=%s",
4c7c22aa4bd7 LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents: 21182
diff changeset
1055 block, instr, operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1056 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1057 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1058 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1059 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1060
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1061 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1062 * Operands are not changed when an interval is split during allocation, so search the
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1063 * right interval here.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1064 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1065 interval = splitChildAtOpId(interval, opId, mode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1066 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1067
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1068 if (isIllegal(interval.location()) && interval.canMaterialize()) {
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1069 assert mode != OperandMode.DEF;
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1070 return interval.getMaterializedValue();
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1071 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1072 return interval.location();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1073 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1074
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1075 private boolean isMaterialized(AllocatableValue operand, int opId, OperandMode mode) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1076 Interval interval = intervalFor(operand);
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1077 assert interval != null : "interval must exist";
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1078
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1079 if (opId != -1) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1080 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1081 * Operands are not changed when an interval is split during allocation, so search the
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1082 * right interval here.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1083 */
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1084 interval = splitChildAtOpId(interval, opId, mode);
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1085 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1086
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1087 return isIllegal(interval.location()) && interval.canMaterialize();
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1088 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1089
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1090 protected IntervalWalker initIntervalWalker(IntervalPredicate predicate) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1091 // setup lists of potential oops for walking
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1092 Interval oopIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1093 Interval nonOopIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1094
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1095 oopIntervals = createUnhandledLists(predicate, null).first;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1096
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1097 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1098 * Intervals that have no oops inside need not to be processed. to ensure a walking until
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1099 * the last instruction id, add a dummy interval with a high operation id.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1100 */
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
1101 nonOopIntervals = new Interval(Value.ILLEGAL, -1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1102 nonOopIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1103
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1104 return new IntervalWalker(this, oopIntervals, nonOopIntervals);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1105 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1106
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1107 private boolean isCallerSave(Value operand) {
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
1108 return attributes(asRegister(operand)).isCallerSave();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1109 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1110
17413
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1111 /**
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1112 * @param op
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1113 * @param operand
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1114 * @param valueMode
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1115 * @param flags
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1116 * @see InstructionValueProcedure#doValue(LIRInstruction, Value, OperandMode, EnumSet)
0a2e65e74a9c LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents: 17298
diff changeset
1117 */
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1118 private Value debugInfoProcedure(LIRInstruction op, Value operand, OperandMode valueMode, EnumSet<OperandFlag> flags) {
18610
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18512
diff changeset
1119 if (isVirtualStackSlot(operand)) {
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18512
diff changeset
1120 return operand;
6a6291c31657 Add LocationMarker.
Josef Eisl <josef.eisl@jku.at>
parents: 18512
diff changeset
1121 }
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1122 int tempOpId = op.id();
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1123 OperandMode mode = OperandMode.USE;
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1124 AbstractBlockBase<?> block = blockForId(tempOpId);
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1125 if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1126 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1127 * Generating debug information for the last instruction of a block. If this instruction
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1128 * is a branch, spill moves are inserted before this branch and so the wrong operand
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1129 * would be returned (spill moves at block boundaries are not considered in the live
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1130 * ranges of intervals).
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1131 *
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1132 * Solution: use the first opId of the branch target block instead.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1133 */
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1134 final LIRInstruction instr = ir.getLIRforBlock(block).get(ir.getLIRforBlock(block).size() - 1);
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1135 if (instr instanceof StandardOp.JumpOp) {
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1136 if (blockData.get(block).liveOut.get(operandNumber(operand))) {
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1137 tempOpId = getFirstLirInstructionId(block.getSuccessors().iterator().next());
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1138 mode = OperandMode.DEF;
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 16118
diff changeset
1139 }
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 16118
diff changeset
1140 }
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1141 }
17297
07d5cf34b3c5 Work around uninitialized variables problem with javac and lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17294
diff changeset
1142
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1143 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1144 * Get current location of operand. The operand must be live because debug information is
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1145 * considered when building the intervals if the interval is not live, colorLirOperand will
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1146 * cause an assert on failure.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1147 */
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1148 Value result = colorLirOperand((Variable) operand, tempOpId, mode);
18436
59e65d3aa2fc Use StackSlotValue where appropriate.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
1149 assert !hasCall(tempOpId) || isStackSlotValue(result) || isConstant(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls";
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1150 return result;
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1151 }
16138
f315b1c0a590 Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents: 16118
diff changeset
1152
19019
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
1153 private void computeDebugInfo(final LIRInstruction op, LIRFrameState info) {
17298
831e96d0777d Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents: 17297
diff changeset
1154 info.forEachState(op, this::debugInfoProcedure);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1155 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1156
19019
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
1157 private void assignLocations(List<LIRInstruction> instructions) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1158 int numInst = instructions.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1159 boolean hasDead = false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1160
17291
182062f9739d LSRA: replace anonymous InstructionValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents: 17285
diff changeset
1161 InstructionValueProcedure assignProc = (op, operand, mode, flags) -> isVariable(operand) ? colorLirOperand((Variable) operand, op.id(), mode) : operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1162 for (int j = 0; j < numInst; j++) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1163 final LIRInstruction op = instructions.get(j);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1164 if (op == null) { // this can happen when spill-moves are removed in eliminateSpillMoves
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1165 hasDead = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1166 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1167 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1168
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1169 // remove useless moves
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1170 MoveOp move = null;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1171 if (op instanceof MoveOp) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1172 move = (MoveOp) op;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1173 AllocatableValue result = move.getResult();
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1174 if (isVariable(result) && isMaterialized(result, op.id(), OperandMode.DEF)) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1175 /*
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1176 * This happens if a materializable interval is originally not spilled but then
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1177 * kicked out in LinearScanWalker.splitForSpilling(). When kicking out such an
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1178 * interval this move operation was already generated.
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1179 */
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1180 instructions.set(j, null);
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1181 hasDead = true;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1182 continue;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1183 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1184 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1185
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1186 op.forEachInput(assignProc);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1187 op.forEachAlive(assignProc);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1188 op.forEachTemp(assignProc);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1189 op.forEachOutput(assignProc);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1190
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1191 // compute reference map and debug information
19019
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
1192 op.forEachState((inst, state) -> computeDebugInfo(inst, state));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1193
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1194 // remove useless moves
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1195 if (move != null) {
9628
8851fabf2265 LinearScan: Can no longer check for object equality after removal of RegisterValue cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9614
diff changeset
1196 if (move.getInput().equals(move.getResult())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1197 instructions.set(j, null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1198 hasDead = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1199 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1200 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1201 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1202
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1203 if (hasDead) {
6321
9418ff4c9e7c Clean up ControlFlowOptimizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6317
diff changeset
1204 // Remove null values from the list.
9418ff4c9e7c Clean up ControlFlowOptimizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6317
diff changeset
1205 instructions.removeAll(Collections.singleton(null));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1206 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1207 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1208
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1209 private void assignLocations() {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1210 try (Indent indent = Debug.logAndIndent("assign locations")) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1211 for (AbstractBlockBase<?> block : sortedBlocks) {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1212 try (Indent indent2 = Debug.logAndIndent("assign locations in block B%d", block.getId())) {
19019
56e6b5756886 LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 18674
diff changeset
1213 assignLocations(ir.getLIRforBlock(block));
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1214 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1215 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1216 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1217 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1218
21315
5f4847feeb69 LinearScan: add createLifetimeAnalysis().
Josef Eisl <josef.eisl@jku.at>
parents: 21314
diff changeset
1219 protected LifetimeAnalysis createLifetimeAnalysis() {
5f4847feeb69 LinearScan: add createLifetimeAnalysis().
Josef Eisl <josef.eisl@jku.at>
parents: 21314
diff changeset
1220 return new LifetimeAnalysis(this);
5f4847feeb69 LinearScan: add createLifetimeAnalysis().
Josef Eisl <josef.eisl@jku.at>
parents: 21314
diff changeset
1221 }
5f4847feeb69 LinearScan: add createLifetimeAnalysis().
Josef Eisl <josef.eisl@jku.at>
parents: 21314
diff changeset
1222
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1223 <B extends AbstractBlockBase<B>> void allocate(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder, SpillMoveFactory spillMoveFactory) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1224
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1225 /*
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1226 * This is the point to enable debug logging for the whole register allocation.
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1227 */
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1228 try (Indent indent = Debug.logAndIndent("LinearScan allocate")) {
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1229 AllocationContext context = new AllocationContext(spillMoveFactory);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1230
21315
5f4847feeb69 LinearScan: add createLifetimeAnalysis().
Josef Eisl <josef.eisl@jku.at>
parents: 21314
diff changeset
1231 createLifetimeAnalysis().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, false);
21313
bb9d3f0616a3 LinearScan: reorganize LIR and Interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 21312
diff changeset
1232 new RegisterAllocation().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, false);
bb9d3f0616a3 LinearScan: reorganize LIR and Interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 21312
diff changeset
1233
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1234 if (LinearScan.Options.LSRAOptimizeSpillPosition.getValue()) {
21313
bb9d3f0616a3 LinearScan: reorganize LIR and Interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 21312
diff changeset
1235 new OptimizeSpillPosition().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, false);
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1236 }
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1237 new ResolveDataFlow().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1238
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1239 sortIntervalsAfterAllocation();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1240
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1241 if (DetailedAsserts.getValue()) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1242 verify();
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1243 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1244
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1245 new EliminateSpillMove().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1246 new AssignLocations().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
1247
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1248 if (DetailedAsserts.getValue()) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1249 verifyIntervals();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1250 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1251 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1252 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1253
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1254 private final class RegisterAllocation extends AllocationPhase {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1255
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1256 @Override
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1257 protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder,
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1258 SpillMoveFactory spillMoveFactory) {
21314
8908ac7d2c86 LinearScan: move call to sortIntervalsBeforeAllocation to RegisterAllocation phase.
Josef Eisl <josef.eisl@jku.at>
parents: 21313
diff changeset
1259 sortIntervalsBeforeAllocation();
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1260 printIntervals("Before register allocation");
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1261 allocateRegisters();
21313
bb9d3f0616a3 LinearScan: reorganize LIR and Interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 21312
diff changeset
1262 printIntervals("After register allocation");
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1263 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1264
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1265 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1266
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1267 private final class OptimizeSpillPosition extends AllocationPhase {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1268
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1269 @Override
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1270 protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder,
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1271 SpillMoveFactory spillMoveFactory) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1272 optimizeSpillPosition();
21313
bb9d3f0616a3 LinearScan: reorganize LIR and Interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 21312
diff changeset
1273 printIntervals("After optimize spill position");
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1274 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1275
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1276 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1277
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1278 private final class ResolveDataFlow extends AllocationPhase {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1279
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1280 @Override
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1281 protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder,
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1282 SpillMoveFactory spillMoveFactory) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1283 resolveDataFlow();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1284 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1285
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1286 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1287
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1288 private final class EliminateSpillMove extends AllocationPhase {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1289
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1290 @Override
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1291 protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder,
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1292 SpillMoveFactory spillMoveFactory) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1293 beforeSpillMoveElimination();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1294 eliminateSpillMoves();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1295 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1296
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1297 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1298
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1299 private final class AssignLocations extends AllocationPhase {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1300
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1301 @Override
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1302 protected <B extends AbstractBlockBase<B>> void run(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder,
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1303 SpillMoveFactory spillMoveFactory) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1304 assignLocations();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1305 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1306
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1307 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
1308
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
1309 protected void beforeSpillMoveElimination() {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
1310 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
1311
19693
2cca53fbf38f Debug.metrics should be static final
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19565
diff changeset
1312 private static final DebugMetric betterSpillPos = Debug.metric("BetterSpillPosition");
2cca53fbf38f Debug.metrics should be static final
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19565
diff changeset
1313 private static final DebugMetric betterSpillPosWithLowerProbability = Debug.metric("BetterSpillPositionWithLowerProbability");
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1314
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
1315 private void optimizeSpillPosition() {
16378
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1316 LIRInsertionBuffer[] insertionBuffers = new LIRInsertionBuffer[ir.linearScanOrder().size()];
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1317 for (Interval interval : intervals) {
16359
f686fae77383 LSRA spill optimization: rename SpillInDominator.MultipleSpills to SpillState.SpillInDominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16358
diff changeset
1318 if (interval != null && interval.isSplitParent() && interval.spillState() == SpillState.SpillInDominator) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1319 AbstractBlockBase<?> defBlock = blockForId(interval.spillDefinitionPos());
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1320 AbstractBlockBase<?> spillBlock = null;
16369
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1321 Interval firstSpillChild = null;
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1322 try (Indent indent = Debug.logAndIndent("interval %s (%s)", interval, defBlock)) {
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1323 for (Interval splitChild : interval.getSplitChildren()) {
18436
59e65d3aa2fc Use StackSlotValue where appropriate.
Josef Eisl <josef.eisl@jku.at>
parents: 18425
diff changeset
1324 if (isStackSlotValue(splitChild.location())) {
16369
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1325 if (firstSpillChild == null || splitChild.from() < firstSpillChild.from()) {
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1326 firstSpillChild = splitChild;
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1327 } else {
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1328 assert firstSpillChild.from() < splitChild.from();
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1329 }
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1330 // iterate all blocks where the interval has use positions
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1331 for (AbstractBlockBase<?> splitBlock : blocksForInterval(splitChild)) {
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1332 if (dominates(defBlock, splitBlock)) {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1333 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1334 Debug.log("Split interval %s, block %s", splitChild, splitBlock);
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1335 }
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1336 if (spillBlock == null) {
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1337 spillBlock = splitBlock;
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1338 } else {
16506
505c17ed39da LSRA spill optimization: use AbstractControlFlowGraph.commonDominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16505
diff changeset
1339 spillBlock = commonDominator(spillBlock, splitBlock);
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1340 assert spillBlock != null;
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1341 }
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1342 }
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1343 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1344 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1345 }
16360
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1346 if (spillBlock == null) {
16358
9371b9c246ca LSRA spill optimization: spill at earliest dominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16357
diff changeset
1347 // no spill interval
9371b9c246ca LSRA spill optimization: spill at earliest dominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16357
diff changeset
1348 interval.setSpillState(SpillState.StoreAtDefinition);
9371b9c246ca LSRA spill optimization: spill at earliest dominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16357
diff changeset
1349 } else {
16360
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1350 // move out of loops
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1351 if (defBlock.getLoopDepth() < spillBlock.getLoopDepth()) {
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1352 spillBlock = moveSpillOutOfLoop(defBlock, spillBlock);
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1353 }
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1354
16369
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1355 /*
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1356 * If the spill block is the begin of the first split child (aka the value
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1357 * is on the stack) spill in the dominator.
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1358 */
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1359 assert firstSpillChild != null;
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1360 if (!defBlock.equals(spillBlock) && spillBlock.equals(blockForId(firstSpillChild.from()))) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1361 AbstractBlockBase<?> dom = spillBlock.getDominator();
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1362 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1363 Debug.log("Spill block (%s) is the beginning of a spill child -> use dominator (%s)", spillBlock, dom);
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1364 }
16369
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1365 spillBlock = dom;
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1366 }
f8ba57019a5d LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16368
diff changeset
1367
16360
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1368 if (!defBlock.equals(spillBlock)) {
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1369 assert dominates(defBlock, spillBlock);
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1370 betterSpillPos.increment();
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1371 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1372 Debug.log("Better spill position found (Block %s)", spillBlock);
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
1373 }
16361
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1374
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1375 if (defBlock.probability() <= spillBlock.probability()) {
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1376 // better spill block has the same probability -> do nothing
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1377 interval.setSpillState(SpillState.StoreAtDefinition);
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1378 } else {
16378
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1379 LIRInsertionBuffer insertionBuffer = insertionBuffers[spillBlock.getId()];
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1380 if (insertionBuffer == null) {
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1381 insertionBuffer = new LIRInsertionBuffer();
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1382 insertionBuffers[spillBlock.getId()] = insertionBuffer;
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1383 insertionBuffer.init(ir.getLIRforBlock(spillBlock));
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1384 }
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1385 int spillOpId = getFirstLirInstructionId(spillBlock);
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1386 // insert spill move
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1387 AllocatableValue fromLocation = interval.getSplitChildAtOpId(spillOpId, OperandMode.DEF, this).location();
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1388 AllocatableValue toLocation = canonicalSpillOpr(interval);
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
1389 LIRInstruction move = getSpillMoveFactory().createMove(toLocation, fromLocation);
16380
8057279ec60e LSRA spill optimization: use DOMINATOR_SPILL_MOVE_ID to mark moves.
Josef Eisl <josef.eisl@jku.at>
parents: 16379
diff changeset
1390 move.setId(DOMINATOR_SPILL_MOVE_ID);
16378
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1391 /*
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1392 * We can use the insertion buffer directly because we always insert
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1393 * at position 1.
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1394 */
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1395 insertionBuffer.append(1, move);
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1396
16361
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1397 betterSpillPosWithLowerProbability.increment();
16378
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1398 interval.setSpillDefinitionPos(spillOpId);
16361
faff09aa5999 LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents: 16360
diff changeset
1399 }
16360
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1400 } else {
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1401 // definition is the best choice
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1402 interval.setSpillState(SpillState.StoreAtDefinition);
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1403 }
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1404 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1405 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1406 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1407 }
16378
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1408 for (LIRInsertionBuffer insertionBuffer : insertionBuffers) {
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1409 if (insertionBuffer != null) {
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1410 assert insertionBuffer.initialized() : "Insertion buffer is nonnull but not initialized!";
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1411 insertionBuffer.finish();
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1412 }
d075b97fbd31 LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents: 16377
diff changeset
1413 }
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1414 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
1415
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1416 /**
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1417 * Iterate over all {@link AbstractBlockBase blocks} of an interval.
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1418 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1419 private class IntervalBlockIterator implements Iterator<AbstractBlockBase<?>> {
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1420
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1421 Range range;
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1422 AbstractBlockBase<?> block;
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1423
16376
ef21879c0c8f LSRA spill optimization: rename UseBlockIterator to IntervalBlockIterator.
Josef Eisl <josef.eisl@jku.at>
parents: 16375
diff changeset
1424 public IntervalBlockIterator(Interval interval) {
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1425 range = interval.first();
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1426 block = blockForId(range.from);
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1427 }
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1428
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1429 public AbstractBlockBase<?> next() {
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1430 AbstractBlockBase<?> currentBlock = block;
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1431 int nextBlockIndex = block.getLinearScanNumber() + 1;
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1432 if (nextBlockIndex < sortedBlocks.size()) {
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1433 block = sortedBlocks.get(nextBlockIndex);
16375
ff14306337f2 LSRA spill optimization: fix UseBlockIterator.
Josef Eisl <josef.eisl@jku.at>
parents: 16374
diff changeset
1434 if (range.to <= getFirstLirInstructionId(block)) {
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1435 range = range.next;
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1436 if (range == Range.EndMarker) {
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1437 block = null;
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1438 } else {
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1439 block = blockForId(range.from);
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1440 }
16370
3324ab9fe71a LSRA spill optimization: iterate all ranges of spill interval.
Josef Eisl <josef.eisl@jku.at>
parents: 16369
diff changeset
1441 }
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1442 } else {
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1443 block = null;
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1444 }
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1445 return currentBlock;
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1446 }
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1447
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1448 public boolean hasNext() {
16373
74e93f5ba4f3 LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents: 16372
diff changeset
1449 return block != null;
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1450 }
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1451 }
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1452
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1453 private Iterable<AbstractBlockBase<?>> blocksForInterval(Interval interval) {
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1454 return new Iterable<AbstractBlockBase<?>>() {
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1455 public Iterator<AbstractBlockBase<?>> iterator() {
16376
ef21879c0c8f LSRA spill optimization: rename UseBlockIterator to IntervalBlockIterator.
Josef Eisl <josef.eisl@jku.at>
parents: 16375
diff changeset
1456 return new IntervalBlockIterator(interval);
16364
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1457 }
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1458 };
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1459 }
a54a64af1e82 LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents: 16363
diff changeset
1460
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1461 private static AbstractBlockBase<?> moveSpillOutOfLoop(AbstractBlockBase<?> defBlock, AbstractBlockBase<?> spillBlock) {
16360
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1462 int defLoopDepth = defBlock.getLoopDepth();
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1463 for (AbstractBlockBase<?> block = spillBlock.getDominator(); !defBlock.equals(block); block = block.getDominator()) {
16360
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1464 assert block != null : "spill block not dominated by definition block?";
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1465 if (block.getLoopDepth() <= defLoopDepth) {
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1466 assert block.getLoopDepth() == defLoopDepth : "Cannot spill an interval outside of the loop where it is defined!";
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1467 return block;
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1468 }
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1469 }
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1470 return defBlock;
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1471 }
ec54fc47ba5d LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents: 16359
diff changeset
1472
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1473 void printIntervals(String label) {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1474 if (Debug.isLogEnabled()) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1475 try (Indent indent = Debug.logAndIndent("intervals %s", label)) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1476 for (Interval interval : intervals) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1477 if (interval != null) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1478 Debug.log("%s", interval.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1479 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1480 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1481
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1482 try (Indent indent2 = Debug.logAndIndent("Basic Blocks")) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1483 for (int i = 0; i < blockCount(); i++) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1484 AbstractBlockBase<?> block = blockAt(i);
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1485 Debug.log("B%d [%d, %d, %s] ", block.getId(), getFirstLirInstructionId(block), getLastLirInstructionId(block), block.getLoop());
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1486 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1487 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1488 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1489 }
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
1490 Debug.dump(Arrays.copyOf(intervals, intervalsSize), label);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1491 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1492
7556
630ea5001e33 Modified formatter settings to not insert line break after annotation on parameters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
1493 void printLir(String label, @SuppressWarnings("unused") boolean hirValid) {
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
1494 Debug.dump(ir, label);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1495 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1496
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1497 boolean verify() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1498 // (check that all intervals have a correct register and that no registers are overwritten)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1499 verifyIntervals();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1500
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1501 verifyRegisters();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1502
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1503 Debug.log("no errors found");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1504
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1505 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1506 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1507
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1508 private void verifyRegisters() {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1509 // Enable this logging to get output for the verification process.
13546
43bd3d7254d1 don?t explicitly disable debug log output in linear scan and graphbuilder
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13467
diff changeset
1510 try (Indent indent = Debug.logAndIndent("verifying register allocation")) {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1511 RegisterVerifier verifier = new RegisterVerifier(this);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1512 verifier.verify(blockAt(0));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1513 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1514 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1515
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1516 void verifyIntervals() {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1517 try (Indent indent = Debug.logAndIndent("verifying intervals")) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1518 int len = intervalsSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1519
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1520 for (int i = 0; i < len; i++) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1521 Interval i1 = intervals[i];
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1522 if (i1 == null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1523 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1524 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1525
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1526 i1.checkSplitChildren();
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1527
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1528 if (i1.operandNumber != i) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1529 Debug.log("Interval %d is on position %d in list", i1.operandNumber, i);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1530 Debug.log(i1.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1531 throw new GraalInternalError("");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1532 }
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1533
16118
5cbaad0b7387 Verify usage of equals method in LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 16094
diff changeset
1534 if (isVariable(i1.operand) && i1.kind().equals(LIRKind.Illegal)) {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1535 Debug.log("Interval %d has no type assigned", i1.operandNumber);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1536 Debug.log(i1.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1537 throw new GraalInternalError("");
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1538 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1539
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1540 if (i1.location() == null) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1541 Debug.log("Interval %d has no register assigned", i1.operandNumber);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1542 Debug.log(i1.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1543 throw new GraalInternalError("");
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1544 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1545
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1546 if (i1.first() == Range.EndMarker) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1547 Debug.log("Interval %d has no Range", i1.operandNumber);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1548 Debug.log(i1.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1549 throw new GraalInternalError("");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1550 }
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1551
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1552 for (Range r = i1.first(); r != Range.EndMarker; r = r.next) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1553 if (r.from >= r.to) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1554 Debug.log("Interval %d has zero length range", i1.operandNumber);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1555 Debug.log(i1.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1556 throw new GraalInternalError("");
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1557 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1558 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1559
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1560 for (int j = i + 1; j < len; j++) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1561 Interval i2 = intervals[j];
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1562 if (i2 == null) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1563 continue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1564 }
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1565
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1566 // special intervals that are created in MoveResolver
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1567 // . ignore them because the range information has no meaning there
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1568 if (i1.from() == 1 && i1.to() == 2) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1569 continue;
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1570 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1571 if (i2.from() == 1 && i2.to() == 2) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1572 continue;
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1573 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1574 Value l1 = i1.location();
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1575 Value l2 = i2.location();
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1576 if (i1.intersects(i2) && !isIllegal(l1) && (l1.equals(l2))) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1577 if (DetailedAsserts.getValue()) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1578 Debug.log("Intervals %d and %d overlap and have the same register assigned", i1.operandNumber, i2.operandNumber);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1579 Debug.log(i1.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1580 Debug.log(i2.logString(this));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1581 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1582 throw new BailoutException("");
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1583 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1584 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1585 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1586 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1587 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1588
17285
3a834111a632 Make [Instruction]ValueProcedure and [Instruction]ValueConsumer a FunctionalInterface.
Josef Eisl <josef.eisl@jku.at>
parents: 17284
diff changeset
1589 class CheckConsumer implements ValueConsumer {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1590
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1591 boolean ok;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1592 Interval curInterval;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1593
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1594 @Override
17284
d21962ea9617 Remove ValueConsumer.visitValue(Value).
Josef Eisl <josef.eisl@jku.at>
parents: 17283
diff changeset
1595 public void visitValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1596 if (isRegister(operand)) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1597 if (intervalFor(operand) == curInterval) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1598 ok = true;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1599 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1600 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1601 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1602 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1603
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1604 void verifyNoOopsInFixedIntervals() {
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1605 try (Indent indent = Debug.logAndIndent("verifying that no oops are in fixed intervals *")) {
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1606 CheckConsumer checkConsumer = new CheckConsumer();
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1607
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1608 Interval fixedIntervals;
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1609 Interval otherIntervals;
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1610 fixedIntervals = createUnhandledLists(IS_PRECOLORED_INTERVAL, null).first;
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1611 // to ensure a walking until the last instruction id, add a dummy interval
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1612 // with a high operation id
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1613 otherIntervals = new Interval(Value.ILLEGAL, -1);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1614 otherIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1615 IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1616
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1617 for (AbstractBlockBase<?> block : sortedBlocks) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
1618 List<LIRInstruction> instructions = ir.getLIRforBlock(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1619
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1620 for (int j = 0; j < instructions.size(); j++) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1621 LIRInstruction op = instructions.get(j);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1622
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1623 if (op.hasState()) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1624 iw.walkBefore(op.id());
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1625 boolean checkLive = true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1626
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1627 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1628 * Make sure none of the fixed registers is live across an oopmap since we
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1629 * can't handle that correctly.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1630 */
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1631 if (checkLive) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1632 for (Interval interval = iw.activeLists.get(RegisterBinding.Fixed); interval != Interval.EndMarker; interval = interval.next) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1633 if (interval.currentTo() > op.id() + 1) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1634 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1635 * This interval is live out of this op so make sure that this
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1636 * interval represents some value that's referenced by this op
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1637 * either as an input or output.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1638 */
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1639 checkConsumer.curInterval = interval;
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1640 checkConsumer.ok = false;
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1641
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1642 op.visitEachInput(checkConsumer);
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1643 op.visitEachAlive(checkConsumer);
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1644 op.visitEachTemp(checkConsumer);
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1645 op.visitEachOutput(checkConsumer);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1646
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1647 assert checkConsumer.ok : "fixed intervals should never be live across an oopmap point";
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1648 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1649 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1650 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1651 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1652 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1653 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1654 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1655 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1656
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1657 /**
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1658 * Returns a value for a interval definition, which can be used for re-materialization.
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
1659 *
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1660 * @param op An instruction which defines a value
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1661 * @param operand The destination operand of the instruction
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1662 * @param interval The interval for this defined value.
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1663 * @return Returns the value which is moved to the instruction and which can be reused at all
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1664 * reload-locations in case the interval of this instruction is spilled. Currently this
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18152
diff changeset
1665 * can only be a {@link JavaConstant}.
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1666 */
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18152
diff changeset
1667 public static JavaConstant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) {
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1668 if (op instanceof MoveOp) {
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1669 MoveOp move = (MoveOp) op;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18152
diff changeset
1670 if (move.getInput() instanceof JavaConstant) {
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1671 /*
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1672 * Check if the interval has any uses which would accept an stack location (priority
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1673 * == ShouldHaveRegister). Rematerialization of such intervals can result in a
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1674 * degradation, because rematerialization always inserts a constant load, even if
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1675 * the value is not needed in a register.
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1676 */
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1677 Interval.UsePosList usePosList = interval.usePosList();
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1678 int numUsePos = usePosList.size();
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1679 for (int useIdx = 0; useIdx < numUsePos; useIdx++) {
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1680 Interval.RegisterPriority priority = usePosList.registerPriority(useIdx);
15920
4b835260c746 backout 88a6017687c9
Josef Eisl <josef.eisl@jku.at>
parents: 15914
diff changeset
1681 if (priority == Interval.RegisterPriority.ShouldHaveRegister) {
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1682 return null;
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1683 }
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1684 }
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18152
diff changeset
1685 return (JavaConstant) move.getInput();
14070
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1686 }
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1687 }
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1688 return null;
a8a82c6e2981 Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents: 14057
diff changeset
1689 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1690 }