Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: test/mjsunit/elements-transition-hoisting.js

Issue 10878047: Revert to code state of 3.13.1 plus r12350 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/debug-script.js ('k') | test/mjsunit/regress/regress-2296.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --allow-natives-syntax --smi-only-arrays --noparallel-recompilation 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
29 // Flags: --noparallel-recompilation
29 30
30 // Ensure that ElementsKind transitions in various situations are hoisted (or 31 // Ensure that ElementsKind transitions in various situations are hoisted (or
31 // not hoisted) correctly, don't change the semantics programs and don't trigger 32 // not hoisted) correctly, don't change the semantics programs and don't trigger
32 // deopt through hoisting in important situations. 33 // deopt through hoisting in important situations.
33 34
34 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); 35 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6));
35 36
36 if (support_smi_only_arrays) { 37 if (support_smi_only_arrays) {
37 print("Tests include smi-only arrays."); 38 print("Tests include smi-only arrays.");
38 } else { 39 } else {
39 print("Tests do NOT include smi-only arrays."); 40 print("Tests do NOT include smi-only arrays.");
40 } 41 }
41 42
43 // Force existing ICs from previous stress runs to be flushed, otherwise the
44 // assumptions in this test about when deoptimizations get triggered are not
45 // valid.
46 gc();
47
42 if (support_smi_only_arrays) { 48 if (support_smi_only_arrays) {
43 // Make sure that a simple elements array transitions inside a loop before 49 // Make sure that a simple elements array transitions inside a loop before
44 // stores to an array gets hoisted in a way that doesn't generate a deopt in 50 // stores to an array gets hoisted in a way that doesn't generate a deopt in
45 // simple cases.} 51 // simple cases.}
46 function testDoubleConversion4(a) { 52 function testDoubleConversion4(a) {
47 var object = new Object(); 53 var object = new Object();
48 a[0] = 0; 54 a[0] = 0;
49 var count = 3; 55 var count = 3;
50 do { 56 do {
51 a[0] = object; 57 a[0] = object;
52 } while (--count > 0); 58 } while (--count > 0);
53 } 59 }
54 60
55 testDoubleConversion4(new Array(5)); 61 testDoubleConversion4(new Array(5));
56 testDoubleConversion4(new Array(5)); // Call twice to make sure that second 62 testDoubleConversion4(new Array(5)); // Call twice to make sure that second
57 // store is a transition and not 63 // store is a transition and not
58 // optimistically MONOMORPHIC 64 // optimistically MONOMORPHIC
59 %OptimizeFunctionOnNextCall(testDoubleConversion4); 65 %OptimizeFunctionOnNextCall(testDoubleConversion4);
60 testDoubleConversion4(new Array(5)); 66 testDoubleConversion4(new Array(5));
61 testDoubleConversion4(new Array(5)); 67 testDoubleConversion4(new Array(5));
62 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4)); 68 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4));
63 %ClearFunctionTypeFeedback(testDoubleConversion4);
64 69
65 // Make sure that non-element related map checks that are not preceded by 70 // Make sure that non-element related map checks that are not preceded by
66 // transitions in a loop still get hoisted in a way that doesn't generate a 71 // transitions in a loop still get hoisted in a way that doesn't generate a
67 // deopt in simple cases. 72 // deopt in simple cases.
68 function testExactMapHoisting(a) { 73 function testExactMapHoisting(a) {
69 var object = new Object(); 74 var object = new Object();
70 a.foo = 0; 75 a.foo = 0;
71 a[0] = 0; 76 a[0] = 0;
72 a[1] = 1; 77 a[1] = 1;
73 var count = 3; 78 var count = 3;
74 do { 79 do {
75 a.foo = object; // This map check should be hoistable 80 a.foo = object; // This map check should be hoistable
76 a[1] = object; 81 a[1] = object;
77 result = a.foo == object && a[1] == object; 82 result = a.foo == object && a[1] == object;
78 } while (--count > 0); 83 } while (--count > 0);
79 } 84 }
80 85
81 testExactMapHoisting(new Array(5)); 86 testExactMapHoisting(new Array(5));
82 testExactMapHoisting(new Array(5)); // Call twice to make sure that second 87 testExactMapHoisting(new Array(5)); // Call twice to make sure that second
83 // store is a transition and not 88 // store is a transition and not
84 // optimistically MONOMORPHIC 89 // optimistically MONOMORPHIC
85 %OptimizeFunctionOnNextCall(testExactMapHoisting); 90 %OptimizeFunctionOnNextCall(testExactMapHoisting);
86 testExactMapHoisting(new Array(5)); 91 testExactMapHoisting(new Array(5));
87 testExactMapHoisting(new Array(5)); 92 testExactMapHoisting(new Array(5));
88 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting)); 93 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting));
89 %ClearFunctionTypeFeedback(testExactMapHoisting);
90 94
91 // Make sure that non-element related map checks do NOT get hoisted if they 95 // Make sure that non-element related map checks do NOT get hoisted if they
92 // depend on an elements transition before them and it's not possible to hoist 96 // depend on an elements transition before them and it's not possible to hoist
93 // that transition. 97 // that transition.
94 function testExactMapHoisting2(a) { 98 function testExactMapHoisting2(a) {
95 var object = new Object(); 99 var object = new Object();
96 a.foo = 0; 100 a.foo = 0;
97 a[0] = 0; 101 a[0] = 0;
98 a[1] = 1; 102 a[1] = 1;
99 var count = 3; 103 var count = 3;
(...skipping 11 matching lines...) Expand all
111 115
112 testExactMapHoisting2(new Array(5)); 116 testExactMapHoisting2(new Array(5));
113 testExactMapHoisting2(new Array(5)); // Call twice to make sure that second 117 testExactMapHoisting2(new Array(5)); // Call twice to make sure that second
114 // store is a transition and not 118 // store is a transition and not
115 // optimistically MONOMORPHIC 119 // optimistically MONOMORPHIC
116 %OptimizeFunctionOnNextCall(testExactMapHoisting2); 120 %OptimizeFunctionOnNextCall(testExactMapHoisting2);
117 testExactMapHoisting2(new Array(5)); 121 testExactMapHoisting2(new Array(5));
118 testExactMapHoisting2(new Array(5)); 122 testExactMapHoisting2(new Array(5));
119 // Temporarily disabled - see bug 2176. 123 // Temporarily disabled - see bug 2176.
120 // assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2)); 124 // assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2));
121 %ClearFunctionTypeFeedback(testExactMapHoisting2);
122 125
123 // Make sure that non-element related map checks do get hoisted if they use 126 // Make sure that non-element related map checks do get hoisted if they use
124 // the transitioned map for the check and all transitions that they depend 127 // the transitioned map for the check and all transitions that they depend
125 // upon can hoisted, too. 128 // upon can hoisted, too.
126 function testExactMapHoisting3(a) { 129 function testExactMapHoisting3(a) {
127 var object = new Object(); 130 var object = new Object();
128 a.foo = 0; 131 a.foo = 0;
129 a[0] = 0; 132 a[0] = 0;
130 a[1] = 1; 133 a[1] = 1;
131 var count = 3; 134 var count = 3;
132 do { 135 do {
133 a[1] = 2.5; 136 a[1] = 2.5;
134 a.foo = object; // This map check should be hoistable because all element s 137 a.foo = object; // This map check should be hoistable because all element s
135 // transitions in the loop can also be hoisted. 138 // transitions in the loop can also be hoisted.
136 } while (--count > 0); 139 } while (--count > 0);
137 } 140 }
138 141
139 var add_transition = new Array(5); 142 var add_transition = new Array(5);
140 add_transition.foo = 0; 143 add_transition.foo = 0;
141 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be create d 144 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be create d
142 testExactMapHoisting3(new Array(5)); 145 testExactMapHoisting3(new Array(5));
143 testExactMapHoisting3(new Array(5)); // Call twice to make sure that second 146 testExactMapHoisting3(new Array(5)); // Call twice to make sure that second
144 // store is a transition and not 147 // store is a transition and not
145 // optimistically MONOMORPHIC 148 // optimistically MONOMORPHIC
146 %OptimizeFunctionOnNextCall(testExactMapHoisting3); 149 %OptimizeFunctionOnNextCall(testExactMapHoisting3);
147 testExactMapHoisting3(new Array(5)); 150 testExactMapHoisting3(new Array(5));
148 testExactMapHoisting3(new Array(5)); 151 testExactMapHoisting3(new Array(5));
149 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3)); 152 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3));
150 %ClearFunctionTypeFeedback(testExactMapHoisting3);
151 153
152 function testDominatingTransitionHoisting1(a) { 154 function testDominatingTransitionHoisting1(a) {
153 var object = new Object(); 155 var object = new Object();
154 a[0] = 0; 156 a[0] = 0;
155 var count = 3; 157 var count = 3;
156 do { 158 do {
157 if (a.baz != true) { 159 if (a.baz != true) {
158 a[1] = 2.5; 160 a[1] = 2.5;
159 } 161 }
160 a[0] = object; 162 a[0] = object;
161 } while (--count > 3); 163 } while (--count > 3);
162 } 164 }
163 165
164 testDominatingTransitionHoisting1(new Array(5)); 166 testDominatingTransitionHoisting1(new Array(5));
165 testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure 167 testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure
166 // that second store is a 168 // that second store is a
167 // transition and not 169 // transition and not
168 // optimistically MONOMORPHI C 170 // optimistically MONOMORPHI C
169 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); 171 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1);
170 testDominatingTransitionHoisting1(new Array(5)); 172 testDominatingTransitionHoisting1(new Array(5));
171 testDominatingTransitionHoisting1(new Array(5)); 173 testDominatingTransitionHoisting1(new Array(5));
172 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1)); 174 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1));
173 %ClearFunctionTypeFeedback(testDominatingTransitionHoisting1);
174 175
175 function testHoistingWithSideEffect(a) { 176 function testHoistingWithSideEffect(a) {
176 var object = new Object(); 177 var object = new Object();
177 a[0] = 0; 178 a[0] = 0;
178 var count = 3; 179 var count = 3;
179 do { 180 do {
180 assertTrue(true); 181 assertTrue(true);
181 a[0] = object; 182 a[0] = object;
182 } while (--count > 3); 183 } while (--count > 3);
183 } 184 }
184 185
185 testHoistingWithSideEffect(new Array(5)); 186 testHoistingWithSideEffect(new Array(5));
186 testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that 187 testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that
187 // second store is a transition and 188 // second store is a transition and
188 // not optimistically MONOMORPHIC 189 // not optimistically MONOMORPHIC
189 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); 190 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect);
190 testHoistingWithSideEffect(new Array(5)); 191 testHoistingWithSideEffect(new Array(5));
191 testHoistingWithSideEffect(new Array(5)); 192 testHoistingWithSideEffect(new Array(5));
192 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); 193 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect));
193 %ClearFunctionTypeFeedback(testHoistingWithSideEffect);
194 194
195 function testStraightLineDupeElimination(a,b,c,d,e,f) { 195 function testStraightLineDupeElinination(a,b,c,d,e,f) {
196 var count = 3; 196 var count = 3;
197 do { 197 do {
198 assertTrue(true); 198 assertTrue(true);
199 a[0] = b; 199 a[0] = b;
200 a[1] = c; 200 a[1] = c;
201 a[2] = d; 201 a[2] = d;
202 assertTrue(true); 202 assertTrue(true);
203 a[3] = e; // TransitionElementsKind should be eliminated despite call. 203 a[3] = e; // TransitionElementsKind should be eliminated despite call.
204 a[4] = f; 204 a[4] = f;
205 } while (--count > 3); 205 } while (--count > 3);
206 } 206 }
207 207
208 testStraightLineDupeElimination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5); 208 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5);
209 testStraightLineDupeElimination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0); 209 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0);
210 testStraightLineDupeElimination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0); 210 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0);
211 testStraightLineDupeElimination(new Array(0, 0, 0, 0, 0),0,.5,0,0,0); 211 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,.5,0,0,0);
212 testStraightLineDupeElimination(new Array(0, 0, 0, 0, 0),.5,0,0,0,0); 212 testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),.5,0,0,0,0);
213 testStraightLineDupeElimination(new Array(.1,.1,.1,.1,.1),0,0,0,0,.5); 213 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,0,.5);
214 testStraightLineDupeElimination(new Array(.1,.1,.1,.1,.1),0,0,0,.5,0); 214 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,.5,0);
215 testStraightLineDupeElimination(new Array(.1,.1,.1,.1,.1),0,0,.5,0,0); 215 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,.5,0,0);
216 testStraightLineDupeElimination(new Array(.1,.1,.1,.1,.1),0,.5,0,0,0); 216 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,.5,0,0,0);
217 testStraightLineDupeElimination(new Array(.1,.1,.1,.1,.1),.5,0,0,0,0); 217 testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),.5,0,0,0,0);
218 testStraightLineDupeElimination(new Array(5),.5,0,0,0,0); 218 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0);
219 testStraightLineDupeElimination(new Array(5),0,.5,0,0,0); 219 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0);
220 testStraightLineDupeElimination(new Array(5),0,0,.5,0,0); 220 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0);
221 testStraightLineDupeElimination(new Array(5),0,0,0,.5,0); 221 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0);
222 testStraightLineDupeElimination(new Array(5),0,0,0,0,.5); 222 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5);
223 testStraightLineDupeElimination(new Array(5),.5,0,0,0,0); 223 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0);
224 testStraightLineDupeElimination(new Array(5),0,.5,0,0,0); 224 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0);
225 testStraightLineDupeElimination(new Array(5),0,0,.5,0,0); 225 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0);
226 testStraightLineDupeElimination(new Array(5),0,0,0,.5,0); 226 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0);
227 testStraightLineDupeElimination(new Array(5),0,0,0,0,.5); 227 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5);
228 %OptimizeFunctionOnNextCall(testStraightLineDupeElimination); 228 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination);
229 testStraightLineDupeElimination(new Array(5)); 229 testStraightLineDupeElinination(new Array(5));
230 testStraightLineDupeElimination(new Array(5)); 230 testStraightLineDupeElinination(new Array(5));
231 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElimination)); 231 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination));
232 %ClearFunctionTypeFeedback(testStraightLineDupeElimination);
233 } 232 }
OLDNEW
« no previous file with comments | « test/mjsunit/debug-script.js ('k') | test/mjsunit/regress/regress-2296.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698