annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java @ 12722:b87c2f34e0e0

Maintain lastLocationAccess in WriteNode.
author Roland Schatz <roland.schatz@oracle.com>
date Fri, 08 Nov 2013 13:22:03 +0100
parents f5faf49a86dd
children 640516a8ca6b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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 */
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
23 package com.oracle.graal.phases.common;
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.*;
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
26
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
9792
06dc2d2324d6 pulled LocationIdentity into a top level class and moved it to the api.meta project
Doug Simon <doug.simon@oracle.com>
parents: 9646
diff changeset
29 import com.oracle.graal.api.meta.*;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
30 import com.oracle.graal.nodes.*;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
31 import com.oracle.graal.nodes.PhiNode.PhiType;
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
32 import com.oracle.graal.nodes.extended.*;
6526
ee651c726397 split phases out of graal.phases project into graal.phases.common project
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
33 import com.oracle.graal.phases.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6522
diff changeset
34 import com.oracle.graal.phases.graph.*;
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
35 import com.oracle.graal.phases.graph.ReentrantNodeIterator.LoopInfo;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
36 import com.oracle.graal.phases.graph.ReentrantNodeIterator.NodeIteratorClosure;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 public class FloatingReadPhase extends Phase {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
40 public enum ExecutionMode {
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
41 ANALYSIS_ONLY, CREATE_FLOATING_READS
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
42 }
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
43
11847
f5faf49a86dd remove MemoryState, make MemoryMap a node, add MemoryMap input to ReturnNode
Bernhard Urban <bernhard.urban@jku.at>
parents: 11844
diff changeset
44 public static class MemoryMapImpl extends MemoryMapNode {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7257
diff changeset
45
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
46 private IdentityHashMap<LocationIdentity, ValueNode> lastMemorySnapshot;
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
47
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
48 public MemoryMapImpl(MemoryMapImpl memoryMap) {
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
49 lastMemorySnapshot = new IdentityHashMap<>(memoryMap.lastMemorySnapshot);
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
50 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
51
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
52 public MemoryMapImpl(StartNode start) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
53 this();
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
54 lastMemorySnapshot.put(ANY_LOCATION, start);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
57 public MemoryMapImpl() {
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
58 lastMemorySnapshot = new IdentityHashMap<>();
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
59 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
60
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
61 @Override
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
62 public ValueNode getLastLocationAccess(LocationIdentity locationIdentity) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
63 ValueNode lastLocationAccess;
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
64 if (locationIdentity == FINAL_LOCATION) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
65 return null;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
66 } else {
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
67 lastLocationAccess = lastMemorySnapshot.get(locationIdentity);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
68 if (lastLocationAccess == null) {
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
69 lastLocationAccess = lastMemorySnapshot.get(ANY_LOCATION);
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
70 assert lastLocationAccess != null;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
71 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
72 return lastLocationAccess;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
73 }
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
74 }
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
75
11768
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
76 public boolean isEmpty() {
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
77 if (lastMemorySnapshot.size() == 0) {
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
78 return true;
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
79 }
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
80 if (lastMemorySnapshot.size() == 1) {
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
81 if (lastMemorySnapshot.get(ANY_LOCATION) instanceof StartNode) {
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
82 return true;
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
83 }
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
84 }
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
85 return false;
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
86 }
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
87
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
88 public Set<LocationIdentity> getLocations() {
11844
1ce74467ab51 SnippetTemplate: remove canonicalizer. remove loop for return node. copy Set on user side
Bernhard Urban <bernhard.urban@jku.at>
parents: 11768
diff changeset
89 return lastMemorySnapshot.keySet();
11768
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
90 }
e53399f1b2cd SnippetTemplate: add assertions regarding memory kills
Bernhard Urban <bernhard.urban@jku.at>
parents: 11767
diff changeset
91
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
94 private final ExecutionMode execmode;
11747
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
95
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
96 public FloatingReadPhase() {
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
97 this(ExecutionMode.CREATE_FLOATING_READS);
11747
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
98 }
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
99
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
100 public FloatingReadPhase(ExecutionMode execmode) {
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
101 this.execmode = execmode;
11747
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
102 }
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
103
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 protected void run(StructuredGraph graph) {
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
106 Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = new IdentityHashMap<>();
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
107 ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet<LocationIdentity>(), null);
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
108 ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start()), null);
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
109 if (execmode == ExecutionMode.CREATE_FLOATING_READS) {
11766
c9c3f8efe6a9 FloatingReadPhase: add attribute to graph about application of FloatingReadPhase to this graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11750
diff changeset
110 assert !graph.isAfterFloatingReadPhase();
c9c3f8efe6a9 FloatingReadPhase: add attribute to graph about application of FloatingReadPhase to this graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11750
diff changeset
111 graph.setAfterFloatingReadPhase(true);
c9c3f8efe6a9 FloatingReadPhase: add attribute to graph about application of FloatingReadPhase to this graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11750
diff changeset
112 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
115 private static class CollectMemoryCheckpointsClosure extends NodeIteratorClosure<Set<LocationIdentity>> {
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
116
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
117 private final Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops;
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
118
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
119 public CollectMemoryCheckpointsClosure(Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops) {
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
120 this.modifiedInLoops = modifiedInLoops;
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
121 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
122
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
123 @Override
9623
76c40c3f6bb7 let ReentrantNodeIterator.processNode return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
124 protected Set<LocationIdentity> processNode(FixedNode node, Set<LocationIdentity> currentState) {
10090
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
125 if (node instanceof MemoryCheckpoint.Single) {
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
126 currentState.add(((MemoryCheckpoint.Single) node).getLocationIdentity());
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
127 } else if (node instanceof MemoryCheckpoint.Multi) {
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
128 for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) {
8394
7aefc149c471 allow multiple identities in MemoryCheckpoint interface
Lukas Stadler <lukas.stadler@jku.at>
parents: 8381
diff changeset
129 currentState.add(identity);
7aefc149c471 allow multiple identities in MemoryCheckpoint interface
Lukas Stadler <lukas.stadler@jku.at>
parents: 8381
diff changeset
130 }
7864
b66a826acf4b add location identity to MemoryCheckpoint and let WriteNode implement MemoryCheckpoint
Lukas Stadler <lukas.stadler@jku.at>
parents: 7745
diff changeset
131 }
9623
76c40c3f6bb7 let ReentrantNodeIterator.processNode return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
132 return currentState;
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
133 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
134
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
135 @Override
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
136 protected Set<LocationIdentity> merge(MergeNode merge, List<Set<LocationIdentity>> states) {
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
137 Set<LocationIdentity> result = new HashSet<>();
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
138 for (Set<LocationIdentity> other : states) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
139 result.addAll(other);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
140 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
141 return result;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
142 }
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
143
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
144 @Override
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
145 protected Set<LocationIdentity> afterSplit(AbstractBeginNode node, Set<LocationIdentity> oldState) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
146 return new HashSet<>(oldState);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
147 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
148
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
149 @Override
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
150 protected Map<LoopExitNode, Set<LocationIdentity>> processLoop(LoopBeginNode loop, Set<LocationIdentity> initialState) {
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
151 LoopInfo<Set<LocationIdentity>> loopInfo = ReentrantNodeIterator.processLoop(this, loop, new HashSet<LocationIdentity>());
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
152 Set<LocationIdentity> modifiedLocations = new HashSet<>();
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
153 for (Set<LocationIdentity> end : loopInfo.endStates.values()) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
154 modifiedLocations.addAll(end);
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
155 }
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
156 for (Set<LocationIdentity> exit : loopInfo.exitStates.values()) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
157 exit.addAll(modifiedLocations);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
158 exit.addAll(initialState);
7868
7a5bbcc36bb2 add location identity to Pointer read and write operations
Lukas Stadler <lukas.stadler@jku.at>
parents: 7864
diff changeset
159 }
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
160 assert !modifiedLocations.contains(FINAL_LOCATION);
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
161 modifiedInLoops.put(loop, modifiedLocations);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
162 return loopInfo.exitStates;
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
163 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
164
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
165 }
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
166
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
167 private static class FloatingReadClosure extends NodeIteratorClosure<MemoryMapImpl> {
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
168
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
169 private final Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops;
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
170 private final ExecutionMode execmode;
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
171
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
172 public FloatingReadClosure(Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops, ExecutionMode execmode) {
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
173 this.modifiedInLoops = modifiedInLoops;
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
174 this.execmode = execmode;
9134
da92cfd1ceaf Make FloatingReadPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents: 8634
diff changeset
175 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
176
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
177 @Override
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
178 protected MemoryMapImpl processNode(FixedNode node, MemoryMapImpl state) {
12722
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
179 if (node instanceof MemoryAccess) {
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
180 processAccess((MemoryAccess) node, state);
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
181 }
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
182
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
183 if (node instanceof FloatableAccessNode && execmode == ExecutionMode.CREATE_FLOATING_READS) {
8423
86ef0438d1d3 Generalize FloatingReadPhase to support arbitrary floatable access nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 8394
diff changeset
184 processFloatable((FloatableAccessNode) node, state);
10090
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
185 } else if (node instanceof MemoryCheckpoint.Single) {
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
186 processCheckpoint((MemoryCheckpoint.Single) node, state);
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
187 } else if (node instanceof MemoryCheckpoint.Multi) {
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
188 processCheckpoint((MemoryCheckpoint.Multi) node, state);
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
189 }
10090
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
190 assert MemoryCheckpoint.TypeAssertion.correctType(node) : node;
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
191
11767
ac252c4c920b FloatingReadPhase: use enum for describing the execution mode of the phase
Bernhard Urban <bernhard.urban@jku.at>
parents: 11766
diff changeset
192 if (execmode == ExecutionMode.ANALYSIS_ONLY && node instanceof ReturnNode) {
11847
f5faf49a86dd remove MemoryState, make MemoryMap a node, add MemoryMap input to ReturnNode
Bernhard Urban <bernhard.urban@jku.at>
parents: 11844
diff changeset
193 ((ReturnNode) node).setMemoryMap(node.graph().unique(new MemoryMapImpl(state)));
11747
a66ecc6a6393 FloatingReadPhase: add MemoryState information to graph
Bernhard Urban <bernhard.urban@jku.at>
parents: 11746
diff changeset
194 }
9623
76c40c3f6bb7 let ReentrantNodeIterator.processNode return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents: 9602
diff changeset
195 return state;
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
196 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
197
12722
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
198 private static void processAccess(MemoryAccess access, MemoryMapImpl state) {
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
199 LocationIdentity locationIdentity = access.getLocationIdentity();
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
200 if (locationIdentity != LocationIdentity.ANY_LOCATION) {
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
201 ValueNode lastLocationAccess = state.getLastLocationAccess(locationIdentity);
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
202 access.setLastLocationAccess(lastLocationAccess);
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
203 }
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
204 }
b87c2f34e0e0 Maintain lastLocationAccess in WriteNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 11847
diff changeset
205
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
206 private static void processCheckpoint(MemoryCheckpoint.Single checkpoint, MemoryMapImpl state) {
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
207 processIdentity(checkpoint.getLocationIdentity(), checkpoint, state);
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
208 }
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
209
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
210 private static void processCheckpoint(MemoryCheckpoint.Multi checkpoint, MemoryMapImpl state) {
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
211 for (LocationIdentity identity : checkpoint.getLocationIdentities()) {
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
212 processIdentity(identity, checkpoint, state);
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
213 }
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
214 }
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
215
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
216 private static void processIdentity(LocationIdentity identity, MemoryCheckpoint checkpoint, MemoryMapImpl state) {
10090
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
217 if (identity == ANY_LOCATION) {
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
218 state.lastMemorySnapshot.clear();
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
219 }
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
220 state.lastMemorySnapshot.put(identity, (ValueNode) checkpoint);
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
221 }
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
222
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
223 private static void processFloatable(FloatableAccessNode accessNode, MemoryMapImpl state) {
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9526
diff changeset
224 StructuredGraph graph = accessNode.graph();
8423
86ef0438d1d3 Generalize FloatingReadPhase to support arbitrary floatable access nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 8394
diff changeset
225 assert accessNode.getNullCheck() == false;
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
226 LocationIdentity locationIdentity = accessNode.location().getLocationIdentity();
10492
34444b095a51 Read nodes with attached barrier (G1) can not float
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10090
diff changeset
227 if (accessNode.canFloat()) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
228 ValueNode lastLocationAccess = state.getLastLocationAccess(locationIdentity);
8423
86ef0438d1d3 Generalize FloatingReadPhase to support arbitrary floatable access nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 8394
diff changeset
229 FloatingAccessNode floatingNode = accessNode.asFloatingNode(lastLocationAccess);
86ef0438d1d3 Generalize FloatingReadPhase to support arbitrary floatable access nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 8394
diff changeset
230 floatingNode.setNullCheck(accessNode.getNullCheck());
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
231 ValueAnchorNode anchor = null;
9646
183d33c76419 Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9623
diff changeset
232 GuardingNode guard = accessNode.getGuard();
183d33c76419 Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9623
diff changeset
233 if (guard != null) {
183d33c76419 Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9623
diff changeset
234 anchor = graph.add(new ValueAnchorNode(guard.asNode()));
183d33c76419 Removed ValueNode.dependencies
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9623
diff changeset
235 graph.addAfterFixed(accessNode, anchor);
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
236 }
8423
86ef0438d1d3 Generalize FloatingReadPhase to support arbitrary floatable access nodes.
Roland Schatz <roland.schatz@oracle.com>
parents: 8394
diff changeset
237 graph.replaceFixedWithFloating(accessNode, floatingNode);
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4525
diff changeset
238 }
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
239 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
240
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
241 @Override
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
242 protected MemoryMapImpl merge(MergeNode merge, List<MemoryMapImpl> states) {
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
243 MemoryMapImpl newState = new MemoryMapImpl();
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
244
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
245 Set<LocationIdentity> keys = new HashSet<>();
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
246 for (MemoryMapImpl other : states) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
247 keys.addAll(other.lastMemorySnapshot.keySet());
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
248 }
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
249 assert !keys.contains(FINAL_LOCATION);
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
250
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
251 for (LocationIdentity key : keys) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
252 int mergedStatesCount = 0;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
253 boolean isPhi = false;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
254 ValueNode merged = null;
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
255 for (MemoryMapImpl state : states) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
256 ValueNode last = state.getLastLocationAccess(key);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
257 if (isPhi) {
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
258 ((PhiNode) merged).addInput(last);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
259 } else {
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
260 if (merged == last) {
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
261 // nothing to do
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
262 } else if (merged == null) {
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
263 merged = last;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
264 } else {
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10492
diff changeset
265 PhiNode phi = merge.graph().addWithoutUnique(new PhiNode(PhiType.Memory, merge, key));
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
266 for (int j = 0; j < mergedStatesCount; j++) {
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
267 phi.addInput(merged);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
268 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
269 phi.addInput(last);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
270 merged = phi;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
271 isPhi = true;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
272 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
273 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
274 mergedStatesCount++;
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
275 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
276 newState.lastMemorySnapshot.put(key, merged);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
277 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
278 return newState;
5845
421e767d8038 Make FloatingRead phase respect loop closed form and use PostOrderNodeIterator
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5637
diff changeset
279 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
280
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
281 @Override
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
282 protected MemoryMapImpl afterSplit(AbstractBeginNode node, MemoryMapImpl oldState) {
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
283 MemoryMapImpl result = new MemoryMapImpl(oldState);
8381
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
284 if (node.predecessor() instanceof InvokeWithExceptionNode) {
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
285 /*
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
286 * InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode.
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
287 * Since it is both the invoke and a control flow split, the scheduler cannot
10090
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
288 * schedule anything immediately after the invoke. It can only schedule in the
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
289 * normal or exceptional successor - and we have to tell the scheduler here which
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
290 * side it needs to choose by putting in the location identity on both successors.
8381
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
291 */
10090
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
292 InvokeWithExceptionNode invoke = (InvokeWithExceptionNode) node.predecessor();
ae6f0c381087 split MemoryCheckpoint interface into Single and Multi
Lukas Stadler <lukas.stadler@jku.at>
parents: 9793
diff changeset
293 result.lastMemorySnapshot.put(invoke.getLocationIdentity(), node);
8381
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
294 }
807fd844ed2a InvokeWithException cannot be the lastLocationAccess for a FloatingReadNode. Since it is both the invoke and a control flow split, the scheduler cannot schedule anything immediately the invoke. It can only schedule in the normal or exceptional successor - and we have to tell the scheduler here which side it needs to choose by putting in the location identity on both successors.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7897
diff changeset
295 return result;
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
296 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
297
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
298 @Override
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
299 protected Map<LoopExitNode, MemoryMapImpl> processLoop(LoopBeginNode loop, MemoryMapImpl initialState) {
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
300 Set<LocationIdentity> modifiedLocations = modifiedInLoops.get(loop);
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
301 if (modifiedLocations.contains(ANY_LOCATION)) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
302 // create phis for all locations if ANY is modified in the loop
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
303 modifiedLocations = new HashSet<>(modifiedLocations);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
304 modifiedLocations.addAll(initialState.lastMemorySnapshot.keySet());
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
305 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
306
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
307 Map<LocationIdentity, PhiNode> phis = new HashMap<>();
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
308 for (LocationIdentity location : modifiedLocations) {
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10492
diff changeset
309 PhiNode phi = loop.graph().addWithoutUnique(new PhiNode(PhiType.Memory, loop, location));
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
310 phi.addInput(initialState.getLastLocationAccess(location));
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
311 phis.put(location, phi);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
312 initialState.lastMemorySnapshot.put(location, phi);
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
313 }
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
314
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
315 LoopInfo<MemoryMapImpl> loopInfo = ReentrantNodeIterator.processLoop(this, loop, initialState);
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
316
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
317 for (Map.Entry<LoopEndNode, MemoryMapImpl> entry : loopInfo.endStates.entrySet()) {
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
318 int endIndex = loop.phiPredecessorIndex(entry.getKey());
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
319 for (Map.Entry<LocationIdentity, PhiNode> phiEntry : phis.entrySet()) {
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
320 LocationIdentity key = phiEntry.getKey();
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
321 PhiNode phi = phiEntry.getValue();
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
322 phi.initializeValueAt(endIndex, entry.getValue().getLastLocationAccess(key));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324 }
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
325 for (Map.Entry<LoopExitNode, MemoryMapImpl> entry : loopInfo.exitStates.entrySet()) {
7895
f7b40e9d490c ValueProxyNodes for memory locations at loop exits
Lukas Stadler <lukas.stadler@jku.at>
parents: 7875
diff changeset
326 LoopExitNode exit = entry.getKey();
11746
661e10237142 FloatingReadPhase: add interface to access memory state
Bernhard Urban <bernhard.urban@jku.at>
parents: 11652
diff changeset
327 MemoryMapImpl state = entry.getValue();
9526
ae5cd887e67c Use a LocationIdentity interface instead of just Object for the location identity of a LocationNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9525
diff changeset
328 for (LocationIdentity location : modifiedLocations) {
7895
f7b40e9d490c ValueProxyNodes for memory locations at loop exits
Lukas Stadler <lukas.stadler@jku.at>
parents: 7875
diff changeset
329 ValueNode lastAccessAtExit = state.lastMemorySnapshot.get(location);
f7b40e9d490c ValueProxyNodes for memory locations at loop exits
Lukas Stadler <lukas.stadler@jku.at>
parents: 7875
diff changeset
330 if (lastAccessAtExit != null) {
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9526
diff changeset
331 state.lastMemorySnapshot.put(location, ProxyNode.forMemory(lastAccessAtExit, exit, location, loop.graph()));
7895
f7b40e9d490c ValueProxyNodes for memory locations at loop exits
Lukas Stadler <lukas.stadler@jku.at>
parents: 7875
diff changeset
332 }
f7b40e9d490c ValueProxyNodes for memory locations at loop exits
Lukas Stadler <lukas.stadler@jku.at>
parents: 7875
diff changeset
333 }
f7b40e9d490c ValueProxyNodes for memory locations at loop exits
Lukas Stadler <lukas.stadler@jku.at>
parents: 7875
diff changeset
334 }
7875
d2790497ce71 FloatingReadPhase changes to accomodate new scheduling behavior
Lukas Stadler <lukas.stadler@jku.at>
parents: 7868
diff changeset
335 return loopInfo.exitStates;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }