Mercurial > hg > truffle
annotate graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java @ 9877:fe02e8159afa
PEA: changes to allow BlockState to be extended
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 05 Jun 2013 11:47:46 +0200 |
parents | 063a712fe8d8 |
children | eef9281ec13b |
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 |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
25 import static com.oracle.graal.api.meta.LocationIdentity.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9812
diff
changeset
|
26 import static com.oracle.graal.phases.GraalOptions.*; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 import java.util.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 |
7761
eaecd7c187ad
add Assumptions to VirtualizerTool
Lukas Stadler <lukas.stadler@jku.at>
parents:
7728
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.debug.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.graph.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.PhiNode.PhiType; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.nodes.VirtualState.NodeClosure; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.cfg.*; |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
38 import com.oracle.graal.nodes.extended.*; |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
39 import com.oracle.graal.nodes.java.*; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 import com.oracle.graal.nodes.spi.*; |
8556
c69b29285ff8
better read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8552
diff
changeset
|
41 import com.oracle.graal.nodes.spi.Virtualizable.EscapeState; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 import com.oracle.graal.nodes.virtual.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 import com.oracle.graal.phases.graph.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 import com.oracle.graal.phases.graph.ReentrantBlockIterator.BlockIteratorClosure; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 import com.oracle.graal.phases.graph.ReentrantBlockIterator.LoopInfo; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 import com.oracle.graal.phases.schedule.*; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 import com.oracle.graal.virtual.nodes.*; |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
48 import com.oracle.graal.virtual.phases.ea.BlockState.ReadCacheEntry; |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
49 import com.oracle.graal.virtual.phases.ea.EffectList.Effect; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 |
9877
fe02e8159afa
PEA: changes to allow BlockState to be extended
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
51 public class PartialEscapeClosure<BlockT extends BlockState> extends PartialEscapeAnalysisPhase.Closure<BlockT> { |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
53 public static final DebugMetric METRIC_MATERIALIZATIONS = Debug.metric("Materializations"); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
54 public static final DebugMetric METRIC_MATERIALIZATIONS_PHI = Debug.metric("MaterializationsPhi"); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
55 public static final DebugMetric METRIC_MATERIALIZATIONS_MERGE = Debug.metric("MaterializationsMerge"); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
56 public static final DebugMetric METRIC_MATERIALIZATIONS_UNHANDLED = Debug.metric("MaterializationsUnhandled"); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
57 public static final DebugMetric METRIC_MATERIALIZATIONS_LOOP_REITERATION = Debug.metric("MaterializationsLoopReiteration"); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
58 public static final DebugMetric METRIC_MATERIALIZATIONS_LOOP_END = Debug.metric("MaterializationsLoopEnd"); |
7550
2820060df953
removed space in metric name
Doug Simon <doug.simon@oracle.com>
parents:
7394
diff
changeset
|
59 public static final DebugMetric METRIC_ALLOCATION_REMOVED = Debug.metric("AllocationsRemoved"); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
60 |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
61 public static final DebugMetric METRIC_MEMORYCHECKOINT = Debug.metric("MemoryCheckpoint"); |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
62 |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
63 private final NodeBitMap usages; |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
64 private final SchedulePhase schedule; |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
65 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
66 private final BlockMap<GraphEffectList> blockEffects; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
67 private final IdentityHashMap<Loop, GraphEffectList> loopMergeEffects = new IdentityHashMap<>(); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
68 |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
69 private final VirtualizerToolImpl tool; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
70 |
8552
31b7a648b4b3
turn inlining hints into a map
Lukas Stadler <lukas.stadler@jku.at>
parents:
8551
diff
changeset
|
71 private final Map<Invoke, Double> hints = new IdentityHashMap<>(); |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
72 |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
73 private boolean changed; |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
74 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
75 public PartialEscapeClosure(SchedulePhase schedule, MetaAccessProvider metaAccess, Assumptions assumptions) { |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
76 this.usages = schedule.getCFG().graph.createNodeBitMap(); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
77 this.schedule = schedule; |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
78 this.tool = new VirtualizerToolImpl(usages, metaAccess, assumptions); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
79 this.blockEffects = new BlockMap<>(schedule.getCFG()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
80 for (Block block : schedule.getCFG().getBlocks()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
81 blockEffects.put(block, new GraphEffectList()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
82 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
83 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
85 @SuppressWarnings("unchecked") |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
86 @Override |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
87 protected BlockT getInitialState() { |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
88 return (BlockT) new BlockState(); |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
89 } |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
90 |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
91 @Override |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
92 public boolean hasChanged() { |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
93 return changed; |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
94 } |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
95 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
96 @Override |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
97 public void applyEffects() { |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
98 final StructuredGraph graph = schedule.getCFG().graph; |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
99 final ArrayList<Node> obsoleteNodes = new ArrayList<>(0); |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
100 BlockIteratorClosure<Void> closure = new BlockIteratorClosure<Void>() { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
101 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
102 @Override |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
103 protected Void getInitialState() { |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
104 return null; |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
105 } |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
106 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
107 private void apply(GraphEffectList effects, Object context) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
108 if (!effects.isEmpty()) { |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
109 Debug.log(" ==== effects for %s", context); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
110 for (Effect effect : effects) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
111 effect.apply(graph, obsoleteNodes); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
112 if (effect.isVisible()) { |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
113 Debug.log(" %s", effect); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
114 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
115 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
116 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
117 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
118 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
119 @Override |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
120 protected Void processBlock(Block block, Void currentState) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
121 apply(blockEffects.get(block), block); |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
122 return currentState; |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
123 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
124 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
125 @Override |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
126 protected Void merge(Block merge, List<Void> states) { |
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
127 return null; |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
128 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
129 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
130 @Override |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
131 protected Void cloneState(Void oldState) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
132 return oldState; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
133 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
134 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
135 @Override |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
136 protected List<Void> processLoop(Loop loop, Void initialState) { |
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
137 LoopInfo<Void> info = ReentrantBlockIterator.processLoop(this, loop, initialState); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
138 apply(loopMergeEffects.get(loop), loop); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
139 return info.exitStates; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
140 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
141 }; |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
142 ReentrantBlockIterator.apply(closure, schedule.getCFG().getStartBlock()); |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
143 assert VirtualUtil.assertNonReachable(graph, obsoleteNodes); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
144 } |
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
145 |
8552
31b7a648b4b3
turn inlining hints into a map
Lukas Stadler <lukas.stadler@jku.at>
parents:
8551
diff
changeset
|
146 public Map<Invoke, Double> getHints() { |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
147 return hints; |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
148 } |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
149 |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 @Override |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
151 protected BlockT processBlock(Block block, BlockT state) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
152 GraphEffectList effects = blockEffects.get(block); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
153 tool.setEffects(effects); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
154 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
155 VirtualUtil.trace("\nBlock: %s (", block); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 List<ScheduledNode> nodeList = schedule.getBlockToNodesMap().get(block); |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
157 |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 FixedWithNextNode lastFixedNode = null; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 for (Node node : nodeList) { |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
160 boolean deleted; |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
161 boolean isMarked = usages.isMarked(node); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
162 if (isMarked || node instanceof VirtualizableRoot) { |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
163 VirtualUtil.trace("[[%s]] ", node); |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
164 FixedNode nextFixedNode = lastFixedNode == null ? null : lastFixedNode.next(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
165 deleted = processNode((ValueNode) node, nextFixedNode, state, effects, isMarked); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 } else { |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
167 VirtualUtil.trace("%s ", node); |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
168 deleted = false; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 } |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9812
diff
changeset
|
170 if (OptEarlyReadElimination.getValue()) { |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
171 if (!deleted && node instanceof MemoryCheckpoint) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
172 METRIC_MEMORYCHECKOINT.increment(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
173 MemoryCheckpoint checkpoint = (MemoryCheckpoint) node; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
174 for (LocationIdentity identity : checkpoint.getLocationIdentities()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
175 if (identity instanceof ResolvedJavaField) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
176 state.killReadCache((ResolvedJavaField) identity); |
9793
b4f12c603be5
added support for the runtime to specify for each foreign call whether it is re-executable and what memory locations it kills
Doug Simon <doug.simon@oracle.com>
parents:
9792
diff
changeset
|
177 } else if (identity == ANY_LOCATION) { |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
178 state.killReadCache(); |
8552
31b7a648b4b3
turn inlining hints into a map
Lukas Stadler <lukas.stadler@jku.at>
parents:
8551
diff
changeset
|
179 } |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
180 } |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
181 } |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
182 } |
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
183 if (node instanceof FixedWithNextNode) { |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
184 lastFixedNode = (FixedWithNextNode) node; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
185 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
186 } |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
187 VirtualUtil.trace(")\n end state: %s\n", state); |
9624
87eafaddf9d9
let ReentrantBlockIterator.processBlock return the next state
Lukas Stadler <lukas.stadler@jku.at>
parents:
9526
diff
changeset
|
188 return state; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
190 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
191 private boolean processNode(final ValueNode node, FixedNode insertBefore, final BlockT state, final GraphEffectList effects, boolean isMarked) { |
9634
f3dfca9fd0b3
PEA: replace customAction with addNode (GRAAL-260)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9624
diff
changeset
|
192 tool.reset(state, node, insertBefore); |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
193 if (node instanceof Virtualizable) { |
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
194 ((Virtualizable) node).virtualize(tool); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
195 } |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
196 if (tool.isDeleted()) { |
9686
69ac49574222
PEA: virtualizing CommitAllocationNode and AllocatedObjectNode is not useful progress
Lukas Stadler <lukas.stadler@jku.at>
parents:
9635
diff
changeset
|
197 if (!(node instanceof CommitAllocationNode || node instanceof AllocatedObjectNode)) { |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
198 changed = true; |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
199 } |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
200 return true; |
6710
6db6881c1270
add Virtualizable and VirtualizerTool, refactor PEA to use it
Lukas Stadler <lukas.stadler@jku.at>
parents:
6666
diff
changeset
|
201 } |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
202 if (isMarked) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
203 if (node instanceof StateSplit) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
204 StateSplit split = (StateSplit) node; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
205 FrameState stateAfter = split.stateAfter(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
206 if (stateAfter != null) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
207 if (stateAfter.usages().count() > 1) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
208 stateAfter = (FrameState) stateAfter.copyWithInputs(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
209 split.setStateAfter(stateAfter); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
210 } |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
211 final HashSet<ObjectState> virtual = new HashSet<>(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
212 stateAfter.applyToNonVirtual(new NodeClosure<ValueNode>() { |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
214 @Override |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
215 public void apply(Node usage, ValueNode value) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
216 ObjectState valueObj = state.getObjectState(value); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
217 if (valueObj != null) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
218 virtual.add(valueObj); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
219 effects.replaceFirstInput(usage, value, valueObj.virtual); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
220 } else if (value instanceof VirtualObjectNode) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
221 ObjectState virtualObj = null; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
222 for (ObjectState obj : state.getStates()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
223 if (value == obj.virtual) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
224 virtualObj = obj; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
225 break; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
226 } |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
227 } |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
228 if (virtualObj != null) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
229 virtual.add(virtualObj); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
230 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
231 } |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
232 } |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
233 }); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
234 for (ObjectState obj : state.getStates()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
235 if (obj.isVirtual() && obj.hasLocks()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
236 virtual.add(obj); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
237 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
238 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
239 |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
240 ArrayDeque<ObjectState> queue = new ArrayDeque<>(virtual); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
241 while (!queue.isEmpty()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
242 ObjectState obj = queue.removeLast(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
243 if (obj.isVirtual()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
244 for (ValueNode field : obj.getEntries()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
245 ObjectState fieldObj = state.getObjectState(field); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
246 if (fieldObj != null) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
247 if (fieldObj.isVirtual() && !virtual.contains(fieldObj)) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
248 virtual.add(fieldObj); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
249 queue.addLast(fieldObj); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
250 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
251 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
252 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
253 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
254 } |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
255 for (ObjectState obj : virtual) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
256 EscapeObjectState v; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
257 if (obj.isVirtual()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
258 ValueNode[] fieldState = obj.getEntries().clone(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
259 for (int i = 0; i < fieldState.length; i++) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
260 ObjectState valueObj = state.getObjectState(fieldState[i]); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
261 if (valueObj != null) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
262 if (valueObj.isVirtual()) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
263 fieldState[i] = valueObj.virtual; |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
264 } else { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
265 fieldState[i] = valueObj.getMaterializedValue(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
266 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
267 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
268 } |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
269 v = new VirtualObjectState(obj.virtual, fieldState); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
270 } else { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
271 v = new MaterializedObjectState(obj.virtual, obj.getMaterializedValue()); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
272 } |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
273 effects.addVirtualMapping(stateAfter, v); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
274 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
275 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
276 } |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
277 for (ValueNode input : node.inputs().filter(ValueNode.class)) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
278 ObjectState obj = state.getObjectState(input); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
279 if (obj != null) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
280 if (obj.isVirtual() && node instanceof MethodCallTargetNode) { |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
281 Invoke invoke = ((MethodCallTargetNode) node).invoke(); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
282 hints.put(invoke, 5d); |
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
283 } |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
284 VirtualUtil.trace("replacing input %s at %s: %s", input, node, obj); |
9755
432b8405e056
small refactoring of early read elimination (move logic into "virtualize" methods)
Lukas Stadler <lukas.stadler@jku.at>
parents:
9686
diff
changeset
|
285 replaceWithMaterialized(input, node, insertBefore, state, obj, effects, METRIC_MATERIALIZATIONS_UNHANDLED); |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
286 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
287 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
288 } |
8548
51d5999900e2
simple iterative inlining, simple read elimination in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
8544
diff
changeset
|
289 return false; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
290 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
291 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
292 private static void ensureMaterialized(BlockState state, ObjectState obj, FixedNode materializeBefore, GraphEffectList effects, DebugMetric metric) { |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
293 assert obj != null; |
7394
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
294 if (obj.getState() == EscapeState.Virtual) { |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
295 metric.increment(); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
296 state.materializeBefore(materializeBefore, obj.virtual, EscapeState.Global, effects); |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
297 } else { |
94f032472c28
changed PEA interface:
Lukas Stadler <lukas.stadler@jku.at>
parents:
7123
diff
changeset
|
298 assert obj.getState() == EscapeState.Global; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
299 } |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
300 assert !obj.isVirtual(); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
301 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
302 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
303 private static void replaceWithMaterialized(ValueNode value, Node usage, FixedNode materializeBefore, BlockState state, ObjectState obj, GraphEffectList effects, DebugMetric metric) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
304 ensureMaterialized(state, obj, materializeBefore, effects, metric); |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
305 effects.replaceFirstInput(usage, value, obj.getMaterializedValue()); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
306 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
307 |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
308 @Override |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
309 protected BlockT merge(Block merge, List<BlockT> states) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
310 assert blockEffects.get(merge).isEmpty(); |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
311 MergeProcessor<BlockT> processor = new MergeProcessor<>(merge, usages, blockEffects); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
312 processor.merge(states); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
313 blockEffects.get(merge).addAll(processor.mergeEffects); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
314 blockEffects.get(merge).addAll(processor.afterMergeEffects); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
315 return processor.newState; |
6666
49cd16dfb10c
fix lock-related assertion in PEA
Lukas Stadler <lukas.stadler@jku.at>
parents:
6665
diff
changeset
|
316 |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
317 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
318 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
319 @SuppressWarnings("unchecked") |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
320 @Override |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
321 protected BlockT cloneState(BlockState oldState) { |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
322 return (BlockT) oldState.cloneState(); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
323 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
324 |
9812
8a3242d49786
move @SuppressWarnings from local var to method
Lukas Stadler <lukas.stadler@jku.at>
parents:
9811
diff
changeset
|
325 @SuppressWarnings("unchecked") |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
326 @Override |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
327 protected List<BlockT> processLoop(Loop loop, BlockT initialState) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
328 BlockState loopEntryState = initialState; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
329 BlockState lastMergedState = initialState; |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
330 MergeProcessor<BlockT> mergeProcessor = new MergeProcessor<>(loop.header, usages, blockEffects); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
331 for (int iteration = 0; iteration < 10; iteration++) { |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
332 LoopInfo<BlockT> info = ReentrantBlockIterator.processLoop(this, loop, (BlockT) lastMergedState.cloneState()); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
333 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
334 List<BlockT> states = new ArrayList<>(); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
335 states.add(initialState); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
336 states.addAll(info.endStates); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
337 mergeProcessor.merge(states); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
338 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
339 Debug.log("================== %s", loop.header); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
340 Debug.log("%s", mergeProcessor.newState); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
341 Debug.log("===== vs."); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
342 Debug.log("%s", lastMergedState); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
343 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
344 if (mergeProcessor.newState.equivalentTo(lastMergedState)) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
345 blockEffects.get(loop.header).insertAll(mergeProcessor.mergeEffects, 0); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
346 loopMergeEffects.put(loop, mergeProcessor.afterMergeEffects); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
347 |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
348 assert info.exitStates.size() == loop.exits.size(); |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
349 for (int i = 0; i < loop.exits.size(); i++) { |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
350 BlockState exitState = info.exitStates.get(i); |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
351 assert exitState != null : "no loop exit state at " + loop.exits.get(i) + " / " + loop.header; |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
352 processLoopExit((LoopExitNode) loop.exits.get(i).getBeginNode(), loopEntryState, exitState, blockEffects.get(loop.exits.get(i))); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
353 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
354 |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
355 return info.exitStates; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
356 } else { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
357 lastMergedState = mergeProcessor.newState; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
358 for (Block block : loop.blocks) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
359 blockEffects.get(block).clear(); |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
360 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
361 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
362 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
363 throw new GraalInternalError("too many iterations at %s", loop); |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
364 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
365 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
366 private static void processLoopExit(LoopExitNode exitNode, BlockState initialState, BlockState exitState, GraphEffectList effects) { |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7761
diff
changeset
|
367 HashMap<VirtualObjectNode, ProxyNode> proxies = new HashMap<>(); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
368 |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7761
diff
changeset
|
369 for (ProxyNode proxy : exitNode.proxies()) { |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
370 ObjectState obj = exitState.getObjectState(proxy.value()); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
371 if (obj != null) { |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
372 proxies.put(obj.virtual, proxy); |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
373 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
374 } |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
375 for (ObjectState obj : exitState.getStates()) { |
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
376 ObjectState initialObj = initialState.getObjectStateOptional(obj.virtual); |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
377 if (obj.isVirtual()) { |
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
378 for (int i = 0; i < obj.getEntries().length; i++) { |
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
379 ValueNode value = obj.getEntry(i); |
6657
768793150bcd
more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents:
6656
diff
changeset
|
380 ObjectState valueObj = exitState.getObjectState(value); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
381 if (valueObj == null) { |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
382 if (exitNode.loopBegin().isPhiAtMerge(value) || initialObj == null || !initialObj.isVirtual() || initialObj.getEntry(i) != value) { |
8551
0f6dd67470d9
location identity on PhiNodes and ProxyNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
383 ProxyNode proxy = new ProxyNode(value, exitNode, PhiType.Value, null); |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
384 obj.setEntry(i, proxy); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
385 effects.addFloatingNode(proxy, "virtualProxy"); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
386 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
387 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
388 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
389 } else { |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
390 if (initialObj == null || initialObj.isVirtual()) { |
7897
a58851061377
rename ValueProxyNode to ProxyNode
Lukas Stadler <lukas.stadler@jku.at>
parents:
7761
diff
changeset
|
391 ProxyNode proxy = proxies.get(obj.virtual); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
392 if (proxy == null) { |
8551
0f6dd67470d9
location identity on PhiNodes and ProxyNodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8548
diff
changeset
|
393 proxy = new ProxyNode(obj.getMaterializedValue(), exitNode, PhiType.Value, null); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
394 effects.addFloatingNode(proxy, "proxy"); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
395 } else { |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
396 effects.replaceFirstInput(proxy, proxy.value(), obj.getMaterializedValue()); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
397 // nothing to do - will be handled in processNode |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
398 } |
6655
b01f9c391e17
first part of PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
6650
diff
changeset
|
399 obj.updateMaterializedValue(proxy); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
400 } else { |
8981
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
401 if (initialObj.getMaterializedValue() == obj.getMaterializedValue()) { |
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
402 Debug.log("materialized value changes within loop: %s vs. %s at %s", initialObj.getMaterializedValue(), obj.getMaterializedValue(), exitNode); |
09cdf7224794
PEA: cleanup and documentation for recent changes
Lukas Stadler <lukas.stadler@jku.at>
parents:
8924
diff
changeset
|
403 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
404 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
405 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
406 } |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
407 |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
408 for (Map.Entry<ReadCacheEntry, ValueNode> entry : exitState.getReadCache().entrySet()) { |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
409 if (initialState.getReadCache().get(entry.getKey()) != entry.getValue()) { |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
410 ProxyNode proxy = new ProxyNode(exitState.getReadCache(entry.getKey().object, entry.getKey().identity), exitNode, PhiType.Value, null); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
411 effects.addFloatingNode(proxy, "readCacheProxy"); |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
412 entry.setValue(proxy); |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
413 } |
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
414 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
415 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
416 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
417 private static class MergeProcessor<BlockT extends BlockState> { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
418 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
419 private final Block mergeBlock; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
420 private final MergeNode merge; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
421 private final NodeBitMap usages; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
422 private final BlockMap<GraphEffectList> blockEffects; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
423 private final GraphEffectList mergeEffects; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
424 private final GraphEffectList afterMergeEffects; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
425 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
426 private final HashMap<Object, PhiNode> materializedPhis = new HashMap<>(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
427 private final IdentityHashMap<VirtualObjectNode, PhiNode[]> valuePhis = new IdentityHashMap<>(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
428 private final IdentityHashMap<PhiNode, PhiNode[]> valueObjectMergePhis = new IdentityHashMap<>(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
429 private final IdentityHashMap<PhiNode, VirtualObjectNode> valueObjectVirtuals = new IdentityHashMap<>(); |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
430 private BlockT newState; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
431 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
432 public MergeProcessor(Block mergeBlock, NodeBitMap usages, BlockMap<GraphEffectList> blockEffects) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
433 this.usages = usages; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
434 this.mergeBlock = mergeBlock; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
435 this.blockEffects = blockEffects; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
436 this.merge = (MergeNode) mergeBlock.getBeginNode(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
437 this.mergeEffects = new GraphEffectList(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
438 this.afterMergeEffects = new GraphEffectList(); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
439 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
440 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
441 private <T> PhiNode getCachedPhi(T virtual, Kind kind) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
442 PhiNode result = materializedPhis.get(virtual); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
443 if (result == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
444 result = new PhiNode(kind, merge); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
445 materializedPhis.put(virtual, result); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
446 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
447 return result; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
448 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
449 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
450 private PhiNode[] getValuePhis(VirtualObjectNode virtual) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
451 PhiNode[] result = valuePhis.get(virtual); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
452 if (result == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
453 result = new PhiNode[virtual.entryCount()]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
454 valuePhis.put(virtual, result); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
455 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
456 return result; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
457 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
458 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
459 private PhiNode[] getValueObjectMergePhis(PhiNode phi, int entryCount) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
460 PhiNode[] result = valueObjectMergePhis.get(phi); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
461 if (result == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
462 result = new PhiNode[entryCount]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
463 valueObjectMergePhis.put(phi, result); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
464 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
465 return result; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
466 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
467 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
468 private VirtualObjectNode getValueObjectVirtual(PhiNode phi, VirtualObjectNode virtual) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
469 VirtualObjectNode result = valueObjectVirtuals.get(phi); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
470 if (result == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
471 result = virtual.duplicate(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
472 valueObjectVirtuals.put(phi, result); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
473 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
474 return result; |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
475 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
476 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
477 @SuppressWarnings("unchecked") |
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
478 private void merge(List<BlockT> states) { |
9877
fe02e8159afa
PEA: changes to allow BlockState to be extended
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
479 newState = (BlockT) states.get(0).cloneEmptyState(); |
fe02e8159afa
PEA: changes to allow BlockState to be extended
Lukas Stadler <lukas.stadler@jku.at>
parents:
9864
diff
changeset
|
480 newState.meetAliases(states); |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
481 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
482 /* |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
483 * Iterative processing: Merging the materialized/virtual state of virtual objects can |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
484 * lead to new materializations, which can lead to new materializations because of phis, |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
485 * and so on. |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
486 */ |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
487 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
488 HashSet<VirtualObjectNode> virtualObjects = new HashSet<>(newState.getVirtualObjects()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
489 boolean materialized; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
490 do { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
491 mergeEffects.clear(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
492 afterMergeEffects.clear(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
493 materialized = false; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
494 for (VirtualObjectNode object : virtualObjects) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
495 ObjectState[] objStates = new ObjectState[states.size()]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
496 for (int i = 0; i < states.size(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
497 objStates[i] = states.get(i).getObjectState(object); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
498 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
499 int virtual = 0; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
500 ObjectState startObj = objStates[0]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
501 boolean locksMatch = true; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
502 ValueNode singleValue = startObj.isVirtual() ? null : startObj.getMaterializedValue(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
503 for (ObjectState obj : objStates) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
504 if (obj.isVirtual()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
505 virtual++; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
506 singleValue = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
507 } else { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
508 if (obj.getMaterializedValue() != singleValue) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
509 singleValue = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
510 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
511 } |
9504
106f0a0acafa
refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents:
9033
diff
changeset
|
512 locksMatch &= obj.locksEqual(startObj); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
513 } |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
514 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
515 assert virtual < states.size() || locksMatch : "mismatching lock counts at " + merge; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
516 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
517 if (virtual < states.size()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
518 if (singleValue == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
519 PhiNode materializedValuePhi = getCachedPhi(object, Kind.Object); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
520 mergeEffects.addFloatingNode(materializedValuePhi, "materializedPhi"); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
521 for (int i = 0; i < states.size(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
522 BlockState state = states.get(i); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
523 ObjectState obj = objStates[i]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
524 materialized |= obj.isVirtual(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
525 Block predecessor = mergeBlock.getPredecessors().get(i); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
526 ensureMaterialized(state, obj, predecessor.getEndNode(), blockEffects.get(predecessor), METRIC_MATERIALIZATIONS_MERGE); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
527 afterMergeEffects.addPhiInput(materializedValuePhi, obj.getMaterializedValue()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
528 } |
9504
106f0a0acafa
refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents:
9033
diff
changeset
|
529 newState.addObject(object, new ObjectState(object, materializedValuePhi, EscapeState.Global, null)); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
530 } else { |
9504
106f0a0acafa
refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents:
9033
diff
changeset
|
531 newState.addObject(object, new ObjectState(object, singleValue, EscapeState.Global, null)); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
532 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
533 } else { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
534 assert virtual == states.size(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
535 ValueNode[] values = startObj.getEntries().clone(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
536 PhiNode[] phis = getValuePhis(object); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
537 for (int index = 0; index < values.length; index++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
538 for (int i = 1; i < states.size(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
539 ValueNode[] fields = objStates[i].getEntries(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
540 if (phis[index] == null && values[index] != fields[index]) { |
9804
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
541 Kind kind = values[index].kind(); |
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
542 if (kind == Kind.Illegal) { |
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
543 // Can happen if one of the values is virtual and is only |
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
544 // materialized in the following loop. |
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
545 kind = Kind.Object; |
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
546 } |
79d65c694a3b
Make escape analysis and phi nodes more robust with additional assertions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9793
diff
changeset
|
547 phis[index] = new PhiNode(kind, merge); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
548 } |
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
549 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
550 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
551 outer: for (int index = 0; index < values.length; index++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
552 if (phis[index] != null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
553 mergeEffects.addFloatingNode(phis[index], "virtualMergePhi"); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
554 for (int i = 0; i < states.size(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
555 if (!objStates[i].isVirtual()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
556 break outer; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
557 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
558 ValueNode[] fields = objStates[i].getEntries(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
559 ObjectState obj = states.get(i).getObjectState(fields[index]); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
560 if (obj != null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
561 materialized |= obj.isVirtual(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
562 Block predecessor = mergeBlock.getPredecessors().get(i); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
563 ensureMaterialized(states.get(i), obj, predecessor.getEndNode(), blockEffects.get(predecessor), METRIC_MATERIALIZATIONS_MERGE); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
564 fields[index] = obj.getMaterializedValue(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
565 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
566 afterMergeEffects.addPhiInput(phis[index], fields[index]); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
567 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
568 values[index] = phis[index]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
569 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
570 } |
9504
106f0a0acafa
refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents:
9033
diff
changeset
|
571 newState.addObject(object, new ObjectState(object, values, EscapeState.Virtual, startObj.getLocks())); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
572 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
573 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
574 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
575 for (PhiNode phi : merge.phis()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
576 if (usages.isMarked(phi) && phi.type() == PhiType.Value) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
577 materialized |= processPhi(phi, states); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
578 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
579 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
580 } while (materialized); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
581 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
582 mergeReadCache(states); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
583 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
584 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
585 private boolean processPhi(PhiNode phi, List<BlockT> states) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
586 assert states.size() == phi.valueCount(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
587 int virtualInputs = 0; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
588 boolean materialized = false; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
589 VirtualObjectNode sameObject = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
590 ResolvedJavaType sameType = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
591 int sameEntryCount = -1; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
592 boolean hasIdentity = false; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
593 for (int i = 0; i < phi.valueCount(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
594 ValueNode value = phi.valueAt(i); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
595 ObjectState obj = states.get(i).getObjectState(value); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
596 if (obj != null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
597 if (obj.isVirtual()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
598 virtualInputs++; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
599 if (i == 0) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
600 sameObject = obj.virtual; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
601 sameType = obj.virtual.type(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
602 sameEntryCount = obj.virtual.entryCount(); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
603 } else { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
604 if (sameObject != obj.virtual) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
605 sameObject = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
606 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
607 if (sameType != obj.virtual.type()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
608 sameType = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
609 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
610 if (sameEntryCount != obj.virtual.entryCount()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
611 sameEntryCount = -1; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
612 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
613 hasIdentity |= obj.virtual.hasIdentity(); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
614 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
615 } else { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
616 afterMergeEffects.setPhiInput(phi, i, obj.getMaterializedValue()); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
617 } |
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
618 } |
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
619 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
620 boolean materialize = false; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
621 if (virtualInputs == 0) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
622 // nothing to do... |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
623 } else if (virtualInputs == phi.valueCount()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
624 if (sameObject != null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
625 newState.addAndMarkAlias(sameObject, phi, usages); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
626 } else if (sameType != null && sameEntryCount != -1) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
627 if (!hasIdentity) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
628 VirtualObjectNode virtual = getValueObjectVirtual(phi, states.get(0).getObjectState(phi.valueAt(0)).virtual); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
629 |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
630 PhiNode[] phis = getValueObjectMergePhis(phi, virtual.entryCount()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
631 for (int i = 0; i < virtual.entryCount(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
632 assert virtual.entryKind(i) != Kind.Object; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
633 if (phis[i] == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
634 phis[i] = new PhiNode(virtual.entryKind(i), merge); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
635 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
636 mergeEffects.addFloatingNode(phis[i], "valueObjectPhi"); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
637 for (int i2 = 0; i2 < phi.valueCount(); i2++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
638 afterMergeEffects.addPhiInput(phis[i], states.get(i2).getObjectState(phi.valueAt(i2)).getEntry(i)); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
639 } |
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
640 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
641 mergeEffects.addFloatingNode(virtual, "valueObjectNode"); |
9504
106f0a0acafa
refactored monitor handling in EA: MonitorEnter/Exit is removed, not eliminated
Lukas Stadler <lukas.stadler@jku.at>
parents:
9033
diff
changeset
|
642 newState.addObject(virtual, new ObjectState(virtual, Arrays.copyOf(phis, phis.length, ValueNode[].class), EscapeState.Virtual, null)); |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
643 newState.addAndMarkAlias(virtual, virtual, usages); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
644 newState.addAndMarkAlias(virtual, phi, usages); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
645 } else { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
646 materialize = true; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
647 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
648 } else { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
649 materialize = true; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
650 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
651 } else { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
652 materialize = true; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
653 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
654 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
655 if (materialize) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
656 for (int i = 0; i < phi.valueCount(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
657 ValueNode value = phi.valueAt(i); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
658 ObjectState obj = states.get(i).getObjectState(value); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
659 if (obj != null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
660 materialized |= obj.isVirtual(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
661 Block predecessor = mergeBlock.getPredecessors().get(i); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
662 replaceWithMaterialized(value, phi, predecessor.getEndNode(), states.get(i), obj, blockEffects.get(predecessor), METRIC_MATERIALIZATIONS_PHI); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
663 } |
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
664 } |
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
665 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
666 return materialized; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
667 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
668 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
669 private void mergeReadCache(List<BlockT> states) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
670 for (Map.Entry<ReadCacheEntry, ValueNode> entry : states.get(0).readCache.entrySet()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
671 ReadCacheEntry key = entry.getKey(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
672 ValueNode value = entry.getValue(); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
673 boolean phi = false; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
674 for (int i = 1; i < states.size(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
675 ValueNode otherValue = states.get(i).readCache.get(key); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
676 if (otherValue == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
677 value = null; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
678 phi = false; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
679 break; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
680 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
681 if (!phi && otherValue != value) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
682 phi = true; |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
683 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
684 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
685 if (phi) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
686 PhiNode phiNode = getCachedPhi(entry, value.kind()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
687 mergeEffects.addFloatingNode(phiNode, "mergeReadCache"); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
688 for (int i = 0; i < states.size(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
689 afterMergeEffects.addPhiInput(phiNode, states.get(i).getReadCache(key.object, key.identity)); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
690 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
691 newState.readCache.put(key, phiNode); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
692 } else if (value != null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
693 newState.readCache.put(key, value); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
694 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
695 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
696 for (PhiNode phi : merge.phis()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
697 if (phi.kind() == Kind.Object) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
698 for (Map.Entry<ReadCacheEntry, ValueNode> entry : states.get(0).readCache.entrySet()) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
699 if (entry.getKey().object == phi.valueAt(0)) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
700 mergeReadCachePhi(phi, entry.getKey().identity, states); |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
701 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
702 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
703 |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
704 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
705 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
706 } |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
707 |
9809
a8a5d5832def
first step towards extensibility of the escape analysis phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
9755
diff
changeset
|
708 private void mergeReadCachePhi(PhiNode phi, ResolvedJavaField identity, List<BlockT> states) { |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
709 ValueNode[] values = new ValueNode[phi.valueCount()]; |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
710 for (int i = 0; i < phi.valueCount(); i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
711 ValueNode value = states.get(i).getReadCache(phi.valueAt(i), identity); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
712 if (value == null) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
713 return; |
8911
5cf8471a4034
small PEA refactoring
Lukas Stadler <lukas.stadler@jku.at>
parents:
8620
diff
changeset
|
714 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
715 values[i] = value; |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
716 } |
8924
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
717 |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
718 PhiNode phiNode = getCachedPhi(new ReadCacheEntry(identity, phi), values[0].kind()); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
719 mergeEffects.addFloatingNode(phiNode, "mergeReadCachePhi"); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
720 for (int i = 0; i < values.length; i++) { |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
721 afterMergeEffects.addPhiInput(phiNode, values[i]); |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
722 } |
fc972f34c1d5
PEA: unify merge and loop logic, implement handling of identity-less virtual objects
Lukas Stadler <lukas.stadler@jku.at>
parents:
8911
diff
changeset
|
723 newState.readCache.put(new ReadCacheEntry(identity, phi), phiNode); |
8559
af0c1352f969
more work on read elimination
Lukas Stadler <lukas.stadler@jku.at>
parents:
8556
diff
changeset
|
724 } |
6650
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
725 } |
ea38da80dd29
refactor PEA into separate classes
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
726 } |