Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java @ 10503:2393c37d1997
Merge
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Fri, 21 Jun 2013 23:12:51 +0200 |
parents | 491cd7d69539 |
children | 968215f13aad |
rev | line source |
---|---|
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.compiler.test; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
25 import static org.junit.Assert.*; |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
26 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import java.util.concurrent.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import org.junit.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.api.code.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.debug.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.graph.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.extended.*; |
9906
fc93d919f896
PhaseContext: add an instance of CanonicalizerPhase to context
Bernhard Urban <bernhard.urban@jku.at>
parents:
9602
diff
changeset
|
36 import com.oracle.graal.nodes.spi.Lowerable.LoweringType; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.nodes.util.*; |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
38 import com.oracle.graal.phases.*; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 import com.oracle.graal.phases.common.*; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 import com.oracle.graal.phases.schedule.*; |
9267
950a385e059b
Make LoweringPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9266
diff
changeset
|
41 import com.oracle.graal.phases.tiers.*; |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 /** |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 * In these test the FrameStates are explicitly cleared out, so that the scheduling of |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 * FloatingReadNodes depends solely on the scheduling algorithm. The FrameStates normally keep the |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 * FloatingReadNodes above a certain point, so that they (most of the time...) magically do the |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 * right thing. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 * |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 * The scheduling shouldn't depend on FrameStates, which is tested by this class. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
51 public class MemoryScheduleTest extends GraphScheduleTest { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
53 private static enum TestMode { |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
54 WITH_FRAMESTATES, WITHOUT_FRAMESTATES, INLINED_WITHOUT_FRAMESTATES |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
56 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
57 public static class Container { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
58 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
59 public int a; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
60 public int b; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
61 public int c; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
62 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
63 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
64 private static final Container container = new Container(); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
66 /** |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
67 * In this test the read should be scheduled before the write. |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
68 */ |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
69 public static int testSimpleSnippet() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
70 try { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
71 return container.a; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
72 } finally { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
73 container.a = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
74 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
75 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
76 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
77 @Test |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
78 public void testSimple() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
79 for (TestMode mode : TestMode.values()) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
80 SchedulePhase schedule = getFinalSchedule("testSimpleSnippet", mode); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
81 assertReadAfterWrite(schedule, false); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
83 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 /** |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 * In this case the read should be scheduled in the first block. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
87 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 public static int testSplitSnippet1(int a) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
89 try { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 return container.a; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 } finally { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
92 if (a < 0) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
93 container.a = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
94 } else { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
95 container.b = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
99 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
100 @Test |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
101 public void testSplit1() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 for (TestMode mode : TestMode.values()) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 SchedulePhase schedule = getFinalSchedule("testSplitSnippet1", mode); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 assertReadWithinStartBlock(schedule, true); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 /** |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 * Here the read should float to the end. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
111 public static int testSplit2Snippet(int a) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 try { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
113 return container.a; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 } finally { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
115 if (a < 0) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 container.c = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
117 } else { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 container.b = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 @Test |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 public void testSplit2() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
125 SchedulePhase schedule = getFinalSchedule("testSplit2Snippet", TestMode.WITHOUT_FRAMESTATES); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 assertReadWithinStartBlock(schedule, false); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
127 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
128 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
129 /** |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 * Here the read should not float to the end. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
131 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 public static int testLoop1Snippet(int a, int b) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
133 try { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
134 return container.a; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 } finally { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 for (int i = 0; i < a; i++) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 if (b < 0) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 container.b = 10; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 } else { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 container.a = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
141 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
142 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
146 @Test |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
147 public void testLoop1() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
148 SchedulePhase schedule = getFinalSchedule("testLoop1Snippet", TestMode.WITHOUT_FRAMESTATES); |
9601
278a50fb49c7
Create a LoadFieldNode for a getstatic of a static final field in the graph builder, and rely on the canonicalizer for replacing it with the constant value.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9267
diff
changeset
|
149 assertEquals(6, schedule.getCFG().getBlocks().length); |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 assertReadWithinStartBlock(schedule, true); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
151 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
152 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
153 /** |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
154 * Here the read should float to the end. |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
155 */ |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 public static int testLoop2Snippet(int a, int b) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
157 try { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 return container.a; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 } finally { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
160 for (int i = 0; i < a; i++) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 if (b < 0) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
162 container.b = 10; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
163 } else { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
164 container.c = 15; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
165 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 @Test |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 public void testLoop2() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
172 SchedulePhase schedule = getFinalSchedule("testLoop2Snippet", TestMode.WITHOUT_FRAMESTATES); |
9601
278a50fb49c7
Create a LoadFieldNode for a getstatic of a static final field in the graph builder, and rely on the canonicalizer for replacing it with the constant value.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9267
diff
changeset
|
173 assertEquals(6, schedule.getCFG().getBlocks().length); |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 assertReadWithinStartBlock(schedule, false); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
176 |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
177 /** |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
178 * Here the read should float to the end (into the same block as the return). |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
179 */ |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
180 public static int testArrayCopySnippet(Integer intValue, char[] a, char[] b, int len) { |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
181 System.arraycopy(a, 0, b, 0, len); |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
182 return intValue.intValue(); |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
183 } |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
184 |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
185 @Test |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
186 public void testArrayCopy() { |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
187 SchedulePhase schedule = getFinalSchedule("testArrayCopySnippet", TestMode.INLINED_WITHOUT_FRAMESTATES); |
9602
19c5a07c7843
Introduce a graph() method that returns a StructuredGraph, to make many explicit casts unnecessary
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9601
diff
changeset
|
188 StructuredGraph graph = schedule.getCFG().getStartBlock().getBeginNode().graph(); |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
189 ReturnNode ret = graph.getNodes(ReturnNode.class).first(); |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
190 assertTrue(ret.result() instanceof FloatingReadNode); |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
191 assertEquals(schedule.getCFG().blockFor(ret), schedule.getCFG().blockFor(ret.result())); |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
192 } |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
193 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
194 private void assertReadAfterWrite(SchedulePhase schedule, boolean readAfterWrite) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
195 boolean writeEncountered = false; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
196 assertEquals(1, schedule.getCFG().getBlocks().length); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
197 for (Node node : schedule.getBlockToNodesMap().get(schedule.getCFG().getStartBlock())) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
198 if (node instanceof WriteNode) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
199 writeEncountered = true; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
200 } else if (node instanceof FloatingReadNode) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
201 assertEquals(readAfterWrite, writeEncountered); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
202 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
203 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
204 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
205 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
206 private void assertReadWithinStartBlock(SchedulePhase schedule, boolean withinStartBlock) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
207 boolean readEncountered = false; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
208 for (Node node : schedule.getBlockToNodesMap().get(schedule.getCFG().getStartBlock())) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
209 if (node instanceof FloatingReadNode) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
210 readEncountered = true; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
211 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 assertEquals(withinStartBlock, readEncountered); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
215 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
216 private SchedulePhase getFinalSchedule(final String snippet, final TestMode mode) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
217 return Debug.scope("FloatingReadTest", new DebugDumpScope(snippet), new Callable<SchedulePhase>() { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
218 |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
219 @Override |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
220 public SchedulePhase call() throws Exception { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
221 StructuredGraph graph = parse(snippet); |
9601
278a50fb49c7
Create a LoadFieldNode for a getstatic of a static final field in the graph builder, and rely on the canonicalizer for replacing it with the constant value.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
9267
diff
changeset
|
222 Assumptions assumptions = new Assumptions(false); |
9916
491cd7d69539
CanonicalizerPhase: remove it from context, add it to tiers instead and configure/pass it there (GRAAL-309)
Bernhard Urban <bernhard.urban@jku.at>
parents:
9909
diff
changeset
|
223 HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); |
491cd7d69539
CanonicalizerPhase: remove it from context, add it to tiers instead and configure/pass it there (GRAAL-309)
Bernhard Urban <bernhard.urban@jku.at>
parents:
9909
diff
changeset
|
224 new CanonicalizerPhase(true).apply(graph, context); |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
225 if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) { |
8636
ac4dbfecec8f
passed a Replacements object to inlining utility methods that need one instead of the GraalRuntime API
Doug Simon <doug.simon@oracle.com>
parents:
7896
diff
changeset
|
226 new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
227 } |
9267
950a385e059b
Make LoweringPhase reentrant.
Roland Schatz <roland.schatz@oracle.com>
parents:
9266
diff
changeset
|
228 new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
229 if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) { |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
230 for (Node node : graph.getNodes()) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
231 if (node instanceof StateSplit) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
232 FrameState stateAfter = ((StateSplit) node).stateAfter(); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
233 if (stateAfter != null) { |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
234 ((StateSplit) node).setStateAfter(null); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
235 GraphUtil.killWithUnusedFloatingInputs(stateAfter); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
236 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
237 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
238 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
239 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
240 new FloatingReadPhase().apply(graph); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
241 |
7896
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
242 new RemoveValueProxyPhase().apply(graph); |
649379d3f88d
don't kill memory proxies during RemoveValueProxyPhase
Lukas Stadler <lukas.stadler@jku.at>
parents:
7871
diff
changeset
|
243 |
7871
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
244 SchedulePhase schedule = new SchedulePhase(); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
245 schedule.apply(graph); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
246 return schedule; |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
247 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
248 }); |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
249 } |
886990f21773
memory-aware scheduling phase
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
250 } |