Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java @ 9933:78a1232be418
Fixed a warning.
author | Christian Haeubl <haeubl@ssw.jku.at> |
---|---|
date | Fri, 07 Jun 2013 16:10:07 +0200 |
parents | 3d5fdf185a67 |
children | de73bbbde021 |
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 */ |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
23 package com.oracle.graal.phases.graph; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
27 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
28 import com.oracle.graal.nodes.*; |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
29 import com.oracle.graal.nodes.extended.*; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
30 import com.oracle.graal.nodes.util.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
7522
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
32 /** |
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
33 * Computes probabilities for nodes in a graph. |
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
34 * <p> |
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
35 * The computation of absolute probabilities works in three steps: |
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
36 * <ol> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
37 * <li>{@link PropagateProbability} traverses the graph in post order (merges after their ends, ...) |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
38 * and keeps track of the "probability state". Whenever it encounters a {@link ControlSplitNode} it |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
39 * uses the split's probability information to divide the probability upon the successors. Whenever |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
40 * it encounters an {@link Invoke} it assumes that the exception edge is unlikely and propagates the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
41 * whole probability to the normal successor. Whenever it encounters a {@link MergeNode} it sums up |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
42 * the probability of all predecessors. It also maintains a set of active loops (whose |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
43 * {@link LoopBeginNode} has been visited) and builds def/use information for step 2.</li> |
7522
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
44 * <li></li> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
45 * <li>{@link PropagateLoopFrequency} propagates the loop frequencies and multiplies each |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
46 * {@link FixedNode}'s probability with its loop frequency.</li> |
7522
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
47 * </ol> |
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
48 * TODO: add exception probability information to Invokes |
4cc0efe5cffe
disabled auto-formatting of manually formatted code
Doug Simon <doug.simon@oracle.com>
parents:
7392
diff
changeset
|
49 */ |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
50 public class ComputeProbabilityClosure { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
51 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 private static final double EPSILON = 1d / Integer.MAX_VALUE; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
54 private final StructuredGraph graph; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
55 private final NodesToDoubles nodeProbabilities; |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
56 private final Set<LoopInfo> loopInfos; |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
57 private final Map<MergeNode, Set<LoopInfo>> mergeLoops; |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
58 |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
59 public ComputeProbabilityClosure(StructuredGraph graph) { |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
60 this.graph = graph; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
61 this.nodeProbabilities = new NodesToDoubles(graph.getNodeCount()); |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
62 this.loopInfos = new HashSet<>(); |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
63 this.mergeLoops = new IdentityHashMap<>(); |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
64 } |
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
65 |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
66 public NodesToDoubles apply() { |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
67 adjustControlSplitProbabilities(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 new PropagateProbability(graph.start()).apply(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 computeLoopFactors(); |
4638
a9181b59a6bf
added another variant for propagating loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4614
diff
changeset
|
70 new PropagateLoopFrequency(graph.start()).apply(); |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
71 assert verifyProbabilities(); |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
72 return nodeProbabilities; |
4706
a59fe7906f0b
additional LoopFrequencyPropagationPolicy versions
Lukas Stadler <lukas.stadler@jku.at>
parents:
4638
diff
changeset
|
73 } |
a59fe7906f0b
additional LoopFrequencyPropagationPolicy versions
Lukas Stadler <lukas.stadler@jku.at>
parents:
4638
diff
changeset
|
74 |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
75 /** |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
76 * Assume that paths with a DeoptimizeNode at their end are taken infrequently. |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
77 */ |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
78 private void adjustControlSplitProbabilities() { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
79 HashSet<ControlSplitNode> result = new HashSet<>(); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
80 NodeBitMap visitedNodes = new NodeBitMap(graph); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
81 for (DeoptimizeNode n : graph.getNodes(DeoptimizeNode.class)) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
82 if (n.action().doesInvalidateCompilation()) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
83 findParentControlSplitNodes(result, n, visitedNodes); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
84 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
85 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
86 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
87 for (ControlSplitNode n : result) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
88 if (!allSuxVisited(n, visitedNodes)) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
89 modifyProbabilities(n, visitedNodes); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
90 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
91 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
92 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
93 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
94 private static void findParentControlSplitNodes(HashSet<ControlSplitNode> result, DeoptimizeNode n, NodeBitMap visitedNodes) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
95 ArrayDeque<FixedNode> nodes = new ArrayDeque<>(); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
96 nodes.push(n); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
97 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
98 Node currentNode; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
99 do { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
100 currentNode = nodes.pop(); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
101 visitedNodes.mark(currentNode); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
102 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
103 for (Node pred : currentNode.cfgPredecessors()) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
104 FixedNode fixedPred = (FixedNode) pred; |
9932
3d5fdf185a67
Bugfix concerning ComputeProbabilityClosure.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9931
diff
changeset
|
105 if (allSuxVisited(fixedPred, visitedNodes) || fixedPred instanceof InvokeWithExceptionNode) { |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
106 nodes.push(fixedPred); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
107 } else { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
108 assert fixedPred instanceof ControlSplitNode : "only control splits can have more than one sux"; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
109 result.add((ControlSplitNode) fixedPred); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
110 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
111 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
112 } while (!nodes.isEmpty()); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
113 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
114 |
9932
3d5fdf185a67
Bugfix concerning ComputeProbabilityClosure.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9931
diff
changeset
|
115 private static void modifyProbabilities(ControlSplitNode node, NodeBitMap visitedNodes) { |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
116 if (node instanceof IfNode) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
117 IfNode ifNode = (IfNode) node; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
118 assert visitedNodes.isMarked(ifNode.falseSuccessor()) ^ visitedNodes.isMarked(ifNode.trueSuccessor()); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
119 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
120 if (visitedNodes.isMarked(ifNode.trueSuccessor())) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
121 if (ifNode.probability(ifNode.trueSuccessor()) > 0) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
122 ifNode.setTrueSuccessorProbability(0); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
123 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
124 } else { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
125 if (ifNode.probability(ifNode.trueSuccessor()) < 1) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
126 ifNode.setTrueSuccessorProbability(1); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
127 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
128 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
129 } else if (node instanceof SwitchNode) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
130 SwitchNode switchNode = (SwitchNode) node; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
131 for (Node sux : switchNode.successors()) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
132 if (visitedNodes.isMarked(sux)) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
133 switchNode.setProbability(sux, 0); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
134 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
135 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
136 } else { |
9932
3d5fdf185a67
Bugfix concerning ComputeProbabilityClosure.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9931
diff
changeset
|
137 GraalInternalError.shouldNotReachHere(); |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
138 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
139 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
140 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
141 private static boolean allSuxVisited(FixedNode fixedPred, NodeBitMap visitedNodes) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
142 for (Node sux : fixedPred.successors()) { |
9931 | 143 if (!visitedNodes.contains(sux)) { |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
144 return false; |
9931 | 145 } |
9930
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
146 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
147 return true; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
148 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
149 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
150 private boolean verifyProbabilities() { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
151 if (doesNotAlwaysDeopt(graph)) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
152 for (DeoptimizeNode n : graph.getNodes(DeoptimizeNode.class)) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
153 if (n.action().doesInvalidateCompilation() && nodeProbabilities.get(n) > 0.01) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
154 throw new AssertionError(String.format("%s with reason %s and probability %f in graph %s", n, n.reason(), nodeProbabilities.get(n), graph)); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
155 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
156 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
157 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
158 return true; |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
159 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
160 |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
161 private static boolean doesNotAlwaysDeopt(StructuredGraph graph) { |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
162 return graph.getNodes(ReturnNode.class).iterator().hasNext(); |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
163 } |
5a4fbe932ab3
Assume that those path which end in a DeoptimizeNode are taken less frequently.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9704
diff
changeset
|
164 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 private void computeLoopFactors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 for (LoopInfo info : loopInfos) { |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
167 double frequency = info.loopFrequency(nodeProbabilities); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 assert frequency != -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 public static class LoopInfo { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
173 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 public final LoopBeginNode loopBegin; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
176 public final NodeMap<Set<LoopInfo>> requires; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 private double loopFrequency = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 public boolean ended = false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 public LoopInfo(LoopBeginNode loopBegin) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 this.loopBegin = loopBegin; |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
183 this.requires = loopBegin.graph().createNodeMap(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
186 public double loopFrequency(NodesToDoubles nodeProbabilities) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 if (loopFrequency == -1 && ended) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
188 double backEdgeProb = 0.0; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
189 for (LoopEndNode le : loopBegin.loopEnds()) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
190 double factor = 1; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
191 Set<LoopInfo> requireds = requires.get(le); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
192 for (LoopInfo required : requireds) { |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
193 double t = required.loopFrequency(nodeProbabilities); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
194 if (t == -1) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
195 return -1; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
196 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
197 factor *= t; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 } |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
199 backEdgeProb += nodeProbabilities.get(le) * factor; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 } |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
201 double d = nodeProbabilities.get(loopBegin) - backEdgeProb; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 if (d < EPSILON) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 d = EPSILON; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 } |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
205 loopFrequency = nodeProbabilities.get(loopBegin) / d; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 loopBegin.setLoopFrequency(loopFrequency); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 return loopFrequency; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 private class Probability implements MergeableState<Probability> { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
213 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 public double probability; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 public HashSet<LoopInfo> loops; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 public LoopInfo loopInfo; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 public Probability(double probability, HashSet<LoopInfo> loops) { |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
219 assert probability >= 0.0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 this.probability = probability; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
221 this.loops = new HashSet<>(4); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 if (loops != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 this.loops.addAll(loops); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 public Probability clone() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 return new Probability(probability, loops); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
230 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 @Override |
5074
ad00d1d02ed2
change MergeableState to use List<T> instead of Collection<T>
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
233 public boolean merge(MergeNode merge, List<Probability> withStates) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
234 if (merge.forwardEndCount() > 1) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
235 HashSet<LoopInfo> intersection = new HashSet<>(loops); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 for (Probability other : withStates) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 intersection.retainAll(other.loops); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 for (LoopInfo info : loops) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 if (!intersection.contains(info)) { |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
241 double loopFrequency = info.loopFrequency(nodeProbabilities); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 if (loopFrequency == -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 probability *= loopFrequency; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
247 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 for (Probability other : withStates) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 double prob = other.probability; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 for (LoopInfo info : other.loops) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 if (!intersection.contains(info)) { |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
252 double loopFrequency = info.loopFrequency(nodeProbabilities); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
253 if (loopFrequency == -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 prob *= loopFrequency; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 probability += prob; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 loops = intersection; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
262 mergeLoops.put(merge, new HashSet<>(intersection)); |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
263 probability = Math.max(0.0, probability); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 public void loopBegin(LoopBeginNode loopBegin) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 loopInfo = new LoopInfo(loopBegin); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 loopInfos.add(loopInfo); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 loops.add(loopInfo); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 @Override |
5074
ad00d1d02ed2
change MergeableState to use List<T> instead of Collection<T>
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
276 public void loopEnds(LoopBeginNode loopBegin, List<Probability> loopEndStates) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 assert loopInfo != null; |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
278 List<LoopEndNode> loopEnds = loopBegin.orderedLoopEnds(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
279 int i = 0; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
280 for (Probability proba : loopEndStates) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
281 LoopEndNode loopEnd = loopEnds.get(i++); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
282 Set<LoopInfo> requires = loopInfo.requires.get(loopEnd); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
283 if (requires == null) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
284 requires = new HashSet<>(); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
285 loopInfo.requires.set(loopEnd, requires); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
286 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
287 for (LoopInfo innerLoop : proba.loops) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
288 if (innerLoop != loopInfo && !this.loops.contains(innerLoop)) { |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
289 requires.add(innerLoop); |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
290 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 loopInfo.ended = true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 @Override |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
297 public void afterSplit(AbstractBeginNode node) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 assert node.predecessor() != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 Node pred = node.predecessor(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 if (pred instanceof Invoke) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 Invoke x = (Invoke) pred; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 if (x.next() != node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 probability = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 assert pred instanceof ControlSplitNode; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 ControlSplitNode x = (ControlSplitNode) pred; |
9467
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
308 double nodeProbability = x.probability(node); |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
309 assert nodeProbability >= 0.0 : "Node " + x + " provided negative probability for begin " + node + ": " + nodeProbability; |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
310 probability *= nodeProbability; |
3531cdfddff6
Ensure probabilities are never negative. Add additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9436
diff
changeset
|
311 assert probability >= 0.0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 private class PropagateProbability extends PostOrderNodeIterator<Probability> { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 public PropagateProbability(FixedNode start) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 super(start, new Probability(1d, null)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
321 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 protected void node(FixedNode node) { |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
324 nodeProbabilities.put(node, state.probability); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 private class LoopCount implements MergeableState<LoopCount> { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7522
diff
changeset
|
329 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
330 public double count; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 public LoopCount(double count) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 this.count = count; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 public LoopCount clone() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 return new LoopCount(count); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 @Override |
5074
ad00d1d02ed2
change MergeableState to use List<T> instead of Collection<T>
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
342 public boolean merge(MergeNode merge, List<LoopCount> withStates) { |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
343 assert merge.forwardEndCount() == withStates.size() + 1; |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4569
diff
changeset
|
344 if (merge.forwardEndCount() > 1) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 Set<LoopInfo> loops = mergeLoops.get(merge); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 assert loops != null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 double countProd = 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 for (LoopInfo loop : loops) { |
9234
b9cf7d0b598e
removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9113
diff
changeset
|
349 countProd *= loop.loopFrequency(nodeProbabilities); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 count = countProd; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
355 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
356 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 public void loopBegin(LoopBeginNode loopBegin) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 count *= loopBegin.loopFrequency(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 @Override |
5074
ad00d1d02ed2
change MergeableState to use List<T> instead of Collection<T>
Lukas Stadler <lukas.stadler@jku.at>
parents:
5061
diff
changeset
|
362 public void loopEnds(LoopBeginNode loopBegin, List<LoopCount> loopEndStates) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 // nothing to do... |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 @Override |
9436
ae815a4c112a
Rename BeginNode => AbstractBeginNode and make abstract. Introduce concrete subclass BeginNode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9238
diff
changeset
|
367 public void afterSplit(AbstractBeginNode node) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
368 // nothing to do... |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
369 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
370 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 private class PropagateLoopFrequency extends PostOrderNodeIterator<LoopCount> { |
4706
a59fe7906f0b
additional LoopFrequencyPropagationPolicy versions
Lukas Stadler <lukas.stadler@jku.at>
parents:
4638
diff
changeset
|
373 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 public PropagateLoopFrequency(FixedNode start) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 super(start, new LoopCount(1d)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
377 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
378 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
379 protected void node(FixedNode node) { |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
380 nodeProbabilities.put(node, nodeProbabilities.get(node) * state.count); |
4638
a9181b59a6bf
added another variant for propagating loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4614
diff
changeset
|
381 } |
a9181b59a6bf
added another variant for propagating loop frequencies
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4614
diff
changeset
|
382 |
4706
a59fe7906f0b
additional LoopFrequencyPropagationPolicy versions
Lukas Stadler <lukas.stadler@jku.at>
parents:
4638
diff
changeset
|
383 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 } |