Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java @ 15534:4bd6ad45ee0a
Encapsulate members of Loop.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 05 May 2014 11:10:19 +0200 |
parents | 81eee524bbec |
children | f0254bab4c6b |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
2 * Copyright (c) 2011, 2013, 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 */ |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
23 package com.oracle.graal.phases.schedule; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
25 import static com.oracle.graal.api.meta.LocationIdentity.*; |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
26 import static com.oracle.graal.compiler.common.GraalOptions.*; |
10609
5f016460f95b
scheduling: remove duplicated code
Bernhard Urban <bernhard.urban@jku.at>
parents:
10490
diff
changeset
|
27 import static com.oracle.graal.nodes.cfg.ControlFlowGraph.*; |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
28 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 |
9792
06dc2d2324d6
pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents:
9725
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15192
diff
changeset
|
32 import com.oracle.graal.compiler.common.*; |
15192
644dfe49c0f4
Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents:
15173
diff
changeset
|
33 import com.oracle.graal.compiler.common.cfg.*; |
6500
8fd4201ce98c
moved TTY and LogStream to com.oracle.graal.debug
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
34 import com.oracle.graal.debug.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.graph.Node.Verbosity; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.nodes.*; |
6529
2e96dc4eb8e2
renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents:
6526
diff
changeset
|
38 import com.oracle.graal.nodes.cfg.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 import com.oracle.graal.nodes.extended.*; |
11787
4fc75b6ca3dd
Introduce NodeWithState for nodes that hold some VirtualState. Use this interface in the required special cases (Scheduling and PEA)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11501
diff
changeset
|
40 import com.oracle.graal.nodes.spi.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.nodes.virtual.*; |
6525
2c913b643422
rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents:
6522
diff
changeset
|
42 import com.oracle.graal.phases.*; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
43 import com.oracle.graal.phases.graph.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
44 import com.oracle.graal.phases.graph.ReentrantBlockIterator.BlockIteratorClosure; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
45 import com.oracle.graal.phases.graph.ReentrantBlockIterator.LoopInfo; |
13369
c3ecad078114
utils: introduce ArraySet. use it instead of HashSet at some places
Bernhard Urban <bernhard.urban@jku.at>
parents:
13327
diff
changeset
|
46 import com.oracle.graal.phases.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
48 public final class SchedulePhase extends Phase { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
49 |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
50 /** |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
51 * Error thrown when a graph cannot be scheduled. |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
52 */ |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
53 public static class SchedulingError extends Error { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
54 |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
55 private static final long serialVersionUID = 1621001069476473145L; |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
56 |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
57 public SchedulingError() { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
58 super(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
59 } |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
60 |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
61 /** |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
62 * This constructor creates a {@link SchedulingError} with a message assembled via |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
63 * {@link String#format(String, Object...)}. |
14763 | 64 * |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
65 * @param format a {@linkplain Formatter format} string |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
66 * @param args parameters to {@link String#format(String, Object...)} |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
67 */ |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
68 public SchedulingError(String format, Object... args) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
69 super(String.format(format, args)); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
70 } |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
71 |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
72 } |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
73 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
74 public static enum SchedulingStrategy { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14906
diff
changeset
|
75 EARLIEST, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14906
diff
changeset
|
76 LATEST, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14906
diff
changeset
|
77 LATEST_OUT_OF_LOOPS |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
78 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
79 |
10894
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
80 public static enum MemoryScheduling { |
14908
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14906
diff
changeset
|
81 NONE, |
8db6e76cb658
Formatter: Keep one enum constant per line
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14906
diff
changeset
|
82 OPTIMAL |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
83 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
84 |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
85 private class KillSet implements Iterable<LocationIdentity> { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
86 private final Set<LocationIdentity> set; |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
87 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
88 public KillSet() { |
13369
c3ecad078114
utils: introduce ArraySet. use it instead of HashSet at some places
Bernhard Urban <bernhard.urban@jku.at>
parents:
13327
diff
changeset
|
89 this.set = new ArraySet<>(); |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
90 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
91 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
92 public KillSet(KillSet other) { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
93 this.set = new HashSet<>(other.set); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
94 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
95 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
96 public void add(LocationIdentity locationIdentity) { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
97 set.add(locationIdentity); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
98 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
99 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
100 public void addAll(KillSet other) { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
101 set.addAll(other.set); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
102 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
103 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
104 public Iterator<LocationIdentity> iterator() { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
105 return set.iterator(); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
106 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
107 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
108 public boolean isKilled(LocationIdentity locationIdentity) { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
109 return set.contains(locationIdentity); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
110 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
111 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
112 } |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
113 |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
114 private class NewMemoryScheduleClosure extends BlockIteratorClosure<KillSet> { |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
115 private Node excludeNode; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
116 private Block upperBoundBlock; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
117 |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
118 public NewMemoryScheduleClosure(Node excludeNode, Block upperBoundBlock) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
119 this.excludeNode = excludeNode; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
120 this.upperBoundBlock = upperBoundBlock; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
121 } |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
122 |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
123 public NewMemoryScheduleClosure() { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
124 this(null, null); |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
125 } |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
126 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
127 @Override |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
128 protected KillSet getInitialState() { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
129 return cloneState(blockToKillSet.get(getCFG().getStartBlock())); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
130 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
131 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
132 @Override |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
133 protected KillSet processBlock(Block block, KillSet currentState) { |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
134 assert block != null; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
135 currentState.addAll(computeKillSet(block, block == upperBoundBlock ? excludeNode : null)); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
136 return currentState; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
137 } |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
138 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
139 @Override |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
140 protected KillSet merge(Block merge, List<KillSet> states) { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
141 assert merge.getBeginNode() instanceof MergeNode; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
142 |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
143 KillSet initKillSet = new KillSet(); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
144 for (KillSet state : states) { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
145 initKillSet.addAll(state); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
146 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
147 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
148 return initKillSet; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
149 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
150 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
151 @Override |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
152 protected KillSet cloneState(KillSet state) { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
153 return new KillSet(state); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
154 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
155 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
156 @Override |
15107 | 157 protected List<KillSet> processLoop(Loop<Block> loop, KillSet state) { |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
158 LoopInfo<KillSet> info = ReentrantBlockIterator.processLoop(this, loop, cloneState(state)); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
159 |
15534
4bd6ad45ee0a
Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents:
15423
diff
changeset
|
160 assert loop.getHeader().getBeginNode() instanceof LoopBeginNode; |
4bd6ad45ee0a
Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents:
15423
diff
changeset
|
161 KillSet headerState = merge(loop.getHeader(), info.endStates); |
11863
7763a42d1658
NewMemoryAwareScheduling: handle MemoryPhis properly
Bernhard Urban <bernhard.urban@jku.at>
parents:
11787
diff
changeset
|
162 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
163 // second iteration, for propagating information to loop exits |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
164 info = ReentrantBlockIterator.processLoop(this, loop, cloneState(headerState)); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
165 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
166 return info.exitStates; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
167 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
168 } |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
169 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
170 /** |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
171 * gather all kill locations by iterating trough the nodes assigned to a block. |
14763 | 172 * |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
173 * assumptions: {@link MemoryCheckpoint MemoryCheckPoints} are {@link FixedNode FixedNodes}. |
14763 | 174 * |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
175 * @param block block to analyze |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
176 * @param excludeNode if null, compute normal set of kill locations. if != null, don't add kills |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
177 * until we reach excludeNode. |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
178 * @return all killed locations |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
179 */ |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
180 private KillSet computeKillSet(Block block, Node excludeNode) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
181 // cache is only valid if we don't potentially exclude kills from the set |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
182 if (excludeNode == null) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
183 KillSet cachedSet = blockToKillSet.get(block); |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
184 if (cachedSet != null) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
185 return cachedSet; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
186 } |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
187 } |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
188 |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
189 // add locations to excludedLocations until we reach the excluded node |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
190 boolean foundExcludeNode = excludeNode == null; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
191 |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
192 KillSet set = new KillSet(); |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
193 KillSet excludedLocations = new KillSet(); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
194 if (block.getBeginNode() instanceof MergeNode) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
195 MergeNode mergeNode = (MergeNode) block.getBeginNode(); |
13152
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
13092
diff
changeset
|
196 for (MemoryPhiNode phi : mergeNode.usages().filter(MemoryPhiNode.class)) { |
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
13092
diff
changeset
|
197 if (foundExcludeNode) { |
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
13092
diff
changeset
|
198 set.add(phi.getLocationIdentity()); |
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
13092
diff
changeset
|
199 } else { |
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
13092
diff
changeset
|
200 excludedLocations.add(phi.getLocationIdentity()); |
640516a8ca6b
Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents:
13092
diff
changeset
|
201 foundExcludeNode = phi == excludeNode; |
11863
7763a42d1658
NewMemoryAwareScheduling: handle MemoryPhis properly
Bernhard Urban <bernhard.urban@jku.at>
parents:
11787
diff
changeset
|
202 } |
7763a42d1658
NewMemoryAwareScheduling: handle MemoryPhis properly
Bernhard Urban <bernhard.urban@jku.at>
parents:
11787
diff
changeset
|
203 } |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
204 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
205 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15107
diff
changeset
|
206 BeginNode startNode = cfg.getStartBlock().getBeginNode(); |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
207 assert startNode instanceof StartNode; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
208 |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
209 KillSet accm = foundExcludeNode ? set : excludedLocations; |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
210 for (Node node : block.getNodes()) { |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
211 if (!foundExcludeNode && node == excludeNode) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
212 foundExcludeNode = true; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
213 } |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
214 if (node == startNode) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
215 continue; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
216 } |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
217 if (node instanceof MemoryCheckpoint.Single) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
218 LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity(); |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
219 accm.add(identity); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
220 } else if (node instanceof MemoryCheckpoint.Multi) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
221 for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) { |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
222 accm.add(identity); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
223 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
224 } |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
225 assert MemoryCheckpoint.TypeAssertion.correctType(node); |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
226 |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
227 if (foundExcludeNode) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
228 accm = set; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
229 } |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
230 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
231 |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
232 // merge it for the cache entry |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
233 excludedLocations.addAll(set); |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
234 blockToKillSet.put(block, excludedLocations); |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
235 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
236 return set; |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
237 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
238 |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
239 private KillSet computeKillSet(Block block) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
240 return computeKillSet(block, null); |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
241 } |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
242 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
243 private ControlFlowGraph cfg; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 private NodeMap<Block> earliestCache; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
246 /** |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
247 * Map from blocks to the nodes in each block. |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
248 */ |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
249 private BlockMap<List<ScheduledNode>> blockToNodesMap; |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
250 private BlockMap<KillSet> blockToKillSet; |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
251 private final SchedulingStrategy selectedStrategy; |
10894
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
252 private final MemoryScheduling memsched; |
8325
330b455f18be
Make scheduling phase customizable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8323
diff
changeset
|
253 |
330b455f18be
Make scheduling phase customizable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8323
diff
changeset
|
254 public SchedulePhase() { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9810
diff
changeset
|
255 this(OptScheduleOutOfLoops.getValue() ? SchedulingStrategy.LATEST_OUT_OF_LOOPS : SchedulingStrategy.LATEST); |
8325
330b455f18be
Make scheduling phase customizable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8323
diff
changeset
|
256 } |
330b455f18be
Make scheduling phase customizable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8323
diff
changeset
|
257 |
330b455f18be
Make scheduling phase customizable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8323
diff
changeset
|
258 public SchedulePhase(SchedulingStrategy strategy) { |
13370
3e67710a6d08
SchedulePhase: remove old memory aware scheudling
Bernhard Urban <bernhard.urban@jku.at>
parents:
13369
diff
changeset
|
259 this.memsched = MemoryAwareScheduling.getValue() ? MemoryScheduling.OPTIMAL : MemoryScheduling.NONE; |
8330
022ae20329fb
Rename field.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8325
diff
changeset
|
260 this.selectedStrategy = strategy; |
8325
330b455f18be
Make scheduling phase customizable.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8323
diff
changeset
|
261 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 |
10925
32a48a01e411
SchedulePhase: remove debugging boolean
Bernhard Urban <bernhard.urban@jku.at>
parents:
10924
diff
changeset
|
263 public SchedulePhase(SchedulingStrategy strategy, MemoryScheduling memsched) { |
10894
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
264 this.selectedStrategy = strategy; |
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
265 this.memsched = memsched; |
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
266 } |
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
267 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 protected void run(StructuredGraph graph) { |
13729
9a6faa08bffe
cyclic graph verification
Lukas Stadler <lukas.stadler@jku.at>
parents:
13599
diff
changeset
|
270 assert GraphOrder.assertNonCyclicGraph(graph); |
9413
4f8b7dc2766d
SchedulePhase: compute post-dominators in CFG-graph
Bernhard Urban <bernhard.urban@jku.at>
parents:
8957
diff
changeset
|
271 cfg = ControlFlowGraph.compute(graph, true, true, true, true); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 earliestCache = graph.createNodeMap(); |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
273 blockToNodesMap = new BlockMap<>(cfg); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 |
13370
3e67710a6d08
SchedulePhase: remove old memory aware scheudling
Bernhard Urban <bernhard.urban@jku.at>
parents:
13369
diff
changeset
|
275 if (memsched == MemoryScheduling.OPTIMAL && selectedStrategy != SchedulingStrategy.EARLIEST && graph.getNodes(FloatingReadNode.class).isNotEmpty()) { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
276 blockToKillSet = new BlockMap<>(cfg); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
277 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
278 assignBlockToNodes(graph, selectedStrategy); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
279 printSchedule("after assign nodes to blocks"); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
280 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
281 sortNodesWithinBlocks(graph, selectedStrategy); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
282 printSchedule("after sorting nodes within blocks"); |
10894
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
283 } else { |
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
284 assignBlockToNodes(graph, selectedStrategy); |
af441d477a40
SchedulingPhase: add option for new memory aware scheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10892
diff
changeset
|
285 sortNodesWithinBlocks(graph, selectedStrategy); |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
286 } |
3733
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 |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
289 private Block blockForMemoryNode(MemoryNode memory) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
290 MemoryNode current = memory; |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
291 while (current instanceof MemoryProxy) { |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
292 current = ((MemoryProxy) current).getOriginalMemoryNode(); |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
293 } |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
294 Block b = cfg.getNodeToBlock().get(current.asNode()); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
295 assert b != null : "all lastAccess locations should have a block assignment from CFG"; |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
296 return b; |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
297 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
298 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
299 private void printSchedule(String desc) { |
14534
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
300 if (Debug.isLogEnabled()) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
301 Formatter buf = new Formatter(); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
302 buf.format("=== %s / %s / %s (%s) ===%n", getCFG().getStartBlock().getBeginNode().graph(), selectedStrategy, memsched, desc); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
303 for (Block b : getCFG().getBlocks()) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
304 buf.format("==== b: %s (loopDepth: %s). ", b, b.getLoopDepth()); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
305 buf.format("dom: %s. ", b.getDominator()); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
306 buf.format("post-dom: %s. ", b.getPostdominator()); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
307 buf.format("preds: %s. ", b.getPredecessors()); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
308 buf.format("succs: %s ====%n", b.getSuccessors()); |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
309 BlockMap<KillSet> killSets = blockToKillSet; |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
310 if (killSets != null) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
311 buf.format("X block kills: %n"); |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
312 if (killSets.get(b) != null) { |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
313 for (LocationIdentity locId : killSets.get(b)) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
314 buf.format("X %s killed by %s%n", locId, "dunno anymore"); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
315 } |
11863
7763a42d1658
NewMemoryAwareScheduling: handle MemoryPhis properly
Bernhard Urban <bernhard.urban@jku.at>
parents:
11787
diff
changeset
|
316 } |
7763a42d1658
NewMemoryAwareScheduling: handle MemoryPhis properly
Bernhard Urban <bernhard.urban@jku.at>
parents:
11787
diff
changeset
|
317 } |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
318 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
319 if (blockToNodesMap.get(b) != null) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
320 for (Node n : nodesFor(b)) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
321 printNode(n); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
322 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
323 } else { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
324 for (Node n : b.getNodes()) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
325 printNode(n); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
326 } |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
327 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
328 } |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
329 buf.format("%n"); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
330 Debug.log("%s", buf); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
331 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
332 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
333 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
334 private static void printNode(Node n) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
335 Formatter buf = new Formatter(); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
336 buf.format("%s", n); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
337 if (n instanceof MemoryCheckpoint.Single) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
338 buf.format(" // kills %s", ((MemoryCheckpoint.Single) n).getLocationIdentity()); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
339 } else if (n instanceof MemoryCheckpoint.Multi) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
340 buf.format(" // kills "); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
341 for (LocationIdentity locid : ((MemoryCheckpoint.Multi) n).getLocationIdentities()) { |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
342 buf.format("%s, ", locid); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
343 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
344 } else if (n instanceof FloatingReadNode) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
345 FloatingReadNode frn = (FloatingReadNode) n; |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
346 buf.format(" // from %s", frn.location().getLocationIdentity()); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
347 buf.format(", lastAccess: %s", frn.getLastLocationAccess()); |
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
348 buf.format(", object: %s", frn.object()); |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
349 } else if (n instanceof GuardNode) { |
15008
01fdabd19cd5
new AnchoringNode interface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14908
diff
changeset
|
350 buf.format(", anchor: %s", ((GuardNode) n).getAnchor()); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
351 } |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
352 Debug.log("%s", buf); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
353 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
354 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
355 public ControlFlowGraph getCFG() { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
356 return cfg; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
359 /** |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
360 * Gets the map from each block to the nodes in the block. |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
361 */ |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
362 public BlockMap<List<ScheduledNode>> getBlockToNodesMap() { |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
363 return blockToNodesMap; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
364 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
366 /** |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
367 * Gets the nodes in a given block. |
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
368 */ |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
369 public List<ScheduledNode> nodesFor(Block block) { |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
370 return blockToNodesMap.get(block); |
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 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
373 private void assignBlockToNodes(StructuredGraph graph, SchedulingStrategy strategy) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
374 for (Block block : cfg.getBlocks()) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
375 List<ScheduledNode> nodes = new ArrayList<>(); |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
376 if (blockToNodesMap.get(block) != null) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
377 throw new SchedulingError(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
378 } |
5248
066f1687ba24
rename: nodesFor -> blockToNodesMap
Doug Simon <doug.simon@oracle.com>
parents:
5210
diff
changeset
|
379 blockToNodesMap.put(block, nodes); |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
380 for (FixedNode node : block.getNodes()) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
381 nodes.add(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
382 } |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
385 for (Node n : graph.getNodes()) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
386 if (n instanceof ScheduledNode) { |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
387 assignBlockToNode((ScheduledNode) n, strategy); |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
388 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
392 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
393 * Assigns a block to the given node. This method expects that PhiNodes and FixedNodes are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
394 * already assigned to a block. |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
395 */ |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
396 private void assignBlockToNode(ScheduledNode node, SchedulingStrategy strategy) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
397 assert !node.isDeleted(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 |
14534
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
399 if (cfg.getNodeToBlock().containsKey(node)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
400 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 } |
10892
caa8706c6202
CFG: attach proxies to loop exits
Bernhard Urban <bernhard.urban@jku.at>
parents:
10891
diff
changeset
|
402 // PhiNodes, ProxyNodes and FixedNodes should already have been placed in blocks by |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
403 // ControlFlowGraph.identifyBlocks |
10892
caa8706c6202
CFG: attach proxies to loop exits
Bernhard Urban <bernhard.urban@jku.at>
parents:
10891
diff
changeset
|
404 if (node instanceof PhiNode || node instanceof ProxyNode || node instanceof FixedNode) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
405 throw new SchedulingError("%s should already have been placed in a block", node); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
406 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
407 |
11865
3d97040060d4
SchedulePhase: bail out with SchedulingError if scheduled block is not dominated by earliest
Bernhard Urban <bernhard.urban@jku.at>
parents:
11864
diff
changeset
|
408 Block earliestBlock = earliestBlock(node); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
409 Block block = null; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
410 Block latest = null; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
411 switch (strategy) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
412 case EARLIEST: |
11865
3d97040060d4
SchedulePhase: bail out with SchedulingError if scheduled block is not dominated by earliest
Bernhard Urban <bernhard.urban@jku.at>
parents:
11864
diff
changeset
|
413 block = earliestBlock; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
414 break; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
415 case LATEST: |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
416 case LATEST_OUT_OF_LOOPS: |
12772
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
417 boolean scheduleRead = memsched == MemoryScheduling.OPTIMAL && node instanceof FloatingReadNode && ((FloatingReadNode) node).location().getLocationIdentity() != FINAL_LOCATION; |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
418 if (scheduleRead) { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
419 FloatingReadNode read = (FloatingReadNode) node; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
420 block = optimalBlock(read, strategy); |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
421 Debug.log("schedule for %s: %s", read, block); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
422 assert earliestBlock.dominates(block) : String.format("%s (%s) cannot be scheduled before earliest schedule (%s). location: %s", read, block, earliestBlock, |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
423 read.getLocationIdentity()); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
424 } else { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
425 block = latestBlock(node, strategy); |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
426 } |
12772
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
427 if (block == null) { |
14534
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
428 // handle nodes without usages |
12772
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
429 block = earliestBlock; |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
430 } else if (strategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS && !(node instanceof VirtualObjectNode)) { |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
431 // schedule at the latest position possible in the outermost loop possible |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
432 latest = block; |
12772
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
433 block = scheduleOutOfLoops(node, block, earliestBlock); |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
434 } |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
435 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
436 if (assertionEnabled()) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
437 if (scheduleRead) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
438 FloatingReadNode read = (FloatingReadNode) node; |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
439 MemoryNode lastLocationAccess = read.getLastLocationAccess(); |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
440 Block upperBound = blockForMemoryNode(lastLocationAccess); |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
441 assert upperBound.dominates(block) : String.format( |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
442 "out of loop movement voilated memory semantics for %s (location %s). moved to %s but upper bound is %s (earliest: %s, latest: %s)", read, |
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
443 read.getLocationIdentity(), block, upperBound, earliestBlock, latest); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
444 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
445 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
446 break; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
447 default: |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
448 throw new GraalInternalError("unknown scheduling strategy"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 } |
11865
3d97040060d4
SchedulePhase: bail out with SchedulingError if scheduled block is not dominated by earliest
Bernhard Urban <bernhard.urban@jku.at>
parents:
11864
diff
changeset
|
450 if (!earliestBlock.dominates(block)) { |
3d97040060d4
SchedulePhase: bail out with SchedulingError if scheduled block is not dominated by earliest
Bernhard Urban <bernhard.urban@jku.at>
parents:
11864
diff
changeset
|
451 throw new SchedulingError("%s: Graph cannot be scheduled : inconsistent for %s, %d usages, (%s needs to dominate %s)", node.graph(), node, node.usages().count(), earliestBlock, block); |
3d97040060d4
SchedulePhase: bail out with SchedulingError if scheduled block is not dominated by earliest
Bernhard Urban <bernhard.urban@jku.at>
parents:
11864
diff
changeset
|
452 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
453 cfg.getNodeToBlock().set(node, block); |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
454 blockToNodesMap.get(block).add(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
455 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
456 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
457 @SuppressWarnings("all") |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
458 private static boolean assertionEnabled() { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
459 boolean enabled = false; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
460 assert enabled = true; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
461 return enabled; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
462 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
463 |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
464 /** |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
465 * this method tries to find the "optimal" schedule for a read, by pushing it down towards its |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
466 * latest schedule starting by the earliest schedule. By doing this, it takes care of memory |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
467 * dependencies using kill sets. |
14763 | 468 * |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
469 * In terms of domination relation, it looks like this: |
14763 | 470 * |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
471 * <pre> |
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
472 * U upperbound block, defined by last access location of the floating read |
14906 | 473 * ∧ |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
474 * E earliest block |
14906 | 475 * ∧ |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
476 * O optimal block, first block that contains a kill of the read's location |
14906 | 477 * ∧ |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
478 * L latest block |
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
479 * </pre> |
14763 | 480 * |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
481 * i.e. <code>upperbound `dom` earliest `dom` optimal `dom` latest</code>. |
14763 | 482 * |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
483 */ |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
484 private Block optimalBlock(FloatingReadNode n, SchedulingStrategy strategy) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
485 assert memsched == MemoryScheduling.OPTIMAL; |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
486 |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
487 LocationIdentity locid = n.location().getLocationIdentity(); |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
488 assert locid != FINAL_LOCATION; |
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
489 |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
490 Block upperBoundBlock = blockForMemoryNode(n.getLastLocationAccess()); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
491 Block earliestBlock = earliestBlock(n); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
492 assert upperBoundBlock.dominates(earliestBlock) : "upper bound (" + upperBoundBlock + ") should dominate earliest (" + earliestBlock + ")"; |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
493 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
494 Block latestBlock = latestBlock(n, strategy); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
495 assert latestBlock != null && earliestBlock.dominates(latestBlock) : "earliest (" + earliestBlock + ") should dominate latest block (" + latestBlock + ")"; |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
496 |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
497 Debug.log("processing %s (accessing %s): latest %s, earliest %s, upper bound %s (%s)", n, locid, latestBlock, earliestBlock, upperBoundBlock, n.getLastLocationAccess()); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
498 if (earliestBlock == latestBlock) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
499 // read is fixed to this block, nothing to schedule |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
500 return latestBlock; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
501 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
502 |
13599
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
503 Deque<Block> path = computePathInDominatorTree(earliestBlock, latestBlock); |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
504 Debug.log("|path| is %d: %s", path.size(), path); |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
505 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
506 // follow path, start at earliest schedule |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
507 while (path.size() > 0) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
508 Block currentBlock = path.pop(); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
509 Block dominatedBlock = path.size() == 0 ? null : path.peek(); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
510 if (dominatedBlock != null && !currentBlock.getSuccessors().contains(dominatedBlock)) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
511 // the dominated block is not a successor -> we have a split |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
512 assert dominatedBlock.getBeginNode() instanceof MergeNode; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
513 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
514 HashSet<Block> region = computeRegion(currentBlock, dominatedBlock); |
14873
00eb80d735ed
removed Debug.printf and added multi-arg versions of Debug.dump
Doug Simon <doug.simon@oracle.com>
parents:
14763
diff
changeset
|
515 Debug.log("> merge. %s: region for %s -> %s: %s", n, currentBlock, dominatedBlock, region); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
516 |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
517 NewMemoryScheduleClosure closure = null; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
518 if (currentBlock == upperBoundBlock) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
519 assert earliestBlock == upperBoundBlock; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
520 // don't treat lastLocationAccess node as a kill for this read. |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
521 closure = new NewMemoryScheduleClosure(ValueNodeUtil.asNode(n.getLastLocationAccess()), upperBoundBlock); |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
522 } else { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
523 closure = new NewMemoryScheduleClosure(); |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
524 } |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
525 Map<FixedNode, KillSet> states; |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
526 states = ReentrantBlockIterator.apply(closure, currentBlock, new KillSet(), region); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
527 |
12774
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
528 KillSet mergeState = states.get(dominatedBlock.getBeginNode()); |
1729072a893a
NewMemoryAwareScheduling: hide data structure behind wrapper class
Bernhard Urban <bernhard.urban@jku.at>
parents:
12773
diff
changeset
|
529 if (mergeState.isKilled(locid)) { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
530 // location got killed somewhere in the branches, |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
531 // thus we've to move the read above it |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
532 return currentBlock; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
533 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
534 } else { |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
535 if (currentBlock == upperBoundBlock) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
536 assert earliestBlock == upperBoundBlock; |
13153
ae0001b445c0
Common base interface for nodes in the memory graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
13152
diff
changeset
|
537 KillSet ks = computeKillSet(upperBoundBlock, ValueNodeUtil.asNode(n.getLastLocationAccess())); |
13092
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
538 if (ks.isKilled(locid)) { |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
539 return upperBoundBlock; |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
540 } |
b334ca53f077
NewMemoryAwareScheduling: don't consider lastAccessLocation of a read as a kill
Bernhard Urban <bernhard.urban@jku.at>
parents:
12774
diff
changeset
|
541 } else if (dominatedBlock == null || computeKillSet(currentBlock).isKilled(locid)) { |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
542 return currentBlock; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
543 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
544 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
545 } |
13370
3e67710a6d08
SchedulePhase: remove old memory aware scheudling
Bernhard Urban <bernhard.urban@jku.at>
parents:
13369
diff
changeset
|
546 throw new SchedulingError("should have found a block for " + n); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
547 } |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
548 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
549 /** |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
550 * compute path in dominator tree from earliest schedule to latest schedule. |
14763 | 551 * |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
552 * @return the order of the stack is such as the first element is the earliest schedule. |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
553 */ |
13599
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
554 private static Deque<Block> computePathInDominatorTree(Block earliestBlock, Block latestBlock) { |
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
555 Deque<Block> path = new LinkedList<>(); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
556 Block currentBlock = latestBlock; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
557 while (currentBlock != null && earliestBlock.dominates(currentBlock)) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
558 path.push(currentBlock); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
559 currentBlock = currentBlock.getDominator(); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
560 } |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
561 assert path.peek() == earliestBlock; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
562 return path; |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
563 } |
10920
9802c478a26c
NewMemoryAwareScheduling: fix out of loop scheduling for floating reads (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10919
diff
changeset
|
564 |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
565 /** |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
566 * compute a set that contains all blocks in a region spanned by dominatorBlock and |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
567 * dominatedBlock (exclusive the dominatedBlock). |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
568 */ |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
569 private static HashSet<Block> computeRegion(Block dominatorBlock, Block dominatedBlock) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
570 HashSet<Block> region = new HashSet<>(); |
13599
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
571 Queue<Block> workList = new LinkedList<>(); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
572 |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
573 region.add(dominatorBlock); |
13599
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
574 workList.addAll(dominatorBlock.getSuccessors()); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
575 while (workList.size() > 0) { |
13599
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
576 Block current = workList.poll(); |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
577 if (current != dominatedBlock) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
578 region.add(current); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
579 for (Block b : current.getSuccessors()) { |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
580 if (!region.contains(b) && !workList.contains(b)) { |
13599
29b1b216d20a
SchedulePhase: use {Queue,Deque}/LinkedList instead of Stack
Bernhard Urban <bernhard.urban@jku.at>
parents:
13370
diff
changeset
|
581 workList.offer(b); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
582 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
583 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
584 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
585 } |
12773
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
586 assert !region.contains(dominatedBlock) && region.containsAll(dominatedBlock.getPredecessors()); |
b6e04d6fe3a7
NewMemoryAwareScheduling: rewrite to set based approach
Bernhard Urban <bernhard.urban@jku.at>
parents:
12772
diff
changeset
|
587 return region; |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
588 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
589 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
590 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
591 * Calculates the last block that the given node could be scheduled in, i.e., the common |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
592 * dominator of all usages. To do so all usages are also assigned to blocks. |
14763 | 593 * |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
594 * @param strategy |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
595 */ |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
596 private Block latestBlock(ScheduledNode node, SchedulingStrategy strategy) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
597 CommonDominatorBlockClosure cdbc = new CommonDominatorBlockClosure(null); |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
598 for (Node succ : node.successors().nonNull()) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
599 if (cfg.getNodeToBlock().get(succ) == null) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
600 throw new SchedulingError(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
601 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
602 cdbc.apply(cfg.getNodeToBlock().get(succ)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
603 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
604 ensureScheduledUsages(node, strategy); |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
605 if (node.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
606 for (Node usage : node.usages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
607 blocksForUsage(node, usage, cdbc, strategy); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
608 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
609 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
610 |
13298
5a3491b0c2f0
convert assertion in SchedulePhase to raise SchedulingError instead of AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
611 if (assertionEnabled()) { |
5a3491b0c2f0
convert assertion in SchedulePhase to raise SchedulingError instead of AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
612 if (cdbc.block != null && !earliestBlock(node).dominates(cdbc.block)) { |
5a3491b0c2f0
convert assertion in SchedulePhase to raise SchedulingError instead of AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
613 throw new SchedulingError("failed to find correct latest schedule for %s. cdbc: %s, earliest: %s", node, cdbc.block, earliestBlock(node)); |
5a3491b0c2f0
convert assertion in SchedulePhase to raise SchedulingError instead of AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
614 } |
5a3491b0c2f0
convert assertion in SchedulePhase to raise SchedulingError instead of AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
13153
diff
changeset
|
615 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 return cdbc.block; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
617 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
618 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
619 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
620 * A closure that will calculate the common dominator of all blocks passed to its |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
621 * {@link #apply(Block)} method. |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
622 */ |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
623 private static class CommonDominatorBlockClosure implements BlockClosure { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
624 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 public Block block; |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
626 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
627 public CommonDominatorBlockClosure(Block block) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 this.block = block; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
629 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
630 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
631 @Override |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
632 public void apply(Block newBlock) { |
10609
5f016460f95b
scheduling: remove duplicated code
Bernhard Urban <bernhard.urban@jku.at>
parents:
10490
diff
changeset
|
633 this.block = commonDominator(this.block, newBlock); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
634 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
635 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
636 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
637 /** |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
638 * Determines the earliest block in which the given node can be scheduled. |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
639 */ |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
640 private Block earliestBlock(Node node) { |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
641 Block earliest = cfg.getNodeToBlock().get(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
642 if (earliest != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
643 return earliest; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
645 earliest = earliestCache.get(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 if (earliest != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 return earliest; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
649 /* |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
650 * All inputs must be in a dominating block, otherwise the graph cannot be scheduled. This |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
651 * implies that the inputs' blocks have a total ordering via their dominance relation. So in |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
652 * order to find the earliest block placement for this node we need to find the input block |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
653 * that is dominated by all other input blocks. |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
654 */ |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
655 |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
656 if (node.predecessor() != null) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
657 throw new SchedulingError(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
658 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
659 for (Node input : node.inputs().nonNull()) { |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
660 assert input instanceof ValueNode; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
661 Block inputEarliest; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
662 if (input instanceof InvokeWithExceptionNode) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
663 inputEarliest = cfg.getNodeToBlock().get(((InvokeWithExceptionNode) input).next()); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
664 } else { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
665 inputEarliest = earliestBlock(input); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
666 } |
15173
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
667 if (earliest == null) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
668 earliest = inputEarliest; |
15173
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
669 } else if (earliest != inputEarliest) { |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
670 // Find out whether earliest or inputEarliest is earlier. |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
671 Block a = earliest.getDominator(); |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
672 Block b = inputEarliest; |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
673 while (true) { |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
674 if (a == inputEarliest || b == null) { |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
675 // Nothing to change, the previous earliest block is still earliest. |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
676 break; |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
677 } else if (b == earliest || a == null) { |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
678 // New earliest is the earliest. |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
679 earliest = inputEarliest; |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
680 break; |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
681 } |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
682 a = a.getDominator(); |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
683 b = b.getDominator(); |
fc7f2bbd4edd
Improve schedule phase to avoid allocation of a BitSet per scheduled node.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15157
diff
changeset
|
684 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
686 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 if (earliest == null) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
688 earliest = cfg.getStartBlock(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
690 earliestCache.set(node, earliest); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 return earliest; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 |
12772
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
694 /** |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
695 * Schedules a node out of loop based on its earliest schedule. Note that this movement is only |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
696 * valid if it's done for <b>every</b> other node in the schedule, otherwise this movement is |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
697 * not valid. |
14763 | 698 * |
12772
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
699 * @param n Node to schedule |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
700 * @param latestBlock latest possible schedule for {@code n} |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
701 * @param earliest earliest possible schedule for {@code n} |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
702 * @return block schedule for {@code n} which is not inside a loop (if possible) |
6a7b6dcb7f67
NewMemoryAwareScheduling: fix out of loop for FloatingReadNodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
12722
diff
changeset
|
703 */ |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
704 private static Block scheduleOutOfLoops(Node n, Block latestBlock, Block earliest) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
705 if (latestBlock == null) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
706 throw new SchedulingError("no latest : %s", n); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
707 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 Block cur = latestBlock; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
709 Block result = latestBlock; |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
710 while (cur.getLoop() != null && cur != earliest && cur.getDominator() != null) { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
711 Block dom = cur.getDominator(); |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
712 if (dom.getLoopDepth() < result.getLoopDepth()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 result = dom; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
714 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
715 cur = dom; |
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 return result; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
718 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
719 |
5583
8f529640e430
fix to SchedulePhase: correctly handle outer frame states that take a phi from the
Lukas Stadler <lukas.stadler@jku.at>
parents:
5541
diff
changeset
|
720 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
721 * Passes all blocks that a specific usage of a node is in to a given closure. This is more |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
722 * complex than just taking the usage's block because of of PhiNodes and FrameStates. |
14763 | 723 * |
5583
8f529640e430
fix to SchedulePhase: correctly handle outer frame states that take a phi from the
Lukas Stadler <lukas.stadler@jku.at>
parents:
5541
diff
changeset
|
724 * @param node the node that needs to be scheduled |
8f529640e430
fix to SchedulePhase: correctly handle outer frame states that take a phi from the
Lukas Stadler <lukas.stadler@jku.at>
parents:
5541
diff
changeset
|
725 * @param usage the usage whose blocks need to be considered |
8f529640e430
fix to SchedulePhase: correctly handle outer frame states that take a phi from the
Lukas Stadler <lukas.stadler@jku.at>
parents:
5541
diff
changeset
|
726 * @param closure the closure that will be called for each block |
8f529640e430
fix to SchedulePhase: correctly handle outer frame states that take a phi from the
Lukas Stadler <lukas.stadler@jku.at>
parents:
5541
diff
changeset
|
727 */ |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
728 private void blocksForUsage(ScheduledNode node, Node usage, BlockClosure closure, SchedulingStrategy strategy) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
729 if (node instanceof PhiNode) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
730 throw new SchedulingError(node.toString()); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
731 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
732 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 if (usage instanceof PhiNode) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
734 // An input to a PhiNode is used at the end of the predecessor block that corresponds to |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
735 // the PhiNode input. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
736 // One PhiNode can use an input multiple times, the closure will be called for each |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
737 // usage. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
738 PhiNode phi = (PhiNode) usage; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 MergeNode merge = phi.merge(); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
740 Block mergeBlock = cfg.getNodeToBlock().get(merge); |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
741 if (mergeBlock == null) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
742 throw new SchedulingError("no block for merge %s", merge.toString(Verbosity.Id)); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
743 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 for (int i = 0; i < phi.valueCount(); ++i) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 if (phi.valueAt(i) == node) { |
7499
ca3e5df0e6cf
Small clean up of access to predecessor/successor of blocks.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
6670
diff
changeset
|
746 if (mergeBlock.getPredecessorCount() <= i) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
747 TTY.println(merge.toString()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 TTY.println(phi.toString()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
749 TTY.println(merge.cfgPredecessors().toString()); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4525
diff
changeset
|
750 TTY.println(mergeBlock.getPredecessors().toString()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 TTY.println(phi.inputs().toString()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
752 TTY.println("value count: " + phi.valueCount()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
753 } |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4525
diff
changeset
|
754 closure.apply(mergeBlock.getPredecessors().get(i)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
755 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
756 } |
5598
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5591
diff
changeset
|
757 } else if (usage instanceof VirtualState) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
758 // The following logic does not work if node is a PhiNode, but this method is never |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
759 // called for PhiNodes. |
5598
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5591
diff
changeset
|
760 for (Node unscheduledUsage : usage.usages()) { |
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5591
diff
changeset
|
761 if (unscheduledUsage instanceof VirtualState) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
762 // If a FrameState is an outer FrameState this method behaves as if the inner |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
763 // FrameState was the actual usage, by recursing. |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
764 blocksForUsage(node, unscheduledUsage, closure, strategy); |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15107
diff
changeset
|
765 } else if (unscheduledUsage instanceof BeginNode) { |
11460
ac2bddbe3b51
SchedulePhase: schedule inputs of framestates which are attached to AbstractBeginNodes to the dominator (not just for MergeNodes)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10925
diff
changeset
|
766 // Only FrameStates can be connected to BeginNodes. |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
767 if (!(usage instanceof FrameState)) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
768 throw new SchedulingError(usage.toString()); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
769 } |
14534
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
770 if (unscheduledUsage instanceof StartNode) { |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
771 closure.apply(cfg.getNodeToBlock().get(unscheduledUsage)); |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
772 } else { |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
773 // If a FrameState belongs to a BeginNode then it's inputs will be placed at |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
774 // the common dominator of all EndNodes. |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
775 for (Node pred : unscheduledUsage.cfgPredecessors()) { |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
776 closure.apply(cfg.getNodeToBlock().get(pred)); |
ccf090d3be47
new graph ordering assertion mechanism
Lukas Stadler <lukas.stadler@oracle.com>
parents:
13729
diff
changeset
|
777 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
778 } |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
779 } else { |
13293
5215f94f94ec
GRAAL-632: Clarify difference between states managed by StateSplit and DeoptimizingNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13153
diff
changeset
|
780 // For the time being, FrameStates can only be connected to NodeWithState. |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
781 if (!(usage instanceof FrameState)) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
782 throw new SchedulingError(usage.toString()); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
783 } |
11787
4fc75b6ca3dd
Introduce NodeWithState for nodes that hold some VirtualState. Use this interface in the required special cases (Scheduling and PEA)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11501
diff
changeset
|
784 if (!(unscheduledUsage instanceof NodeWithState)) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
785 throw new SchedulingError(unscheduledUsage.toString()); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
786 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
787 // Otherwise: Put the input into the same block as the usage. |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
788 assignBlockToNode((ScheduledNode) unscheduledUsage, strategy); |
5598
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5591
diff
changeset
|
789 closure.apply(cfg.getNodeToBlock().get(unscheduledUsage)); |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
790 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
791 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
792 } else { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
793 // All other types of usages: Put the input into the same block as the usage. |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
794 assignBlockToNode((ScheduledNode) usage, strategy); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
795 closure.apply(cfg.getNodeToBlock().get(usage)); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
797 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
799 private void ensureScheduledUsages(Node node, SchedulingStrategy strategy) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
800 if (node.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
801 for (Node usage : node.usages().filter(ScheduledNode.class)) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
802 assignBlockToNode((ScheduledNode) usage, strategy); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
803 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 // now true usages are ready |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
806 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
808 private void sortNodesWithinBlocks(StructuredGraph graph, SchedulingStrategy strategy) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
809 NodeBitMap visited = graph.createNodeBitMap(); |
10921
b73121a215f7
NewMemoryAwareScheduling: create nodebitmap once per graph (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10920
diff
changeset
|
810 NodeBitMap beforeLastLocation = graph.createNodeBitMap(); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
811 for (Block b : cfg.getBlocks()) { |
10921
b73121a215f7
NewMemoryAwareScheduling: create nodebitmap once per graph (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10920
diff
changeset
|
812 sortNodesWithinBlock(b, visited, beforeLastLocation, strategy); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
813 assert noDuplicatedNodesInBlock(b) : "duplicated nodes in " + b; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
814 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
815 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
817 private boolean noDuplicatedNodesInBlock(Block b) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
818 List<ScheduledNode> list = blockToNodesMap.get(b); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
819 HashSet<ScheduledNode> hashset = new HashSet<>(list); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
820 return list.size() == hashset.size(); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
821 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
822 |
10921
b73121a215f7
NewMemoryAwareScheduling: create nodebitmap once per graph (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10920
diff
changeset
|
823 private void sortNodesWithinBlock(Block b, NodeBitMap visited, NodeBitMap beforeLastLocation, SchedulingStrategy strategy) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
824 if (visited.isMarked(b.getBeginNode()) || cfg.blockFor(b.getBeginNode()) != b) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
825 throw new SchedulingError(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
826 } |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
827 if (visited.isMarked(b.getEndNode()) || cfg.blockFor(b.getEndNode()) != b) { |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
828 throw new SchedulingError(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
829 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
830 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
831 List<ScheduledNode> sortedInstructions; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
832 switch (strategy) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
833 case EARLIEST: |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
834 sortedInstructions = sortNodesWithinBlockEarliest(b, visited); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
835 break; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
836 case LATEST: |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
837 case LATEST_OUT_OF_LOOPS: |
10921
b73121a215f7
NewMemoryAwareScheduling: create nodebitmap once per graph (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10920
diff
changeset
|
838 sortedInstructions = sortNodesWithinBlockLatest(b, visited, beforeLastLocation); |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
839 break; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
840 default: |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
841 throw new GraalInternalError("unknown scheduling strategy"); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
842 } |
10922
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
843 assert filterSchedulableNodes(blockToNodesMap.get(b)).size() == removeProxies(sortedInstructions).size() : "sorted block does not contain the same amount of nodes: " + |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
844 filterSchedulableNodes(blockToNodesMap.get(b)) + " vs. " + removeProxies(sortedInstructions); |
10890
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
845 assert sameOrderForFixedNodes(blockToNodesMap.get(b), sortedInstructions) : "fixed nodes in sorted block are not in the same order"; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
846 blockToNodesMap.put(b, sortedInstructions); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
847 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
848 |
10922
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
849 private static List<ScheduledNode> removeProxies(List<ScheduledNode> list) { |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
850 List<ScheduledNode> result = new ArrayList<>(); |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
851 for (ScheduledNode n : list) { |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
852 if (!(n instanceof ProxyNode)) { |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
853 result.add(n); |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
854 } |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
855 } |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
856 return result; |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
857 } |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
858 |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
859 private static List<ScheduledNode> filterSchedulableNodes(List<ScheduledNode> list) { |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
860 List<ScheduledNode> result = new ArrayList<>(); |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
861 for (ScheduledNode n : list) { |
11501
a116fb4875a6
SchedulePhase: remove special handling of localnodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
11460
diff
changeset
|
862 if (!(n instanceof PhiNode)) { |
10922
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
863 result.add(n); |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
864 } |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
865 } |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
866 return result; |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
867 } |
1d1675f18e85
Scheduling: add assert about nodes in a block after sorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10921
diff
changeset
|
868 |
10890
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
869 private static boolean sameOrderForFixedNodes(List<ScheduledNode> fixed, List<ScheduledNode> sorted) { |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
870 Iterator<ScheduledNode> fixedIterator = fixed.iterator(); |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
871 Iterator<ScheduledNode> sortedIterator = sorted.iterator(); |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
872 |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
873 while (sortedIterator.hasNext()) { |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
874 ScheduledNode sortedCurrent = sortedIterator.next(); |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
875 if (sortedCurrent instanceof FixedNode) { |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
876 if (!(fixedIterator.hasNext() && fixedIterator.next() == sortedCurrent)) { |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
877 return false; |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
878 } |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
879 } |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
880 } |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
881 |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
882 while (fixedIterator.hasNext()) { |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
883 if (fixedIterator.next() instanceof FixedNode) { |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
884 return false; |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
885 } |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
886 } |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
887 |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
888 return true; |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
889 } |
2cdd22e1ac5e
SchedulingPhase: check if fixed nodes have the same order before and after sorting a block
Bernhard Urban <bernhard.urban@jku.at>
parents:
10609
diff
changeset
|
890 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
891 private static class SortState { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
892 private Block block; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
893 private NodeBitMap visited; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
894 private NodeBitMap beforeLastLocation; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
895 private List<ScheduledNode> sortedInstructions; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
896 private List<FloatingReadNode> reads; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
897 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
898 SortState(Block block, NodeBitMap visited, NodeBitMap beforeLastLocation, List<ScheduledNode> sortedInstructions) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
899 this.block = block; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
900 this.visited = visited; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
901 this.beforeLastLocation = beforeLastLocation; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
902 this.sortedInstructions = sortedInstructions; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
903 this.reads = null; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
904 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
905 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
906 public Block currentBlock() { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
907 return block; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
908 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
909 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
910 void markVisited(Node n) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
911 visited.mark(n); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
912 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
913 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
914 boolean isVisited(Node n) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
915 return visited.isMarked(n); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
916 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
917 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
918 void markBeforeLastLocation(FloatingReadNode n) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
919 beforeLastLocation.mark(n); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
920 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
921 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
922 void clearBeforeLastLocation(FloatingReadNode frn) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
923 beforeLastLocation.clear(frn); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
924 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
925 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
926 boolean isBeforeLastLocation(FloatingReadNode n) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
927 return beforeLastLocation.isMarked(n); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
928 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
929 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
930 void addRead(FloatingReadNode n) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
931 if (reads == null) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
932 reads = new ArrayList<>(); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
933 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
934 reads.add(n); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
935 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
936 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
937 int readsSize() { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
938 if (reads == null) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
939 return 0; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
940 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
941 return reads.size(); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
942 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
943 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
944 void removeRead(ScheduledNode i) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
945 assert reads != null; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
946 reads.remove(i); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
947 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
948 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
949 List<FloatingReadNode> readsSnapshot() { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
950 assert reads != null; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
951 return new ArrayList<>(reads); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
952 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
953 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
954 List<ScheduledNode> getSortedInstructions() { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
955 return sortedInstructions; |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
956 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
957 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
958 boolean containsInstruction(ScheduledNode i) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
959 return sortedInstructions.contains(i); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
960 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
961 |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
962 void addInstruction(ScheduledNode i) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
963 sortedInstructions.add(i); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
964 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
965 } |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
966 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
967 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
968 * Sorts the nodes within a block by adding the nodes to a list in a post-order iteration over |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
969 * all inputs. This means that a node is added to the list after all its inputs have been |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
970 * processed. |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
971 */ |
10921
b73121a215f7
NewMemoryAwareScheduling: create nodebitmap once per graph (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10920
diff
changeset
|
972 private List<ScheduledNode> sortNodesWithinBlockLatest(Block b, NodeBitMap visited, NodeBitMap beforeLastLocation) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
973 SortState state = new SortState(b, visited, beforeLastLocation, new ArrayList<>(blockToNodesMap.get(b).size() + 2)); |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
974 List<ScheduledNode> instructions = blockToNodesMap.get(b); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
975 |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
976 if (memsched == MemoryScheduling.OPTIMAL) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
977 for (ScheduledNode i : instructions) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
978 if (i instanceof FloatingReadNode) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
979 FloatingReadNode frn = (FloatingReadNode) i; |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
980 if (frn.location().getLocationIdentity() != FINAL_LOCATION) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
981 state.addRead(frn); |
12722
b87c2f34e0e0
Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12721
diff
changeset
|
982 if (nodesFor(b).contains(frn.getLastLocationAccess())) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
983 assert !state.isBeforeLastLocation(frn); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
984 state.markBeforeLastLocation(frn); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
985 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
986 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
987 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
988 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
989 } |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
990 |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
991 for (ScheduledNode i : instructions) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
992 addToLatestSorting(i, state); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
993 } |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
994 assert state.readsSize() == 0 : "not all reads are scheduled"; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
995 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
996 // Make sure that last node gets really last (i.e. when a frame state successor hangs off |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
997 // it). |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
998 List<ScheduledNode> sortedInstructions = state.getSortedInstructions(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
999 Node lastSorted = sortedInstructions.get(sortedInstructions.size() - 1); |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
1000 if (lastSorted != b.getEndNode()) { |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
1001 int idx = sortedInstructions.indexOf(b.getEndNode()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1002 boolean canNotMove = false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1003 for (int i = idx + 1; i < sortedInstructions.size(); i++) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
1004 if (sortedInstructions.get(i).inputs().contains(b.getEndNode())) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1005 canNotMove = true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1006 break; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1007 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1008 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1009 if (canNotMove) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
1010 if (b.getEndNode() instanceof ControlSplitNode) { |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15192
diff
changeset
|
1011 throw new GraalGraphInternalError("Schedule is not possible : needs to move a node after the last node of the block which can not be move").addContext(lastSorted).addContext( |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
1012 b.getEndNode()); |
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 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
1015 // b.setLastNode(lastSorted); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1016 } else { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
1017 sortedInstructions.remove(b.getEndNode()); |
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4413
diff
changeset
|
1018 sortedInstructions.add(b.getEndNode()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1019 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1020 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1021 return sortedInstructions; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1022 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1023 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1024 private void processKillLocation(Node node, LocationIdentity identity, SortState state) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1025 for (FloatingReadNode frn : state.readsSnapshot()) { |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1026 LocationIdentity readLocation = frn.location().getLocationIdentity(); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1027 assert readLocation != FINAL_LOCATION; |
12722
b87c2f34e0e0
Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
12721
diff
changeset
|
1028 if (frn.getLastLocationAccess() == node) { |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1029 assert identity == ANY_LOCATION || readLocation == identity : "location doesn't match: " + readLocation + ", " + identity; |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1030 state.clearBeforeLastLocation(frn); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1031 } else if (!state.isBeforeLastLocation(frn) && (readLocation == identity || (node != getCFG().graph.start() && ANY_LOCATION == identity))) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1032 state.removeRead(frn); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1033 addToLatestSorting(frn, state); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1034 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1035 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1036 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1037 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1038 private void addUnscheduledToLatestSorting(VirtualState state, SortState sortState) { |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1039 if (state != null) { |
5598
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5591
diff
changeset
|
1040 // UnscheduledNodes should never be marked as visited. |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1041 if (sortState.isVisited(state)) { |
8950
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
1042 throw new SchedulingError(); |
43fb04e78250
modified (some) checks in SchedulePhase to raise a SchedulingError instead of an AssertionError
Doug Simon <doug.simon@oracle.com>
parents:
8920
diff
changeset
|
1043 } |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1044 |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1045 for (Node input : state.inputs()) { |
5598
a9b615da0cba
removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents:
5591
diff
changeset
|
1046 if (input instanceof VirtualState) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1047 addUnscheduledToLatestSorting((VirtualState) input, sortState); |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13299
diff
changeset
|
1048 } else { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1049 addToLatestSorting((ScheduledNode) input, sortState); |
5591
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1050 } |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1051 } |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1052 } |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1053 } |
d52edd1af4c4
SchedulePhase doesn't schedule FrameStates, added documentation, cleanups
Lukas Stadler <lukas.stadler@jku.at>
parents:
5583
diff
changeset
|
1054 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1055 private void addToLatestSorting(ScheduledNode i, SortState state) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1056 if (i == null || state.isVisited(i) || cfg.getNodeToBlock().get(i) != state.currentBlock() || i instanceof PhiNode) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1057 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1058 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1059 |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1060 FrameState stateAfter = null; |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1061 if (i instanceof StateSplit) { |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1062 stateAfter = ((StateSplit) i).stateAfter(); |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1063 } |
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1064 |
15284
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1065 if (i instanceof LoopExitNode) { |
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1066 for (ProxyNode proxy : ((LoopExitNode) i).proxies()) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1067 addToLatestSorting(proxy, state); |
15284
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1068 } |
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1069 } |
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1070 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1071 for (Node input : i.inputs()) { |
10891
8c0ab217ed00
Scheduling: remove dead code in addToLatestSorting
Bernhard Urban <bernhard.urban@jku.at>
parents:
10890
diff
changeset
|
1072 if (input instanceof FrameState) { |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1073 if (input != stateAfter) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1074 addUnscheduledToLatestSorting((FrameState) input, state); |
14734
6ae9af961b7c
Introduce separate interfaces for deoptimizing nodes that deopt to a state before, during or after their execution.
Roland Schatz <roland.schatz@oracle.com>
parents:
14534
diff
changeset
|
1075 } |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13299
diff
changeset
|
1076 } else { |
15284
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1077 if (!(i instanceof ProxyNode && input instanceof LoopExitNode)) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1078 addToLatestSorting((ScheduledNode) input, state); |
15284
9b122a4d2e94
correctly schedule loop proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15259
diff
changeset
|
1079 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1080 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1081 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1082 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1083 if (memsched == MemoryScheduling.OPTIMAL && state.readsSize() != 0) { |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1084 if (i instanceof MemoryCheckpoint.Single) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1085 LocationIdentity identity = ((MemoryCheckpoint.Single) i).getLocationIdentity(); |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1086 processKillLocation(i, identity, state); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1087 } else if (i instanceof MemoryCheckpoint.Multi) { |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1088 for (LocationIdentity identity : ((MemoryCheckpoint.Multi) i).getLocationIdentities()) { |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1089 processKillLocation(i, identity, state); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1090 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1091 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1092 assert MemoryCheckpoint.TypeAssertion.correctType(i); |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1093 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1094 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1095 addToLatestSorting((ScheduledNode) i.predecessor(), state); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1096 state.markVisited(i); |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1097 addUnscheduledToLatestSorting(stateAfter, state); |
3733
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 // Now predecessors and inputs are scheduled => we can add this node. |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1100 if (!state.containsInstruction(i)) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1101 state.addInstruction(i); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1102 } |
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1103 |
15423
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1104 if (state.readsSize() != 0 && i instanceof FloatingReadNode) { |
81eee524bbec
SchedulePhase: refactoring
Bernhard Urban <bernhard.urban@jku.at>
parents:
15422
diff
changeset
|
1105 state.removeRead(i); |
10896
8106edbdeac9
add NewMemoryAwareScheduling (GRAAL-159)
Bernhard Urban <bernhard.urban@jku.at>
parents:
10894
diff
changeset
|
1106 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1107 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1108 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1109 /** |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1110 * Sorts the nodes within a block by adding the nodes to a list in a post-order iteration over |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1111 * all usages. The resulting list is reversed to create an earliest-possible scheduling of |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1112 * nodes. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1113 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1114 private List<ScheduledNode> sortNodesWithinBlockEarliest(Block b, NodeBitMap visited) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1115 List<ScheduledNode> sortedInstructions = new ArrayList<>(blockToNodesMap.get(b).size() + 2); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1116 addToEarliestSorting(b, b.getEndNode(), sortedInstructions, visited); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1117 Collections.reverse(sortedInstructions); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1118 return sortedInstructions; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1119 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1120 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1121 private void addToEarliestSorting(Block b, ScheduledNode i, List<ScheduledNode> sortedInstructions, NodeBitMap visited) { |
8542
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1122 ScheduledNode instruction = i; |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1123 while (true) { |
11501
a116fb4875a6
SchedulePhase: remove special handling of localnodes
Bernhard Urban <bernhard.urban@jku.at>
parents:
11460
diff
changeset
|
1124 if (instruction == null || visited.isMarked(instruction) || cfg.getNodeToBlock().get(instruction) != b || instruction instanceof PhiNode) { |
8542
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1125 return; |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1126 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1127 |
8542
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1128 visited.mark(instruction); |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1129 if (instruction.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1130 for (Node usage : instruction.usages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1131 if (usage instanceof VirtualState) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1132 // only fixed nodes can have VirtualState -> no need to schedule them |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1133 } else { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1134 if (instruction instanceof LoopExitNode && usage instanceof ProxyNode) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1135 // value proxies should be scheduled before the loopexit, not after |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1136 } else { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1137 addToEarliestSorting(b, (ScheduledNode) usage, sortedInstructions, visited); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11865
diff
changeset
|
1138 } |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1139 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1140 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1141 } |
8542
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1142 |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15107
diff
changeset
|
1143 if (instruction instanceof BeginNode) { |
14763 | 1144 ArrayList<ProxyNode> proxies = (instruction instanceof LoopExitNode) ? new ArrayList<>() : null; |
8542
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1145 for (ScheduledNode inBlock : blockToNodesMap.get(b)) { |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1146 if (!visited.isMarked(inBlock)) { |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1147 if (inBlock instanceof ProxyNode) { |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1148 proxies.add((ProxyNode) inBlock); |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1149 } else { |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1150 addToEarliestSorting(b, inBlock, sortedInstructions, visited); |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1151 } |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1152 } |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1153 } |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1154 sortedInstructions.add(instruction); |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1155 if (proxies != null) { |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1156 sortedInstructions.addAll(proxies); |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1157 } |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1158 break; |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1159 } else { |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1160 sortedInstructions.add(instruction); |
30a141944bcb
tail recursion for SchedulePhase.addToEarliestSorting (fixes StackOverflowErrors)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8394
diff
changeset
|
1161 instruction = (ScheduledNode) instruction.predecessor(); |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1162 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1163 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7530
diff
changeset
|
1164 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1165 } |