annotate graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java @ 15146:65efd2eeea1b

Remove AbstractNodeIterable, move its methods to default methods on NodeIterable. This allows to remove a number of duplicated methods in NodeList NodeClassIterable is also interface instead of an abstract class.
author Gilles Duboscq <duboscq@ssw.jku.at>
date Mon, 14 Apr 2014 16:31:13 +0200
parents df2ef5204f2b
children 1dc1af3bf402
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
6523
c8763a2deb0c rename packages in graal.loop to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6522
diff changeset
23 package com.oracle.graal.loop;
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
25 import java.util.*;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
26
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
27 import com.oracle.graal.graph.*;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
28 import com.oracle.graal.graph.Graph.DuplicationReplacement;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
29 import com.oracle.graal.graph.iterators.*;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
30 import com.oracle.graal.nodes.*;
5732
e1d5c642d022 Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5713
diff changeset
31 import com.oracle.graal.nodes.VirtualState.VirtualClosure;
6529
2e96dc4eb8e2 renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents: 6523
diff changeset
32 import com.oracle.graal.nodes.cfg.*;
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13327
diff changeset
33 import com.oracle.graal.nodes.java.*;
12479
36a438ebab50 duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 12437
diff changeset
34 import com.oracle.graal.nodes.virtual.*;
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
35
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6709
diff changeset
36 public abstract class LoopFragment {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
37
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
38 private final LoopEx loop;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
39 private final LoopFragment original;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
40 protected NodeBitMap nodes;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
41 protected boolean nodesReady;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
42 private Map<Node, Node> duplicationMap;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
43
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
44 public LoopFragment(LoopEx loop) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
45 this(loop, null);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
46 this.nodesReady = true;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
47 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
48
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
49 public LoopFragment(LoopEx loop, LoopFragment original) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
50 this.loop = loop;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
51 this.original = original;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
52 this.nodesReady = false;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
53 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
54
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
55 public LoopEx loop() {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
56 return loop;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
57 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
58
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
59 public abstract LoopFragment duplicate();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
60
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
61 public abstract void insertBefore(LoopEx l);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
62
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63 public void disconnect() {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
64 // TODO (gd) possibly abstract
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
66
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 public boolean contains(Node n) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
68 return nodes().contains(n);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
69 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
70
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
71 @SuppressWarnings("unchecked")
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
72 public <New extends Node, Old extends New> New getDuplicatedNode(Old n) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
73 assert isDuplicate();
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13152
diff changeset
74 return (New) duplicationMap.get(n);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
75 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
76
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
77 protected <New extends Node, Old extends New> void putDuplicatedNode(Old oldNode, New newNode) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
78 duplicationMap.put(oldNode, newNode);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
79 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
80
15143
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
81 /**
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
82 * Gets the corresponding value in this fragment. Should be called on duplicate fragments with a
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
83 * node from the original fragment as argument.
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
84 *
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
85 * @param b original value
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
86 * @return corresponding value in the peel
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
87 */
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
88 protected abstract ValueNode prim(ValueNode b);
c68064651847 Make prim method from LoopFragmentInside to an abstract method on LoopFragment
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14995
diff changeset
89
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
90 public boolean isDuplicate() {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
91 return original != null;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
92 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
93
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
94 public LoopFragment original() {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
95 return original;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
96 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
97
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
98 public abstract NodeIterable<Node> nodes();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
99
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
100 public StructuredGraph graph() {
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
101 LoopEx l;
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
102 if (isDuplicate()) {
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
103 l = original().loop();
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
104 } else {
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
105 l = loop();
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
106 }
9602
19c5a07c7843 Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9600
diff changeset
107 return l.loopBegin().graph();
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
108 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
109
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
110 protected abstract DuplicationReplacement getDuplicationReplacement();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
111
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
112 protected abstract void finishDuplication();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
113
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
114 protected void patchNodes(final DuplicationReplacement dataFix) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
115 if (isDuplicate() && !nodesReady) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
116 assert !original.isDuplicate();
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
117 final DuplicationReplacement cfgFix = original().getDuplicationReplacement();
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
118 DuplicationReplacement dr;
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
119 if (cfgFix == null && dataFix != null) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
120 dr = dataFix;
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
121 } else if (cfgFix != null && dataFix == null) {
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
122 dr = cfgFix;
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
123 } else if (cfgFix != null && dataFix != null) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
124 dr = new DuplicationReplacement() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6709
diff changeset
125
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
126 @Override
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
127 public Node replacement(Node o) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
128 Node r1 = dataFix.replacement(o);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
129 if (r1 != o) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
130 assert cfgFix.replacement(o) == o;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
131 return r1;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
132 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
133 Node r2 = cfgFix.replacement(o);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
134 if (r2 != o) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
135 return r2;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
136 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
137 return o;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
138 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
139 };
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
140 } else {
11671
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
141 dr = null;
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
142 }
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11671
diff changeset
143 NodeIterable<Node> nodesIterable = original().nodes();
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11671
diff changeset
144 duplicationMap = graph().addDuplicates(nodesIterable, graph(), nodesIterable.count(), dr);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
145 finishDuplication();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
146 nodesReady = true;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
147 } else {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6709
diff changeset
148 // TODO (gd) apply fix ?
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
149 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
150 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
151
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
152 protected static NodeBitMap computeNodes(Graph graph, Iterable<BeginNode> blocks) {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
153 return computeNodes(graph, blocks, Collections.emptyList());
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
154 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
155
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
156 protected static NodeBitMap computeNodes(Graph graph, Iterable<BeginNode> blocks, Iterable<LoopExitNode> earlyExits) {
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
157 final NodeBitMap nodes = graph.createNodeBitMap(true);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
158 for (BeginNode b : blocks) {
12750
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
159 if (b.isDeleted()) {
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
160 continue;
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
161 }
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
162
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
163 for (Node n : b.getBlockNodes()) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
164 if (n instanceof Invoke) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
165 nodes.mark(((Invoke) n).callTarget());
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
166 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
167 if (n instanceof StateSplit) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
168 FrameState stateAfter = ((StateSplit) n).stateAfter();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
169 if (stateAfter != null) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
170 nodes.mark(stateAfter);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
171 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
172 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
173 nodes.mark(n);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
174 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
175 }
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
176 for (LoopExitNode earlyExit : earlyExits) {
12750
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
177 if (earlyExit.isDeleted()) {
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
178 continue;
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
179 }
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
180
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
181 FrameState stateAfter = earlyExit.stateAfter();
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5519
diff changeset
182 if (stateAfter != null) {
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5519
diff changeset
183 nodes.mark(stateAfter);
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
184 stateAfter.applyToVirtual(new VirtualClosure() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6709
diff changeset
185
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
186 @Override
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
187 public void apply(VirtualState node) {
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
188 nodes.mark(node);
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
189 }
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
190 });
5610
9f3250602d69 Preliminary counted loop detection
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5519
diff changeset
191 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
192 nodes.mark(earlyExit);
7897
a58851061377 rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
193 for (ProxyNode proxy : earlyExit.proxies()) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
194 nodes.mark(proxy);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
195 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
196 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
197
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
198 final NodeBitMap notloopNodes = graph.createNodeBitMap(true);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
199 for (BeginNode b : blocks) {
12750
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
200 if (b.isDeleted()) {
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
201 continue;
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
202 }
c61d1f1bbee0 Invalidate cached nodes after canonicalization in full unrolling.
Roland Schatz <roland.schatz@oracle.com>
parents: 12655
diff changeset
203
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
204 for (Node n : b.getBlockNodes()) {
12479
36a438ebab50 duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 12437
diff changeset
205 if (n instanceof CommitAllocationNode) {
36a438ebab50 duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 12437
diff changeset
206 for (VirtualObjectNode obj : ((CommitAllocationNode) n).getVirtualObjects()) {
36a438ebab50 duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 12437
diff changeset
207 markFloating(obj, nodes, notloopNodes);
36a438ebab50 duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 12437
diff changeset
208 }
36a438ebab50 duplicate VirtualObjectNodes when peeling / unrolling loops
Lukas Stadler <lukas.stadler@jku.at>
parents: 12437
diff changeset
209 }
13554
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13327
diff changeset
210 if (n instanceof MonitorEnterNode) {
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13327
diff changeset
211 markFloating(((MonitorEnterNode) n).getMonitorId(), nodes, notloopNodes);
83fd2094ff66 rework of monitorenter/exit (use MonitorIdNode)
Lukas Stadler <lukas.stadler@jku.at>
parents: 13327
diff changeset
212 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
213 for (Node usage : n.usages()) {
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
214 markFloating(usage, nodes, notloopNodes);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
215 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
216 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
217 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
218
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
219 return nodes;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
220 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
221
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
222 private static boolean markFloating(Node n, NodeBitMap loopNodes, NodeBitMap notloopNodes) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
223 if (loopNodes.isMarked(n)) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
224 return true;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
225 }
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
226 if (notloopNodes.isMarked(n)) {
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
227 return false;
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
228 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
229 if (n instanceof FixedNode) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
230 return false;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
231 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
232 boolean mark = false;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
233 if (n instanceof PhiNode) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
234 PhiNode phi = (PhiNode) n;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
235 mark = loopNodes.isMarked(phi.merge());
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
236 if (mark) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
237 loopNodes.mark(n);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
238 } else {
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
239 notloopNodes.mark(n);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
240 return false;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
241 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
242 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
243 for (Node usage : n.usages()) {
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
244 if (markFloating(usage, loopNodes, notloopNodes)) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
245 mark = true;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
246 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
247 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
248 if (mark) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
249 loopNodes.mark(n);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
250 return true;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
251 }
9600
20c09d314168 Improve markFloating in LoopFragment (avoids recursion explosion)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9436
diff changeset
252 notloopNodes.mark(n);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
253 return false;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
254 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
255
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
256 public static NodeIterable<BeginNode> toHirBlocks(final Iterable<Block> blocks) {
15146
65efd2eeea1b Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15145
diff changeset
257 return new NodeIterable<BeginNode>() {
11522
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
258
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
259 public Iterator<BeginNode> iterator() {
11522
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
260 final Iterator<Block> it = blocks.iterator();
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
261 return new Iterator<BeginNode>() {
11522
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
262
12437
c991f8291f1b add missing @Override to Iterator.remove overrides
twisti
parents: 11675
diff changeset
263 @Override
11522
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
264 public void remove() {
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
265 throw new UnsupportedOperationException();
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
266 }
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
267
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
268 public BeginNode next() {
11522
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
269 return it.next().getBeginNode();
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
270 }
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
271
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
272 public boolean hasNext() {
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
273 return it.hasNext();
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
274 }
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
275 };
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
276 }
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
277
dbf968195ca1 use iterable for LoopFragment.toHirBlocks rather than reify collections
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9602
diff changeset
278 };
5732
e1d5c642d022 Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5713
diff changeset
279 }
e1d5c642d022 Started to draft a loop unswitching policy
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5713
diff changeset
280
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
281 public static NodeIterable<LoopExitNode> toHirExits(final Iterable<Block> blocks) {
15146
65efd2eeea1b Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15145
diff changeset
282 return new NodeIterable<LoopExitNode>() {
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
283
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
284 public Iterator<LoopExitNode> iterator() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
285 final Iterator<Block> it = blocks.iterator();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
286 return new Iterator<LoopExitNode>() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
287
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
288 @Override
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
289 public void remove() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
290 throw new UnsupportedOperationException();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
291 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
292
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
293 public LoopExitNode next() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
294 return (LoopExitNode) it.next().getBeginNode();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
295 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
296
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
297 public boolean hasNext() {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
298 return it.hasNext();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
299 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
300 };
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
301 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
302
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
303 };
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
304 }
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
305
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
306 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6709
diff changeset
307 * Merges the early exits (i.e. loop exits) that were duplicated as part of this fragment, with
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 6709
diff changeset
308 * the original fragment's exits.
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
309 */
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
310 protected void mergeEarlyExits() {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
311 assert isDuplicate();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
312 StructuredGraph graph = graph();
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
313 for (BeginNode earlyExit : LoopFragment.toHirBlocks(original().loop().lirLoop().exits)) {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
314 LoopExitNode loopEarlyExit = (LoopExitNode) earlyExit;
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
315 FixedNode next = loopEarlyExit.next();
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
316 if (loopEarlyExit.isDeleted() || !this.original().contains(loopEarlyExit)) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
317 continue;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
318 }
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
319 BeginNode newEarlyExit = getDuplicatedNode(loopEarlyExit);
5741
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
320 if (newEarlyExit == null) {
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
321 continue;
c84c75339af1 Work on loop unswitching, things look ok, still disabled until FloatingRead preserves loop-closed form
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5732
diff changeset
322 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
323 MergeNode merge = graph.add(new MergeNode());
9434
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
324 AbstractEndNode originalEnd = graph.add(new EndNode());
50f02c7d1cec Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9234
diff changeset
325 AbstractEndNode newEnd = graph.add(new EndNode());
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
326 merge.addForwardEnd(originalEnd);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
327 merge.addForwardEnd(newEnd);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
328 loopEarlyExit.setNext(originalEnd);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
329 newEarlyExit.setNext(newEnd);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
330 merge.setNext(next);
5639
d1d649d2f97c set correct probabilities on MergeNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5612
diff changeset
331
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
332 FrameState exitState = loopEarlyExit.stateAfter();
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
333 FrameState state = null;
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
334 if (exitState != null) {
6706
e9e724ea5097 make LoopFragment deal correctly with GVN'd VirtualState
Lukas Stadler <lukas.stadler@jku.at>
parents: 6545
diff changeset
335 state = exitState;
e9e724ea5097 make LoopFragment deal correctly with GVN'd VirtualState
Lukas Stadler <lukas.stadler@jku.at>
parents: 6545
diff changeset
336 exitState = exitState.duplicateWithVirtualState();
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
337 loopEarlyExit.setStateAfter(exitState);
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
338 merge.setStateAfter(state);
14110
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
339 /*
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
340 * Using the old exit's state as the merge's state is necessary because some of the
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
341 * VirtualState nodes contained in the old exit's state may be shared by other
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
342 * dominated VirtualStates. Those dominated virtual states need to see the
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
343 * proxy->phi update that are applied below.
15146
65efd2eeea1b Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15145
diff changeset
344 *
14110
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
345 * We now update the original fragment's nodes accordingly:
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
346 */
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
347 state.applyToVirtual(new VirtualClosure() {
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
348 public void apply(VirtualState node) {
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
349 original.nodes.clear(node);
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
350 }
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
351 });
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
352 exitState.applyToVirtual(new VirtualClosure() {
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
353 public void apply(VirtualState node) {
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
354 original.nodes.mark(node);
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
355 }
e55082b1e727 During LoopFragment.mergeEarlyExits we need to update the orignal fragement's nodes bitmap
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13554
diff changeset
356 });
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
357 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
358
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
359 for (Node anchored : loopEarlyExit.anchored().snapshot()) {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
360 anchored.replaceFirstInput(loopEarlyExit, merge);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
361 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
362
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
363 boolean newEarlyExitIsLoopExit = newEarlyExit instanceof LoopExitNode;
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
364 for (final ProxyNode vpn : loopEarlyExit.proxies().snapshot()) {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
365 if (vpn.usages().isEmpty()) {
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
366 continue;
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
367 }
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
368 final ValueNode replaceWith;
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
369 ValueNode newVpn = prim(newEarlyExitIsLoopExit ? vpn : vpn.value());
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
370 if (newVpn != null) {
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 12750
diff changeset
371 PhiNode phi;
14978
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
372 if (vpn instanceof ValueProxyNode) {
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
373 phi = graph.addWithoutUnique(new ValuePhiNode(vpn.stamp(), merge));
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
374 } else if (vpn instanceof GuardProxyNode) {
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
375 phi = graph.addWithoutUnique(new GuardPhiNode(merge));
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
376 } else if (vpn instanceof MemoryProxyNode) {
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
377 phi = graph.addWithoutUnique(new MemoryPhiNode(merge, ((MemoryProxyNode) vpn).getLocationIdentity()));
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
378 } else {
e302df8bf51c separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14826
diff changeset
379 throw GraalInternalError.shouldNotReachHere();
13152
640516a8ca6b Separate class for MemoryProxy and MemoryPhi.
Roland Schatz <roland.schatz@oracle.com>
parents: 12750
diff changeset
380 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
381 phi.addInput(vpn);
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15143
diff changeset
382 phi.addInput(newVpn);
5598
a9b615da0cba removed delta-encoding of VirtualObjectState
Lukas Stadler <lukas.stadler@jku.at>
parents: 5519
diff changeset
383 replaceWith = phi;
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
384 } else {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
385 replaceWith = vpn.value();
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
386 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
387 for (Node usage : vpn.usages().snapshot()) {
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
388 if (!merge.isPhiAtMerge(usage)) {
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
389 if (usage instanceof VirtualState) {
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
390 VirtualState stateUsage = (VirtualState) usage;
6706
e9e724ea5097 make LoopFragment deal correctly with GVN'd VirtualState
Lukas Stadler <lukas.stadler@jku.at>
parents: 6545
diff changeset
391 if (exitState.isPartOfThisState(stateUsage)) {
5713
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
392 continue;
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
393 }
8c478272fb34 Cleanup and fixes in handling of VirtualStates around loop exits merging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5678
diff changeset
394 }
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
395 usage.replaceFirstInput(vpn, replaceWith);
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
396 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
397 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
398 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
399 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
400 }
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
401 }