Mercurial > hg > truffle
annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java @ 21246:b2b3c514a391
MoveResolver: don't call check from constructor.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 05 May 2015 16:24:39 +0200 |
parents | 1e9242c9735e |
children | 8ecb442fc864 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15927
diff
changeset
|
2 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
19166
39e99cf01468
Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents:
19165
diff
changeset
|
23 package com.oracle.graal.lir.alloc.lsra; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5542
diff
changeset
|
25 import static com.oracle.graal.api.code.CodeUtil.*; |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5711
diff
changeset
|
26 import static com.oracle.graal.api.code.ValueUtil.*; |
19163
0751ebc54c13
Move DetailedAsserts Option to GraalOptions.
Josef Eisl <josef.eisl@jku.at>
parents:
19162
diff
changeset
|
27 import static com.oracle.graal.compiler.common.GraalOptions.*; |
16505
45f92700119f
Move AbstractBlock.{dominates, isDominatedBy} to AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents:
16380
diff
changeset
|
28 import static com.oracle.graal.compiler.common.cfg.AbstractControlFlowGraph.*; |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5711
diff
changeset
|
29 import static com.oracle.graal.lir.LIRValueUtil.*; |
19164
b215b88e215f
Introduce LIRGenerationDebugContext.
Josef Eisl <josef.eisl@jku.at>
parents:
19163
diff
changeset
|
30 import static com.oracle.graal.lir.debug.LIRGenerationDebugContext.*; |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5711
diff
changeset
|
31 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
34 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
|
35 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15192
diff
changeset
|
36 import com.oracle.graal.compiler.common.*; |
19165
b3b81dfff200
Move ComputeBlockOrder to compiler.common and delete c.o.g.alloc project.
Josef Eisl <josef.eisl@jku.at>
parents:
19164
diff
changeset
|
37 import com.oracle.graal.compiler.common.alloc.*; |
15192
644dfe49c0f4
Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents:
15157
diff
changeset
|
38 import com.oracle.graal.compiler.common.cfg.*; |
19162
c06f39fa2228
Move HIR independent utilities to c.o.g.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
19020
diff
changeset
|
39 import com.oracle.graal.compiler.common.util.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
40 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
|
41 import com.oracle.graal.debug.Debug.Scope; |
5060
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; |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
45 import com.oracle.graal.lir.StandardOp.LabelOp; |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5711
diff
changeset
|
46 import com.oracle.graal.lir.StandardOp.MoveOp; |
19166
39e99cf01468
Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents:
19165
diff
changeset
|
47 import com.oracle.graal.lir.alloc.lsra.Interval.RegisterBinding; |
39e99cf01468
Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents:
19165
diff
changeset
|
48 import com.oracle.graal.lir.alloc.lsra.Interval.RegisterPriority; |
39e99cf01468
Move LinearScan to c.o.g.lir.alloc.lsra.
Josef Eisl <josef.eisl@jku.at>
parents:
19165
diff
changeset
|
49 import com.oracle.graal.lir.alloc.lsra.Interval.SpillState; |
18443
1c92d437179b
FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents:
18441
diff
changeset
|
50 import com.oracle.graal.lir.framemap.*; |
18152
ff694c40bdee
LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents:
18151
diff
changeset
|
51 import com.oracle.graal.lir.gen.*; |
19549
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
52 import com.oracle.graal.lir.gen.LIRGeneratorTool.SpillMoveFactory; |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
53 import com.oracle.graal.options.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
56 * 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
|
57 * 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
|
58 * >"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
|
59 * Hanspeter Moessenboeck. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 */ |
21240
1e9242c9735e
Introduce SSALinearScan and SSAMoveResolver.
Josef Eisl <josef.eisl@jku.at>
parents:
21236
diff
changeset
|
61 class LinearScan { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 |
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 TargetDescription target; |
18152
ff694c40bdee
LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents:
18151
diff
changeset
|
64 final LIRGenerationResult res; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 final LIR ir; |
18150
22f2e42923de
Use FrameMapBuilder in LinearScan (except for location marking).
Josef Eisl <josef.eisl@jku.at>
parents:
18123
diff
changeset
|
66 final FrameMapBuilder frameMapBuilder; |
19549
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
67 final SpillMoveFactory spillMoveFactory; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5542
diff
changeset
|
68 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
|
69 final Register[] registers; |
20915
916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents:
20151
diff
changeset
|
70 final RegisterAllocationConfig regAllocConfig; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 |
18512
bcf66634c55c
Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents:
18446
diff
changeset
|
72 final boolean callKillsRegisters; |
10961 | 73 |
16380
8057279ec60e
LSRA spill optimization: use DOMINATOR_SPILL_MOVE_ID to mark moves.
Josef Eisl <josef.eisl@jku.at>
parents:
16379
diff
changeset
|
74 public static final int DOMINATOR_SPILL_MOVE_ID = -2; |
15885
4d18c6bb6b3a
LinearScan: Improve initialization and resizing of intervals array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15884
diff
changeset
|
75 private static final int SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT = 1; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
77 public static class Options { |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
78 // @formatter:off |
18674
ecb9d0cedbab
First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18610
diff
changeset
|
79 @Option(help = "Enable spill position optimization", type = OptionType.Debug) |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
80 public static final OptionValue<Boolean> LSRAOptimizeSpillPosition = new OptionValue<>(true); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
81 // @formatter:on |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
82 } |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
83 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
84 public static class BlockData { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
85 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
86 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
87 * 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
|
88 * 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
|
89 * 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
|
90 * operand number}. |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
91 */ |
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
|
92 public BitSet liveIn; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
93 |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
94 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
95 * 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
|
96 * 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
|
97 * 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
|
98 * {@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
|
99 */ |
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
|
100 public BitSet liveOut; |
4435
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
103 * 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
|
104 * 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
|
105 * 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
|
106 */ |
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
|
107 public BitSet liveGen; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
108 |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
109 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
110 * 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
|
111 * 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
|
112 */ |
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
|
113 public BitSet liveKill; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
114 } |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
115 |
19212 | 116 final BlockMap<BlockData> blockData; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
117 |
3733
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 * 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
|
120 */ |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
121 final List<? extends AbstractBlockBase<?>> sortedBlocks; |
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 /** |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
124 * 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
|
125 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 Interval[] intervals; |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 * The number of valid entries in {@link #intervals}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 int intervalsSize; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
134 * 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
|
135 * {@linkplain #createDerivedInterval(Interval) derived interval}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 int firstDerivedIntervalIndex = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 * Intervals sorted by {@link Interval#from()}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 Interval[] sortedIntervals; |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
145 * 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
|
146 * 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
|
147 * array. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 LIRInstruction[] opIdToInstructionMap; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 /** |
19565
9bb45bec2b1f
Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19563
diff
changeset
|
152 * Map from an instruction {@linkplain LIRInstruction#id id} to the |
9bb45bec2b1f
Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19563
diff
changeset
|
153 * {@linkplain AbstractBlockBase block} containing the instruction. Entries should be retrieved |
9bb45bec2b1f
Run eclipseformat.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19563
diff
changeset
|
154 * with {@link #blockForId(int)} as the id is not simply an index into this array. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 */ |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
156 AbstractBlockBase<?>[] opIdToBlockMap; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 * 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
|
160 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 BitMap2D intervalInLoop; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
163 /** |
5711
4d7175cf3526
enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents:
5552
diff
changeset
|
164 * 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
|
165 */ |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
166 private final int firstVariableNumber; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
167 |
20915
916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents:
20151
diff
changeset
|
168 LinearScan(TargetDescription target, LIRGenerationResult res, SpillMoveFactory spillMoveFactory, RegisterAllocationConfig regAllocConfig) { |
4265
4643ccd37dac
* removed CiStatistics
Lukas Stadler <lukas.stadler@jku.at>
parents:
4262
diff
changeset
|
169 this.target = target; |
18152
ff694c40bdee
LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents:
18151
diff
changeset
|
170 this.res = res; |
ff694c40bdee
LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents:
18151
diff
changeset
|
171 this.ir = res.getLIR(); |
19549
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
172 this.spillMoveFactory = spillMoveFactory; |
18152
ff694c40bdee
LIRGenerationResult: add buildFrameMap() and getFrameMap().
Josef Eisl <josef.eisl@jku.at>
parents:
18151
diff
changeset
|
173 this.frameMapBuilder = res.getFrameMapBuilder(); |
7501
799dd373fcb6
Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7499
diff
changeset
|
174 this.sortedBlocks = ir.linearScanOrder(); |
20915
916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents:
20151
diff
changeset
|
175 this.registerAttributes = regAllocConfig.getRegisterConfig().getAttributesMap(); |
916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents:
20151
diff
changeset
|
176 this.regAllocConfig = regAllocConfig; |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
177 |
6582
cc32ce37eddc
deleted Architecture.twoOperandMode() and encapsulated all public fields in Architecture with getters
Doug Simon <doug.simon@oracle.com>
parents:
6581
diff
changeset
|
178 this.registers = target.arch.getRegisters(); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
179 this.firstVariableNumber = registers.length; |
14145
4ff08c0366ae
Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14142
diff
changeset
|
180 this.blockData = new BlockMap<>(ir.getControlFlowGraph()); |
18512
bcf66634c55c
Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents:
18446
diff
changeset
|
181 |
bcf66634c55c
Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents:
18446
diff
changeset
|
182 // If all allocatable registers are caller saved, then no registers are live across a call |
bcf66634c55c
Make LinearScan.callKillsRegisters final.
Josef Eisl <josef.eisl@jku.at>
parents:
18446
diff
changeset
|
183 // site. The register allocator can save time not trying to find a register at a call site. |
20915
916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents:
20151
diff
changeset
|
184 this.callKillsRegisters = regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
187 int getFirstLirInstructionId(AbstractBlockBase<?> block) { |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
188 int result = ir.getLIRforBlock(block).get(0).id(); |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6352
diff
changeset
|
189 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
|
190 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
|
191 } |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6352
diff
changeset
|
192 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
193 int getLastLirInstructionId(AbstractBlockBase<?> block) { |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
194 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
6411
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6352
diff
changeset
|
195 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
|
196 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
|
197 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
|
198 } |
c5afcc2ebd3d
change of project structure: separate compiler and LIR, put EA into separate project
Lukas Stadler <lukas.stadler@jku.at>
parents:
6352
diff
changeset
|
199 |
19549
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
200 SpillMoveFactory getSpillMoveFactory() { |
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
201 return spillMoveFactory; |
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
202 } |
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
203 |
21203
9f45587ad8f5
LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents:
21193
diff
changeset
|
204 protected MoveResolver createMoveResolver() { |
21246
b2b3c514a391
MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents:
21240
diff
changeset
|
205 MoveResolver moveResolver = new MoveResolver(this); |
b2b3c514a391
MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents:
21240
diff
changeset
|
206 assert moveResolver.checkEmpty(); |
b2b3c514a391
MoveResolver: don't call check from constructor.
Josef Eisl <josef.eisl@jku.at>
parents:
21240
diff
changeset
|
207 return moveResolver; |
21203
9f45587ad8f5
LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents:
21193
diff
changeset
|
208 } |
9f45587ad8f5
LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents:
21193
diff
changeset
|
209 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
210 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
|
211 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
|
212 } |
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
|
213 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
215 * 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
|
216 * 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
|
217 * by this allocator. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 */ |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
219 private int operandNumber(Value operand) { |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
220 if (isRegister(operand)) { |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
221 int number = asRegister(operand).number; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
222 assert number < firstVariableNumber; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
223 return number; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
224 } |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
225 assert isVariable(operand) : operand; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
226 return firstVariableNumber + ((Variable) operand).index; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
229 /** |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
230 * 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
|
231 */ |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
232 private int operandSize() { |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
233 return firstVariableNumber + ir.numVariables(); |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
234 } |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
235 |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
236 /** |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
237 * 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
|
238 */ |
19212 | 239 int maxRegisterNumber() { |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
240 return firstVariableNumber - 1; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
241 } |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
242 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
243 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
|
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 isRegister(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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 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
|
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) { |
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
|
255 return isVariable(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 |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
259 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
|
260 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 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
|
263 return !isRegister(i.operand); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 }; |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
268 * 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
|
269 * configuration. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 */ |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5542
diff
changeset
|
271 RegisterAttributes attributes(Register reg) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 return registerAttributes[reg.number]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 void assignSpillSlot(Interval interval) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 // 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
|
277 // 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
|
278 if (interval.canMaterialize()) { |
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
279 interval.assignLocation(Value.ILLEGAL); |
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
280 } else if (interval.spillSlot() != null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 interval.assignLocation(interval.spillSlot()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 } else { |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18420
diff
changeset
|
283 VirtualStackSlot slot = frameMapBuilder.allocateSpillSlot(interval.kind()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 interval.setSpillSlot(slot); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 interval.assignLocation(slot); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 * Creates a new interval. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
291 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 * @param operand the operand for the interval |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 * @return the created interval |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 */ |
9297
a5f2b9012865
Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents:
8402
diff
changeset
|
295 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
|
296 assert isLegal(operand); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 int operandNumber = operandNumber(operand); |
4352
5a84f5548fc4
More work on new debug infrastructure.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4350
diff
changeset
|
298 Interval interval = new Interval(operand, operandNumber); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 assert operandNumber < intervalsSize; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 assert intervals[operandNumber] == null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 intervals[operandNumber] = interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 return interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 * Creates an interval as a result of splitting or spilling another interval. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
307 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 * @param source an interval being split of spilled |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 * @return a new interval derived from {@code source} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 Interval createDerivedInterval(Interval source) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 if (firstDerivedIntervalIndex == -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 firstDerivedIntervalIndex = intervalsSize; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 if (intervalsSize == intervals.length) { |
15885
4d18c6bb6b3a
LinearScan: Improve initialization and resizing of intervals array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15884
diff
changeset
|
316 intervals = Arrays.copyOf(intervals, intervals.length + (intervals.length >> SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 intervalsSize++; |
9425
3ec29630cfb4
Use register categories instead of register flags.
Roland Schatz <roland.schatz@oracle.com>
parents:
9422
diff
changeset
|
319 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
|
320 |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
321 Interval interval = createInterval(variable); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 assert intervals[intervalsSize - 1] == interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 return interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 // 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
|
327 int blockCount() { |
7501
799dd373fcb6
Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7499
diff
changeset
|
328 return sortedBlocks.size(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
330 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
331 AbstractBlockBase<?> blockAt(int index) { |
7501
799dd373fcb6
Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7499
diff
changeset
|
332 return sortedBlocks.get(index); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
336 * 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
|
337 * 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
|
338 * {@linkplain #createDerivedInterval(Interval) derived intervals}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 int liveSetSize() { |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
341 return firstDerivedIntervalIndex == -1 ? operandSize() : firstDerivedIntervalIndex; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 int numLoops() { |
15107 | 345 return ir.getControlFlowGraph().getLoops().size(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 boolean isIntervalInLoop(int interval, int loop) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 return intervalInLoop.at(interval, loop); |
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 |
15884
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
352 Interval intervalFor(int operandNumber) { |
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
353 return intervals[operandNumber]; |
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
354 } |
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
355 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
356 Interval intervalFor(Value operand) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 int operandNumber = operandNumber(operand); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 assert operandNumber < intervalsSize; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 return intervals[operandNumber]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 |
9297
a5f2b9012865
Interval locations can only be AllocatableValues.
Roland Schatz <roland.schatz@oracle.com>
parents:
8402
diff
changeset
|
362 Interval getOrCreateInterval(AllocatableValue operand) { |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
363 Interval ret = intervalFor(operand); |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
364 if (ret == null) { |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
365 return createInterval(operand); |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
366 } else { |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
367 return ret; |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
368 } |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
369 } |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
370 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 * 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
|
373 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 int maxOpId() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 assert opIdToInstructionMap.length > 0 : "no operations"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 return (opIdToInstructionMap.length - 1) << 1; |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
380 * 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
|
381 * 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
|
382 * 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
|
383 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 static int opIdToIndex(int opId) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
385 return opId >> 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
388 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 * Retrieves the {@link LIRInstruction} based on its {@linkplain LIRInstruction#id id}. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
390 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 * @param opId an instruction {@linkplain LIRInstruction#id id} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
392 * @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
|
393 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
394 LIRInstruction instructionForId(int opId) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
395 assert isEven(opId) : "opId not even"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
396 LIRInstruction instr = opIdToInstructionMap[opIdToIndex(opId)]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
397 assert instr.id() == opId; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 return instr; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
399 } |
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 * Gets the block containing a given instruction. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
403 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 * @param opId an instruction {@linkplain LIRInstruction#id id} |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 * @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
|
406 */ |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
407 AbstractBlockBase<?> blockForId(int opId) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 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
|
409 return opIdToBlockMap[opIdToIndex(opId)]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
412 boolean isBlockBegin(int opId) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
413 return opId == 0 || blockForId(opId) != blockForId(opId - 1); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
414 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
415 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 boolean coversBlockBegin(int opId1, int opId2) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 return blockForId(opId1) != blockForId(opId2); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 |
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 * Determines if an {@link LIRInstruction} destroys all caller saved registers. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
422 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 * @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
|
424 * @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
|
425 * registers. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 boolean hasCall(int opId) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
428 assert isEven(opId) : "opId not even"; |
9454
85a836bcd796
renaming for improved clarity: hasCall -> destroysCallerSavedRegisters
Doug Simon <doug.simon@oracle.com>
parents:
9425
diff
changeset
|
429 return instructionForId(opId).destroysCallerSavedRegisters(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
430 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 * 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
|
434 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 void changeSpillDefinitionPos(Interval interval, int defPos) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 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
|
437 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 switch (interval.spillState()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
439 case NoDefinitionFound: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 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
|
441 interval.setSpillDefinitionPos(defPos); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 interval.setSpillState(SpillState.NoSpillStore); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 case NoSpillStore: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 assert defPos <= interval.spillDefinitionPos() : "positions are processed in reverse order when intervals are created"; |
6462 | 447 if (defPos < interval.spillDefinitionPos() - 2) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 // 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
|
449 interval.setSpillState(SpillState.NoOptimization); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 // 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
|
452 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
|
453 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
455 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
456 case NoOptimization: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
457 // nothing to do |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
459 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 default: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5542
diff
changeset
|
461 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
|
462 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
463 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
464 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
465 // called during register allocation |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 void changeSpillState(Interval interval, int spillPos) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 switch (interval.spillState()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 case NoSpillStore: { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
469 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
|
470 int spillLoopDepth = blockForId(spillPos).getLoopDepth(); |
3733
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 if (defLoopDepth < spillLoopDepth) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
473 // the loop depth of the spilling position is higher then the loop depth |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
474 // at the definition of the interval . move write to memory out of loop. |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
475 if (Options.LSRAOptimizeSpillPosition.getValue()) { |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
476 // find best spill position in dominator the tree |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
477 interval.setSpillState(SpillState.SpillInDominator); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
478 } else { |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
479 // store at definition of the interval |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
480 interval.setSpillState(SpillState.StoreAtDefinition); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
481 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 // 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
|
484 // reason to store the interval at the definition |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 interval.setSpillState(SpillState.OneSpillStore); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 } |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
490 case OneSpillStore: { |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
491 if (Options.LSRAOptimizeSpillPosition.getValue()) { |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
492 // the interval is spilled more then once |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
493 interval.setSpillState(SpillState.SpillInDominator); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
494 } else { |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
495 // it is better to store it to |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
496 // memory at the definition |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
497 interval.setSpillState(SpillState.StoreAtDefinition); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
498 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 |
16359
f686fae77383
LSRA spill optimization: rename SpillInDominator.MultipleSpills to SpillState.SpillInDominator.
Josef Eisl <josef.eisl@jku.at>
parents:
16358
diff
changeset
|
502 case SpillInDominator: |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 case StoreAtDefinition: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 case StartInMemory: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 case NoOptimization: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 case NoDefinitionFound: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 // nothing to do |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 default: |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5542
diff
changeset
|
511 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
|
512 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 abstract static class IntervalPredicate { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
516 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 abstract boolean apply(Interval i); |
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 |
16379
c5257d58b71a
LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents:
16378
diff
changeset
|
520 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
|
521 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 public boolean apply(Interval i) { |
16379
c5257d58b71a
LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents:
16378
diff
changeset
|
524 return i.isSplitParent() && i.spillState() == SpillState.StoreAtDefinition; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 }; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
528 /** |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
529 * @return the index of the first instruction that is of interest for |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
530 * {@link #eliminateSpillMoves()} |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
531 */ |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
532 protected int firstInstructionOfInterest() { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
533 // skip the first because it is always a label |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
534 return 1; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
535 } |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
536 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 // called once before assignment of register numbers |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 void eliminateSpillMoves() { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
539 try (Indent indent = Debug.logAndIndent("Eliminating unnecessary spill moves")) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
540 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
541 // collect all intervals that must be stored after their definition. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
542 // the list is sorted by Interval.spillDefinitionPos |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
543 Interval interval; |
16379
c5257d58b71a
LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents:
16378
diff
changeset
|
544 interval = createUnhandledLists(mustStoreAtDefinition, null).first; |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
545 if (DetailedAsserts.getValue()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
546 checkIntervals(interval); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
547 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
548 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
549 LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer(); |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
550 for (AbstractBlockBase<?> block : sortedBlocks) { |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
551 try (Indent indent1 = Debug.logAndIndent("Handle %s", block)) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
552 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
553 int numInst = instructions.size(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
554 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
555 // iterate all instructions of the block. |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
556 for (int j = firstInstructionOfInterest(); j < numInst; j++) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
557 LIRInstruction op = instructions.get(j); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
558 int opId = op.id(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
559 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
560 if (opId == -1) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
561 MoveOp move = (MoveOp) op; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
562 /* |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
563 * Remove move from register to stack if the stack slot is guaranteed to |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
564 * be correct. Only moves that have been inserted by LinearScan can be |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
565 * removed. |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
566 */ |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
567 if (canEliminateSpillMove(block, move)) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
568 /* |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
569 * Move target is a stack slot that is always correct, so eliminate |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
570 * instruction. |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
571 */ |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
572 if (Debug.isLogEnabled()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
573 Debug.log("eliminating move from interval %d (%s) to %d (%s) in block %s", operandNumber(move.getInput()), move.getInput(), operandNumber(move.getResult()), |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
574 move.getResult(), block); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
575 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
576 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
577 // null-instructions are deleted by assignRegNum |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
578 instructions.set(j, null); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
579 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
580 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
581 } else { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
582 /* |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
583 * Insert move from register to stack just after the beginning of the |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
584 * interval. |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
585 */ |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
586 assert interval == Interval.EndMarker || interval.spillDefinitionPos() >= opId : "invalid order"; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
587 assert interval == Interval.EndMarker || (interval.isSplitParent() && interval.spillState() == SpillState.StoreAtDefinition) : "invalid interval"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
588 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
589 while (interval != Interval.EndMarker && interval.spillDefinitionPos() == opId) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
590 if (!interval.canMaterialize()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
591 if (!insertionBuffer.initialized()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
592 /* |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
593 * prepare insertion buffer (appended when all instructions |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
594 * in the block are processed) |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
595 */ |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
596 insertionBuffer.init(instructions); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
597 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
598 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
599 AllocatableValue fromLocation = interval.location(); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
600 AllocatableValue toLocation = canonicalSpillOpr(interval); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
601 if (!fromLocation.equals(toLocation)) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
602 |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
603 assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
604 interval.spillState(); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
605 assert isStackSlotValue(toLocation) : "to operand must be a stack slot"; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
606 |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
607 LIRInstruction move = getSpillMoveFactory().createMove(toLocation, fromLocation); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
608 insertionBuffer.append(j + 1, move); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
609 |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
610 if (Debug.isLogEnabled()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
611 Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
612 } |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
613 } |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
614 } |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
615 interval = interval.next; |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
616 } |
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
|
617 } |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
618 } // end of instruction iteration |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
619 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
620 if (insertionBuffer.initialized()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
621 insertionBuffer.finish(); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
622 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
623 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
624 } // end of block iteration |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
626 assert interval == Interval.EndMarker : "missed an interval"; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
627 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
629 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
630 /** |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
631 * @param block The block {@code move} is located in. |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
632 * @param move Spill move. |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
633 */ |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
634 protected boolean canEliminateSpillMove(AbstractBlockBase<?> block, MoveOp move) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
635 assert isVariable(move.getResult()) : "LinearScan inserts only moves to variables: " + move; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
636 |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
637 Interval curInterval = intervalFor(move.getResult()); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
638 |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
639 if (!isRegister(curInterval.location()) && curInterval.alwaysInMemory()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
640 assert isStackSlotValue(curInterval.location()) : "Not a stack slot: " + curInterval.location(); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
641 return true; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
642 } |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
643 return false; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
644 } |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
645 |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
646 private static void checkIntervals(Interval interval) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 Interval prev = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 Interval temp = interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
649 while (temp != Interval.EndMarker) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 assert temp.spillDefinitionPos() > 0 : "invalid spill definition pos"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
651 if (prev != null) { |
16379
c5257d58b71a
LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents:
16378
diff
changeset
|
652 assert temp.from() >= prev.from() : "intervals not sorted"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 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
|
654 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
656 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
|
657 assert temp.spillDefinitionPos() >= temp.from() : "invalid order"; |
16379
c5257d58b71a
LSRA spill optimization: backout changesets obsoleted by eager spill move placement.
Josef Eisl <josef.eisl@jku.at>
parents:
16378
diff
changeset
|
658 assert temp.spillDefinitionPos() <= temp.from() + 2 : "only intervals defined once at their start-pos can be optimized"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
659 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
660 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
661 Debug.log("interval %d (from %d to %d) must be stored at %d", temp.operandNumber, temp.from(), temp.to(), temp.spillDefinitionPos()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
662 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
663 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
664 prev = temp; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
665 temp = temp.next; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
666 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
667 } |
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 * 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
|
671 * {@linkplain ComputeBlockOrder linear scan order}. |
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 numberInstructions() { |
15884
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
674 |
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
675 intervalsSize = operandSize(); |
15885
4d18c6bb6b3a
LinearScan: Improve initialization and resizing of intervals array.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15884
diff
changeset
|
676 intervals = new Interval[intervalsSize + (intervalsSize >> SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT)]; |
15884
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
677 |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
678 ValueConsumer setVariableConsumer = (value, mode, flags) -> { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
679 if (isVariable(value)) { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
680 getOrCreateInterval(asVariable(value)); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
681 } |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
682 }; |
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
683 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
684 // 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
|
685 int numInstructions = 0; |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
686 for (AbstractBlockBase<?> block : sortedBlocks) { |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
687 numInstructions += ir.getLIRforBlock(block).size(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 // initialize with correct length |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 opIdToInstructionMap = new LIRInstruction[numInstructions]; |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
692 opIdToBlockMap = new AbstractBlockBase<?>[numInstructions]; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
694 int opId = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
695 int index = 0; |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
696 for (AbstractBlockBase<?> block : sortedBlocks) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
697 blockData.put(block, new BlockData()); |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4394
diff
changeset
|
698 |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
699 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
700 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
701 int numInst = instructions.size(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
702 for (int j = 0; j < numInst; j++) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
703 LIRInstruction op = instructions.get(j); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 op.setId(opId); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
705 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 opIdToInstructionMap[index] = op; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 opIdToBlockMap[index] = block; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 assert instructionForId(opId) == op : "must match"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
709 |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
710 op.visitEachTemp(setVariableConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
711 op.visitEachOutput(setVariableConsumer); |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
712 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 index++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
714 opId += 2; // numbering of lirOps by two |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
715 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
716 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
717 assert index == numInstructions : "must match"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
718 assert (index << 1) == opId : "must match: " + (index << 1); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
719 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
720 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
721 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
722 * 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
|
723 * separately for each block. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
724 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
725 void computeLocalLiveSets() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
726 int liveSize = liveSetSize(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
727 |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
728 intervalInLoop = new BitMap2D(operandSize(), numLoops()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
729 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
730 // iterate all blocks |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
731 for (final AbstractBlockBase<?> block : sortedBlocks) { |
21193
8d868b026691
LinearScan: improve assert messages.
Josef Eisl <josef.eisl@jku.at>
parents:
21192
diff
changeset
|
732 try (Indent indent = Debug.logAndIndent("compute local live sets for block %s", block)) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
733 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
734 final BitSet liveGen = new BitSet(liveSize); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
735 final BitSet liveKill = new BitSet(liveSize); |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
736 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
737 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
738 int numInst = instructions.size(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
740 ValueConsumer useConsumer = (operand, mode, flags) -> { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
741 if (isVariable(operand)) { |
15887
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
742 int operandNum = operandNumber(operand); |
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
743 if (!liveKill.get(operandNum)) { |
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
744 liveGen.set(operandNum); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
745 if (Debug.isLogEnabled()) { |
21193
8d868b026691
LinearScan: improve assert messages.
Josef Eisl <josef.eisl@jku.at>
parents:
21192
diff
changeset
|
746 Debug.log("liveGen for operand %d(%s)", operandNum, operand); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
747 } |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
748 } |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
749 if (block.getLoop() != null) { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
750 intervalInLoop.setBit(operandNum, block.getLoop().getIndex()); |
15887
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
751 } |
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
752 } |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
753 |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
754 if (DetailedAsserts.getValue()) { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
755 verifyInput(block, liveKill, operand); |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
756 } |
15887
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
757 }; |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
758 ValueConsumer stateConsumer = (operand, mode, flags) -> { |
18441
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
759 if (isVariableOrRegister(operand)) { |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
760 int operandNum = operandNumber(operand); |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
761 if (!liveKill.get(operandNum)) { |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
762 liveGen.set(operandNum); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
763 if (Debug.isLogEnabled()) { |
21193
8d868b026691
LinearScan: improve assert messages.
Josef Eisl <josef.eisl@jku.at>
parents:
21192
diff
changeset
|
764 Debug.log("liveGen in state for operand %d(%s)", operandNum, operand); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
765 } |
18441
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
766 } |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
767 } |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
768 }; |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
769 ValueConsumer defConsumer = (operand, mode, flags) -> { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
770 if (isVariable(operand)) { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
771 int varNum = operandNumber(operand); |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
772 liveKill.set(varNum); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
773 if (Debug.isLogEnabled()) { |
21193
8d868b026691
LinearScan: improve assert messages.
Josef Eisl <josef.eisl@jku.at>
parents:
21192
diff
changeset
|
774 Debug.log("liveKill for operand %d(%s)", varNum, operand); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
775 } |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
776 if (block.getLoop() != null) { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
777 intervalInLoop.setBit(varNum, block.getLoop().getIndex()); |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
778 } |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
779 } |
15887
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
780 |
17294
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
781 if (DetailedAsserts.getValue()) { |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
782 // fixed intervals are never live at block boundaries, so |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
783 // they need not be processed in live sets |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
784 // process them only in debug mode so that this can be checked |
6d85dfeb6981
LSRA: replace anonymous ValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17293
diff
changeset
|
785 verifyTemp(liveKill, operand); |
15887
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
786 } |
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
787 }; |
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
788 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
789 // iterate all instructions of the block |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
790 for (int j = 0; j < numInst; j++) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
791 final LIRInstruction op = instructions.get(j); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
792 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
793 try (Indent indent2 = Debug.logAndIndent("handle op %d", op.id())) { |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
794 op.visitEachInput(useConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
795 op.visitEachAlive(useConsumer); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
796 // Add uses of live locals from interpreter's point of view for proper debug |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
797 // information generation |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
798 op.visitEachState(stateConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
799 op.visitEachTemp(defConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
800 op.visitEachOutput(defConsumer); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
801 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
802 } // end of instruction iteration |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
804 BlockData blockSets = blockData.get(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
805 blockSets.liveGen = liveGen; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
806 blockSets.liveKill = liveKill; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
807 blockSets.liveIn = new BitSet(liveSize); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
808 blockSets.liveOut = new BitSet(liveSize); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
809 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
810 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
811 Debug.log("liveGen B%d %s", block.getId(), blockSets.liveGen); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
812 Debug.log("liveKill B%d %s", block.getId(), blockSets.liveKill); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
813 } |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
814 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
815 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 } // end of block iteration |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 |
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
|
819 private void verifyTemp(BitSet liveKill, Value operand) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 // 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
|
821 // they need not be processed in live sets |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 // 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
|
823 if (isRegister(operand)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 if (isProcessed(operand)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 liveKill.set(operandNumber(operand)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
827 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
830 private void verifyInput(AbstractBlockBase<?> block, BitSet liveKill, Value operand) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
831 // 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
|
832 // they need not be processed in live sets. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
833 // 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
|
834 // the entry block may have incoming |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
835 // values in registers, which is ok. |
14145
4ff08c0366ae
Encapsulate LIR class fields.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14142
diff
changeset
|
836 if (isRegister(operand) && block != ir.getControlFlowGraph().getStartBlock()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
837 if (isProcessed(operand)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
838 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
|
839 } |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
842 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
844 * 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
|
845 * {@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
|
846 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
847 void computeGlobalLiveSets() { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
848 try (Indent indent = Debug.logAndIndent("compute global live sets")) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
849 int numBlocks = blockCount(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
850 boolean changeOccurred; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
851 boolean changeOccurredInBlock; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
852 int iterationCount = 0; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
853 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
|
854 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
855 // Perform a backward dataflow analysis to compute liveOut and liveIn for each block. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
856 // The loop is executed until a fixpoint is reached (no changes in an iteration) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
857 do { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
858 changeOccurred = false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
860 try (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
|
861 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
862 // iterate all blocks in reverse order |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
863 for (int i = numBlocks - 1; i >= 0; i--) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
864 AbstractBlockBase<?> block = blockAt(i); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
865 BlockData blockSets = blockData.get(block); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
867 changeOccurredInBlock = false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
868 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
869 // liveOut(block) is the union of liveIn(sux), for successors sux of block |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
870 int n = block.getSuccessorCount(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
871 if (n > 0) { |
15850
9ce2ca72efef
small cleanup in LinearScan
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15534
diff
changeset
|
872 liveOut.clear(); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
873 // block has successors |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
874 if (n > 0) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
875 for (AbstractBlockBase<?> successor : block.getSuccessors()) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
876 liveOut.or(blockData.get(successor).liveIn); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
877 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
878 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
879 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
880 if (!blockSets.liveOut.equals(liveOut)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
881 // A change occurred. Swap the old and new live out |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
882 // sets to avoid copying. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
883 BitSet temp = blockSets.liveOut; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
884 blockSets.liveOut = liveOut; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
885 liveOut = temp; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
886 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
887 changeOccurred = true; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
888 changeOccurredInBlock = true; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
889 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
891 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
892 if (iterationCount == 0 || changeOccurredInBlock) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
893 // liveIn(block) is the union of liveGen(block) with (liveOut(block) & |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
894 // !liveKill(block)) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
895 // note: liveIn has to be computed only in first iteration |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
896 // or if liveOut has changed! |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
897 BitSet liveIn = blockSets.liveIn; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
898 liveIn.clear(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
899 liveIn.or(blockSets.liveOut); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
900 liveIn.andNot(blockSets.liveKill); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
901 liveIn.or(blockSets.liveGen); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
902 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
903 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
904 Debug.log("block %d: livein = %s, liveout = %s", block.getId(), liveIn, blockSets.liveOut); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
905 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
906 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
907 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
908 iterationCount++; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
909 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
910 if (changeOccurred && iterationCount > 50) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
911 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
|
912 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
913 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
914 } while (changeOccurred); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
915 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
916 if (DetailedAsserts.getValue()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
917 verifyLiveness(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
918 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
919 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
920 // check that the liveIn set of the first block is empty |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
921 AbstractBlockBase<?> startBlock = ir.getControlFlowGraph().getStartBlock(); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
922 if (blockData.get(startBlock).liveIn.cardinality() != 0) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
923 if (DetailedAsserts.getValue()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
924 reportFailure(numBlocks); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
925 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
926 // bailout if this occurs in product mode. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
927 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
|
928 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
929 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
930 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
931 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
932 private void reportFailure(int numBlocks) { |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
933 try (Scope s = Debug.forceLog()) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
934 try (Indent indent = Debug.logAndIndent("report failure")) { |
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
|
935 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
936 BitSet startBlockLiveIn = blockData.get(ir.getControlFlowGraph().getStartBlock()).liveIn; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
937 try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
938 for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { |
17070
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
939 Interval interval = intervalFor(operandNum); |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
940 if (interval != null) { |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
941 Value operand = interval.operand; |
19164
b215b88e215f
Introduce LIRGenerationDebugContext.
Josef Eisl <josef.eisl@jku.at>
parents:
19163
diff
changeset
|
942 Debug.log("var %d; operand=%s; node=%s", operandNum, operand, getSourceForOperandFromDebugContext(operand)); |
17070
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
943 } else { |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
944 Debug.log("var %d; missing operand", operandNum); |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
945 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
946 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
947 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
948 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
949 // print some additional information to simplify debugging |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
950 for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { |
17070
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
951 Interval interval = intervalFor(operandNum); |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
952 Value operand = null; |
19164
b215b88e215f
Introduce LIRGenerationDebugContext.
Josef Eisl <josef.eisl@jku.at>
parents:
19163
diff
changeset
|
953 Object valueForOperandFromDebugContext = null; |
17070
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
954 if (interval != null) { |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
955 operand = interval.operand; |
19164
b215b88e215f
Introduce LIRGenerationDebugContext.
Josef Eisl <josef.eisl@jku.at>
parents:
19163
diff
changeset
|
956 valueForOperandFromDebugContext = getSourceForOperandFromDebugContext(operand); |
17070
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
957 } |
6e45ae59781c
Let linear scan DetailedAsserts deal with missing intervals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16801
diff
changeset
|
958 try (Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, valueForOperandFromDebugContext)) { |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
959 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
960 Deque<AbstractBlockBase<?>> definedIn = new ArrayDeque<>(); |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
961 HashSet<AbstractBlockBase<?>> usedIn = new HashSet<>(); |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
962 for (AbstractBlockBase<?> block : sortedBlocks) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
963 if (blockData.get(block).liveGen.get(operandNum)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
964 usedIn.add(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
965 try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
966 for (LIRInstruction ins : ir.getLIRforBlock(block)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
967 try (Indent indent4 = Debug.logAndIndent("%d: %s", ins.id(), ins)) { |
17292
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
968 ins.forEachState((liveStateOperand, mode, flags) -> { |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
969 Debug.log("operand=%s", liveStateOperand); |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
970 return liveStateOperand; |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
971 }); |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
972 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
973 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
974 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
975 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
976 if (blockData.get(block).liveKill.get(operandNum)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
977 definedIn.add(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
978 try (Indent indent3 = Debug.logAndIndent("defined in block B%d", block.getId())) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
979 for (LIRInstruction ins : ir.getLIRforBlock(block)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
980 Debug.log("%d: %s", ins.id(), ins); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
981 } |
14109
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
982 } |
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
983 } |
85969b1aba78
Use a forceLog scope for LinearScan.reportFailure. Remove @SuppressWarnings on DebugScope.scope
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14070
diff
changeset
|
984 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
985 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
986 int[] hitCount = new int[numBlocks]; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
987 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
988 while (!definedIn.isEmpty()) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
989 AbstractBlockBase<?> block = definedIn.removeFirst(); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
990 usedIn.remove(block); |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
991 for (AbstractBlockBase<?> successor : block.getSuccessors()) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
992 if (successor.isLoopHeader()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
993 if (!block.isLoopEnd()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
994 definedIn.add(successor); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
995 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
996 } else { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
997 if (++hitCount[successor.getId()] == successor.getPredecessorCount()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
998 definedIn.add(successor); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
999 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1000 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1001 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1002 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1003 try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1004 for (AbstractBlockBase<?> block : usedIn) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1005 Debug.log("B%d", block.getId()); |
12569
1c8d5a0891b5
improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents:
11537
diff
changeset
|
1006 } |
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
|
1007 } |
12569
1c8d5a0891b5
improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents:
11537
diff
changeset
|
1008 } |
1c8d5a0891b5
improved error reporting in LSRA
Doug Simon <doug.simon@oracle.com>
parents:
11537
diff
changeset
|
1009 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1010 } |
17211
1ac6b4879443
Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents:
17195
diff
changeset
|
1011 } catch (Throwable e) { |
1ac6b4879443
Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents:
17195
diff
changeset
|
1012 throw Debug.handle(e); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1013 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1014 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1015 |
7501
799dd373fcb6
Remove caching of sorted blocks in LSRA.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7499
diff
changeset
|
1016 private void verifyLiveness() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1017 // 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
|
1018 // (live set must be empty at fixed intervals) |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1019 for (AbstractBlockBase<?> block : sortedBlocks) { |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
1020 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
|
1021 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
|
1022 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
|
1023 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
|
1024 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1025 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1026 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1027 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15927
diff
changeset
|
1028 void addUse(AllocatableValue operand, int from, int to, RegisterPriority registerPriority, LIRKind kind) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1029 if (!isProcessed(operand)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1030 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1031 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1032 |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1033 Interval interval = getOrCreateInterval(operand); |
16118
5cbaad0b7387
Verify usage of equals method in LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
1034 if (!kind.equals(LIRKind.Illegal)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1035 interval.setKind(kind); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1036 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1037 |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
1038 interval.addRange(from, to); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1039 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1040 // Register use position at even instruction id. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1041 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
|
1042 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1043 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1044 Debug.log("add use: %s, from %d to %d (%s)", interval, from, to, registerPriority.name()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1045 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1046 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1047 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15927
diff
changeset
|
1048 void addTemp(AllocatableValue operand, int tempPos, RegisterPriority registerPriority, LIRKind kind) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1049 if (!isProcessed(operand)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1050 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1051 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1052 |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1053 Interval interval = getOrCreateInterval(operand); |
16118
5cbaad0b7387
Verify usage of equals method in LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
1054 if (!kind.equals(LIRKind.Illegal)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1055 interval.setKind(kind); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1056 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1057 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1058 interval.addRange(tempPos, tempPos + 1); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1059 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
|
1060 interval.addMaterializationValue(null); |
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1061 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1062 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1063 Debug.log("add temp: %s tempPos %d (%s)", interval, tempPos, RegisterPriority.MustHaveRegister.name()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1064 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1065 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1066 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
1067 boolean isProcessed(Value operand) { |
5552
69a8969dbf40
Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
1068 return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable(); |
3733
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 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15927
diff
changeset
|
1071 void addDef(AllocatableValue operand, LIRInstruction op, RegisterPriority registerPriority, LIRKind kind) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1072 if (!isProcessed(operand)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1073 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1074 } |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1075 int defPos = op.id(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1076 |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1077 Interval interval = getOrCreateInterval(operand); |
16118
5cbaad0b7387
Verify usage of equals method in LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
1078 if (!kind.equals(LIRKind.Illegal)) { |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1079 interval.setKind(kind); |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1080 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1081 |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1082 Range r = interval.first(); |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1083 if (r.from <= defPos) { |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1084 // 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
|
1085 // 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
|
1086 r.from = defPos; |
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1087 interval.addUsePos(defPos, registerPriority); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1088 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1089 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1090 // Dead value - make vacuous interval |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1091 // also add register priority for dead intervals |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1092 interval.addRange(defPos, defPos + 1); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1093 interval.addUsePos(defPos, registerPriority); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1094 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1095 Debug.log("Warning: def of operand %s at %d occurs without use", operand, defPos); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1096 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1097 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1098 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1099 changeSpillDefinitionPos(interval, defPos); |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1100 if (registerPriority == RegisterPriority.None && interval.spillState().ordinal() <= SpillState.StartInMemory.ordinal() && isStackSlot(operand)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1101 // detection of method-parameters and roundfp-results |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1102 interval.setSpillState(SpillState.StartInMemory); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1103 } |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
1104 interval.addMaterializationValue(LinearScan.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
|
1105 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1106 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1107 Debug.log("add def: %s defPos %d (%s)", interval, defPos, registerPriority.name()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1108 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1109 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1110 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1111 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1112 * 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
|
1113 */ |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
1114 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
|
1115 if (op instanceof MoveOp) { |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
1116 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
|
1117 if (optimizeMethodArgument(move.getInput())) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1118 return RegisterPriority.None; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1119 } |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1120 } else if (op instanceof LabelOp) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1121 LabelOp label = (LabelOp) op; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1122 if (label.isPhiIn()) { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1123 return RegisterPriority.None; |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1124 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1125 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1126 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1127 // all other operands require a register |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1128 return RegisterPriority.MustHaveRegister; |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1131 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
1132 * 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
|
1133 * register. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1134 */ |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
1135 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
|
1136 if (flags.contains(OperandFlag.STACK)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1137 return RegisterPriority.ShouldHaveRegister; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1138 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1139 // all other operands require a register |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1140 return RegisterPriority.MustHaveRegister; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1141 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1142 |
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
|
1143 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
|
1144 /* |
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
|
1145 * 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
|
1146 * 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
|
1147 */ |
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
|
1148 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
|
1149 } |
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
|
1150 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1151 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
1152 * 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
|
1153 * 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
|
1154 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1155 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
|
1156 if (op instanceof MoveOp) { |
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
1157 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
|
1158 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
|
1159 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
|
1160 if (DetailedAsserts.getValue()) { |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
1161 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
|
1162 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
|
1163 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
|
1164 |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1165 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1166 Debug.log("found move from stack slot %s to %s", slot, move.getResult()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1167 } |
3733
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 |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
1170 Interval interval = intervalFor(move.getResult()); |
4213
e4cfa571d8c4
Do not emit stack-to-stack moves.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4207
diff
changeset
|
1171 interval.setSpillSlot(slot); |
e4cfa571d8c4
Do not emit stack-to-stack moves.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4207
diff
changeset
|
1172 interval.assignLocation(slot); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1173 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1174 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1175 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1176 |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1177 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
|
1178 if (flags.contains(OperandFlag.HINT) && isVariableOrRegister(targetValue)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1179 |
17292
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1180 op.forEachRegisterHint(targetValue, mode, (registerHint, valueMode, valueFlags) -> { |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1181 if (isVariableOrRegister(registerHint)) { |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1182 Interval from = getOrCreateInterval((AllocatableValue) registerHint); |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1183 Interval to = getOrCreateInterval((AllocatableValue) targetValue); |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1184 |
17292
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1185 /* hints always point from def to use */ |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1186 if (hintAtDef) { |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1187 to.setLocationHint(from); |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1188 } else { |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1189 from.setLocationHint(to); |
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1190 } |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1191 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1192 Debug.log("operation at opId %d: added hint from interval %d to %d", op.id(), from.operandNumber, to.operandNumber); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1193 } |
8220
2c5df42999dd
Fix hinting in register allocator.
Roland Schatz <roland.schatz@oracle.com>
parents:
7648
diff
changeset
|
1194 |
17292
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1195 return registerHint; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1196 } |
17292
4c31d6e44c18
LSRA: replace anonymous ValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17291
diff
changeset
|
1197 return null; |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
1198 }); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1199 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1200 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1201 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1202 void buildIntervals() { |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1203 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1204 try (Indent indent = Debug.logAndIndent("build intervals")) { |
17293
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1205 InstructionValueConsumer outputConsumer = (op, operand, mode, flags) -> { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1206 if (isVariableOrRegister(operand)) { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1207 addDef((AllocatableValue) operand, op, registerPriorityOfOutputOperand(op), operand.getLIRKind()); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1208 addRegisterHint(op, operand, mode, flags, true); |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1209 } |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1210 }; |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1211 |
17293
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1212 InstructionValueConsumer tempConsumer = (op, operand, mode, flags) -> { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1213 if (isVariableOrRegister(operand)) { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1214 addTemp((AllocatableValue) operand, op.id(), RegisterPriority.MustHaveRegister, operand.getLIRKind()); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1215 addRegisterHint(op, operand, mode, flags, false); |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1216 } |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1217 }; |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1218 |
17293
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1219 InstructionValueConsumer aliveConsumer = (op, operand, mode, flags) -> { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1220 if (isVariableOrRegister(operand)) { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1221 RegisterPriority p = registerPriorityOfInputOperand(flags); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1222 int opId = op.id(); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1223 int blockFrom = getFirstLirInstructionId((blockForId(opId))); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1224 addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getLIRKind()); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1225 addRegisterHint(op, operand, mode, flags, false); |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1226 } |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1227 }; |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1228 |
17293
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1229 InstructionValueConsumer inputConsumer = (op, operand, mode, flags) -> { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1230 if (isVariableOrRegister(operand)) { |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1231 int opId = op.id(); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1232 int blockFrom = getFirstLirInstructionId((blockForId(opId))); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1233 RegisterPriority p = registerPriorityOfInputOperand(flags); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1234 addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getLIRKind()); |
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1235 addRegisterHint(op, operand, mode, flags, false); |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1236 } |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1237 }; |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1238 |
17293
6855e4c325d0
LSRA: replace anonymous InstructionValueConsumers with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17292
diff
changeset
|
1239 InstructionValueConsumer stateProc = (op, operand, mode, flags) -> { |
18441
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
1240 if (isVariableOrRegister(operand)) { |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
1241 int opId = op.id(); |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
1242 int blockFrom = getFirstLirInstructionId((blockForId(opId))); |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
1243 addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getLIRKind()); |
d11ce424f09d
Allow updating HotSpotMonitorValue.slot.
Josef Eisl <josef.eisl@jku.at>
parents:
18439
diff
changeset
|
1244 } |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1245 }; |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1246 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1247 // create a list with all caller-save registers (cpu, fpu, xmm) |
20915
916aac9fe6f7
LinearScan: use RegisterAllocationConfig.
Josef Eisl <josef.eisl@jku.at>
parents:
20151
diff
changeset
|
1248 Register[] callerSaveRegs = regAllocConfig.getRegisterConfig().getCallerSaveRegisters(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1249 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1250 // iterate all blocks in reverse order |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1251 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
|
1252 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1253 AbstractBlockBase<?> block = blockAt(i); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1254 try (Indent indent2 = Debug.logAndIndent("handle block %d", block.getId())) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1255 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1256 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1257 final int blockFrom = getFirstLirInstructionId(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1258 int blockTo = getLastLirInstructionId(block); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1259 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1260 assert blockFrom == instructions.get(0).id(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1261 assert blockTo == instructions.get(instructions.size() - 1).id(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1262 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1263 // Update intervals for operands live at the end of this block; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1264 BitSet live = blockData.get(block).liveOut; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1265 for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1266 assert live.get(operandNum) : "should not stop here otherwise"; |
15884
0e6f83eeb0ab
Clean up in LinearScan: Remove the need for a mapping of variable index to variable object.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15850
diff
changeset
|
1267 AllocatableValue operand = intervalFor(operandNum).operand; |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1268 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1269 Debug.log("live in %d: %s", operandNum, operand); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1270 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1271 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15927
diff
changeset
|
1272 addUse(operand, blockFrom, blockTo + 2, RegisterPriority.None, LIRKind.Illegal); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1273 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1274 // add special use positions for loop-end blocks when the |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1275 // interval is used anywhere inside this loop. It's possible |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1276 // that the block was part of a non-natural loop, so it might |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1277 // have an invalid loop index. |
15534
4bd6ad45ee0a
Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
1278 if (block.isLoopEnd() && block.getLoop() != null && isIntervalInLoop(operandNum, block.getLoop().getIndex())) { |
15887
839ea165f816
LinearScan: Small cleanup.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15886
diff
changeset
|
1279 intervalFor(operandNum).addUsePos(blockTo + 1, RegisterPriority.LiveAtLoopEnd); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1280 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1281 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1282 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1283 // iterate all instructions of the block in reverse order. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1284 // definitions of intervals are processed before uses |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1285 for (int j = instructions.size() - 1; j >= 0; j--) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1286 final LIRInstruction op = instructions.get(j); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1287 final int opId = op.id(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1288 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1289 try (Indent indent3 = Debug.logAndIndent("handle inst %d: %s", opId, op)) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
1290 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1291 // add a temp range for each register if operation destroys |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1292 // caller-save registers |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1293 if (op.destroysCallerSavedRegisters()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1294 for (Register r : callerSaveRegs) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1295 if (attributes(r).isAllocatable()) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15927
diff
changeset
|
1296 addTemp(r.asValue(), opId, RegisterPriority.None, LIRKind.Illegal); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1297 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1298 } |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1299 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1300 Debug.log("operation destroys all caller-save registers"); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1301 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1302 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1303 |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
1304 op.visitEachOutput(outputConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
1305 op.visitEachTemp(tempConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
1306 op.visitEachAlive(aliveConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
1307 op.visitEachInput(inputConsumer); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
1308 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1309 // Add uses of live locals from interpreter's point of view for proper |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1310 // debug information generation |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1311 // Treat these operands as temp values (if the live range is extended |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1312 // to a call site, the value would be in a register at |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1313 // the call otherwise) |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
1314 op.visitEachState(stateProc); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1315 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1316 // special steps for some instructions (especially moves) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1317 handleMethodArguments(op); |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1318 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1319 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1320 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1321 } // end of instruction iteration |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1322 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1323 } // end of block iteration |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1324 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1325 // add the range [0, 1] to all fixed intervals. |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1326 // the register allocator need not handle unhandled fixed intervals |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1327 for (Interval interval : intervals) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1328 if (interval != null && isRegister(interval.operand)) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1329 interval.addRange(0, 1); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1330 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1331 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1332 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1333 } |
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 // * Phase 5: actual register allocation |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1336 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
1337 private static boolean isSorted(Interval[] intervals) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1338 int from = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1339 for (Interval interval : intervals) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1340 assert interval != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1341 assert from <= interval.from(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1342 from = interval.from(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1343 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1344 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1345 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1346 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
1347 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
|
1348 Interval newFirst = first; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1349 if (prev != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1350 prev.next = interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1351 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1352 newFirst = interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1353 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1354 return newFirst; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1355 } |
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 Interval.Pair createUnhandledLists(IntervalPredicate isList1, IntervalPredicate isList2) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1358 assert isSorted(sortedIntervals) : "interval list is not sorted"; |
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 Interval list1 = Interval.EndMarker; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1361 Interval list2 = Interval.EndMarker; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1362 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1363 Interval list1Prev = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1364 Interval list2Prev = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1365 Interval v; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1366 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1367 int n = sortedIntervals.length; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1368 for (int i = 0; i < n; i++) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1369 v = sortedIntervals[i]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1370 if (v == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1371 continue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1372 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1373 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1374 if (isList1.apply(v)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1375 list1 = addToList(list1, list1Prev, v); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1376 list1Prev = v; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1377 } else if (isList2 == null || isList2.apply(v)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1378 list2 = addToList(list2, list2Prev, v); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1379 list2Prev = v; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1380 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1381 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1382 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1383 if (list1Prev != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1384 list1Prev.next = Interval.EndMarker; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1385 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1386 if (list2Prev != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1387 list2Prev.next = Interval.EndMarker; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1388 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1389 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1390 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
|
1391 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
|
1392 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1393 return new Interval.Pair(list1, list2); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1394 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1395 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1396 void sortIntervalsBeforeAllocation() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1397 int sortedLen = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1398 for (Interval interval : intervals) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1399 if (interval != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1400 sortedLen++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1401 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1402 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1403 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1404 Interval[] sortedList = new Interval[sortedLen]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1405 int sortedIdx = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1406 int sortedFromMax = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1407 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1408 // 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
|
1409 // 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
|
1410 for (Interval interval : intervals) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1411 if (interval != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1412 int from = interval.from(); |
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 if (sortedFromMax <= from) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1415 sortedList[sortedIdx++] = interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1416 sortedFromMax = interval.from(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1417 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1418 // 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
|
1419 // so this interval must be sorted in manually |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1420 int j; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1421 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
|
1422 sortedList[j + 1] = sortedList[j]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1423 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1424 sortedList[j + 1] = interval; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1425 sortedIdx++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1426 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1427 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1428 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1429 sortedIntervals = sortedList; |
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 void sortIntervalsAfterAllocation() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1433 if (firstDerivedIntervalIndex == -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1434 // 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
|
1435 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1436 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1437 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1438 Interval[] oldList = sortedIntervals; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1439 Interval[] newList = Arrays.copyOfRange(intervals, firstDerivedIntervalIndex, intervalsSize); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1440 int oldLen = oldList.length; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1441 int newLen = newList.length; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1442 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1443 // conventional sort-algorithm for new intervals |
15886
e5e7d9dfff1a
LinearScan: Clean up interval comparator and replace with lambda form.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15885
diff
changeset
|
1444 Arrays.sort(newList, (Interval a, Interval b) -> a.from() - b.from()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1445 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1446 // 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
|
1447 Interval[] combinedList = new Interval[oldLen + newLen]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1448 int oldIdx = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1449 int newIdx = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1450 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1451 while (oldIdx + newIdx < combinedList.length) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1452 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
|
1453 combinedList[oldIdx + newIdx] = oldList[oldIdx]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1454 oldIdx++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1455 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1456 combinedList[oldIdx + newIdx] = newList[newIdx]; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1457 newIdx++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1458 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1459 } |
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 sortedIntervals = combinedList; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1462 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1463 |
19212 | 1464 void allocateRegisters() { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1465 try (Indent indent = Debug.logAndIndent("allocate registers")) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1466 Interval precoloredIntervals; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1467 Interval notPrecoloredIntervals; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1468 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1469 Interval.Pair result = createUnhandledLists(IS_PRECOLORED_INTERVAL, IS_VARIABLE_INTERVAL); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1470 precoloredIntervals = result.first; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1471 notPrecoloredIntervals = result.second; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1472 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1473 // allocate cpu registers |
15927
96229f219351
LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents:
15920
diff
changeset
|
1474 LinearScanWalker lsw; |
96229f219351
LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents:
15920
diff
changeset
|
1475 if (OptimizingLinearScanWalker.Options.LSRAOptimization.getValue()) { |
96229f219351
LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents:
15920
diff
changeset
|
1476 lsw = new OptimizingLinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals); |
96229f219351
LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents:
15920
diff
changeset
|
1477 } else { |
96229f219351
LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents:
15920
diff
changeset
|
1478 lsw = new LinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals); |
96229f219351
LSRA: add OptimizingLinearScanWalker.
Josef Eisl <josef.eisl@jku.at>
parents:
15920
diff
changeset
|
1479 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1480 lsw.walk(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1481 lsw.finishAllocation(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1482 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1483 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1484 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1485 // * Phase 6: resolve data flow |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1486 // (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
|
1487 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1488 // 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
|
1489 // instead of returning null |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1490 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
|
1491 Interval result = interval.getSplitChildAtOpId(opId, mode, this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1492 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1493 if (result != null) { |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1494 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1495 Debug.log("Split child at pos %d of interval %s is %s", opId, interval, result); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1496 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1497 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1498 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1499 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5542
diff
changeset
|
1500 throw new BailoutException("LinearScan: interval is null"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1501 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1502 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1503 void resolveCollectMappings(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, AbstractBlockBase<?> midBlock, MoveResolver moveResolver) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1504 assert moveResolver.checkEmpty(); |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1505 assert midBlock == null || |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1506 (midBlock.getPredecessorCount() == 1 && midBlock.getSuccessorCount() == 1 && midBlock.getPredecessors().get(0).equals(fromBlock) && midBlock.getSuccessors().get(0).equals( |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1507 toBlock)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1508 |
20979
65d8d305f9c0
Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20915
diff
changeset
|
1509 int toBlockFirstInstructionId = getFirstLirInstructionId(toBlock); |
65d8d305f9c0
Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20915
diff
changeset
|
1510 int fromBlockLastInstructionId = getLastLirInstructionId(fromBlock) + 1; |
4206
430b5db3e6f8
Remove CiVariable from the CRI
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4199
diff
changeset
|
1511 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
|
1512 BitSet liveAtEdge = blockData.get(toBlock).liveIn; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1513 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1514 // 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
|
1515 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
|
1516 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
|
1517 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
|
1518 |
20979
65d8d305f9c0
Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20915
diff
changeset
|
1519 Interval fromInterval = splitChildAtOpId(intervalFor(operandNum), fromBlockLastInstructionId, LIRInstruction.OperandMode.DEF); |
65d8d305f9c0
Minor linear scan tweaks
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20915
diff
changeset
|
1520 Interval toInterval = splitChildAtOpId(intervalFor(operandNum), toBlockFirstInstructionId, LIRInstruction.OperandMode.DEF); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1521 |
9632
97db51025787
Value: use `equals()' instead of object equality
Bernhard Urban <bernhard.urban@jku.at>
parents:
9628
diff
changeset
|
1522 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
|
1523 // need to insert move instruction |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1524 moveResolver.addMapping(fromInterval, toInterval); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1525 } |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1528 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1529 void resolveFindInsertPos(AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock, MoveResolver moveResolver) { |
7497
0f8c6dbf68be
Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6582
diff
changeset
|
1530 if (fromBlock.getSuccessorCount() <= 1) { |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1531 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1532 Debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1533 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1534 |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
1535 List<LIRInstruction> instructions = ir.getLIRforBlock(fromBlock); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1536 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
|
1537 if (instr instanceof StandardOp.JumpOp) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1538 // 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
|
1539 moveResolver.setInsertPosition(instructions, instructions.size() - 1); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1540 } 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
|
1541 moveResolver.setInsertPosition(instructions, instructions.size()); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1544 } else { |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1545 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1546 Debug.log("inserting moves at beginning of toBlock B%d", toBlock.getId()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1547 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1548 |
9855
6898d8995866
converted more options from GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9632
diff
changeset
|
1549 if (DetailedAsserts.getValue()) { |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
1550 assert ir.getLIRforBlock(fromBlock).get(0) instanceof StandardOp.LabelOp : "block does not start with a label"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1551 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1552 // 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
|
1553 // 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
|
1554 // 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
|
1555 // that all predecessors will be the same. |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1556 for (AbstractBlockBase<?> predecessor : toBlock.getPredecessors()) { |
7497
0f8c6dbf68be
Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6582
diff
changeset
|
1557 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
|
1558 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1559 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1560 |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
1561 moveResolver.setInsertPosition(ir.getLIRforBlock(toBlock), 1); |
3733
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1566 * 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
|
1567 * have been split. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1568 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1569 void resolveDataFlow() { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1570 try (Indent indent = Debug.logAndIndent("resolve data flow")) { |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1571 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1572 int numBlocks = blockCount(); |
21203
9f45587ad8f5
LinearScan: add createMoveResolver().
Josef Eisl <josef.eisl@jku.at>
parents:
21193
diff
changeset
|
1573 MoveResolver moveResolver = createMoveResolver(); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1574 BitSet blockCompleted = new BitSet(numBlocks); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1575 BitSet alreadyResolved = new BitSet(numBlocks); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1576 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1577 for (AbstractBlockBase<?> block : sortedBlocks) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1578 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1579 // check if block has only one predecessor and only one successor |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1580 if (block.getPredecessorCount() == 1 && block.getSuccessorCount() == 1) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1581 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1582 assert instructions.get(0) instanceof StandardOp.LabelOp : "block must start with label"; |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1583 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
|
1584 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1585 // check if block is empty (only label and branch) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1586 if (instructions.size() == 2) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1587 AbstractBlockBase<?> pred = block.getPredecessors().iterator().next(); |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1588 AbstractBlockBase<?> sux = block.getSuccessors().iterator().next(); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1589 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1590 // prevent optimization of two consecutive blocks |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1591 if (!blockCompleted.get(pred.getLinearScanNumber()) && !blockCompleted.get(sux.getLinearScanNumber())) { |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1592 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1593 Debug.log(" optimizing empty block B%d (pred: B%d, sux: B%d)", block.getId(), pred.getId(), sux.getId()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1594 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1595 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1596 blockCompleted.set(block.getLinearScanNumber()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1597 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1598 // directly resolve between pred and sux (without looking |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1599 // at the empty block |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1600 // between) |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1601 resolveCollectMappings(pred, sux, block, moveResolver); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1602 if (moveResolver.hasMappings()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1603 moveResolver.setInsertPosition(instructions, 1); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1604 moveResolver.resolveAndAppendMoves(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1605 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1606 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1607 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1608 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1609 } |
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
|
1610 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1611 for (AbstractBlockBase<?> fromBlock : sortedBlocks) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1612 if (!blockCompleted.get(fromBlock.getLinearScanNumber())) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1613 alreadyResolved.clear(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1614 alreadyResolved.or(blockCompleted); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1615 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1616 for (AbstractBlockBase<?> toBlock : fromBlock.getSuccessors()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1617 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1618 // check for duplicate edges between the same blocks (can happen with switch |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1619 // blocks) |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1620 if (!alreadyResolved.get(toBlock.getLinearScanNumber())) { |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1621 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1622 Debug.log("processing edge between B%d and B%d", fromBlock.getId(), toBlock.getId()); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1623 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1624 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1625 alreadyResolved.set(toBlock.getLinearScanNumber()); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1626 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1627 // collect all intervals that have been split between |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1628 // fromBlock and toBlock |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1629 resolveCollectMappings(fromBlock, toBlock, null, moveResolver); |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1630 if (moveResolver.hasMappings()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1631 resolveFindInsertPos(fromBlock, toBlock, moveResolver); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1632 moveResolver.resolveAndAppendMoves(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1633 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1634 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1635 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1636 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1637 } |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1638 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1639 } |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1642 // * Phase 7: assign register numbers back to LIR |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1643 // (includes computation of debug information and oop maps) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1644 |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18420
diff
changeset
|
1645 static StackSlotValue canonicalSpillOpr(Interval interval) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1646 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
|
1647 return interval.spillSlot(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1648 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1649 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1650 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1651 * Assigns the allocated location for an LIR instruction operand back into the instruction. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1652 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1653 * @param operand an LIR instruction operand |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1654 * @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
|
1655 * @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
|
1656 * @return the location assigned for the operand |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1657 */ |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
1658 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
|
1659 Interval interval = intervalFor(operand); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1660 assert interval != null : "interval must exist"; |
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 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
|
1663 if (DetailedAsserts.getValue()) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1664 AbstractBlockBase<?> block = blockForId(opId); |
7497
0f8c6dbf68be
Code clean up and documentation for ComputeBlockOrder class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6582
diff
changeset
|
1665 if (block.getSuccessorCount() <= 1 && opId == getLastLirInstructionId(block)) { |
21192
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1666 /* |
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1667 * Check if spill moves could have been appended at the end of this block, but |
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1668 * before the branch instruction. So the split child information for this branch |
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1669 * would be incorrect. |
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1670 */ |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
1671 LIRInstruction instr = ir.getLIRforBlock(block).get(ir.getLIRforBlock(block).size() - 1); |
4323
df5547057954
Remove LIROpcode and use non-anonymous subclasses of LIRInstruction
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
1672 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
|
1673 if (blockData.get(block).liveOut.get(operandNumber(operand))) { |
21192
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1674 assert false : String.format( |
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1675 "can't get split child for the last branch of a block because the information would be incorrect (moves are inserted before the branch in resolveDataFlow) block=%s, instruction=%s, operand=%s", |
4c7c22aa4bd7
LinearScan: add more information to assertion.
Josef Eisl <josef.eisl@jku.at>
parents:
21182
diff
changeset
|
1676 block, instr, operand); |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1679 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1680 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1681 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1682 // 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
|
1683 // so search the right interval here |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1684 interval = splitChildAtOpId(interval, opId, mode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1685 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1686 |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1687 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
|
1688 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
|
1689 return interval.getMaterializedValue(); |
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1690 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1691 return interval.location(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1692 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1693 |
13377
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1694 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
|
1695 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
|
1696 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
|
1697 |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1698 if (opId != -1) { |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1699 // 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
|
1700 // 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
|
1701 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
|
1702 } |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1703 |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1704 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
|
1705 } |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1706 |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1707 protected IntervalWalker initIntervalWalker(IntervalPredicate predicate) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1708 // setup lists of potential oops for walking |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1709 Interval oopIntervals; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1710 Interval nonOopIntervals; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1711 |
13340
9423a38d6437
added rematerialization of constants in LinearScan, but still disabled
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13339
diff
changeset
|
1712 oopIntervals = createUnhandledLists(predicate, null).first; |
3733
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 // 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
|
1715 // 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
|
1716 // 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
|
1717 nonOopIntervals = new Interval(Value.ILLEGAL, -1); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1718 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
|
1719 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1720 return new IntervalWalker(this, oopIntervals, nonOopIntervals); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1721 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1722 |
5539
bc647d8b0080
Renaming RiValue => Value.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5536
diff
changeset
|
1723 private boolean isCallerSave(Value operand) { |
5552
69a8969dbf40
Reduce public fields in api.code project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
1724 return attributes(asRegister(operand)).isCallerSave(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1725 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1726 |
17413
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1727 /** |
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1728 * @param op |
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1729 * @param operand |
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1730 * @param valueMode |
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1731 * @param flags |
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1732 * @see InstructionValueProcedure#doValue(LIRInstruction, Value, OperandMode, EnumSet) |
0a2e65e74a9c
LRSA: minor clean ups around debugInfoProcedure().
Josef Eisl <josef.eisl@jku.at>
parents:
17298
diff
changeset
|
1733 */ |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1734 private Value debugInfoProcedure(LIRInstruction op, Value operand, OperandMode valueMode, EnumSet<OperandFlag> flags) { |
18610 | 1735 if (isVirtualStackSlot(operand)) { |
1736 return operand; | |
1737 } | |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1738 int tempOpId = op.id(); |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1739 OperandMode mode = OperandMode.USE; |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1740 AbstractBlockBase<?> block = blockForId(tempOpId); |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1741 if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) { |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1742 // generating debug information for the last instruction of a block. |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1743 // if this instruction is a branch, spill moves are inserted before this branch |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1744 // and so the wrong operand would be returned (spill moves at block boundaries |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1745 // are not |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1746 // considered in the live ranges of intervals) |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1747 // Solution: use the first opId of the branch target block instead. |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1748 final LIRInstruction instr = ir.getLIRforBlock(block).get(ir.getLIRforBlock(block).size() - 1); |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1749 if (instr instanceof StandardOp.JumpOp) { |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1750 if (blockData.get(block).liveOut.get(operandNumber(operand))) { |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1751 tempOpId = getFirstLirInstructionId(block.getSuccessors().iterator().next()); |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1752 mode = OperandMode.DEF; |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1753 } |
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1754 } |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1755 } |
17297
07d5cf34b3c5
Work around uninitialized variables problem with javac and lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17294
diff
changeset
|
1756 |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1757 // Get current location of operand |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1758 // The operand must be live because debug information is considered when building |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1759 // the intervals |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1760 // if the interval is not live, colorLirOperand will cause an assert on failure |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1761 Value result = colorLirOperand((Variable) operand, tempOpId, mode); |
18436
59e65d3aa2fc
Use StackSlotValue where appropriate.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
1762 assert !hasCall(tempOpId) || isStackSlotValue(result) || isConstant(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls"; |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1763 return result; |
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1764 } |
16138
f315b1c0a590
Introduce InstructionValueProcedure.
Josef Eisl <josef.eisl@jku.at>
parents:
16118
diff
changeset
|
1765 |
19019
56e6b5756886
LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents:
18674
diff
changeset
|
1766 private void computeDebugInfo(final LIRInstruction op, LIRFrameState info) { |
17298
831e96d0777d
Better workaround for the uninitialized variable issue.
Josef Eisl <josef.eisl@jku.at>
parents:
17297
diff
changeset
|
1767 info.forEachState(op, this::debugInfoProcedure); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1768 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1769 |
19019
56e6b5756886
LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents:
18674
diff
changeset
|
1770 private void assignLocations(List<LIRInstruction> instructions) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1771 int numInst = instructions.size(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1772 boolean hasDead = false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1773 |
17291
182062f9739d
LSRA: replace anonymous InstructionValueProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17285
diff
changeset
|
1774 InstructionValueProcedure assignProc = (op, operand, mode, flags) -> isVariable(operand) ? colorLirOperand((Variable) operand, op.id(), mode) : operand; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1775 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
|
1776 final LIRInstruction op = instructions.get(j); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1777 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
|
1778 hasDead = true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1779 continue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1780 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1781 |
13377
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1782 // remove useless moves |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1783 MoveOp move = null; |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1784 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
|
1785 move = (MoveOp) op; |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1786 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
|
1787 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
|
1788 /* |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1789 * 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
|
1790 * 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
|
1791 * 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
|
1792 */ |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1793 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
|
1794 hasDead = true; |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1795 continue; |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1796 } |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1797 } |
40530019af02
enable rematerialization of constants in LinearScan, including a bug fix
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13376
diff
changeset
|
1798 |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
1799 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
|
1800 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
|
1801 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
|
1802 op.forEachOutput(assignProc); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1803 |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5711
diff
changeset
|
1804 // compute reference map and debug information |
19019
56e6b5756886
LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents:
18674
diff
changeset
|
1805 op.forEachState((inst, state) -> computeDebugInfo(inst, state)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1806 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1807 // 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
|
1808 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
|
1809 if (move.getInput().equals(move.getResult())) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1810 instructions.set(j, null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1811 hasDead = true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1812 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1813 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1814 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1815 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1816 if (hasDead) { |
6321
9418ff4c9e7c
Clean up ControlFlowOptimizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6317
diff
changeset
|
1817 // Remove null values from the list. |
9418ff4c9e7c
Clean up ControlFlowOptimizer.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6317
diff
changeset
|
1818 instructions.removeAll(Collections.singleton(null)); |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1821 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1822 private void assignLocations() { |
13467
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
1823 try (Indent indent = Debug.logAndIndent("assign locations")) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1824 for (AbstractBlockBase<?> block : sortedBlocks) { |
13467
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
1825 try (Indent indent2 = Debug.logAndIndent("assign locations in block B%d", block.getId())) { |
19019
56e6b5756886
LinearScan: remove support for markFrameLocations.
Josef Eisl <josef.eisl@jku.at>
parents:
18674
diff
changeset
|
1826 assignLocations(ir.getLIRforBlock(block)); |
13467
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
1827 } |
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 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1829 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1830 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1831 |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1832 private static final DebugTimer lifetimeTimer = Debug.timer("LinearScan_LifetimeAnalysis"); |
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1833 private static final DebugTimer registerAllocationTimer = Debug.timer("LinearScan_RegisterAllocation"); |
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1834 private static final DebugTimer optimizedSpillPositionTimer = Debug.timer("LinearScan_OptimizeSpillPosition"); |
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1835 private static final DebugTimer resolveDataFlowTimer = Debug.timer("LinearScan_ResolveDataFlow"); |
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1836 private static final DebugTimer eliminateSpillMoveTimer = Debug.timer("LinearScan_EliminateSpillMove"); |
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1837 private static final DebugTimer assignLocationsTimer = Debug.timer("LinearScan_AssignLocations"); |
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1838 |
19212 | 1839 void allocate() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1840 |
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
|
1841 /* |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
1842 * 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
|
1843 */ |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1844 try (Indent indent = Debug.logAndIndent("LinearScan allocate")) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1845 |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1846 try (Scope s = Debug.scope("LifetimeAnalysis"); DebugCloseable a = lifetimeTimer.start()) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1847 numberInstructions(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1848 printLir("Before register allocation", true); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1849 computeLocalLiveSets(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1850 computeGlobalLiveSets(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1851 buildIntervals(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1852 sortIntervalsBeforeAllocation(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1853 } catch (Throwable e) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1854 throw Debug.handle(e); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1855 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1856 |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1857 try (Scope s = Debug.scope("RegisterAllocation"); DebugCloseable a = registerAllocationTimer.start()) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1858 printIntervals("Before register allocation"); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1859 allocateRegisters(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1860 } catch (Throwable e) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1861 throw Debug.handle(e); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1862 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
1863 |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
1864 if (Options.LSRAOptimizeSpillPosition.getValue()) { |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1865 try (Scope s = Debug.scope("OptimizeSpillPosition"); DebugCloseable a = optimizedSpillPositionTimer.start()) { |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
1866 optimizeSpillPosition(); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
1867 } catch (Throwable e) { |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
1868 throw Debug.handle(e); |
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
1869 } |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1870 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1871 |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1872 try (Scope s = Debug.scope("ResolveDataFlow"); DebugCloseable a = resolveDataFlowTimer.start()) { |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1873 resolveDataFlow(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1874 } catch (Throwable e) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1875 throw Debug.handle(e); |
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 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1877 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1878 try (Scope s = Debug.scope("DebugInfo")) { |
18420
b7089e3d8457
Print LIR after FrameMap building.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
1879 printIntervals("After register allocation"); |
b7089e3d8457
Print LIR after FrameMap building.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
1880 printLir("After register allocation", true); |
b7089e3d8457
Print LIR after FrameMap building.
Josef Eisl <josef.eisl@jku.at>
parents:
18187
diff
changeset
|
1881 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1882 sortIntervalsAfterAllocation(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1883 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1884 if (DetailedAsserts.getValue()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1885 verify(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1886 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1887 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1888 beforeSpillMoveElimination(); |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1889 |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1890 try (Scope s1 = Debug.scope("EliminateSpillMove"); DebugCloseable a = eliminateSpillMoveTimer.start()) { |
16372
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1891 eliminateSpillMoves(); |
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1892 } catch (Throwable e) { |
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1893 throw Debug.handle(e); |
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1894 } |
17195
41a75081678c
Print LIR after move elimination.
Josef Eisl <josef.eisl@jku.at>
parents:
17126
diff
changeset
|
1895 printLir("After spill move elimination", true); |
16372
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1896 |
20151
bdd5ad8ce088
DebugTimers should be static final when possible
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20108
diff
changeset
|
1897 try (Scope s1 = Debug.scope("AssignLocations"); DebugCloseable a = assignLocationsTimer.start()) { |
16372
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1898 assignLocations(); |
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1899 } catch (Throwable e) { |
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1900 throw Debug.handle(e); |
73d7935be896
LSRA: add debug scope for eliminateSpillMoves() and assignLocations().
Josef Eisl <josef.eisl@jku.at>
parents:
16371
diff
changeset
|
1901 } |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1902 |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1903 if (DetailedAsserts.getValue()) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1904 verifyIntervals(); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1905 } |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1906 } catch (Throwable e) { |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1907 throw Debug.handle(e); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1908 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1909 |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1910 printLir("After register number assignment", true); |
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
1911 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1912 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1913 |
21236
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1914 protected void beforeSpillMoveElimination() { |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1915 } |
8d21d631a82d
LinearScan: minor refactoring and comment cleanup.
Josef Eisl <josef.eisl@jku.at>
parents:
21203
diff
changeset
|
1916 |
19693
2cca53fbf38f
Debug.metrics should be static final
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19565
diff
changeset
|
1917 private static final DebugMetric betterSpillPos = Debug.metric("BetterSpillPosition"); |
2cca53fbf38f
Debug.metrics should be static final
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19565
diff
changeset
|
1918 private static final DebugMetric betterSpillPosWithLowerProbability = Debug.metric("BetterSpillPositionWithLowerProbability"); |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1919 |
16362
b100bd079fff
LSRA spill optimization: add -G:+LSRAOptimizeSpillPosition option (default: enabled).
Josef Eisl <josef.eisl@jku.at>
parents:
16361
diff
changeset
|
1920 private void optimizeSpillPosition() { |
16378
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1921 LIRInsertionBuffer[] insertionBuffers = new LIRInsertionBuffer[ir.linearScanOrder().size()]; |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1922 for (Interval interval : intervals) { |
16359
f686fae77383
LSRA spill optimization: rename SpillInDominator.MultipleSpills to SpillState.SpillInDominator.
Josef Eisl <josef.eisl@jku.at>
parents:
16358
diff
changeset
|
1923 if (interval != null && interval.isSplitParent() && interval.spillState() == SpillState.SpillInDominator) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1924 AbstractBlockBase<?> defBlock = blockForId(interval.spillDefinitionPos()); |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1925 AbstractBlockBase<?> spillBlock = null; |
16369
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1926 Interval firstSpillChild = null; |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1927 try (Indent indent = Debug.logAndIndent("interval %s (%s)", interval, defBlock)) { |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1928 for (Interval splitChild : interval.getSplitChildren()) { |
18436
59e65d3aa2fc
Use StackSlotValue where appropriate.
Josef Eisl <josef.eisl@jku.at>
parents:
18425
diff
changeset
|
1929 if (isStackSlotValue(splitChild.location())) { |
16369
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1930 if (firstSpillChild == null || splitChild.from() < firstSpillChild.from()) { |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1931 firstSpillChild = splitChild; |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1932 } else { |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1933 assert firstSpillChild.from() < splitChild.from(); |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1934 } |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1935 // iterate all blocks where the interval has use positions |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1936 for (AbstractBlockBase<?> splitBlock : blocksForInterval(splitChild)) { |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
1937 if (dominates(defBlock, splitBlock)) { |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1938 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1939 Debug.log("Split interval %s, block %s", splitChild, splitBlock); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1940 } |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
1941 if (spillBlock == null) { |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
1942 spillBlock = splitBlock; |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
1943 } else { |
16506
505c17ed39da
LSRA spill optimization: use AbstractControlFlowGraph.commonDominator.
Josef Eisl <josef.eisl@jku.at>
parents:
16505
diff
changeset
|
1944 spillBlock = commonDominator(spillBlock, splitBlock); |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
1945 assert spillBlock != null; |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
1946 } |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
1947 } |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1948 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1949 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
1950 } |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1951 if (spillBlock == null) { |
16358
9371b9c246ca
LSRA spill optimization: spill at earliest dominator.
Josef Eisl <josef.eisl@jku.at>
parents:
16357
diff
changeset
|
1952 // no spill interval |
9371b9c246ca
LSRA spill optimization: spill at earliest dominator.
Josef Eisl <josef.eisl@jku.at>
parents:
16357
diff
changeset
|
1953 interval.setSpillState(SpillState.StoreAtDefinition); |
9371b9c246ca
LSRA spill optimization: spill at earliest dominator.
Josef Eisl <josef.eisl@jku.at>
parents:
16357
diff
changeset
|
1954 } else { |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1955 // move out of loops |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1956 if (defBlock.getLoopDepth() < spillBlock.getLoopDepth()) { |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1957 spillBlock = moveSpillOutOfLoop(defBlock, spillBlock); |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1958 } |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1959 |
16369
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1960 /* |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1961 * If the spill block is the begin of the first split child (aka the value |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1962 * is on the stack) spill in the dominator. |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1963 */ |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1964 assert firstSpillChild != null; |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1965 if (!defBlock.equals(spillBlock) && spillBlock.equals(blockForId(firstSpillChild.from()))) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
1966 AbstractBlockBase<?> dom = spillBlock.getDominator(); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1967 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1968 Debug.log("Spill block (%s) is the beginning of a spill child -> use dominator (%s)", spillBlock, dom); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1969 } |
16369
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1970 spillBlock = dom; |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1971 } |
f8ba57019a5d
LSRA spill optimization: move spill position to the dominator if at spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16368
diff
changeset
|
1972 |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1973 if (!defBlock.equals(spillBlock)) { |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1974 assert dominates(defBlock, spillBlock); |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
1975 betterSpillPos.increment(); |
20980
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1976 if (Debug.isLogEnabled()) { |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1977 Debug.log("Better spill position found (Block %s)", spillBlock); |
abc059cb0acf
Guard usages of Debug.log in LinearScan
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
20979
diff
changeset
|
1978 } |
16361
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
1979 |
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
1980 if (defBlock.probability() <= spillBlock.probability()) { |
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
1981 // better spill block has the same probability -> do nothing |
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
1982 interval.setSpillState(SpillState.StoreAtDefinition); |
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
1983 } else { |
16378
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1984 LIRInsertionBuffer insertionBuffer = insertionBuffers[spillBlock.getId()]; |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1985 if (insertionBuffer == null) { |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1986 insertionBuffer = new LIRInsertionBuffer(); |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1987 insertionBuffers[spillBlock.getId()] = insertionBuffer; |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1988 insertionBuffer.init(ir.getLIRforBlock(spillBlock)); |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1989 } |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1990 int spillOpId = getFirstLirInstructionId(spillBlock); |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1991 // insert spill move |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1992 AllocatableValue fromLocation = interval.getSplitChildAtOpId(spillOpId, OperandMode.DEF, this).location(); |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1993 AllocatableValue toLocation = canonicalSpillOpr(interval); |
19549
1cf73c50e3dc
Move SpillMoveFactory from LIR to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
19212
diff
changeset
|
1994 LIRInstruction move = getSpillMoveFactory().createMove(toLocation, fromLocation); |
16380
8057279ec60e
LSRA spill optimization: use DOMINATOR_SPILL_MOVE_ID to mark moves.
Josef Eisl <josef.eisl@jku.at>
parents:
16379
diff
changeset
|
1995 move.setId(DOMINATOR_SPILL_MOVE_ID); |
16378
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1996 /* |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1997 * We can use the insertion buffer directly because we always insert |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1998 * at position 1. |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
1999 */ |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2000 insertionBuffer.append(1, move); |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2001 |
16361
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
2002 betterSpillPosWithLowerProbability.increment(); |
16378
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2003 interval.setSpillDefinitionPos(spillOpId); |
16361
faff09aa5999
LSRA spill optimization: only use predecessor block if it has lower probability than the definition.
Josef Eisl <josef.eisl@jku.at>
parents:
16360
diff
changeset
|
2004 } |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2005 } else { |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2006 // definition is the best choice |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2007 interval.setSpillState(SpillState.StoreAtDefinition); |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2008 } |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
2009 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
2010 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
2011 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
2012 } |
16378
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2013 for (LIRInsertionBuffer insertionBuffer : insertionBuffers) { |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2014 if (insertionBuffer != null) { |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2015 assert insertionBuffer.initialized() : "Insertion buffer is nonnull but not initialized!"; |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2016 insertionBuffer.finish(); |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2017 } |
d075b97fbd31
LSRA spill optimization: insert spill moves eagerly.
Josef Eisl <josef.eisl@jku.at>
parents:
16377
diff
changeset
|
2018 } |
16357
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
2019 } |
a07492ccaf52
LSRA spill optimization: calculate optimized spill position.
Josef Eisl <josef.eisl@jku.at>
parents:
16355
diff
changeset
|
2020 |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2021 /** |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2022 * Iterate over all {@link AbstractBlockBase blocks} of an interval. |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2023 */ |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2024 private class IntervalBlockIterator implements Iterator<AbstractBlockBase<?>> { |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2025 |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2026 Range range; |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2027 AbstractBlockBase<?> block; |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2028 |
16376
ef21879c0c8f
LSRA spill optimization: rename UseBlockIterator to IntervalBlockIterator.
Josef Eisl <josef.eisl@jku.at>
parents:
16375
diff
changeset
|
2029 public IntervalBlockIterator(Interval interval) { |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2030 range = interval.first(); |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2031 block = blockForId(range.from); |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2032 } |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2033 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2034 public AbstractBlockBase<?> next() { |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2035 AbstractBlockBase<?> currentBlock = block; |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2036 int nextBlockIndex = block.getLinearScanNumber() + 1; |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2037 if (nextBlockIndex < sortedBlocks.size()) { |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2038 block = sortedBlocks.get(nextBlockIndex); |
16375
ff14306337f2
LSRA spill optimization: fix UseBlockIterator.
Josef Eisl <josef.eisl@jku.at>
parents:
16374
diff
changeset
|
2039 if (range.to <= getFirstLirInstructionId(block)) { |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2040 range = range.next; |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2041 if (range == Range.EndMarker) { |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2042 block = null; |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2043 } else { |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2044 block = blockForId(range.from); |
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2045 } |
16370
3324ab9fe71a
LSRA spill optimization: iterate all ranges of spill interval.
Josef Eisl <josef.eisl@jku.at>
parents:
16369
diff
changeset
|
2046 } |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2047 } else { |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2048 block = null; |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2049 } |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2050 return currentBlock; |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2051 } |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2052 |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2053 public boolean hasNext() { |
16373
74e93f5ba4f3
LSRA spill optimization: consider all spill blocks not only use positions.
Josef Eisl <josef.eisl@jku.at>
parents:
16372
diff
changeset
|
2054 return block != null; |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2055 } |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2056 } |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2057 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2058 private Iterable<AbstractBlockBase<?>> blocksForInterval(Interval interval) { |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2059 return new Iterable<AbstractBlockBase<?>>() { |
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2060 public Iterator<AbstractBlockBase<?>> iterator() { |
16376
ef21879c0c8f
LSRA spill optimization: rename UseBlockIterator to IntervalBlockIterator.
Josef Eisl <josef.eisl@jku.at>
parents:
16375
diff
changeset
|
2061 return new IntervalBlockIterator(interval); |
16364
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2062 } |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2063 }; |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2064 } |
a54a64af1e82
LSRA spill optimization: take all blocks (with usepos) of a spill interval into account.
Josef Eisl <josef.eisl@jku.at>
parents:
16363
diff
changeset
|
2065 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2066 private static AbstractBlockBase<?> moveSpillOutOfLoop(AbstractBlockBase<?> defBlock, AbstractBlockBase<?> spillBlock) { |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2067 int defLoopDepth = defBlock.getLoopDepth(); |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2068 for (AbstractBlockBase<?> block = spillBlock.getDominator(); !defBlock.equals(block); block = block.getDominator()) { |
16360
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2069 assert block != null : "spill block not dominated by definition block?"; |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2070 if (block.getLoopDepth() <= defLoopDepth) { |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2071 assert block.getLoopDepth() == defLoopDepth : "Cannot spill an interval outside of the loop where it is defined!"; |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2072 return block; |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2073 } |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2074 } |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2075 return defBlock; |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2076 } |
ec54fc47ba5d
LSRA spill optimization: move spill out of loops.
Josef Eisl <josef.eisl@jku.at>
parents:
16359
diff
changeset
|
2077 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2078 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
|
2079 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
|
2080 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
|
2081 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
|
2082 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
|
2083 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
|
2084 } |
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 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2086 |
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
|
2087 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
|
2088 for (int i = 0; i < blockCount(); i++) { |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2089 AbstractBlockBase<?> block = blockAt(i); |
13467
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2090 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
|
2091 } |
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 } |
4353
043bec543161
More work on debug framework. Removed concept of GraalContext.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4352
diff
changeset
|
2095 Debug.dump(Arrays.copyOf(intervals, intervalsSize), label); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2096 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2097 |
7556
630ea5001e33
Modified formatter settings to not insert line break after annotation on parameters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
2098 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
|
2099 Debug.dump(ir, label); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2100 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2101 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2102 boolean verify() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2103 // (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
|
2104 verifyIntervals(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2105 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2106 verifyRegisters(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2107 |
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
|
2108 Debug.log("no errors found"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2109 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2110 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2111 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2112 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2113 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
|
2114 // 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
|
2115 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
|
2116 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
|
2117 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
|
2118 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2119 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2120 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2121 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
|
2122 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
|
2123 int len = intervalsSize; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2124 |
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
|
2125 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
|
2126 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
|
2127 if (i1 == null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2128 continue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2129 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2130 |
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
|
2131 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
|
2132 |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2133 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
|
2134 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
|
2135 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
|
2136 throw new GraalInternalError(""); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2137 } |
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
|
2138 |
16118
5cbaad0b7387
Verify usage of equals method in LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
2139 if (isVariable(i1.operand) && i1.kind().equals(LIRKind.Illegal)) { |
13467
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2140 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
|
2141 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
|
2142 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
|
2143 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2144 |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2145 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
|
2146 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
|
2147 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
|
2148 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
|
2149 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2150 |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2151 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
|
2152 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
|
2153 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
|
2154 throw new GraalInternalError(""); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2155 } |
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
|
2156 |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2157 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
|
2158 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
|
2159 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
|
2160 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
|
2161 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
|
2162 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2163 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2164 |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2165 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
|
2166 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
|
2167 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
|
2168 continue; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2169 } |
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
|
2170 |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2171 // 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
|
2172 // . 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
|
2173 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
|
2174 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
|
2175 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2176 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
|
2177 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
|
2178 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2179 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
|
2180 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
|
2181 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
|
2182 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
|
2183 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
|
2184 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
|
2185 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
|
2186 } |
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2187 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
|
2188 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2189 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2190 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2191 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2192 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2193 |
17285
3a834111a632
Make [Instruction]ValueProcedure and [Instruction]ValueConsumer a FunctionalInterface.
Josef Eisl <josef.eisl@jku.at>
parents:
17284
diff
changeset
|
2194 class CheckConsumer implements ValueConsumer { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7512
diff
changeset
|
2195 |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2196 boolean ok; |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2197 Interval curInterval; |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2198 |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2199 @Override |
17284
d21962ea9617
Remove ValueConsumer.visitValue(Value).
Josef Eisl <josef.eisl@jku.at>
parents:
17283
diff
changeset
|
2200 public void visitValue(Value operand, OperandMode mode, EnumSet<OperandFlag> flags) { |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2201 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
|
2202 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
|
2203 ok = true; |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2204 } |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2205 } |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2206 } |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2207 } |
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2208 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2209 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
|
2210 try (Indent indent = Debug.logAndIndent("verifying that no oops are in fixed intervals *")) { |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2211 CheckConsumer checkConsumer = new CheckConsumer(); |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2212 |
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
|
2213 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
|
2214 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
|
2215 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
|
2216 // 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
|
2217 // 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
|
2218 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
|
2219 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
|
2220 IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2221 |
19560
4d70d150944f
Remove AbstractBlock interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19212
diff
changeset
|
2222 for (AbstractBlockBase<?> block : sortedBlocks) { |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14789
diff
changeset
|
2223 List<LIRInstruction> instructions = ir.getLIRforBlock(block); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2224 |
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
|
2225 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
|
2226 LIRInstruction op = instructions.get(j); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2227 |
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
|
2228 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
|
2229 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
|
2230 boolean checkLive = true; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2231 |
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
|
2232 // 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
|
2233 // 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
|
2234 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
|
2235 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
|
2236 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
|
2237 // 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
|
2238 // 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
|
2239 // referenced by this op either as an input or output. |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2240 checkConsumer.curInterval = interval; |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2241 checkConsumer.ok = false; |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2242 |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2243 op.visitEachInput(checkConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2244 op.visitEachAlive(checkConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2245 op.visitEachTemp(checkConsumer); |
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2246 op.visitEachOutput(checkConsumer); |
4245
75c620f90ab9
Support stack-operands and register hints in new register allocator API
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4214
diff
changeset
|
2247 |
16801
067dbd8e7114
Use ValueConsumer in LinearScan where possible.
Josef Eisl <josef.eisl@jku.at>
parents:
16796
diff
changeset
|
2248 assert checkConsumer.ok : "fixed intervals should never be live across an oopmap point"; |
13467
7c694e3e97e5
remove remaining old style TTY debug logging in LinearScan and remove TraceLinearScan option
Erik Eckstein <erik.eckstein@oracle.com>
parents:
13377
diff
changeset
|
2249 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2250 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2251 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2252 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2253 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2254 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2255 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2256 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2257 |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2258 /** |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2259 * Returns a value for a interval definition, which can be used for re-materialization. |
14871
667710021ea1
removed methods in Indent that are redundant with those in Debug
Doug Simon <doug.simon@oracle.com>
parents:
14841
diff
changeset
|
2260 * |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2261 * @param op An instruction which defines a value |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2262 * @param operand The destination operand of the instruction |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2263 * @param interval The interval for this defined value. |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2264 * @return Returns the value which is moved to the instruction and which can be reused at all |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2265 * reload-locations in case the interval of this instruction is spilled. Currently this |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18152
diff
changeset
|
2266 * can only be a {@link JavaConstant}. |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2267 */ |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18152
diff
changeset
|
2268 public static JavaConstant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) { |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2269 if (op instanceof MoveOp) { |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2270 MoveOp move = (MoveOp) op; |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18152
diff
changeset
|
2271 if (move.getInput() instanceof JavaConstant) { |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2272 /* |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2273 * Check if the interval has any uses which would accept an stack location (priority |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2274 * == ShouldHaveRegister). Rematerialization of such intervals can result in a |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2275 * degradation, because rematerialization always inserts a constant load, even if |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2276 * the value is not needed in a register. |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2277 */ |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2278 Interval.UsePosList usePosList = interval.usePosList(); |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2279 int numUsePos = usePosList.size(); |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2280 for (int useIdx = 0; useIdx < numUsePos; useIdx++) { |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2281 Interval.RegisterPriority priority = usePosList.registerPriority(useIdx); |
15920 | 2282 if (priority == Interval.RegisterPriority.ShouldHaveRegister) { |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2283 return null; |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2284 } |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2285 } |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18152
diff
changeset
|
2286 return (JavaConstant) move.getInput(); |
14070
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2287 } |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2288 } |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2289 return null; |
a8a82c6e2981
Remove LIRGenerator from LinearScan.
Josef Eisl <josef.eisl@jku.at>
parents:
14057
diff
changeset
|
2290 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2291 } |