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

Side by Side Diff: test/mjsunit/array-literal-transitions.js

Issue 397253002: Remove experimental flags that are now required (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 6 years, 5 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/array-literal-feedback.js ('k') | test/mjsunit/array-natives-elements.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 --expose-gc 28 // Flags: --allow-natives-syntax --expose-gc
29
30 // Test element kind of objects.
31 // Since --smi-only-arrays affects builtins, its default setting at compile
32 // time sticks if built with snapshot. If --smi-only-arrays is deactivated
33 // by default, only a no-snapshot build actually has smi-only arrays enabled
34 // in this test case. Depending on whether smi-only arrays are actually
35 // enabled, this test takes the appropriate code path to check smi-only arrays.
36
37 support_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]);
38
39 if (support_smi_only_arrays) {
40 print("Tests include smi-only arrays.");
41 } else {
42 print("Tests do NOT include smi-only arrays.");
43 }
44 29
45 // IC and Crankshaft support for smi-only elements in dynamic array literals. 30 // IC and Crankshaft support for smi-only elements in dynamic array literals.
46 function get(foo) { return foo; } // Used to generate dynamic values. 31 function get(foo) { return foo; } // Used to generate dynamic values.
47 32
48 function array_literal_test() { 33 function array_literal_test() {
49 var a0 = [1, 2, 3]; 34 var a0 = [1, 2, 3];
50 assertTrue(%HasFastSmiElements(a0)); 35 assertTrue(%HasFastSmiElements(a0));
51 var a1 = [get(1), get(2), get(3)]; 36 var a1 = [get(1), get(2), get(3)];
52 assertTrue(%HasFastSmiElements(a1)); 37 assertTrue(%HasFastSmiElements(a1));
53 38
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 assertEquals(2, e0[1]); 72 assertEquals(2, e0[1]);
88 assertEquals(1, e0[0]); 73 assertEquals(1, e0[0]);
89 74
90 var f0 = [1, 2, [1, 2]]; 75 var f0 = [1, 2, [1, 2]];
91 assertTrue(%HasFastObjectElements(f0)); 76 assertTrue(%HasFastObjectElements(f0));
92 assertEquals([1,2], f0[2]); 77 assertEquals([1,2], f0[2]);
93 assertEquals(2, f0[1]); 78 assertEquals(2, f0[1]);
94 assertEquals(1, f0[0]); 79 assertEquals(1, f0[0]);
95 } 80 }
96 81
97 if (support_smi_only_arrays) { 82 for (var i = 0; i < 3; i++) {
98 for (var i = 0; i < 3; i++) { 83 array_literal_test();
99 array_literal_test(); 84 }
100 }
101 %OptimizeFunctionOnNextCall(array_literal_test); 85 %OptimizeFunctionOnNextCall(array_literal_test);
102 array_literal_test(); 86 array_literal_test();
103 87
104 function test_large_literal() { 88 function test_large_literal() {
105 89
106 function d() { 90 function d() {
107 gc(); 91 gc();
108 return 2.5; 92 return 2.5;
109 }
110
111 function o() {
112 gc();
113 return new Object();
114 }
115
116 large =
117 [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ];
118 assertFalse(%HasDictionaryElements(large));
119 assertFalse(%HasFastSmiElements(large));
120 assertFalse(%HasFastDoubleElements(large));
121 assertTrue(%HasFastObjectElements(large));
122 assertEquals(large,
123 [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
124 new Object(), new Object(), new Object(), new Object()]);
125 } 93 }
126 94
127 for (var i = 0; i < 3; i++) { 95 function o() {
128 test_large_literal(); 96 gc();
129 } 97 return new Object();
130 %OptimizeFunctionOnNextCall(test_large_literal);
131 test_large_literal();
132
133 function deopt_array(use_literal) {
134 if (use_literal) {
135 return [.5, 3, 4];
136 } else {
137 return new Array();
138 }
139 } 98 }
140 99
141 deopt_array(false); 100 large =
142 deopt_array(false); 101 [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ];
143 deopt_array(false); 102 assertFalse(%HasDictionaryElements(large));
103 assertFalse(%HasFastSmiElements(large));
104 assertFalse(%HasFastDoubleElements(large));
105 assertTrue(%HasFastObjectElements(large));
106 assertEquals(large,
107 [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
108 new Object(), new Object(), new Object(), new Object()]);
109 }
110
111 for (var i = 0; i < 3; i++) {
112 test_large_literal();
113 }
114 %OptimizeFunctionOnNextCall(test_large_literal);
115 test_large_literal();
116
117 function deopt_array(use_literal) {
118 if (use_literal) {
119 return [.5, 3, 4];
120 } else {
121 return new Array();
122 }
123 }
124
125 deopt_array(false);
126 deopt_array(false);
127 deopt_array(false);
144 %OptimizeFunctionOnNextCall(deopt_array); 128 %OptimizeFunctionOnNextCall(deopt_array);
145 var array = deopt_array(false); 129 var array = deopt_array(false);
146 assertOptimized(deopt_array); 130 assertOptimized(deopt_array);
147 deopt_array(true); 131 deopt_array(true);
148 assertOptimized(deopt_array); 132 assertOptimized(deopt_array);
149 array = deopt_array(false); 133 array = deopt_array(false);
150 assertOptimized(deopt_array); 134 assertOptimized(deopt_array);
151 135
152 // Check that unexpected changes in the objects stored into the boilerplate 136 // Check that unexpected changes in the objects stored into the boilerplate
153 // also force a deopt. 137 // also force a deopt.
154 function deopt_array_literal_all_smis(a) { 138 function deopt_array_literal_all_smis(a) {
155 return [0, 1, a]; 139 return [0, 1, a];
156 } 140 }
157 141
158 deopt_array_literal_all_smis(2); 142 deopt_array_literal_all_smis(2);
159 deopt_array_literal_all_smis(3); 143 deopt_array_literal_all_smis(3);
160 deopt_array_literal_all_smis(4); 144 deopt_array_literal_all_smis(4);
161 array = deopt_array_literal_all_smis(4); 145 array = deopt_array_literal_all_smis(4);
162 assertEquals(0, array[0]); 146 assertEquals(0, array[0]);
163 assertEquals(1, array[1]); 147 assertEquals(1, array[1]);
164 assertEquals(4, array[2]); 148 assertEquals(4, array[2]);
165 %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis); 149 %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis);
166 array = deopt_array_literal_all_smis(5); 150 array = deopt_array_literal_all_smis(5);
167 array = deopt_array_literal_all_smis(6); 151 array = deopt_array_literal_all_smis(6);
168 assertOptimized(deopt_array_literal_all_smis); 152 assertOptimized(deopt_array_literal_all_smis);
169 assertEquals(0, array[0]); 153 assertEquals(0, array[0]);
170 assertEquals(1, array[1]); 154 assertEquals(1, array[1]);
171 assertEquals(6, array[2]); 155 assertEquals(6, array[2]);
172 156
173 array = deopt_array_literal_all_smis(.5); 157 array = deopt_array_literal_all_smis(.5);
174 assertUnoptimized(deopt_array_literal_all_smis); 158 assertUnoptimized(deopt_array_literal_all_smis);
175 assertEquals(0, array[0]); 159 assertEquals(0, array[0]);
176 assertEquals(1, array[1]); 160 assertEquals(1, array[1]);
177 assertEquals(.5, array[2]); 161 assertEquals(.5, array[2]);
178 162
179 function deopt_array_literal_all_doubles(a) { 163 function deopt_array_literal_all_doubles(a) {
180 return [0.5, 1, a]; 164 return [0.5, 1, a];
181 } 165 }
182 166
183 deopt_array_literal_all_doubles(.5); 167 deopt_array_literal_all_doubles(.5);
184 deopt_array_literal_all_doubles(.5); 168 deopt_array_literal_all_doubles(.5);
185 deopt_array_literal_all_doubles(.5); 169 deopt_array_literal_all_doubles(.5);
186 array = deopt_array_literal_all_doubles(0.5); 170 array = deopt_array_literal_all_doubles(0.5);
187 assertEquals(0.5, array[0]); 171 assertEquals(0.5, array[0]);
188 assertEquals(1, array[1]); 172 assertEquals(1, array[1]);
189 assertEquals(0.5, array[2]); 173 assertEquals(0.5, array[2]);
190 %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles); 174 %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles);
191 array = deopt_array_literal_all_doubles(5); 175 array = deopt_array_literal_all_doubles(5);
192 array = deopt_array_literal_all_doubles(6); 176 array = deopt_array_literal_all_doubles(6);
193 assertOptimized(deopt_array_literal_all_doubles); 177 assertOptimized(deopt_array_literal_all_doubles);
194 assertEquals(0.5, array[0]); 178 assertEquals(0.5, array[0]);
195 assertEquals(1, array[1]); 179 assertEquals(1, array[1]);
196 assertEquals(6, array[2]); 180 assertEquals(6, array[2]);
197 181
198 var foo = new Object(); 182 var foo = new Object();
199 array = deopt_array_literal_all_doubles(foo); 183 array = deopt_array_literal_all_doubles(foo);
200 assertUnoptimized(deopt_array_literal_all_doubles); 184 assertUnoptimized(deopt_array_literal_all_doubles);
201 assertEquals(0.5, array[0]); 185 assertEquals(0.5, array[0]);
202 assertEquals(1, array[1]); 186 assertEquals(1, array[1]);
203 assertEquals(foo, array[2]); 187 assertEquals(foo, array[2]);
204 }
205 188
206 (function literals_after_osr() { 189 (function literals_after_osr() {
207 var color = [0]; 190 var color = [0];
208 // Trigger OSR, if optimization is not disabled. 191 // Trigger OSR, if optimization is not disabled.
209 if (%GetOptimizationStatus(literals_after_osr) != 4) { 192 if (%GetOptimizationStatus(literals_after_osr) != 4) {
210 while (%GetOptimizationCount(literals_after_osr) == 0) {} 193 while (%GetOptimizationCount(literals_after_osr) == 0) {}
211 } 194 }
212 return [color[0]]; 195 return [color[0]];
213 })(); 196 })();
OLDNEW
« no previous file with comments | « test/mjsunit/array-literal-feedback.js ('k') | test/mjsunit/array-natives-elements.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698