annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java @ 21334:4f68c2550646

LinearScan: outsource ResolveDataFlow.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 12 May 2015 13:34:04 +0200
parents a6e1a98f47e2
children 5661a921e123
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.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
28 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
29
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
32 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
33 import com.oracle.graal.api.meta.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
34 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
35 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
36 import com.oracle.graal.compiler.common.cfg.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
37 import com.oracle.graal.debug.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.lir.*;
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
39 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
40 import com.oracle.graal.lir.LIRInstruction.OperandMode;
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.StandardOp.MoveOp;
19166
39e99cf01468 Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents: 19165
diff changeset
42 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
43 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
44 import com.oracle.graal.lir.framemap.*;
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
45 import com.oracle.graal.lir.gen.*;
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
46 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
47 import com.oracle.graal.lir.phases.*;
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
48 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
49 import com.oracle.graal.options.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
52 * 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
53 * 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
54 * >"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
55 * Hanspeter Moessenboeck.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 */
21240
1e9242c9735e Introduce SSALinearScan and SSAMoveResolver.
Josef Eisl <josef.eisl@jku.at>
parents: 21236
diff changeset
57 class LinearScan {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
59 final LIRGenerationResult res;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 final LIR ir;
18150
22f2e42923de Use FrameMapBuilder in LinearScan (except for location marking).
Josef Eisl <josef.eisl@jku.at>
parents: 18123
diff changeset
61 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
62 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
63 final Register[] registers;
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
64 final RegisterAllocationConfig regAllocConfig;
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
65 private final SpillMoveFactory moveFactory;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
18512
bcf66634c55c Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents: 18446
diff changeset
67 final boolean callKillsRegisters;
10961
d0c9278fe471 move callKillsRegisters to LinearScan
twisti
parents: 9966
diff changeset
68
16380
8057279ec60e LSRA spill optimization: use DOMINATOR_SPILL_MOVE_ID to mark moves.
Josef Eisl <josef.eisl@jku.at>
parents: 16379
diff changeset
69 public static final int DOMINATOR_SPILL_MOVE_ID = -2;
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
70 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
71
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
72 public static class Options {
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
73 // @formatter:off
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18610
diff changeset
74 @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
75 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
76 // @formatter:on
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
77 }
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
78
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
79 public static class BlockData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
80
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
81 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
82 * 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
83 * 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
84 * 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
85 * operand number}.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
86 */
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
87 public BitSet liveIn;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
88
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
89 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
90 * 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
91 * 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
92 * 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
93 * {@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
94 */
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
95 public BitSet liveOut;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
96
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
97 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
98 * 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
99 * 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
100 * 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
101 */
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
102 public BitSet liveGen;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
103
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
104 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
105 * 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
106 * 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
107 */
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
108 public BitSet liveKill;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
109 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
110
21326
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
111 private final BlockMap<BlockData> blockData;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
112
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 * 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
115 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
116 final List<? extends AbstractBlockBase<?>> sortedBlocks;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117
21327
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
118 /** @see #intervals() */
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
119 private Interval[] intervals;
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 * The number of valid entries in {@link #intervals}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 */
21327
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
124 private int intervalsSize;
3733
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
127 * 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
128 * {@linkplain #createDerivedInterval(Interval) derived interval}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 */
21327
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
130 private int firstDerivedIntervalIndex = -1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 * Intervals sorted by {@link Interval#from()}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 */
21327
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
135 private Interval[] sortedIntervals;
3733
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
138 * 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
139 * 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
140 * array.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 */
21328
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
142 private LIRInstruction[] opIdToInstructionMap;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 /**
19565
9bb45bec2b1f Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19563
diff changeset
145 * Map from an instruction {@linkplain LIRInstruction#id id} to the
9bb45bec2b1f Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19563
diff changeset
146 * {@linkplain AbstractBlockBase block} containing the instruction. Entries should be retrieved
9bb45bec2b1f Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19563
diff changeset
147 * 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
148 */
21328
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
149 private AbstractBlockBase<?>[] opIdToBlockMap;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 /**
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5552
diff changeset
152 * 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
153 */
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
154 private final int firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
155
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
156 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
157 this.res = res;
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
158 this.ir = res.getLIR();
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
159 this.moveFactory = spillMoveFactory;
18152
ff694c40bdee LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
160 this.frameMapBuilder = res.getFrameMapBuilder();
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
161 this.sortedBlocks = ir.linearScanOrder();
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
162 this.registerAttributes = regAllocConfig.getRegisterConfig().getAttributesMap();
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
163 this.regAllocConfig = regAllocConfig;
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
164
6582
cc32ce37eddc deleted Architecture.twoOperandMode() and encapsulated all public fields in Architecture with getters
Doug Simon <doug.simon@oracle.com>
parents: 6581
diff changeset
165 this.registers = target.arch.getRegisters();
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
166 this.firstVariableNumber = registers.length;
14145
4ff08c0366ae Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14142
diff changeset
167 this.blockData = new BlockMap<>(ir.getControlFlowGraph());
18512
bcf66634c55c Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents: 18446
diff changeset
168
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
169 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
170 * 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
171 * 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
172 */
20915
916aac9fe6f7 LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents: 20151
diff changeset
173 this.callKillsRegisters = regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
176 int getFirstLirInstructionId(AbstractBlockBase<?> block) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
177 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
178 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
179 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
180 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
181
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
182 int getLastLirInstructionId(AbstractBlockBase<?> block) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
183 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
184 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
185 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
186 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
187 }
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
188
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
189 SpillMoveFactory getSpillMoveFactory() {
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
190 return moveFactory;
19549
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
191 }
1cf73c50e3dc Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents: 19212
diff changeset
192
21203
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
193 protected MoveResolver createMoveResolver() {
21246
b2b3c514a391 MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents: 21240
diff changeset
194 MoveResolver moveResolver = new MoveResolver(this);
b2b3c514a391 MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents: 21240
diff changeset
195 assert moveResolver.checkEmpty();
b2b3c514a391 MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents: 21240
diff changeset
196 return moveResolver;
21203
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
197 }
9f45587ad8f5 LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents: 21193
diff changeset
198
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
199 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
200 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
201 }
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
202
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
204 * 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
205 * 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
206 * by this allocator.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 */
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
208 int operandNumber(Value operand) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
209 if (isRegister(operand)) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
210 int number = asRegister(operand).number;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
211 assert number < firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
212 return number;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
213 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
214 assert isVariable(operand) : operand;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
215 return firstVariableNumber + ((Variable) operand).index;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217
4206
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 * 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
220 */
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
221 int operandSize() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
222 return firstVariableNumber + ir.numVariables();
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
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
225 /**
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
226 * 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
227 */
19212
95a7954ea155 Add LinearScanPhase.
Josef Eisl <josef.eisl@jku.at>
parents: 19166
diff changeset
228 int maxRegisterNumber() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
229 return firstVariableNumber - 1;
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
21326
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
232 BlockData getBlockData(AbstractBlockBase<?> block) {
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
233 return blockData.get(block);
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
234 }
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
235
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
236 void initBlockData(AbstractBlockBase<?> block) {
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
237 blockData.put(block, new BlockData());
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
238 }
8cef2c3f389b LinearScan: encapsulate blockData.
Josef Eisl <josef.eisl@jku.at>
parents: 21325
diff changeset
239
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
240 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
241
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 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
244 return isRegister(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 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
249
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 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
252 return isVariable(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
256 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
257
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 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
260 return !isRegister(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
265 * 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
266 * configuration.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 */
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
268 RegisterAttributes attributes(Register reg) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 return registerAttributes[reg.number];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 void assignSpillSlot(Interval interval) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
273 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
274 * 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
275 * spilled) or allocate a new spill slot.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
276 */
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
277 if (interval.canMaterialize()) {
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
278 interval.assignLocation(Value.ILLEGAL);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
279 } else if (interval.spillSlot() != null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 interval.assignLocation(interval.spillSlot());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 } else {
18425
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18420
diff changeset
282 VirtualStackSlot slot = frameMapBuilder.allocateSpillSlot(interval.kind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 interval.setSpillSlot(slot);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 interval.assignLocation(slot);
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 /**
21327
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
289 * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals.
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
290 */
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
291 Interval[] intervals() {
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
292 return intervals;
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
293 }
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
294
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
295 void initIntervals() {
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
296 intervalsSize = operandSize();
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
297 intervals = new Interval[intervalsSize + (intervalsSize >> SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT)];
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
298 }
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
299
b8dcf353b822 LinearScan: encapsulate intervals.
Josef Eisl <josef.eisl@jku.at>
parents: 21326
diff changeset
300 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 * 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
302 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 * @param operand the operand for the interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 * @return the created interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 */
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
306 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
307 assert isLegal(operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 int operandNumber = operandNumber(operand);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4350
diff changeset
309 Interval interval = new Interval(operand, operandNumber);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 assert operandNumber < intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 assert intervals[operandNumber] == null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312 intervals[operandNumber] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 return interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 * 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
318 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 * @param source an interval being split of spilled
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 * @return a new interval derived from {@code source}
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 Interval createDerivedInterval(Interval source) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 if (firstDerivedIntervalIndex == -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324 firstDerivedIntervalIndex = intervalsSize;
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 if (intervalsSize == intervals.length) {
15885
4d18c6bb6b3a LinearScan: Improve initialization and resizing of intervals array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15884
diff changeset
327 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
328 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 intervalsSize++;
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9422
diff changeset
330 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
331
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
332 Interval interval = createInterval(variable);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 assert intervals[intervalsSize - 1] == interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 return interval;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 // 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
338 int blockCount() {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
339 return sortedBlocks.size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
342 AbstractBlockBase<?> blockAt(int index) {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
343 return sortedBlocks.get(index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
347 * 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
348 * 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
349 * {@linkplain #createDerivedInterval(Interval) derived intervals}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 int liveSetSize() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
352 return firstDerivedIntervalIndex == -1 ? operandSize() : firstDerivedIntervalIndex;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 int numLoops() {
15107
1bf700e19e84 Make Loop generic.
Josef Eisl <josef.eisl@jku.at>
parents: 15026
diff changeset
356 return ir.getControlFlowGraph().getLoops().size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358
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
359 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
360 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
361 }
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
362
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
363 Interval intervalFor(Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 int operandNumber = operandNumber(operand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 assert operandNumber < intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 return intervals[operandNumber];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
369 Interval getOrCreateInterval(AllocatableValue operand) {
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
370 Interval ret = intervalFor(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
371 if (ret == null) {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
372 return createInterval(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
373 } else {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
374 return ret;
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
375 }
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
376 }
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
377
21328
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
378 void initOpIdMaps(int numInstructions) {
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
379 opIdToInstructionMap = new LIRInstruction[numInstructions];
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
380 opIdToBlockMap = new AbstractBlockBase<?>[numInstructions];
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
381 }
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
382
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
383 void putOpIdMaps(int index, LIRInstruction op, AbstractBlockBase<?> block) {
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
384 opIdToInstructionMap[index] = op;
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
385 opIdToBlockMap[index] = block;
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
386 }
de17f6676a43 LinearScan: encapsulate opIdToBlockMap and opIdToInstructionMap.
Josef Eisl <josef.eisl@jku.at>
parents: 21327
diff changeset
387
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 * 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
390 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 int maxOpId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 assert opIdToInstructionMap.length > 0 : "no operations";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 return (opIdToInstructionMap.length - 1) << 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
397 * Converts an {@linkplain LIRInstruction#id instruction id} to an instruction index. All LIR
21329
6a32034ace1b LinearScan: make opIdToIndex private.
Josef Eisl <josef.eisl@jku.at>
parents: 21328
diff changeset
398 * instructions in a method have an index one greater than their linear-scan order predecessor
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 * 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
400 */
21329
6a32034ace1b LinearScan: make opIdToIndex private.
Josef Eisl <josef.eisl@jku.at>
parents: 21328
diff changeset
401 private static int opIdToIndex(int opId) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402 return opId >> 1;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 * 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
407 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 * @param opId an instruction {@linkplain LIRInstruction#id id}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 * @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
410 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 LIRInstruction instructionForId(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 assert isEven(opId) : "opId not even";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 LIRInstruction instr = opIdToInstructionMap[opIdToIndex(opId)];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 assert instr.id() == opId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 return instr;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417
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 * 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
420 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 * @param opId an instruction {@linkplain LIRInstruction#id id}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 * @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
423 */
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
424 AbstractBlockBase<?> blockForId(int opId) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 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
426 return opIdToBlockMap[opIdToIndex(opId)];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 boolean isBlockBegin(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 return opId == 0 || blockForId(opId) != blockForId(opId - 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 boolean coversBlockBegin(int opId1, int opId2) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 return blockForId(opId1) != blockForId(opId2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 * 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
439 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 * @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
441 * @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
442 * registers.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 boolean hasCall(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 assert isEven(opId) : "opId not even";
9454
85a836bcd796 renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents: 9425
diff changeset
446 return instructionForId(opId).destroysCallerSavedRegisters();
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 // called during register allocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 void changeSpillState(Interval interval, int spillPos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 switch (interval.spillState()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 case NoSpillStore: {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
453 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
454 int spillLoopDepth = blockForId(spillPos).getLoopDepth();
3733
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 if (defLoopDepth < spillLoopDepth) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
457 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
458 * 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
459 * 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
460 */
21330
e35311c60c84 LinearScan: move changeSpillDefinitionPos and registerPriorityOf{Output,Output}Operand to LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21329
diff changeset
461 if (LinearScan.Options.LSRAOptimizeSpillPosition.getValue()) {
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
462 // 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
463 interval.setSpillState(SpillState.SpillInDominator);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
464 } else {
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
465 // 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
466 interval.setSpillState(SpillState.StoreAtDefinition);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
467 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 } else {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
469 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
470 * 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
471 * store the interval at the definition.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
472 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 interval.setSpillState(SpillState.OneSpillStore);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 case OneSpillStore: {
21330
e35311c60c84 LinearScan: move changeSpillDefinitionPos and registerPriorityOf{Output,Output}Operand to LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21329
diff changeset
479 if (LinearScan.Options.LSRAOptimizeSpillPosition.getValue()) {
16362
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
480 // 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
481 interval.setSpillState(SpillState.SpillInDominator);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
482 } else {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
483 // 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
484 interval.setSpillState(SpillState.StoreAtDefinition);
b100bd079fff LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents: 16361
diff changeset
485 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488
16359
f686fae77383 LSRA spill optimization: rename SpillInDominator.MultipleSpills to SpillState.SpillInDominator.
Josef Eisl <josef.eisl@jku.at>
parents: 16358
diff changeset
489 case SpillInDominator:
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 case StoreAtDefinition:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491 case StartInMemory:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 case NoOptimization:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 case NoDefinitionFound:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 // nothing to do
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 default:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
498 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
499 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
502 abstract static class IntervalPredicate {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
503
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504 abstract boolean apply(Interval i);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506
16379
c5257d58b71a LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents: 16378
diff changeset
507 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
508
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
509 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 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
511 return i.isSplitParent() && i.spillState() == SpillState.StoreAtDefinition;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
515 /**
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
516 * @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
517 * {@link #eliminateSpillMoves()}
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
518 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
519 protected int firstInstructionOfInterest() {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
520 // 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
521 return 1;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
522 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
523
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 // called once before assignment of register numbers
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 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
526 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
527
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
528 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
529 * 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
530 * by Interval.spillDefinitionPos.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
531 */
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
532 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
533 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
534 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
535 checkIntervals(interval);
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
536 }
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
537
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
538 LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer();
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
539 for (AbstractBlockBase<?> block : sortedBlocks) {
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
540 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
541 List<LIRInstruction> instructions = ir.getLIRforBlock(block);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
542 int numInst = instructions.size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
544 // iterate all instructions of the block.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
545 for (int j = firstInstructionOfInterest(); j < numInst; j++) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
546 LIRInstruction op = instructions.get(j);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
547 int opId = op.id();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
549 if (opId == -1) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
550 MoveOp move = (MoveOp) op;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
551 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
552 * 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
553 * 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
554 * removed.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
555 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
556 if (canEliminateSpillMove(block, move)) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
557 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
558 * 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
559 * instruction.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
560 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
561 if (Debug.isLogEnabled()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
562 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
563 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
564 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
565
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
566 // null-instructions are deleted by assignRegNum
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
567 instructions.set(j, null);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
568 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
569
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
570 } else {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
571 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
572 * 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
573 * interval.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
574 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
575 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
576 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
577
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
578 while (interval != Interval.EndMarker && interval.spillDefinitionPos() == opId) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
579 if (!interval.canMaterialize()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
580 if (!insertionBuffer.initialized()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
581 /*
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
582 * prepare insertion buffer (appended when all instructions
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
583 * in the block are processed)
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
584 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
585 insertionBuffer.init(instructions);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
586 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
587
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
588 AllocatableValue fromLocation = interval.location();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
589 AllocatableValue toLocation = canonicalSpillOpr(interval);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
590 if (!fromLocation.equals(toLocation)) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
591
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
592 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
593 interval.spillState();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
594 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
595
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
596 LIRInstruction move = getSpillMoveFactory().createMove(toLocation, fromLocation);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
597 insertionBuffer.append(j + 1, move);
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
598
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
599 if (Debug.isLogEnabled()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
600 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
601 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
602 }
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
603 }
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
604 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
605 }
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
606 }
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
607 } // end of instruction iteration
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
609 if (insertionBuffer.initialized()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
610 insertionBuffer.finish();
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
611 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
613 } // end of block iteration
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
614
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
615 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
616 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
617 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
618
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
619 /**
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
620 * @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
621 * @param move Spill move.
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
622 */
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
623 protected boolean canEliminateSpillMove(AbstractBlockBase<?> block, MoveOp move) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
624 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
625
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
626 Interval curInterval = intervalFor(move.getResult());
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 if (!isRegister(curInterval.location()) && curInterval.alwaysInMemory()) {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
629 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
630 return true;
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
631 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
632 return false;
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
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
635 private static void checkIntervals(Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636 Interval prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
637 Interval temp = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
638 while (temp != Interval.EndMarker) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
639 assert temp.spillDefinitionPos() > 0 : "invalid spill definition pos";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
640 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
641 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
642 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
643 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
644
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
645 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
646 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
647 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
648
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
649 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
650 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
651 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
652
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
653 prev = temp;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 temp = temp.next;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
655 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
656 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657
21316
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
658 boolean isProcessed(Value operand) {
fd18bffefcc1 LinearScan: outsource LifetimeAnalysis.
Josef Eisl <josef.eisl@jku.at>
parents: 21315
diff changeset
659 return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable();
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 // * Phase 5: actual register allocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
663
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
664 private static boolean isSorted(Interval[] intervals) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
665 int from = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
666 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
667 assert interval != null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
668 assert from <= interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 from = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
670 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
671 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
672 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
673
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
674 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
675 Interval newFirst = first;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
676 if (prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
677 prev.next = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
678 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
679 newFirst = interval;
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 return newFirst;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
682 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 Interval.Pair createUnhandledLists(IntervalPredicate isList1, IntervalPredicate isList2) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685 assert isSorted(sortedIntervals) : "interval list is not sorted";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
687 Interval list1 = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
688 Interval list2 = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
689
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
690 Interval list1Prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
691 Interval list2Prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
692 Interval v;
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 int n = sortedIntervals.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
695 for (int i = 0; i < n; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 v = sortedIntervals[i];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
697 if (v == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
698 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
699 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
700
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
701 if (isList1.apply(v)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
702 list1 = addToList(list1, list1Prev, v);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
703 list1Prev = v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704 } else if (isList2 == null || isList2.apply(v)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 list2 = addToList(list2, list2Prev, v);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
706 list2Prev = v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
707 }
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 if (list1Prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
711 list1Prev.next = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
712 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 if (list2Prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714 list2Prev.next = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
716
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 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
718 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
719
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
720 return new Interval.Pair(list1, list2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
722
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
723 void sortIntervalsBeforeAllocation() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724 int sortedLen = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
725 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 if (interval != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 sortedLen++;
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 }
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 Interval[] sortedList = new Interval[sortedLen];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
732 int sortedIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
733 int sortedFromMax = -1;
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 // 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
736 // 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
737 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
738 if (interval != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
739 int from = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
741 if (sortedFromMax <= from) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
742 sortedList[sortedIdx++] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
743 sortedFromMax = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
744 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
745 // 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
746 // so this interval must be sorted in manually
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747 int j;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748 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
749 sortedList[j + 1] = sortedList[j];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
750 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
751 sortedList[j + 1] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 sortedIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756 sortedIntervals = sortedList;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
759 void sortIntervalsAfterAllocation() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
760 if (firstDerivedIntervalIndex == -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
761 // 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
762 return;
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 Interval[] oldList = sortedIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 Interval[] newList = Arrays.copyOfRange(intervals, firstDerivedIntervalIndex, intervalsSize);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767 int oldLen = oldList.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
768 int newLen = newList.length;
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 // 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
771 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
772
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773 // 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
774 Interval[] combinedList = new Interval[oldLen + newLen];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
775 int oldIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
776 int newIdx = 0;
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 while (oldIdx + newIdx < combinedList.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
779 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
780 combinedList[oldIdx + newIdx] = oldList[oldIdx];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
781 oldIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
782 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
783 combinedList[oldIdx + newIdx] = newList[newIdx];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
784 newIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
786 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
788 sortedIntervals = combinedList;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
789 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
790
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
791 // 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
792 // instead of returning null
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 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
794 Interval result = interval.getSplitChildAtOpId(opId, mode, this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
795
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
796 if (result != null) {
20980
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
797 if (Debug.isLogEnabled()) {
abc059cb0acf Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20979
diff changeset
798 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
799 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800 return result;
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
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
803 throw new BailoutException("LinearScan: interval is null");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805
18425
b856446ff7e0 Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents: 18420
diff changeset
806 static StackSlotValue canonicalSpillOpr(Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 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
808 return interval.spillSlot();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
810
21325
e0400193edca LinearScan: outsource AssignLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 21324
diff changeset
811 boolean isMaterialized(AllocatableValue operand, int opId, OperandMode mode) {
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
812 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
813 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
814
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
815 if (opId != -1) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
816 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
817 * 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
818 * right interval here.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
819 */
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
820 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
821 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
822
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
823 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
824 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
825
21325
e0400193edca LinearScan: outsource AssignLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 21324
diff changeset
826 boolean isCallerSave(Value operand) {
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
827 return attributes(asRegister(operand)).isCallerSave();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
828 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
829
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
830 <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
831
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
832 /*
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
833 * 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
834 */
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
835 try (Indent indent = Debug.logAndIndent("LinearScan allocate")) {
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
836 AllocationContext context = new AllocationContext(spillMoveFactory);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
837
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
838 createLifetimeAnalysisPhase().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, false);
21331
45ff3423d4c4 LinearScan: call sortIntervalsBeforeAllocation in allocate().
Josef Eisl <josef.eisl@jku.at>
parents: 21330
diff changeset
839
45ff3423d4c4 LinearScan: call sortIntervalsBeforeAllocation in allocate().
Josef Eisl <josef.eisl@jku.at>
parents: 21330
diff changeset
840 sortIntervalsBeforeAllocation();
45ff3423d4c4 LinearScan: call sortIntervalsBeforeAllocation in allocate().
Josef Eisl <josef.eisl@jku.at>
parents: 21330
diff changeset
841
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
842 createRegisterAllocationPhase().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
843
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
844 if (LinearScan.Options.LSRAOptimizeSpillPosition.getValue()) {
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
845 createOptimizeSpillPositionPhase().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
846 }
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
847 createResolveDataFlowPhase().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
848
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
849 sortIntervalsAfterAllocation();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
850
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
851 if (DetailedAsserts.getValue()) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
852 verify();
16357
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
853 }
a07492ccaf52 LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents: 16355
diff changeset
854
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
855 createSpillMoveEliminationPhase().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
856 createAssignLocationsPhase().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context);
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
857
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
858 if (DetailedAsserts.getValue()) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
859 verifyIntervals();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860 }
14871
667710021ea1 removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents: 14841
diff changeset
861 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
862 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
863
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
864 protected LifetimeAnalysis createLifetimeAnalysisPhase() {
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
865 return new LifetimeAnalysis(this);
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
866 }
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
867
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
868 protected RegisterAllocation createRegisterAllocationPhase() {
21333
a6e1a98f47e2 LinearScan: outsource RegisterAllocation.
Josef Eisl <josef.eisl@jku.at>
parents: 21332
diff changeset
869 return new RegisterAllocation(this);
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
870 }
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
871
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
872 protected OptimizeSpillPosition createOptimizeSpillPositionPhase() {
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
873 return new OptimizeSpillPosition(this);
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
874 }
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
875
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
876 protected ResolveDataFlow createResolveDataFlowPhase() {
21334
4f68c2550646 LinearScan: outsource ResolveDataFlow.
Josef Eisl <josef.eisl@jku.at>
parents: 21333
diff changeset
877 return new ResolveDataFlow(this);
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
878 }
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
879
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
880 protected EliminateSpillMove createSpillMoveEliminationPhase() {
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
881 return new EliminateSpillMove();
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
882 }
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
883
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
884 protected AssignLocations createAssignLocationsPhase() {
21325
e0400193edca LinearScan: outsource AssignLocations.
Josef Eisl <josef.eisl@jku.at>
parents: 21324
diff changeset
885 return new AssignLocations(this);
21323
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
886 }
3570b7d1a6f9 LinearScan: create factory methods for subr- phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21322
diff changeset
887
21312
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
888 private final class EliminateSpillMove extends AllocationPhase {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
889
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
890 @Override
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
891 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
892 SpillMoveFactory spillMoveFactory) {
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
893 beforeSpillMoveElimination();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
894 eliminateSpillMoves();
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
895 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
896
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
897 }
8ecb442fc864 LinearScan: split into sub-phases.
Josef Eisl <josef.eisl@jku.at>
parents: 21246
diff changeset
898
21236
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
899 protected void beforeSpillMoveElimination() {
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
900 }
8d21d631a82d LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents: 21203
diff changeset
901
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
902 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
903 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
904 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
905 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
906 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
907 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
908 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
909 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
910
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
911 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
912 for (int i = 0; i < blockCount(); i++) {
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
913 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
914 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
915 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
916 }
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 }
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
919 Debug.dump(Arrays.copyOf(intervals, intervalsSize), label);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
920 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
921
7556
630ea5001e33 Modified formatter settings to not insert line break after annotation on parameters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
922 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
923 Debug.dump(ir, label);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
924 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
925
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
926 boolean verify() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
927 // (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
928 verifyIntervals();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
930 verifyRegisters();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
931
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
932 Debug.log("no errors found");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
933
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
934 return true;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
937 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
938 // 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
939 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
940 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
941 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
942 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
943 }
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 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
946 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
947 int len = intervalsSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
948
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
949 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
950 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
951 if (i1 == null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
952 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
953 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
954
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
955 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
956
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
957 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
958 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
959 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
960 throw new GraalInternalError("");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
961 }
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
962
16118
5cbaad0b7387 Verify usage of equals method in LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents: 16094
diff changeset
963 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
964 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
965 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
966 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
967 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
968
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
969 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
970 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
971 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
972 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
973 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
974
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
975 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
976 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
977 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
978 throw new GraalInternalError("");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
979 }
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
980
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
981 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
982 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
983 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
984 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
985 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
986 }
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 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
988
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
989 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
990 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
991 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
992 continue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
993 }
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
994
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
995 // 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
996 // . 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
997 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
998 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
999 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1000 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
1001 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
1002 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1003 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
1004 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
1005 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
1006 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
1007 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
1008 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
1009 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
1010 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1011 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
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1017
17285
3a834111a632 Make [Instruction]ValueProcedure and [Instruction]ValueConsumer a FunctionalInterface.
Josef Eisl <josef.eisl@jku.at>
parents: 17284
diff changeset
1018 class CheckConsumer implements ValueConsumer {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1019
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1020 boolean ok;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1021 Interval curInterval;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1022
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1023 @Override
17284
d21962ea9617 Remove ValueConsumer.visitValue(Value).
Josef Eisl <josef.eisl@jku.at>
parents: 17283
diff changeset
1024 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
1025 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
1026 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
1027 ok = true;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1028 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1029 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1030 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1031 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1032
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1033 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
1034 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
1035 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
1036
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
1037 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
1038 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
1039 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
1040 // 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
1041 // 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
1042 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
1043 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
1044 IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1045
19560
4d70d150944f Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19212
diff changeset
1046 for (AbstractBlockBase<?> block : sortedBlocks) {
14806
a8723f1ff542 LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents: 14789
diff changeset
1047 List<LIRInstruction> instructions = ir.getLIRforBlock(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1048
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
1049 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
1050 LIRInstruction op = instructions.get(j);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1051
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
1052 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
1053 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
1054 boolean checkLive = true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1055
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1056 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1057 * 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
1058 * can't handle that correctly.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1059 */
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
1060 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
1061 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
1062 if (interval.currentTo() > op.id() + 1) {
21319
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1063 /*
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1064 * 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
1065 * 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
1066 * either as an input or output.
9ddb5a749eab LinearScan: use multiline comments.
Josef Eisl <josef.eisl@jku.at>
parents: 21318
diff changeset
1067 */
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1068 checkConsumer.curInterval = interval;
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1069 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
1070
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1071 op.visitEachInput(checkConsumer);
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1072 op.visitEachAlive(checkConsumer);
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1073 op.visitEachTemp(checkConsumer);
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1074 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
1075
16801
067dbd8e7114 Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents: 16796
diff changeset
1076 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
1077 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1078 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1079 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1080 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1081 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1082 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1083 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1084 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1085
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1086 }