annotate graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java @ 14057:38c881305352

Move functionality of SpillMoveFactory to FrameMap.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 25 Feb 2014 17:51:03 +0100
parents a02441dcf05f
children a8a82c6e2981
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 /*
4181
319860ae697a Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4169
diff changeset
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.compiler.alloc;
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.*;
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
27 import static com.oracle.graal.compiler.GraalDebugConfig.*;
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
6317
3ee3eb48e683 Clean up ComputeLinearScanOrder. Rename to ComputeBlockOrder.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5733
diff changeset
32 import com.oracle.graal.alloc.*;
5510
426c605c9d3c Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5507
diff changeset
33 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
34 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
35 import com.oracle.graal.compiler.alloc.Interval.RegisterBinding;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
36 import com.oracle.graal.compiler.alloc.Interval.RegisterPriority;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
37 import com.oracle.graal.compiler.alloc.Interval.SpillState;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
38 import com.oracle.graal.compiler.gen.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
39 import com.oracle.graal.debug.*;
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
40 import com.oracle.graal.debug.Debug.Scope;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
41 import com.oracle.graal.graph.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
42 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
43 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
44 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
45 import com.oracle.graal.lir.LIRInstruction.StateProcedure;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
46 import com.oracle.graal.lir.LIRInstruction.ValueProcedure;
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
47 import com.oracle.graal.lir.StandardOp.MoveOp;
6529
2e96dc4eb8e2 renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
48 import com.oracle.graal.nodes.cfg.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6500
diff changeset
49 import com.oracle.graal.phases.util.*;
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 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 public final class LinearScan {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
59 final TargetDescription target;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 final LIR ir;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 final LIRGenerator gen;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 final FrameMap frameMap;
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
63 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
64 final Register[] registers;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65
10961
d0c9278fe471 move callKillsRegisters to LinearScan
twisti
parents: 9966
diff changeset
66 boolean callKillsRegisters;
d0c9278fe471 move callKillsRegisters to LinearScan
twisti
parents: 9966
diff changeset
67
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 private static final int INITIAL_SPLIT_INTERVALS_CAPACITY = 32;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
70 public static class BlockData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
71
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
72 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
73 * 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
74 * 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
75 * 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
76 * operand number}.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
77 */
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
78 public BitSet liveIn;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
79
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
80 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
81 * 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
82 * 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
83 * 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
84 * {@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
85 */
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
86 public BitSet liveOut;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
87
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
88 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
89 * 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
90 * 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
91 * 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
92 */
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
93 public BitSet liveGen;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
94
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
95 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
96 * 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
97 * 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
98 */
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
99 public BitSet liveKill;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
100 }
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
101
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
102 public final BlockMap<BlockData> blockData;
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
103
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 * 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
106 */
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
107 final List<Block> sortedBlocks;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 /**
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
110 * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 Interval[] intervals;
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 * The number of valid entries in {@link #intervals}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 int intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
120 * 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
121 * {@linkplain #createDerivedInterval(Interval) derived interval}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 int firstDerivedIntervalIndex = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124
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 * Intervals sorted by {@link Interval#from()}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 Interval[] sortedIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
131 * 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
132 * 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
133 * array.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 LIRInstruction[] opIdToInstructionMap;
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 {@linkplain Block block}
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
139 * containing the instruction. Entries should be retrieved with {@link #blockForId(int)} as the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
140 * 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
141 */
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
142 Block[] opIdToBlockMap;
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 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 * Bit set for each variable that is contained in each loop.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 BitMap2D intervalInLoop;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
149 /**
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
150 * The variable operands allocated from this pool. The {@linkplain #operandNumber(Value) number}
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
151 * of the first variable operand in this pool is one greater than the number of the last
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
152 * register operand in the pool.
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 ArrayList<Variable> variables;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
155
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
156 /**
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5552
diff changeset
157 * The {@linkplain #operandNumber(Value) number} of the first variable operand allocated.
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
158 */
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
159 private final int firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
160
9614
59ec6eb8612e removed LinearScan.method field
Doug Simon <doug.simon@oracle.com>
parents: 9454
diff changeset
161 public LinearScan(TargetDescription target, LIR ir, LIRGenerator gen, FrameMap frameMap) {
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4262
diff changeset
162 this.target = target;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 this.ir = ir;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 this.gen = gen;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165 this.frameMap = frameMap;
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
166 this.sortedBlocks = ir.linearScanOrder();
4265
4643ccd37dac * removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents: 4262
diff changeset
167 this.registerAttributes = frameMap.registerConfig.getAttributesMap();
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
168
6582
cc32ce37eddc deleted Architecture.twoOperandMode() and encapsulated all public fields in Architecture with getters
Doug Simon <doug.simon@oracle.com>
parents: 6581
diff changeset
169 this.registers = target.arch.getRegisters();
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
170 this.firstVariableNumber = registers.length;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
171 this.variables = new ArrayList<>(ir.numVariables() * 3 / 2);
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
172 this.blockData = new BlockMap<>(ir.cfg);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174
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
175 public int getFirstLirInstructionId(Block block) {
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
176 int result = ir.lir(block).get(0).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
177 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
178 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
179 }
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 public int getLastLirInstructionId(Block block) {
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
182 List<LIRInstruction> instructions = ir.lir(block);
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
183 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
184 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
185 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
186 }
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
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
188 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
189 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
190 }
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
191
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
193 * 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
194 * 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
195 * by this allocator.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 */
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
197 private int operandNumber(Value operand) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
198 if (isRegister(operand)) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
199 int number = asRegister(operand).number;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
200 assert number < firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
201 return number;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
202 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
203 assert isVariable(operand) : operand;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
204 return firstVariableNumber + ((Variable) operand).index;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
207 /**
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
208 * Gets the operand denoted by a given operand number.
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
209 */
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
210 private AllocatableValue operandFor(int operandNumber) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
211 if (operandNumber < firstVariableNumber) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
212 assert operandNumber >= 0;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
213 return registers[operandNumber].asValue();
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
214 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
215 int index = operandNumber - firstVariableNumber;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
216 Variable variable = variables.get(index);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
217 assert variable.index == index;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
218 return variable;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
219 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
220
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
221 /**
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
222 * 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
223 */
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
224 private int operandSize() {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
225 return firstVariableNumber + ir.numVariables();
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
226 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
227
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
228 /**
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
229 * 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
230 */
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
231 public int maxRegisterNumber() {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
232 return firstVariableNumber - 1;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
233 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
234
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
235 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
236
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 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
239 return isRegister(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 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
244
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 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
247 return isVariable(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
251 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
252
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 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
255 return !isRegister(i.operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
260 * 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
261 * configuration.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 */
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
263 RegisterAttributes attributes(Register reg) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 return registerAttributes[reg.number];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 void assignSpillSlot(Interval interval) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 // assign the canonical spill slot of the parent (if a part of the interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 // is already spilled) or allocate a new spill slot
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
270 if (interval.canMaterialize()) {
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
271 interval.assignLocation(Value.ILLEGAL);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
272 } else if (interval.spillSlot() != null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 interval.assignLocation(interval.spillSlot());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274 } else {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
275 StackSlot slot = frameMap.allocateSpillSlot(interval.kind());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276 interval.setSpillSlot(slot);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 interval.assignLocation(slot);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 * Creates a new interval.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
283 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 * @param operand the operand for the interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 * @return the created interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 */
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
287 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
288 assert isLegal(operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 int operandNumber = operandNumber(operand);
4352
5a84f5548fc4 More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4350
diff changeset
290 Interval interval = new Interval(operand, operandNumber);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291 assert operandNumber < intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 assert intervals[operandNumber] == null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 intervals[operandNumber] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 return interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298 * Creates an interval as a result of splitting or spilling another interval.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
299 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 * @param source an interval being split of spilled
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 * @return a new interval derived from {@code source}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 Interval createDerivedInterval(Interval source) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 if (firstDerivedIntervalIndex == -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 firstDerivedIntervalIndex = intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 if (intervalsSize == intervals.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 intervals = Arrays.copyOf(intervals, intervals.length * 2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 intervalsSize++;
9425
3ec29630cfb4 Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents: 9422
diff changeset
311 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
312 assert variables.size() == variable.index;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
313 variables.add(variable);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
314
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
315 Interval interval = createInterval(variable);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 assert intervals[intervalsSize - 1] == interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 return interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 // 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
321 int blockCount() {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
322 return sortedBlocks.size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
325 Block blockAt(int index) {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
326 return sortedBlocks.get(index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327 }
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
330 * 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
331 * 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
332 * {@linkplain #createDerivedInterval(Interval) derived intervals}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 int liveSetSize() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
335 return firstDerivedIntervalIndex == -1 ? operandSize() : firstDerivedIntervalIndex;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 int numLoops() {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
339 return ir.cfg.getLoops().length;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 boolean isIntervalInLoop(int interval, int loop) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 return intervalInLoop.at(interval, loop);
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
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
346 Interval intervalFor(Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 int operandNumber = operandNumber(operand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 assert operandNumber < intervalsSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 return intervals[operandNumber];
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
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
352 Interval getOrCreateInterval(AllocatableValue operand) {
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
353 Interval ret = intervalFor(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
354 if (ret == null) {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
355 return createInterval(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
356 } else {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
357 return ret;
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
358 }
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
359 }
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
360
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
361 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
362 * 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
363 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 int maxOpId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 assert opIdToInstructionMap.length > 0 : "no operations";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 return (opIdToInstructionMap.length - 1) << 1;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
370 * Converts an {@linkplain LIRInstruction#id instruction id} to an instruction index. All LIR
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
371 * instructions in a method have an index one greater than their linear-scan order predecesor
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 * 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
373 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 static int opIdToIndex(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 return opId >> 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 * Retrieves the {@link LIRInstruction} based on its {@linkplain LIRInstruction#id id}.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
380 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 * @param opId an instruction {@linkplain LIRInstruction#id id}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382 * @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
383 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 LIRInstruction instructionForId(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 assert isEven(opId) : "opId not even";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 LIRInstruction instr = opIdToInstructionMap[opIdToIndex(opId)];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 assert instr.id() == opId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 return instr;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 * Gets the block containing a given instruction.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
393 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 * @param opId an instruction {@linkplain LIRInstruction#id id}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 * @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
396 */
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
397 Block blockForId(int opId) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 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
399 return opIdToBlockMap[opIdToIndex(opId)];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402 boolean isBlockBegin(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 return opId == 0 || blockForId(opId) != blockForId(opId - 1);
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 boolean coversBlockBegin(int opId1, int opId2) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 return blockForId(opId1) != blockForId(opId2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 * Determines if an {@link LIRInstruction} destroys all caller saved registers.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
412 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 * @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
414 * @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
415 * registers.
3733
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 boolean hasCall(int opId) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 assert isEven(opId) : "opId not even";
9454
85a836bcd796 renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents: 9425
diff changeset
419 return instructionForId(opId).destroysCallerSavedRegisters();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 * Eliminates moves from register to stack if the stack slot is known to be correct.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 void changeSpillDefinitionPos(Interval interval, int defPos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 assert interval.isSplitParent() : "can only be called for split parents";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 switch (interval.spillState()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 case NoDefinitionFound:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 assert interval.spillDefinitionPos() == -1 : "must no be set before";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431 interval.setSpillDefinitionPos(defPos);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 interval.setSpillState(SpillState.NoSpillStore);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 case NoSpillStore:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 assert defPos <= interval.spillDefinitionPos() : "positions are processed in reverse order when intervals are created";
6462
b3f5dc099f9d removed XIR
Doug Simon <doug.simon@oracle.com>
parents: 6411
diff changeset
437 if (defPos < interval.spillDefinitionPos() - 2) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 // second definition found, so no spill optimization possible for this interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 interval.setSpillState(SpillState.NoOptimization);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 // two consecutive definitions (because of two-operand LIR form)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 assert blockForId(defPos) == blockForId(interval.spillDefinitionPos()) : "block must be equal";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 case NoOptimization:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447 // nothing to do
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 default:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
451 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
452 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 // called during register allocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 void changeSpillState(Interval interval, int spillPos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 switch (interval.spillState()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 case NoSpillStore: {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
459 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
460 int spillLoopDepth = blockForId(spillPos).getLoopDepth();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 if (defLoopDepth < spillLoopDepth) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463 // the loop depth of the spilling position is higher then the loop depth
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 // at the definition of the interval . move write to memory out of loop
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 // by storing at definitin of the interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 interval.setSpillState(SpillState.StoreAtDefinition);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 // the interval is currently spilled only once, so for now there is no
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469 // reason to store the interval at the definition
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 interval.setSpillState(SpillState.OneSpillStore);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 }
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 case OneSpillStore: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 // the interval is spilled more then once, so it is better to store it to
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 // memory at the definition
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 interval.setSpillState(SpillState.StoreAtDefinition);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 case StoreAtDefinition:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 case StartInMemory:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 case NoOptimization:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 case NoDefinitionFound:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486 // nothing to do
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 break;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489 default:
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
490 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
491 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 abstract static class IntervalPredicate {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
495
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 abstract boolean apply(Interval i);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 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
500
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
502 public boolean apply(Interval i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 return i.isSplitParent() && i.spillState() == SpillState.StoreAtDefinition;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 // called once before assignment of register numbers
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 void eliminateSpillMoves() {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
509 Indent indent = Debug.logAndIndent("Eliminating unnecessary spill moves");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
511 // collect all intervals that must be stored after their definition.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 // the list is sorted by Interval.spillDefinitionPos
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 Interval interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 interval = createUnhandledLists(mustStoreAtDefinition, null).first;
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
515 if (DetailedAsserts.getValue()) {
12726
a95336e46474 made LinearScan.checkIntervals non-static
Doug Simon <doug.simon@oracle.com>
parents: 12683
diff changeset
516 checkIntervals(interval);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519 LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer();
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
520 for (Block block : sortedBlocks) {
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
521 List<LIRInstruction> instructions = ir.lir(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 int numInst = instructions.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 // iterate all instructions of the block. skip the first because it is always a label
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 for (int j = 1; j < numInst; j++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 LIRInstruction op = instructions.get(j);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 int opId = op.id();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 if (opId == -1) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
530 MoveOp move = (MoveOp) op;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
531 // remove move from register to stack if the stack slot is guaranteed to be
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
532 // correct.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 // only moves that have been inserted by LinearScan can be removed.
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
534 assert isVariable(move.getResult()) : "LinearScan inserts only moves to variables";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
536 Interval curInterval = intervalFor(move.getResult());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
537
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
538 if (!isRegister(curInterval.location()) && curInterval.alwaysInMemory()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
539 // move target is a stack slot that is always correct, so eliminate
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
540 // instruction
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
541 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
542 Debug.log("eliminating move from interval %d to %d", operandNumber(move.getInput()), operandNumber(move.getResult()));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
543 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 instructions.set(j, null); // null-instructions are deleted by assignRegNum
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
545 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 // insert move from register to stack just after the beginning of the interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 assert interval == Interval.EndMarker || interval.spillDefinitionPos() >= opId : "invalid order";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550 assert interval == Interval.EndMarker || (interval.isSplitParent() && interval.spillState() == SpillState.StoreAtDefinition) : "invalid interval";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 while (interval != Interval.EndMarker && interval.spillDefinitionPos() == opId) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
553 if (!interval.canMaterialize()) {
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
554 if (!insertionBuffer.initialized()) {
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
555 // prepare insertion buffer (appended when all instructions of the
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
556 // block are processed)
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
557 insertionBuffer.init(instructions);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
558 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
560 AllocatableValue fromLocation = interval.location();
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
561 AllocatableValue toLocation = canonicalSpillOpr(interval);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
563 assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState();
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
564 assert isStackSlot(toLocation) : "to operand must be a stack slot";
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
565
14057
38c881305352 Move functionality of SpillMoveFactory to FrameMap.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13842
diff changeset
566 insertionBuffer.append(j + 1, frameMap.createSpillMove(toLocation, fromLocation));
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
567
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
568 Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
569 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
570 interval = interval.next;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
571 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
573 } // end of instruction iteration
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
574
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
575 if (insertionBuffer.initialized()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
576 insertionBuffer.finish();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
578 } // end of block iteration
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
579
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
580 assert interval == Interval.EndMarker : "missed an interval";
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
581 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
582 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
583
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
584 private static void checkIntervals(Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
585 Interval prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
586 Interval temp = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
587 while (temp != Interval.EndMarker) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
588 assert temp.spillDefinitionPos() > 0 : "invalid spill definition pos";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 if (prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 assert temp.from() >= prev.from() : "intervals not sorted";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
591 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
592 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
594 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
595 assert temp.spillDefinitionPos() >= temp.from() : "invalid order";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 assert temp.spillDefinitionPos() <= temp.from() + 2 : "only intervals defined once at their start-pos can be optimized";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
597
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
598 Debug.log("interval %d (from %d to %d) must be stored at %d", temp.operandNumber, temp.from(), temp.to(), temp.spillDefinitionPos());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
599
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
600 prev = temp;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
601 temp = temp.next;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
602 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
605 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
606 * Numbers all instructions in all blocks. The numbering follows the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
607 * {@linkplain ComputeBlockOrder linear scan order}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 void numberInstructions() {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
610 ValueProcedure setVariableProc = new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
611
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
612 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
613 public Value doValue(Value value) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
614 if (isVariable(value)) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
615 int variableIdx = asVariable(value).index;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
616 while (variables.size() <= variableIdx) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
617 variables.add(null);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
618 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
619 variables.set(variableIdx, asVariable(value));
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
620 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
621 return value;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
622 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
623 };
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
624
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
625 // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
626 int numInstructions = 0;
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
627 for (Block block : sortedBlocks) {
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
628 numInstructions += ir.lir(block).size();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
629 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
630
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
631 // initialize with correct length
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
632 opIdToInstructionMap = new LIRInstruction[numInstructions];
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
633 opIdToBlockMap = new Block[numInstructions];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
634
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
635 int opId = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636 int index = 0;
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
637 for (Block block : sortedBlocks) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
638 blockData.put(block, new BlockData());
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
639
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
640 List<LIRInstruction> instructions = ir.lir(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
641
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
642 int numInst = instructions.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
643 for (int j = 0; j < numInst; j++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
644 LIRInstruction op = instructions.get(j);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
645 op.setId(opId);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
646
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
647 opIdToInstructionMap[index] = op;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
648 opIdToBlockMap[index] = block;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
649 assert instructionForId(opId) == op : "must match";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
650
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
651 op.forEachTemp(setVariableProc);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
652 op.forEachOutput(setVariableProc);
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
653
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
655 opId += 2; // numbering of lirOps by two
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
658 assert index == numInstructions : "must match";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659 assert (index << 1) == opId : "must match: " + (index << 1);
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
660
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
661 if (DetailedAsserts.getValue()) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
662 for (int i = 0; i < variables.size(); i++) {
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
663 assert variables.get(i) != null && variables.get(i).index == i;
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
664 }
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
665 assert variables.size() == ir.numVariables();
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
666 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
667 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
668
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
670 * Computes local live sets (i.e. {@link BlockData#liveGen} and {@link BlockData#liveKill})
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
671 * separately for each block.
3733
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 void computeLocalLiveSets() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
674 int liveSize = liveSetSize();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
675
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
676 intervalInLoop = new BitMap2D(operandSize(), numLoops());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
677
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
678 // iterate all blocks
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
679 for (final Block block : sortedBlocks) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
680 Indent indent = Debug.logAndIndent("compute local live sets for block %d", block.getId());
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
681
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
682 final BitSet liveGen = new BitSet(liveSize);
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
683 final BitSet liveKill = new BitSet(liveSize);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684
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
685 List<LIRInstruction> instructions = ir.lir(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686 int numInst = instructions.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
687
11537
7ce08e264abf Fixed registers that flow into a block need to be inputs of the LabelOp, otherwise the register allocator can insert spill moves before the definition of a fixed register.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10961
diff changeset
688 // iterate all instructions of the block
7ce08e264abf Fixed registers that flow into a block need to be inputs of the LabelOp, otherwise the register allocator can insert spill moves before the definition of a fixed register.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10961
diff changeset
689 for (int j = 0; j < numInst; j++) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
690 final LIRInstruction op = instructions.get(j);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
691
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
692 ValueProcedure useProc = new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
693
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
694 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
695 protected Value doValue(Value operand) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
696 if (isVariable(operand)) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
697 int operandNum = operandNumber(operand);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
698 if (!liveKill.get(operandNum)) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
699 liveGen.set(operandNum);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
700 Debug.log("liveGen for operand %d", operandNum);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
701 }
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
702 if (block.getLoop() != null) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
703 intervalInLoop.setBit(operandNum, block.getLoop().index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
706
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
707 if (DetailedAsserts.getValue()) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
708 verifyInput(block, liveKill, operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
710 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
711 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
712 };
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
713 ValueProcedure stateProc = new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
714
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
715 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
716 public Value doValue(Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 int operandNum = operandNumber(operand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
718 if (!liveKill.get(operandNum)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
719 liveGen.set(operandNum);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
720 Debug.log("liveGen in state for operand %d", operandNum);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
721 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
722 return operand;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
723 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
724 };
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
725 ValueProcedure defProc = new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
726
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
727 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
728 public Value doValue(Value operand) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
729 if (isVariable(operand)) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
730 int varNum = operandNumber(operand);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
731 liveKill.set(varNum);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
732 Debug.log("liveKill for operand %d", varNum);
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
733 if (block.getLoop() != null) {
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
734 intervalInLoop.setBit(varNum, block.getLoop().index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
736 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
737
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
738 if (DetailedAsserts.getValue()) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
739 // fixed intervals are never live at block boundaries, so
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
740 // they need not be processed in live sets
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
741 // process them only in debug mode so that this can be checked
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
742 verifyTemp(liveKill, operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
743 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
744 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
745 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
746 };
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747
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
748 try (Indent indent2 = Debug.logAndIndent("handle op %d", 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
749 op.forEachInput(useProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
750 op.forEachAlive(useProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
751 // Add uses of live locals from interpreter's point of view for proper debug
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
752 // information generation
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
753 op.forEachState(stateProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
754 op.forEachTemp(defProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
755 op.forEachOutput(defProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
756 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
757 } // end of instruction iteration
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
759 BlockData blockSets = blockData.get(block);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
760 blockSets.liveGen = liveGen;
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
761 blockSets.liveKill = liveKill;
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
762 blockSets.liveIn = new BitSet(liveSize);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
763 blockSets.liveOut = new BitSet(liveSize);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
764
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
765 Debug.log("liveGen B%d %s", block.getId(), blockSets.liveGen);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
766 Debug.log("liveKill B%d %s", block.getId(), blockSets.liveKill);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
767
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
768 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
769 } // end of block iteration
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
771
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
772 private void verifyTemp(BitSet liveKill, Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773 // fixed intervals are never live at block boundaries, so
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
774 // they need not be processed in live sets
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
775 // process them only in debug mode so that this can be checked
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
776 if (isRegister(operand)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
777 if (isProcessed(operand)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
778 liveKill.set(operandNumber(operand));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
779 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
780 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
781 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
782
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
783 private void verifyInput(Block block, BitSet liveKill, Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
784 // fixed intervals are never live at block boundaries, so
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 // they need not be processed in live sets.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
786 // this is checked by these assertions to be sure about it.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787 // the entry block may have incoming
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
788 // values in registers, which is ok.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
789 if (isRegister(operand) && block != ir.cfg.getStartBlock()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
790 if (isProcessed(operand)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
791 assert liveKill.get(operandNumber(operand)) : "using fixed register that is not defined in this block";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
792 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
794 }
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
797 * Performs a backward dataflow analysis to compute global live sets (i.e.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
798 * {@link BlockData#liveIn} and {@link BlockData#liveOut}) for each block.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
799 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800 void computeGlobalLiveSets() {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
801 Indent indent = Debug.logAndIndent("compute global live sets");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 int numBlocks = blockCount();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803 boolean changeOccurred;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804 boolean changeOccurredInBlock;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805 int iterationCount = 0;
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
806 BitSet liveOut = new BitSet(liveSetSize()); // scratch set for calculations
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808 // Perform a backward dataflow analysis to compute liveOut and liveIn for each block.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 // The loop is executed until a fixpoint is reached (no changes in an iteration)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
810 do {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
811 changeOccurred = false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812
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
813 Indent indent2 = Debug.logAndIndent("new iteration %d", iterationCount);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
814
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
815 // iterate all blocks in reverse order
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
816 for (int i = numBlocks - 1; i >= 0; i--) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
817 Block block = blockAt(i);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
818 BlockData blockSets = blockData.get(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
819
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
820 changeOccurredInBlock = false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
821
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
822 // liveOut(block) is the union of liveIn(sux), for successors sux of block
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
823 int n = block.getSuccessorCount();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
824 if (n > 0) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
825 // block has successors
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
826 if (n > 0) {
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
827 liveOut.clear();
7498
600f7bad141c Small clean up of the Block class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7497
diff changeset
828 for (Block successor : block.getSuccessors()) {
600f7bad141c Small clean up of the Block class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7497
diff changeset
829 liveOut.or(blockData.get(successor).liveIn);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
830 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
831 } else {
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
832 liveOut.clear();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
833 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
834
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
835 if (!blockSets.liveOut.equals(liveOut)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
836 // A change occurred. Swap the old and new live out sets to avoid copying.
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
837 BitSet temp = blockSets.liveOut;
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
838 blockSets.liveOut = liveOut;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
839 liveOut = temp;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
840
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
841 changeOccurred = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
842 changeOccurredInBlock = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
843 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
844 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
845
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
846 if (iterationCount == 0 || changeOccurredInBlock) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
847 // liveIn(block) is the union of liveGen(block) with (liveOut(block) &
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
848 // !liveKill(block))
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
849 // note: liveIn has to be computed only in first iteration or if liveOut has
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
850 // changed!
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
851 BitSet liveIn = blockSets.liveIn;
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
852 liveIn.clear();
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
853 liveIn.or(blockSets.liveOut);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
854 liveIn.andNot(blockSets.liveKill);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
855 liveIn.or(blockSets.liveGen);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
856
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
857 Debug.log("block %d: livein = %s, liveout = %s", block.getId(), liveIn, blockSets.liveOut);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
858 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
859 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860 iterationCount++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
862 if (changeOccurred && iterationCount > 50) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
863 throw new BailoutException("too many iterations in computeGlobalLiveSets");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
865 indent2.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 } while (changeOccurred);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
867
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
868 if (DetailedAsserts.getValue()) {
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
869 verifyLiveness();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
870 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
871
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
872 // check that the liveIn set of the first block is empty
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
873 Block startBlock = ir.cfg.getStartBlock();
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
874 if (blockData.get(startBlock).liveIn.cardinality() != 0) {
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
875 if (DetailedAsserts.getValue()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
876 reportFailure(numBlocks);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
877 }
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
878 // bailout if this occurs in product mode.
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
879 throw new GraalInternalError("liveIn set of first block must be empty: " + blockData.get(startBlock).liveIn);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
880 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
881 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
882 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
883
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
884 private void reportFailure(int numBlocks) {
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
885 Indent indent = Debug.logAndIndent("report failure, graph: %s", gen.getGraph());
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
886
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
887 BitSet startBlockLiveIn = blockData.get(ir.cfg.getStartBlock()).liveIn;
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
888 try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
889 for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 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
890 Value operand = operandFor(operandNum);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
891 Debug.log("var %d; operand=%s; node=%s", operandNum, operand, gen.valueForOperand(operand));
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
892 }
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
893 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
894
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
895 // print some additional information to simplify debugging
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
896 for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
897 Value operand = operandFor(operandNum);
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
898 final Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, gen.valueForOperand(operand));
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
899
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
900 Deque<Block> definedIn = new ArrayDeque<>();
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
901 HashSet<Block> usedIn = new HashSet<>();
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
902 for (Block block : sortedBlocks) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
903 if (blockData.get(block).liveGen.get(operandNum)) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
904 usedIn.add(block);
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
905 try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) {
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 for (LIRInstruction ins : ir.lir(block)) {
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 try (Indent indent4 = Debug.logAndIndent("%d: %s", ins.id(), ins)) {
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 ins.forEachState(new ValueProcedure() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
909
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
910 @Override
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 public Value doValue(Value liveStateOperand) {
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 Debug.log("operand=%s", liveStateOperand);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
913 return liveStateOperand;
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 }
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 });
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
916 }
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
917 }
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
918 }
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
919 }
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
920 if (blockData.get(block).liveKill.get(operandNum)) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
921 definedIn.add(block);
13467
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
922 try (Indent indent3 = Debug.logAndIndent("defined in block B%d", block.getId())) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
923 for (LIRInstruction ins : ir.lir(block)) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
924 Debug.log("%d: %s", ins.id(), ins);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
925 }
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
926 }
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
927 }
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
928 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
929
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
930 int[] hitCount = new int[numBlocks];
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
931
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
932 while (!definedIn.isEmpty()) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
933 Block block = definedIn.removeFirst();
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
934 usedIn.remove(block);
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
935 for (Block successor : block.getSuccessors()) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
936 if (successor.isLoopHeader()) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
937 if (!block.isLoopEnd()) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
938 definedIn.add(successor);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 }
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
940 } else {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
941 if (++hitCount[successor.getId()] == successor.getPredecessorCount()) {
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
942 definedIn.add(successor);
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
946 }
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
947 try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
948 for (Block block : usedIn) {
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 Debug.log("B%d", block.getId());
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 }
12569
1c8d5a0891b5 improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
951 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
952 indent2.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
953 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
954 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
955 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
956
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
957 private void verifyLiveness() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
958 // check that fixed intervals are not live at block boundaries
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
959 // (live set must be empty at fixed intervals)
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
960 for (Block block : sortedBlocks) {
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
961 for (int j = 0; j <= maxRegisterNumber(); j++) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
962 assert !blockData.get(block).liveIn.get(j) : "liveIn set of fixed register must be empty";
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
963 assert !blockData.get(block).liveOut.get(j) : "liveOut set of fixed register must be empty";
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
964 assert !blockData.get(block).liveGen.get(j) : "liveGen set of fixed register must be empty";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
965 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
966 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
967 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
968
9422
149fe42411df Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
969 void addUse(AllocatableValue operand, int from, int to, RegisterPriority registerPriority, PlatformKind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
970 if (!isProcessed(operand)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
971 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
972 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
973
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
974 Interval interval = getOrCreateInterval(operand);
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5539
diff changeset
975 if (kind != Kind.Illegal) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
976 interval.setKind(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
977 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
978
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
979 interval.addRange(from, to);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
980
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
981 // Register use position at even instruction id.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
982 interval.addUsePos(to & ~1, registerPriority);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
983
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
984 Debug.log("add use: %s, from %d to %d (%s)", interval, from, to, registerPriority.name());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
985 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
986
9422
149fe42411df Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
987 void addTemp(AllocatableValue operand, int tempPos, RegisterPriority registerPriority, PlatformKind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
988 if (!isProcessed(operand)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
989 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
990 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
991
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
992 Interval interval = getOrCreateInterval(operand);
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5539
diff changeset
993 if (kind != Kind.Illegal) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
994 interval.setKind(kind);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
995 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
996
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
997 interval.addRange(tempPos, tempPos + 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
998 interval.addUsePos(tempPos, registerPriority);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
999 interval.addMaterializationValue(null);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1000
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1001 Debug.log("add temp: %s tempPos %d (%s)", interval, tempPos, RegisterPriority.MustHaveRegister.name());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1002 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1003
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1004 boolean isProcessed(Value operand) {
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
1005 return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1006 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1007
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1008 void addDef(AllocatableValue operand, LIRInstruction op, RegisterPriority registerPriority, PlatformKind kind) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1009 if (!isProcessed(operand)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1010 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1011 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1012 int defPos = op.id();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1013
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1014 Interval interval = getOrCreateInterval(operand);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1015 if (kind != Kind.Illegal) {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1016 interval.setKind(kind);
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1017 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1018
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1019 Range r = interval.first();
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1020 if (r.from <= defPos) {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1021 // Update the starting point (when a range is first created for a use, its
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1022 // start is the beginning of the current block until a def is encountered.)
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1023 r.from = defPos;
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1024 interval.addUsePos(defPos, registerPriority);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1025
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1026 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1027 // Dead value - make vacuous interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1028 // also add register priority for dead intervals
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1029 interval.addRange(defPos, defPos + 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1030 interval.addUsePos(defPos, registerPriority);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1031 Debug.log("Warning: def of operand %s at %d occurs without use", operand, defPos);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1033
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1034 changeSpillDefinitionPos(interval, defPos);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1035 if (registerPriority == RegisterPriority.None && interval.spillState().ordinal() <= SpillState.StartInMemory.ordinal()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 // detection of method-parameters and roundfp-results
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1037 interval.setSpillState(SpillState.StartInMemory);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1038 }
13610
6537a75007e3 consider register priority in rematerialization decision
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13546
diff changeset
1039 interval.addMaterializationValue(gen.getMaterializedValue(op, operand, interval));
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1040
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1041 Debug.log("add def: %s defPos %d (%s)", interval, defPos, registerPriority.name());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1042 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1043
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1044 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1045 * Determines the register priority for an instruction's output/result operand.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1046 */
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
1047 static RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1048 if (op instanceof MoveOp) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1049 MoveOp move = (MoveOp) op;
8353
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
1050 if (optimizeMethodArgument(move.getInput())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1051 return RegisterPriority.None;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1052 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1053 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1054
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1055 // all other operands require a register
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1056 return RegisterPriority.MustHaveRegister;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1057 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1058
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1059 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1060 * Determines the priority which with an instruction's input operand will be allocated a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1061 * register.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1062 */
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1063 static RegisterPriority registerPriorityOfInputOperand(EnumSet<OperandFlag> flags) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1064 if (flags.contains(OperandFlag.STACK)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1065 return RegisterPriority.ShouldHaveRegister;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1066 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1067 // all other operands require a register
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1068 return RegisterPriority.MustHaveRegister;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1069 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1070
8353
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
1071 private static boolean optimizeMethodArgument(Value value) {
8402
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
1072 /*
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
1073 * Object method arguments that are passed on the stack are currently not optimized because
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
1074 * this requires that the runtime visits method arguments during stack walking.
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
1075 */
c0db24536e97 Remove flag and optimization for object method arguments in the register allocator. Needs more investigation of GC impact on HotSpot
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8353
diff changeset
1076 return isStackSlot(value) && asStackSlot(value).isInCallerFrame() && value.getKind() != Kind.Object;
8353
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
1077 }
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
1078
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1079 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1080 * Optimizes moves related to incoming stack based arguments. The interval for the destination
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1081 * of such moves is assigned the stack slot (which is in the caller's frame) as its spill slot.
3733
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 void handleMethodArguments(LIRInstruction op) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1084 if (op instanceof MoveOp) {
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1085 MoveOp move = (MoveOp) op;
8353
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
1086 if (optimizeMethodArgument(move.getInput())) {
98b90a7bb764 Only stack slots in caller frame are method arguments. Also optimize object arguments when the runtime supports it.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 8222
diff changeset
1087 StackSlot slot = asStackSlot(move.getInput());
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
1088 if (DetailedAsserts.getValue()) {
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1089 assert op.id() > 0 : "invalid id";
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1090 assert blockForId(op.id()).getPredecessorCount() == 0 : "move from stack must be in first block";
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1091 assert isVariable(move.getResult()) : "result of move must be a variable";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1092
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
1093 Debug.log("found move from stack slot %s to %s", slot, move.getResult());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1094 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1095
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1096 Interval interval = intervalFor(move.getResult());
4213
e4cfa571d8c4 Do not emit stack-to-stack moves.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4207
diff changeset
1097 interval.setSpillSlot(slot);
e4cfa571d8c4 Do not emit stack-to-stack moves.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4207
diff changeset
1098 interval.assignLocation(slot);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1099 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1100 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1101 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1102
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1103 void addRegisterHint(final LIRInstruction op, final Value targetValue, OperandMode mode, EnumSet<OperandFlag> flags, final boolean hintAtDef) {
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1104 if (flags.contains(OperandFlag.HINT) && isVariableOrRegister(targetValue)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1105
4262
744dade427b8 another batch of work towards GraalCompilation removal:
Lukas Stadler <lukas.stadler@jku.at>
parents: 4260
diff changeset
1106 op.forEachRegisterHint(targetValue, mode, new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1107
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1108 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1109 protected Value doValue(Value registerHint) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1110 if (isVariableOrRegister(registerHint)) {
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
1111 Interval from = getOrCreateInterval((AllocatableValue) registerHint);
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
1112 Interval to = getOrCreateInterval((AllocatableValue) targetValue);
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1113
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1114 // hints always point from def to use
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1115 if (hintAtDef) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1116 to.setLocationHint(from);
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1117 } else {
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1118 from.setLocationHint(to);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1119 }
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
1120 Debug.log("operation at opId %d: added hint from interval %d to %d", op.id(), from.operandNumber, to.operandNumber);
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1121
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1122 return registerHint;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1123 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1124 return null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1125 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1126 });
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1127 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1128 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1129
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1130 void buildIntervals() {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1131
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1132 Indent indent = Debug.logAndIndent("build intervals");
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1133
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
1134 intervalsSize = operandSize();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1135 intervals = new Interval[intervalsSize + INITIAL_SPLIT_INTERVALS_CAPACITY];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1136
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1137 // create a list with all caller-save registers (cpu, fpu, xmm)
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
1138 Register[] callerSaveRegs = frameMap.registerConfig.getCallerSaveRegisters();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1139
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1140 // iterate all blocks in reverse order
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1141 for (int i = blockCount() - 1; i >= 0; i--) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1142
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1143 Block 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
1144 Indent indent2 = Debug.logAndIndent("handle block %d", block.getId());
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1145
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
1146 List<LIRInstruction> instructions = ir.lir(block);
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
1147 final int blockFrom = getFirstLirInstructionId(block);
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
1148 int blockTo = getLastLirInstructionId(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1149
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1150 assert blockFrom == instructions.get(0).id();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1151 assert blockTo == instructions.get(instructions.size() - 1).id();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1152
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1153 // Update intervals for operands live at the end of this block;
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
1154 BitSet live = blockData.get(block).liveOut;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1155 for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1156 assert live.get(operandNum) : "should not stop here otherwise";
9297
a5f2b9012865 Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents: 8402
diff changeset
1157 AllocatableValue operand = operandFor(operandNum);
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
1158 Debug.log("live in %d: %s", operandNum, operand);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1159
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5539
diff changeset
1160 addUse(operand, blockFrom, blockTo + 2, RegisterPriority.None, Kind.Illegal);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1161
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1162 // add special use positions for loop-end blocks when the
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1163 // interval is used anywhere inside this loop. It's possible
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1164 // that the block was part of a non-natural loop, so it might
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1165 // have an invalid loop index.
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1166 if (block.isLoopEnd() && block.getLoop() != null && isIntervalInLoop(operandNum, block.getLoop().index)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1167 intervalFor(operand).addUsePos(blockTo + 1, RegisterPriority.LiveAtLoopEnd);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1168 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1169 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1170
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1171 // iterate all instructions of the block in reverse order.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1172 // definitions of intervals are processed before uses
11537
7ce08e264abf Fixed registers that flow into a block need to be inputs of the LabelOp, otherwise the register allocator can insert spill moves before the definition of a fixed register.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 10961
diff changeset
1173 for (int j = instructions.size() - 1; j >= 0; j--) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1174 final LIRInstruction op = instructions.get(j);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1175 final int opId = op.id();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1176
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
1177 Indent indent3 = Debug.logAndIndent("handle inst %d: %s", opId, op);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1178
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1179 // add a temp range for each register if operation destroys caller-save registers
9454
85a836bcd796 renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents: 9425
diff changeset
1180 if (op.destroysCallerSavedRegisters()) {
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
1181 for (Register r : callerSaveRegs) {
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
1182 if (attributes(r).isAllocatable()) {
5540
a891c53a295b Renaming RiKind => Kind.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5539
diff changeset
1183 addTemp(r.asValue(), opId, RegisterPriority.None, Kind.Illegal);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1184 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1185 }
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
1186 Debug.log("operation destroys all caller-save registers");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1187 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1188
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1189 op.forEachOutput(new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1190
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1191 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1192 public Value doValue(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
1193 if (isVariableOrRegister(operand)) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1194 addDef((AllocatableValue) operand, op, registerPriorityOfOutputOperand(op), operand.getPlatformKind());
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1195 addRegisterHint(op, operand, mode, flags, true);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1196 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1197 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1198 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1199 });
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1200 op.forEachTemp(new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1201
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1202 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1203 public Value doValue(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
1204 if (isVariableOrRegister(operand)) {
9422
149fe42411df Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
1205 addTemp((AllocatableValue) operand, opId, RegisterPriority.MustHaveRegister, operand.getPlatformKind());
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1206 addRegisterHint(op, operand, mode, flags, false);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1207 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1208 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1209 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1210 });
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1211 op.forEachAlive(new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1212
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1213 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1214 public Value doValue(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
1215 if (isVariableOrRegister(operand)) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1216 RegisterPriority p = registerPriorityOfInputOperand(flags);
9422
149fe42411df Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
1217 addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getPlatformKind());
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1218 addRegisterHint(op, operand, mode, flags, false);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1219 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1220 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1221 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1222 });
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1223 op.forEachInput(new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1224
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1225 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1226 public Value doValue(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
1227 if (isVariableOrRegister(operand)) {
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1228 RegisterPriority p = registerPriorityOfInputOperand(flags);
9422
149fe42411df Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
1229 addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getPlatformKind());
8220
2c5df42999dd Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents: 7648
diff changeset
1230 addRegisterHint(op, operand, mode, flags, false);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1231 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1232 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1233 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1234 });
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1235
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1236 // Add uses of live locals from interpreter's point of view for proper
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1237 // debug information generation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1238 // Treat these operands as temp values (if the live range is extended
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1239 // to a call site, the value would be in a register at the call otherwise)
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1240 op.forEachState(new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1241
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1242 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1243 public Value doValue(Value operand) {
9422
149fe42411df Use platform specific kind in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 9297
diff changeset
1244 addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getPlatformKind());
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1245 return operand;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1246 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1247 });
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1248
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1249 // special steps for some instructions (especially moves)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1250 handleMethodArguments(op);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1251
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1252 indent3.outdent();
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1253
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1254 } // end of instruction iteration
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1255 indent2.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1256 } // end of block iteration
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1257
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1258 // add the range [0, 1] to all fixed intervals.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1259 // the register allocator need not handle unhandled fixed intervals
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1260 for (Interval interval : intervals) {
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
1261 if (interval != null && isRegister(interval.operand)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1262 interval.addRange(0, 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1263 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1264 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1265 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1266 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1267
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1268 // * Phase 5: actual register allocation
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1269
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1270 private static boolean isSorted(Interval[] intervals) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1271 int from = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1272 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1273 assert interval != null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1274 assert from <= interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1275 from = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1276 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1277 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1278 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1279
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
1280 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
1281 Interval newFirst = first;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1282 if (prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1283 prev.next = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1284 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1285 newFirst = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1286 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1287 return newFirst;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1288 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1289
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1290 Interval.Pair createUnhandledLists(IntervalPredicate isList1, IntervalPredicate isList2) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1291 assert isSorted(sortedIntervals) : "interval list is not sorted";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1292
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1293 Interval list1 = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1294 Interval list2 = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1295
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1296 Interval list1Prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1297 Interval list2Prev = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1298 Interval v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1299
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1300 int n = sortedIntervals.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1301 for (int i = 0; i < n; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1302 v = sortedIntervals[i];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1303 if (v == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1304 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1305 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1306
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1307 if (isList1.apply(v)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1308 list1 = addToList(list1, list1Prev, v);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1309 list1Prev = v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1310 } else if (isList2 == null || isList2.apply(v)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1311 list2 = addToList(list2, list2Prev, v);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1312 list2Prev = v;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1313 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1314 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1315
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1316 if (list1Prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1317 list1Prev.next = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1318 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1319 if (list2Prev != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1320 list2Prev.next = Interval.EndMarker;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1321 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1322
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1323 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
1324 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
1325
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1326 return new Interval.Pair(list1, list2);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1327 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1328
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1329 void sortIntervalsBeforeAllocation() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1330 int sortedLen = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1331 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1332 if (interval != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1333 sortedLen++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1334 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1335 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1336
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1337 Interval[] sortedList = new Interval[sortedLen];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1338 int sortedIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1339 int sortedFromMax = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1340
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1341 // 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
1342 // 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
1343 for (Interval interval : intervals) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1344 if (interval != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1345 int from = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1346
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1347 if (sortedFromMax <= from) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1348 sortedList[sortedIdx++] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1349 sortedFromMax = interval.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1350 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1351 // 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
1352 // so this interval must be sorted in manually
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1353 int j;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1354 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
1355 sortedList[j + 1] = sortedList[j];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1356 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1357 sortedList[j + 1] = interval;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1358 sortedIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1359 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1360 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1361 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1362 sortedIntervals = sortedList;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1363 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1364
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1365 void sortIntervalsAfterAllocation() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1366 if (firstDerivedIntervalIndex == -1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1367 // 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
1368 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1369 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1370
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1371 Interval[] oldList = sortedIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1372 Interval[] newList = Arrays.copyOfRange(intervals, firstDerivedIntervalIndex, intervalsSize);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1373 int oldLen = oldList.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1374 int newLen = newList.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1375
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1376 // conventional sort-algorithm for new intervals
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1377 Arrays.sort(newList, INTERVAL_COMPARATOR);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1378
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1379 // 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
1380 Interval[] combinedList = new Interval[oldLen + newLen];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1381 int oldIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1382 int newIdx = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1383
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1384 while (oldIdx + newIdx < combinedList.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1385 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
1386 combinedList[oldIdx + newIdx] = oldList[oldIdx];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1387 oldIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1388 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1389 combinedList[oldIdx + newIdx] = newList[newIdx];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1390 newIdx++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1391 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1392 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1393
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1394 sortedIntervals = combinedList;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1395 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1396
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1397 private static final Comparator<Interval> INTERVAL_COMPARATOR = new Comparator<Interval>() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1398
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1399 public int compare(Interval a, Interval b) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1400 if (a != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1401 if (b != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1402 return a.from() - b.from();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1403 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1404 return -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1405 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1406 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1407 if (b != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1408 return 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1409 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1410 return 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1411 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1412 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1413 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1414 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1415
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1416 public void allocateRegisters() {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1417 Indent indent = Debug.logAndIndent("allocate registers");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1418 Interval precoloredIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1419 Interval notPrecoloredIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1420
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1421 Interval.Pair result = createUnhandledLists(IS_PRECOLORED_INTERVAL, IS_VARIABLE_INTERVAL);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1422 precoloredIntervals = result.first;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1423 notPrecoloredIntervals = result.second;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1424
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1425 // allocate cpu registers
6581
2a456986716b removed Architecture.isX86() and Architecture.isSPARC()
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
1426 LinearScanWalker lsw = new LinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1427 lsw.walk();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1428 lsw.finishAllocation();
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1429 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1430 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1431
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1432 // * Phase 6: resolve data flow
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1433 // (insert moves at edges between blocks if intervals have been split)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1434
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1435 // 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
1436 // instead of returning null
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1437 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
1438 Interval result = interval.getSplitChildAtOpId(opId, mode, this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1439
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1440 if (result != null) {
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
1441 Debug.log("Split child at pos %d of interval %s is %s", opId, interval, result);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1442 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1443 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1444
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
1445 throw new BailoutException("LinearScan: interval is null");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1446 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1447
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1448 Interval intervalAtBlockBegin(Block block, Value 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
1449 assert isVariable(operand) : "register number out of bounds";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1450 assert intervalFor(operand) != null : "no interval found";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1451
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
1452 return splitChildAtOpId(intervalFor(operand), getFirstLirInstructionId(block), LIRInstruction.OperandMode.DEF);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1453 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1454
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1455 Interval intervalAtBlockEnd(Block block, Value 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
1456 assert isVariable(operand) : "register number out of bounds";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1457 assert intervalFor(operand) != null : "no interval found";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1458
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
1459 return splitChildAtOpId(intervalFor(operand), getLastLirInstructionId(block) + 1, LIRInstruction.OperandMode.DEF);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1460 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1461
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1462 Interval intervalAtOpId(Value operand, int opId) {
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
1463 assert isVariable(operand) : "register number out of bounds";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1464 assert intervalFor(operand) != null : "no interval found";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1465
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1466 return splitChildAtOpId(intervalFor(operand), opId, LIRInstruction.OperandMode.USE);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1467 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1468
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1469 void resolveCollectMappings(Block fromBlock, Block toBlock, MoveResolver moveResolver) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1470 assert moveResolver.checkEmpty();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1471
4206
430b5db3e6f8 Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4199
diff changeset
1472 int numOperands = operandSize();
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5540
diff changeset
1473 BitSet liveAtEdge = blockData.get(toBlock).liveIn;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1474
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1475 // visit all variables for which the liveAtEdge bit is set
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1476 for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 1)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1477 assert operandNum < numOperands : "live information set for not exisiting interval";
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1478 assert blockData.get(fromBlock).liveOut.get(operandNum) && blockData.get(toBlock).liveIn.get(operandNum) : "interval not live at this edge";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1479
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1480 Value liveOperand = operandFor(operandNum);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1481 Interval fromInterval = intervalAtBlockEnd(fromBlock, liveOperand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1482 Interval toInterval = intervalAtBlockBegin(toBlock, liveOperand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1483
9632
97db51025787 Value: use `equals()' instead of object equality
Bernhard Urban <bernhard.urban@jku.at>
parents: 9628
diff changeset
1484 if (fromInterval != toInterval && !fromInterval.location().equals(toInterval.location())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1485 // need to insert move instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1486 moveResolver.addMapping(fromInterval, toInterval);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1487 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1488 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1489 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1490
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
1491 void resolveFindInsertPos(Block fromBlock, Block toBlock, MoveResolver moveResolver) {
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1492 if (fromBlock.getSuccessorCount() <= 1) {
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
1493 Debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1494
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
1495 List<LIRInstruction> instructions = ir.lir(fromBlock);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1496 LIRInstruction instr = instructions.get(instructions.size() - 1);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1497 if (instr instanceof StandardOp.JumpOp) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1498 // insert moves before branch
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
1499 moveResolver.setInsertPosition(instructions, instructions.size() - 1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1500 } else {
6411
c5afcc2ebd3d change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents: 6352
diff changeset
1501 moveResolver.setInsertPosition(instructions, instructions.size());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1502 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1503
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1504 } else {
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
1505 Debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1506
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
1507 if (DetailedAsserts.getValue()) {
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
1508 assert ir.lir(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1509
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1510 // because the number of predecessor edges matches the number of
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1511 // successor edges, blocks which are reached by switch statements
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1512 // may have be more than one predecessor but it will be guaranteed
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1513 // that all predecessors will be the same.
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1514 for (Block predecessor : toBlock.getPredecessors()) {
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1515 assert fromBlock == predecessor : "all critical edges must be broken";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1516 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1517 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1518
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
1519 moveResolver.setInsertPosition(ir.lir(toBlock), 1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1520 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1521 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1522
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1523 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1524 * Inserts necessary moves (spilling or reloading) at edges between blocks for intervals that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1525 * have been split.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1526 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1527 void resolveDataFlow() {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1528 Indent indent = Debug.logAndIndent("resolve data flow");
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1529
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1530 int numBlocks = blockCount();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1531 MoveResolver moveResolver = new MoveResolver(this);
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
1532 BitSet blockCompleted = new BitSet(numBlocks);
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
1533 BitSet alreadyResolved = new BitSet(numBlocks);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1534
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
1535 for (Block block : sortedBlocks) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1536
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1537 // check if block has only one predecessor and only one successor
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1538 if (block.getPredecessorCount() == 1 && block.getSuccessorCount() == 1) {
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
1539 List<LIRInstruction> instructions = ir.lir(block);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1540 assert instructions.get(0) instanceof StandardOp.LabelOp : "block must start with label";
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1541 assert instructions.get(instructions.size() - 1) instanceof StandardOp.JumpOp : "block with successor must end with unconditional jump";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1542
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1543 // check if block is empty (only label and branch)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1544 if (instructions.size() == 2) {
7499
ca3e5df0e6cf Small clean up of access to predecessor/successor of blocks.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7498
diff changeset
1545 Block pred = block.getFirstPredecessor();
ca3e5df0e6cf Small clean up of access to predecessor/successor of blocks.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7498
diff changeset
1546 Block sux = block.getFirstSuccessor();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1547
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1548 // prevent optimization of two consecutive blocks
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1549 if (!blockCompleted.get(pred.getLinearScanNumber()) && !blockCompleted.get(sux.getLinearScanNumber())) {
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
1550 Debug.log(" optimizing empty block B%d (pred: B%d, sux: B%d)", block.getId(), pred.getId(), sux.getId());
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1551
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1552 blockCompleted.set(block.getLinearScanNumber());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1553
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1554 // directly resolve between pred and sux (without looking at the empty block
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1555 // between)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1556 resolveCollectMappings(pred, sux, moveResolver);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1557 if (moveResolver.hasMappings()) {
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
1558 moveResolver.setInsertPosition(instructions, 1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1559 moveResolver.resolveAndAppendMoves();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1560 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1561 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1562 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1563 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1564 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1565
7501
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
1566 for (Block fromBlock : sortedBlocks) {
799dd373fcb6 Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7499
diff changeset
1567 if (!blockCompleted.get(fromBlock.getLinearScanNumber())) {
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
1568 alreadyResolved.clear();
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
1569 alreadyResolved.or(blockCompleted);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1570
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1571 for (Block toBlock : fromBlock.getSuccessors()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1572
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1573 // check for duplicate edges between the same blocks (can happen with switch
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1574 // blocks)
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1575 if (!alreadyResolved.get(toBlock.getLinearScanNumber())) {
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
1576 Debug.log("processing edge between B%d and B%d", fromBlock.getId(), toBlock.getId());
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1577
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1578 alreadyResolved.set(toBlock.getLinearScanNumber());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1579
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1580 // collect all intervals that have been split between fromBlock and toBlock
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1581 resolveCollectMappings(fromBlock, toBlock, moveResolver);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1582 if (moveResolver.hasMappings()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1583 resolveFindInsertPos(fromBlock, toBlock, moveResolver);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1584 moveResolver.resolveAndAppendMoves();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1585 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1586 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1587 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1588 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1589 }
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1590 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1591 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1592
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1593 // * Phase 7: assign register numbers back to LIR
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1594 // (includes computation of debug information and oop maps)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1595
5547
b6617d13ea44 Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5542
diff changeset
1596 static StackSlot canonicalSpillOpr(Interval interval) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1597 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
1598 return interval.spillSlot();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1599 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1600
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1601 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1602 * Assigns the allocated location for an LIR instruction operand back into the instruction.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1603 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1604 * @param operand an LIR instruction operand
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1605 * @param opId the id of the LIR instruction using {@code operand}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1606 * @param mode the usage mode for {@code operand} by the instruction
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1607 * @return the location assigned for the operand
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1608 */
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1609 private Value colorLirOperand(Variable operand, int opId, OperandMode mode) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1610 Interval interval = intervalFor(operand);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1611 assert interval != null : "interval must exist";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1612
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1613 if (opId != -1) {
9855
6898d8995866 converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9632
diff changeset
1614 if (DetailedAsserts.getValue()) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1615 Block block = blockForId(opId);
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1616 if (block.getSuccessorCount() <= 1 && opId == getLastLirInstructionId(block)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1617 // check if spill moves could have been appended at the end of this block, but
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1618 // before the branch instruction. So the split child information for this branch
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1619 // would
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1620 // be incorrect.
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
1621 LIRInstruction instr = ir.lir(block).get(ir.lir(block).size() - 1);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1622 if (instr instanceof StandardOp.JumpOp) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1623 if (blockData.get(block).liveOut.get(operandNumber(operand))) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1624 assert false : "can't get split child for the last branch of a block because the information would be incorrect (moves are inserted before the branch in resolveDataFlow)";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1625 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1626 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1627 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1628 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1629
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1630 // operands are not changed when an interval is split during allocation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1631 // so search the right interval here
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1632 interval = splitChildAtOpId(interval, opId, mode);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1633 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1634
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1635 if (isIllegal(interval.location()) && interval.canMaterialize()) {
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1636 assert mode != OperandMode.DEF;
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1637 return interval.getMaterializedValue();
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1638 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1639 return interval.location();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1640 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1641
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1642 private boolean isMaterialized(AllocatableValue operand, int opId, OperandMode mode) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1643 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
1644 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
1645
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1646 if (opId != -1) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1647 // operands are not changed when an interval is split during allocation,
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1648 // so search the right interval here
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1649 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
1650 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1651
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1652 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
1653 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1654
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1655 protected IntervalWalker initIntervalWalker(IntervalPredicate predicate) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1656 // setup lists of potential oops for walking
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1657 Interval oopIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1658 Interval nonOopIntervals;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1659
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1660 oopIntervals = createUnhandledLists(predicate, null).first;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1661
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1662 // intervals that have no oops inside need not to be processed.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1663 // to ensure a walking until the last instruction id, add a dummy interval
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1664 // with a high operation id
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
1665 nonOopIntervals = new Interval(Value.ILLEGAL, -1);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1666 nonOopIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1667
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1668 return new IntervalWalker(this, oopIntervals, nonOopIntervals);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1669 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1670
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1671 /**
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1672 * Visits all intervals for a frame state. The frame state use this information to build the OOP
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1673 * maps.
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1674 */
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1675 void markFrameLocations(IntervalWalker iw, LIRInstruction op, LIRFrameState info) {
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
1676 Debug.log("creating oop map at opId %d", op.id());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1677
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1678 // walk before the current operation . intervals that start at
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1679 // the operation (i.e. output operands of the operation) are not
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1680 // included in the oop map
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1681 iw.walkBefore(op.id());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1682
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1683 // Iterate through active intervals
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1684 for (Interval interval = iw.activeLists.get(RegisterBinding.Fixed); interval != Interval.EndMarker; interval = interval.next) {
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1685 Value operand = interval.operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1686
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1687 assert interval.currentFrom() <= op.id() && op.id() <= interval.currentTo() : "interval should not be active otherwise";
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
1688 assert isVariable(interval.operand) : "fixed interval found";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1689
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1690 // Check if this range covers the instruction. Intervals that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1691 // start or end at the current operation are not included in the
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1692 // oop map, except in the case of patching moves. For patching
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1693 // moves, any intervals which end at this instruction are included
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1694 // in the oop map since we may safepoint while doing the patch
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1695 // before we've consumed the inputs.
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1696 if (op.id() < interval.currentTo() && !isIllegal(interval.location())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1697 // caller-save registers must not be included into oop-maps at calls
9454
85a836bcd796 renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents: 9425
diff changeset
1698 assert !op.destroysCallerSavedRegisters() || !isRegister(operand) || !isCallerSave(operand) : "interval is in a caller-save register at a call . register will be overwritten";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1699
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1700 info.markLocation(interval.location(), frameMap);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1701
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1702 // Spill optimization: when the stack value is guaranteed to be always correct,
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1703 // then it must be added to the oop map even if the interval is currently in a
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1704 // register
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1705 if (interval.alwaysInMemory() && op.id() > interval.spillDefinitionPos() && !interval.location().equals(interval.spillSlot())) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1706 assert interval.spillDefinitionPos() > 0 : "position not set correctly";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1707 assert interval.spillSlot() != null : "no spill slot assigned";
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
1708 assert !isRegister(interval.operand) : "interval is on stack : so stack slot is registered twice";
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1709 info.markLocation(interval.spillSlot(), frameMap);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1710 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1711 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1712 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1713 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1714
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1715 private boolean isCallerSave(Value operand) {
5552
69a8969dbf40 Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
1716 return attributes(asRegister(operand)).isCallerSave();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1717 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1718
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1719 private void computeDebugInfo(IntervalWalker iw, final LIRInstruction op, LIRFrameState info) {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1720 info.initDebugInfo(frameMap, !op.destroysCallerSavedRegisters() || !callKillsRegisters);
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1721 markFrameLocations(iw, op, info);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1722
4169
f5328dda9714 Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4165
diff changeset
1723 info.forEachState(new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1724
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1725 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1726 public Value doValue(Value operand) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1727 int tempOpId = op.id();
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1728 OperandMode mode = OperandMode.USE;
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1729 Block block = blockForId(tempOpId);
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1730 if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1731 // generating debug information for the last instruction of a block.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1732 // if this instruction is a branch, spill moves are inserted before this branch
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1733 // and so the wrong operand would be returned (spill moves at block boundaries
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1734 // are not
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1735 // considered in the live ranges of intervals)
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1736 // Solution: use the first opId of the branch target block instead.
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
1737 final LIRInstruction instr = ir.lir(block).get(ir.lir(block).size() - 1);
4323
df5547057954 Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
1738 if (instr instanceof StandardOp.JumpOp) {
4435
57cb8ec5f6bb Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4394
diff changeset
1739 if (blockData.get(block).liveOut.get(operandNumber(operand))) {
7497
0f8c6dbf68be Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6582
diff changeset
1740 tempOpId = getFirstLirInstructionId(block.getFirstSuccessor());
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1741 mode = OperandMode.DEF;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1742 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1743 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1744 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1745
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1746 // Get current location of operand
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1747 // The operand must be live because debug information is considered when building
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1748 // the intervals
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1749 // if the interval is not live, colorLirOperand will cause an assert on failure
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1750 Value result = colorLirOperand((Variable) operand, tempOpId, mode);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1751 assert !hasCall(tempOpId) || isStackSlot(result) || isConstant(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1752 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1753 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1754 });
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1755 info.finish(op, frameMap);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1756 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1757
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1758 private void assignLocations(List<LIRInstruction> instructions, final IntervalWalker iw) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1759 int numInst = instructions.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1760 boolean hasDead = false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1761
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1762 for (int j = 0; j < numInst; j++) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1763 final LIRInstruction op = instructions.get(j);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1764 if (op == null) { // this can happen when spill-moves are removed in eliminateSpillMoves
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1765 hasDead = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1766 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1767 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1768
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1769 // remove useless moves
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1770 MoveOp move = null;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1771 if (op instanceof MoveOp) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1772 move = (MoveOp) op;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1773 AllocatableValue result = move.getResult();
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1774 if (isVariable(result) && isMaterialized(result, op.id(), OperandMode.DEF)) {
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1775 /*
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1776 * This happens if a materializable interval is originally not spilled but then
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1777 * kicked out in LinearScanWalker.splitForSpilling(). When kicking out such an
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1778 * interval this move operation was already generated.
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1779 */
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1780 instructions.set(j, null);
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1781 hasDead = true;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1782 continue;
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1783 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1784 }
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1785
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1786 ValueProcedure assignProc = new ValueProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1787
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1788 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
1789 public Value doValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
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
1790 if (isVariable(operand)) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1791 return colorLirOperand((Variable) operand, op.id(), mode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1792 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1793 return operand;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1794 }
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1795 };
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1796
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1797 op.forEachInput(assignProc);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1798 op.forEachAlive(assignProc);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1799 op.forEachTemp(assignProc);
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
1800 op.forEachOutput(assignProc);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1801
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1802 // compute reference map and debug information
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1803 op.forEachState(new StateProcedure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1804
5733
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1805 @Override
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1806 protected void doState(LIRFrameState state) {
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1807 computeDebugInfo(iw, op, state);
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1808 }
141b15521a39 use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5711
diff changeset
1809 });
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1810
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1811 // remove useless moves
13377
40530019af02 enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13376
diff changeset
1812 if (move != null) {
9628
8851fabf2265 LinearScan: Can no longer check for object equality after removal of RegisterValue cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9614
diff changeset
1813 if (move.getInput().equals(move.getResult())) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1814 instructions.set(j, null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1815 hasDead = true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1816 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1817 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1818 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1819
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1820 if (hasDead) {
6321
9418ff4c9e7c Clean up ControlFlowOptimizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6317
diff changeset
1821 // Remove null values from the list.
9418ff4c9e7c Clean up ControlFlowOptimizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 6317
diff changeset
1822 instructions.removeAll(Collections.singleton(null));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1823 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1824 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1825
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1826 private void assignLocations() {
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1827 IntervalWalker iw = initIntervalWalker(IS_STACK_INTERVAL);
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
1828 try (Indent indent = Debug.logAndIndent("assign locations")) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1829 for (Block block : sortedBlocks) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1830 try (Indent indent2 = Debug.logAndIndent("assign locations in block B%d", block.getId())) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1831 assignLocations(ir.lir(block), iw);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1832 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1833 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1834 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1835 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1836
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1837 public void allocate() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1838
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
1839 /*
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1840 * 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
1841 */
13546
43bd3d7254d1 don?t explicitly disable debug log output in linear scan and graphbuilder
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13467
diff changeset
1842 Indent indent = Debug.logAndIndent("LinearScan allocate %s", gen.getGraph().method());
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1843
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1844 try (Scope s = Debug.scope("LifetimeAnalysis")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1845 numberInstructions();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1846 printLir("Before register allocation", true);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1847 computeLocalLiveSets();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1848 computeGlobalLiveSets();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1849 buildIntervals();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1850 sortIntervalsBeforeAllocation();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1851 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1852 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1853 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1854
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1855 try (Scope s = Debug.scope("RegisterAllocation")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1856 printIntervals("Before register allocation");
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1857 allocateRegisters();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1858 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1859 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1860 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1861
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1862 try (Scope s = Debug.scope("ResolveDataFlow")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1863 resolveDataFlow();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1864 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1865 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1866 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1867
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1868 try (Scope s = Debug.scope("DebugInfo")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1869 frameMap.finish();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1870
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1871 printIntervals("After register allocation");
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1872 printLir("After register allocation", true);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1873
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1874 sortIntervalsAfterAllocation();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1875
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1876 if (DetailedAsserts.getValue()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1877 verify();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1878 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1879
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1880 eliminateSpillMoves();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1881 assignLocations();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1882
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1883 if (DetailedAsserts.getValue()) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1884 verifyIntervals();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1885 }
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1886 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1887 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12785
diff changeset
1888 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1889
13842
a02441dcf05f Do control flow optimizations independent of register allocation.
Roland Schatz <roland.schatz@oracle.com>
parents: 13610
diff changeset
1890 printLir("After register number assignment", true);
13340
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1891
9423a38d6437 added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13339
diff changeset
1892 indent.outdent();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1893 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1894
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1895 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
1896 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
1897 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
1898 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
1899 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
1900 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
1901 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1902 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1903
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
1904 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
1905 for (int i = 0; i < blockCount(); 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
1906 Block block = blockAt(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
1907 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
1908 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1909 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1910 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1911 }
4353
043bec543161 More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4352
diff changeset
1912 Debug.dump(Arrays.copyOf(intervals, intervalsSize), label);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1913 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1914
7556
630ea5001e33 Modified formatter settings to not insert line break after annotation on parameters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
1915 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
1916 Debug.dump(ir, label);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1917 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1918
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1919 boolean verify() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1920 // (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
1921 verifyIntervals();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1922
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
1923 // verifyNoOopsInFixedIntervals();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1924
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1925 verifyConstants();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1926
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1927 verifyRegisters();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1928
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
1929 Debug.log("no errors found");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1930
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1931 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1932 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1933
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1934 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
1935 // 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
1936 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
1937 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
1938 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
1939 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1940 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1941
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1942 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
1943 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
1944 int len = intervalsSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1945
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
1946 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
1947 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
1948 if (i1 == null) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1949 continue;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1950 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1951
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
1952 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
1953
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1954 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
1955 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
1956 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
1957 throw new GraalInternalError("");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1958 }
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
1959
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1960 if (isVariable(i1.operand) && i1.kind() == Kind.Illegal) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1961 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
1962 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
1963 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
1964 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1965
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1966 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
1967 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
1968 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
1969 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
1970 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1971
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1972 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
1973 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
1974 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
1975 throw new GraalInternalError("");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1976 }
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
1977
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1978 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
1979 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
1980 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
1981 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
1982 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
1983 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1984 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1985
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1986 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
1987 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
1988 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
1989 continue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1990 }
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
1991
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1992 // 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
1993 // . 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
1994 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
1995 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
1996 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
1997 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
1998 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
1999 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2000 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
2001 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
2002 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
2003 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
2004 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
2005 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
2006 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
2007 }
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2008 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
2009 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2010 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2011 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2012 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2013 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2014
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2015 class CheckProcedure extends ValueProcedure {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7512
diff changeset
2016
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2017 boolean ok;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2018 Interval curInterval;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2019
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2020 @Override
5539
bc647d8b0080 Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
2021 protected Value doValue(Value operand) {
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2022 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
2023 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
2024 ok = true;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2025 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2026 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2027 return operand;
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2028 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2029 }
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2030
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2031 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
2032 try (Indent indent = Debug.logAndIndent("verifying that no oops are in fixed 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
2033 CheckProcedure checkProc = new CheckProcedure();
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2034
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
2035 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
2036 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
2037 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
2038 // 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
2039 // 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
2040 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
2041 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
2042 IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2043
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
2044 for (Block block : sortedBlocks) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2045 List<LIRInstruction> instructions = ir.lir(block);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2046
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
2047 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
2048 LIRInstruction op = instructions.get(j);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2049
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
2050 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
2051 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
2052 boolean checkLive = true;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2053
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
2054 // Make sure none of the fixed registers is live across an
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2055 // oopmap since we can't handle that correctly.
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2056 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
2057 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
2058 if (interval.currentTo() > op.id() + 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
2059 // This interval is live out of this op so make sure
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2060 // that this interval represents some value that's
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2061 // referenced by this op either as an input or output.
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2062 checkProc.curInterval = 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
2063 checkProc.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
2064
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
2065 op.forEachInput(checkProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2066 op.forEachAlive(checkProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2067 op.forEachTemp(checkProc);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2068 op.forEachOutput(checkProc);
4245
75c620f90ab9 Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4214
diff changeset
2069
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
2070 assert checkProc.ok : "fixed intervals should never be live across an oopmap point";
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2071 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2072 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2073 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2074 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2075 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2076 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2077 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2078 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2079
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2080 void verifyConstants() {
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
2081 try (Indent indent = Debug.logAndIndent("verifying that unpinned constants are not alive across block boundaries")) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2082 for (Block block : sortedBlocks) {
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2083 BitSet liveAtEdge = blockData.get(block).liveIn;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2084
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
2085 // visit all operands where the liveAtEdge bit is set
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2086 for (int operandNum = liveAtEdge.nextSetBit(0); operandNum >= 0; operandNum = liveAtEdge.nextSetBit(operandNum + 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
2087 Debug.log("checking interval %d of block B%d", operandNum, block.getId());
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2088 Value operand = operandFor(operandNum);
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2089 assert isVariable(operand) : "value must have variable operand";
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2090 // TKR assert value.asConstant() == null || value.isPinned() :
7c694e3e97e5 remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents: 13377
diff changeset
2091 // "only pinned constants can be alive accross block boundaries";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2092 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2093 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2094 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2095 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2096 }