Mercurial > hg > truffle
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/OptimizeGuardAnchors.java @ 13641:5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Thu, 12 Dec 2013 15:13:02 +0100 |
parents | 79f52f7e7a08 |
children | 53977508b27d |
rev | line source |
---|---|
12481
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.phases.common; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
25 import java.util.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
26 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
27 import com.oracle.graal.debug.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
28 import com.oracle.graal.graph.NodeClass.NodeClassIterator; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.graph.iterators.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.cfg.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.extended.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.phases.*; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
34 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
35 public class OptimizeGuardAnchors extends Phase { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 private static final DebugMetric metricGuardsAnchorOptimized = Debug.metric("GuardsAnchorOptimized"); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
37 private static final DebugMetric metricGuardsOptimizedAtSplit = Debug.metric("GuardsOptimizedAtSplit"); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
38 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
39 private static class LazyCFG { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
40 private ControlFlowGraph cfg; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
41 private StructuredGraph graph; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
43 public LazyCFG(StructuredGraph graph) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
44 this.graph = graph; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
45 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
46 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
47 public ControlFlowGraph get() { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
48 if (cfg == null) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
49 cfg = ControlFlowGraph.compute(graph, true, false, true, true); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
50 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
51 return cfg; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
52 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
53 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
54 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
55 @Override |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 protected void run(StructuredGraph graph) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
57 LazyCFG cfg = new LazyCFG(graph); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
58 for (AbstractBeginNode begin : graph.getNodes(AbstractBeginNode.class)) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
59 if (!(begin instanceof StartNode || begin.predecessor() instanceof ControlSplitNode)) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
60 NodeIterable<GuardNode> guards = begin.guards(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 if (guards.isNotEmpty()) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
62 AbstractBeginNode newAnchor = computeOptimalAnchor(cfg.get(), begin); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
63 // newAnchor == begin is possible because postdominator computation assumes that |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
64 // loops never end |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
65 if (newAnchor != begin) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 for (GuardNode guard : guards.snapshot()) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 guard.setGuard(newAnchor); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
68 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
69 metricGuardsAnchorOptimized.increment(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
70 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
71 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
72 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
73 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
74 for (ControlSplitNode controlSplit : graph.getNodes(ControlSplitNode.class)) { |
13149 | 75 optimizeAtControlSplit(controlSplit, cfg); |
12481
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
76 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
77 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
78 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
79 private static AbstractBeginNode computeOptimalAnchor(ControlFlowGraph cfg, AbstractBeginNode begin) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
80 Block anchor = cfg.blockFor(begin); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
81 while (anchor.getDominator() != null && anchor.getDominator().getPostdominator() == anchor) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
82 anchor = anchor.getDominator(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
83 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
84 return anchor.getBeginNode(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
85 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
86 |
13149 | 87 private static void optimizeAtControlSplit(ControlSplitNode controlSplit, LazyCFG cfg) { |
12481
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
88 AbstractBeginNode successor = findMinimumUsagesSuccessor(controlSplit); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
89 int successorCount = controlSplit.successors().count(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
90 List<GuardNode> otherGuards = new ArrayList<>(successorCount - 1); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
91 for (GuardNode guard : successor.guards().snapshot()) { |
12539
97f56b7e978e
Fix NPE in OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12481
diff
changeset
|
92 if (guard.isDeleted() || guard.condition().usages().count() < successorCount) { |
12481
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
93 continue; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
94 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
95 for (GuardNode conditonGuard : guard.condition().usages().filter(GuardNode.class)) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
96 if (conditonGuard != guard) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
97 GuardingNode conditonGuardAnchor = conditonGuard.getGuard(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
98 if (conditonGuardAnchor.asNode().predecessor() == controlSplit && compatibleGuards(guard, conditonGuard)) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
99 otherGuards.add(conditonGuard); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
100 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
101 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
102 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
103 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
104 if (otherGuards.size() == successorCount - 1) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
105 AbstractBeginNode anchor = computeOptimalAnchor(cfg.get(), AbstractBeginNode.prevBegin(controlSplit)); |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13149
diff
changeset
|
106 GuardNode newGuard = controlSplit.graph().unique(new GuardNode(guard.condition(), anchor, guard.reason(), guard.action(), guard.negated(), guard.getSpeculation())); |
12481
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
107 for (GuardNode otherGuard : otherGuards) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
108 otherGuard.replaceAndDelete(newGuard); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
109 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
110 guard.replaceAndDelete(newGuard); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
111 metricGuardsOptimizedAtSplit.increment(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
112 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
113 otherGuards.clear(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
114 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
115 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
116 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
117 private static boolean compatibleGuards(GuardNode guard, GuardNode conditonGuard) { |
13641
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13149
diff
changeset
|
118 return conditonGuard.negated() == guard.negated() && conditonGuard.action() == guard.action() && conditonGuard.reason() == guard.reason() && |
5a9afbf72714
Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13149
diff
changeset
|
119 conditonGuard.getSpeculation().equals(guard.getSpeculation()); |
12481
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
120 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
121 |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
122 private static AbstractBeginNode findMinimumUsagesSuccessor(ControlSplitNode controlSplit) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
123 NodeClassIterator successors = controlSplit.successors().iterator(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
124 AbstractBeginNode min = (AbstractBeginNode) successors.next(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
125 int minUsages = min.usages().count(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
126 while (successors.hasNext()) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
127 AbstractBeginNode successor = (AbstractBeginNode) successors.next(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
128 int count = successor.usages().count(); |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
129 if (count < minUsages) { |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
130 minUsages = count; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
131 min = successor; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
132 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
133 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
134 return min; |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
135 } |
45daf0d65522
Replace EliminatePartiallyRedundantGuardsPhase with OptimizeGuardAnchors
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
136 } |