Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java @ 9876:975cc822632a
PEA phase only needs PhaseContext
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 05 Jun 2013 11:46:19 +0200 |
parents | 063a712fe8d8 |
children | 97cabe2c4642 |
rev | line source |
---|---|
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.virtual.phases.ea; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9809
diff
changeset
|
25 import static com.oracle.graal.phases.GraalOptions.*; |
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9809
diff
changeset
|
26 |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import java.util.*; |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
28 import java.util.concurrent.*; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.debug.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.graph.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.*; |
8553
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
33 import com.oracle.graal.nodes.java.*; |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
34 import com.oracle.graal.nodes.spi.*; |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
35 import com.oracle.graal.nodes.util.*; |
9501
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
36 import com.oracle.graal.nodes.virtual.*; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.phases.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 import com.oracle.graal.phases.common.*; |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7307
diff
changeset
|
39 import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 import com.oracle.graal.phases.graph.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 import com.oracle.graal.phases.schedule.*; |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
42 import com.oracle.graal.phases.tiers.*; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 |
9876
975cc822632a
PEA phase only needs PhaseContext
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
44 public class PartialEscapeAnalysisPhase extends BasePhase<PhaseContext> { |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
46 public abstract static class Closure<T> extends ReentrantBlockIterator.BlockIteratorClosure<T> { |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
47 |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
48 public abstract boolean hasChanged(); |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
49 |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
50 public abstract void applyEffects(); |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
51 } |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
52 |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
53 private final CustomCanonicalizer customCanonicalizer; |
7012
9b7de658a76a
add test for escape analysis of InstanceOf and CheckCast
Lukas Stadler <lukas.stadler@jku.at>
parents:
6710
diff
changeset
|
54 private final boolean iterative; |
8622
d8f28e2e2b49
make read elimination configurable (for tests)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
55 private final boolean readElimination; |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6654
diff
changeset
|
56 |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
57 public PartialEscapeAnalysisPhase(boolean iterative, boolean readElimination) { |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
58 this(null, iterative, readElimination); |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
59 } |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
60 |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
61 public PartialEscapeAnalysisPhase(CustomCanonicalizer customCanonicalizer, boolean iterative, boolean readElimination) { |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
62 this.customCanonicalizer = customCanonicalizer; |
7012
9b7de658a76a
add test for escape analysis of InstanceOf and CheckCast
Lukas Stadler <lukas.stadler@jku.at>
parents:
6710
diff
changeset
|
63 this.iterative = iterative; |
8622
d8f28e2e2b49
make read elimination configurable (for tests)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
64 this.readElimination = readElimination; |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6654
diff
changeset
|
65 } |
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6654
diff
changeset
|
66 |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
67 @Override |
9876
975cc822632a
PEA phase only needs PhaseContext
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
68 protected void run(StructuredGraph graph, PhaseContext context) { |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
69 runAnalysis(graph, context); |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
70 } |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
71 |
9876
975cc822632a
PEA phase only needs PhaseContext
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
72 public boolean runAnalysis(final StructuredGraph graph, final PhaseContext context) { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9809
diff
changeset
|
73 if (!VirtualUtil.matches(graph, EscapeAnalyzeOnly.getValue())) { |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
74 return false; |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
75 } |
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
76 |
8622
d8f28e2e2b49
make read elimination configurable (for tests)
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
77 if (!readElimination) { |
8556
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
78 boolean analyzableNodes = false; |
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
79 for (Node node : graph.getNodes()) { |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
80 if (node instanceof VirtualizableAllocation) { |
8556
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
81 analyzableNodes = true; |
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
82 break; |
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
83 } |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
84 } |
8556
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
85 if (!analyzableNodes) { |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
86 return false; |
8556
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8553
diff
changeset
|
87 } |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
88 } |
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
89 |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
90 boolean continueIteration = true; |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
91 boolean changed = false; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9809
diff
changeset
|
92 for (int iteration = 0; iteration < EscapeAnalysisIterations.getValue() && continueIteration; iteration++) { |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
93 boolean currentChanged = Debug.scope("iteration " + iteration, new Callable<Boolean>() { |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
94 |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
95 @Override |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
96 public Boolean call() { |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
97 |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
98 SchedulePhase schedule = new SchedulePhase(); |
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
99 schedule.apply(graph, false); |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
100 Closure<?> closure = createAnalysisClosure(context, schedule); |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
101 ReentrantBlockIterator.apply(closure, schedule.getCFG().getStartBlock()); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
102 |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
103 if (!closure.hasChanged()) { |
7024
24950e93b962
only perform PEA iteration if there are analyzable nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
7012
diff
changeset
|
104 return false; |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
105 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
107 // apply the effects collected during the escape analysis iteration |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
108 closure.applyEffects(); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
109 |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
110 Debug.dump(graph, "after PartialEscapeAnalysis iteration"); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
111 |
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
112 new DeadCodeEliminationPhase().apply(graph); |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
113 |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9809
diff
changeset
|
114 if (OptCanonicalizer.getValue()) { |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
115 new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), null, customCanonicalizer).apply(graph); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
116 } |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
117 |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
118 return true; |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
119 } |
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
120 }); |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
121 continueIteration = currentChanged && iterative; |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
122 changed |= currentChanged; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 } |
9050
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
124 |
b393a023dd4e
Make PartialEscapeAnalysisPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9049
diff
changeset
|
125 return changed; |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6655
diff
changeset
|
126 } |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6654
diff
changeset
|
127 |
9876
975cc822632a
PEA phase only needs PhaseContext
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
128 protected Closure<?> createAnalysisClosure(PhaseContext context, SchedulePhase schedule) { |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
129 return new PartialEscapeClosure<>(schedule, context.getRuntime(), context.getAssumptions()); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 } |
8553
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
131 |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
132 public static Map<Invoke, Double> getHints(StructuredGraph graph) { |
9238
8f01fe16e473
refactorings and cleanups for the removal of FixedNode.probability
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9234
diff
changeset
|
133 NodesToDoubles probabilities = new ComputeProbabilityClosure(graph).apply(); |
8553
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
134 Map<Invoke, Double> hints = null; |
9501
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
135 for (CommitAllocationNode commit : graph.getNodes(CommitAllocationNode.class)) { |
8553
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
136 double sum = 0; |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
137 double invokeSum = 0; |
9501
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
138 for (Node commitUsage : commit.usages()) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
139 for (Node usage : commitUsage.usages()) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
140 if (usage instanceof FixedNode) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
141 sum += probabilities.get((FixedNode) usage); |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
142 } else { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
143 if (usage instanceof MethodCallTargetNode) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
144 invokeSum += probabilities.get(((MethodCallTargetNode) usage).invoke().asNode()); |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
145 } |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
146 for (Node secondLevelUage : usage.usages()) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
147 if (secondLevelUage instanceof FixedNode) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
148 sum += probabilities.get(((FixedNode) secondLevelUage)); |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
149 } |
8553
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
150 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
151 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
152 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
153 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
154 // TODO(lstadler) get rid of this magic number |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
155 if (sum > 100 && invokeSum > 0) { |
9501
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
156 for (Node commitUsage : commit.usages()) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
157 for (Node usage : commitUsage.usages()) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
158 if (usage instanceof MethodCallTargetNode) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
159 if (hints == null) { |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
160 hints = new HashMap<>(); |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
161 } |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
162 Invoke invoke = ((MethodCallTargetNode) usage).invoke(); |
bef43373de39
coalesce allocations during escape analysis
Lukas Stadler <lukas.stadler@jku.at>
parents:
9434
diff
changeset
|
163 hints.put(invoke, sum / invokeSum); |
8553
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
164 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
165 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
166 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
167 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
168 } |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
169 return hints; |
ed38b01ce7bc
changes to iterative inlining
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
170 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 } |