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

Side by Side Diff: test/mjsunit/array-constructor-feedback.js

Issue 139973004: A64: Synchronize with r15814. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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-bounds-check-removal.js ('k') | test/mjsunit/array-feedback.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
(...skipping 17 matching lines...) Expand all
28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc
29 // Flags: --track-allocation-sites --noalways-opt 29 // Flags: --track-allocation-sites --noalways-opt
30 30
31 // Test element kind of objects. 31 // Test element kind of objects.
32 // Since --smi-only-arrays affects builtins, its default setting at compile 32 // Since --smi-only-arrays affects builtins, its default setting at compile
33 // time sticks if built with snapshot. If --smi-only-arrays is deactivated 33 // time sticks if built with snapshot. If --smi-only-arrays is deactivated
34 // by default, only a no-snapshot build actually has smi-only arrays enabled 34 // by default, only a no-snapshot build actually has smi-only arrays enabled
35 // in this test case. Depending on whether smi-only arrays are actually 35 // in this test case. Depending on whether smi-only arrays are actually
36 // enabled, this test takes the appropriate code path to check smi-only arrays. 36 // enabled, this test takes the appropriate code path to check smi-only arrays.
37 37
38 // Reset the GC stress mode to be off. Needed because AllocationMementos only
39 // live for one gc, so a gc that happens in certain fragile areas of the test
40 // can break assumptions.
41 %SetFlags("--gc-interval=-1")
42
38 // support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); 43 // support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8));
39 support_smi_only_arrays = true; 44 support_smi_only_arrays = true;
40 45
41 if (support_smi_only_arrays) { 46 if (support_smi_only_arrays) {
42 print("Tests include smi-only arrays."); 47 print("Tests include smi-only arrays.");
43 } else { 48 } else {
44 print("Tests do NOT include smi-only arrays."); 49 print("Tests do NOT include smi-only arrays.");
45 } 50 }
46 51
47 var elements_kind = { 52 var elements_kind = {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 function bar0(t) { 113 function bar0(t) {
109 return new t(); 114 return new t();
110 } 115 }
111 a = bar0(Array); 116 a = bar0(Array);
112 a[0] = 3.5; 117 a[0] = 3.5;
113 b = bar0(Array); 118 b = bar0(Array);
114 assertKind(elements_kind.fast_double, b); 119 assertKind(elements_kind.fast_double, b);
115 %OptimizeFunctionOnNextCall(bar0); 120 %OptimizeFunctionOnNextCall(bar0);
116 b = bar0(Array); 121 b = bar0(Array);
117 assertKind(elements_kind.fast_double, b); 122 assertKind(elements_kind.fast_double, b);
118 assertTrue(2 != %GetOptimizationStatus(bar0)); 123 assertOptimized(bar0);
119 // bar0 should deopt 124 // bar0 should deopt
120 b = bar0(Object); 125 b = bar0(Object);
121 assertTrue(1 != %GetOptimizationStatus(bar0)); 126 assertUnoptimized(bar0)
122 // When it's re-optimized, we should call through the full stub 127 // When it's re-optimized, we should call through the full stub
123 bar0(Array); 128 bar0(Array);
124 %OptimizeFunctionOnNextCall(bar0); 129 %OptimizeFunctionOnNextCall(bar0);
125 b = bar0(Array); 130 b = bar0(Array);
126 // We also lost our ability to record kind feedback, as the site 131 // We also lost our ability to record kind feedback, as the site
127 // is megamorphic now. 132 // is megamorphic now.
128 assertKind(elements_kind.fast_smi_only, b); 133 assertKind(elements_kind.fast_smi_only, b);
129 assertTrue(2 != %GetOptimizationStatus(bar0)); 134 assertOptimized(bar0);
130 b[0] = 3.5; 135 b[0] = 3.5;
131 c = bar0(Array); 136 c = bar0(Array);
132 assertKind(elements_kind.fast_smi_only, c); 137 assertKind(elements_kind.fast_smi_only, c);
133 })(); 138 })();
134 139
135 140
136 // Test: Ensure that bailouts from the stub don't deopt a crankshafted 141 // Test: Ensure that bailouts from the stub don't deopt a crankshafted
137 // method with a call to that stub. 142 // method with a call to that stub.
138 (function() { 143 (function() {
139 function bar(len) { 144 function bar(len) {
140 return new Array(len); 145 return new Array(len);
141 } 146 }
142 a = bar(10); 147 a = bar(10);
143 a[0] = "a string"; 148 a[0] = "a string";
144 a = bar(10); 149 a = bar(10);
145 assertKind(elements_kind.fast, a); 150 assertKind(elements_kind.fast, a);
146 %OptimizeFunctionOnNextCall(bar); 151 %OptimizeFunctionOnNextCall(bar);
147 a = bar(10); 152 a = bar(10);
148 assertKind(elements_kind.fast, a); 153 assertKind(elements_kind.fast, a);
149 assertTrue(2 != %GetOptimizationStatus(bar)); 154 assertOptimized(bar);
150 // The stub bails out, but the method call should be fine. 155 // The stub bails out, but the method call should be fine.
151 a = bar(100000); 156 a = bar(100000);
152 assertTrue(2 != %GetOptimizationStatus(bar)); 157 assertOptimized(bar);
153 assertKind(elements_kind.dictionary, a); 158 assertKind(elements_kind.dictionary, a);
154 159
155 // If the argument isn't a smi, it bails out as well 160 // If the argument isn't a smi, it bails out as well
156 a = bar("oops"); 161 a = bar("oops");
157 assertTrue(2 != %GetOptimizationStatus(bar)); 162 assertOptimized(bar);
158 assertKind(elements_kind.fast, a); 163 assertKind(elements_kind.fast, a);
159 164
160 function barn(one, two, three) { 165 function barn(one, two, three) {
161 return new Array(one, two, three); 166 return new Array(one, two, three);
162 } 167 }
163 168
164 barn(1, 2, 3); 169 barn(1, 2, 3);
165 barn(1, 2, 3); 170 barn(1, 2, 3);
166 %OptimizeFunctionOnNextCall(barn); 171 %OptimizeFunctionOnNextCall(barn);
167 barn(1, 2, 3); 172 barn(1, 2, 3);
168 assertTrue(2 != %GetOptimizationStatus(barn)); 173 assertOptimized(barn);
169 a = barn(1, "oops", 3); 174 a = barn(1, "oops", 3);
170 // The stub should bail out but the method should remain optimized. 175 // The stub should bail out but the method should remain optimized.
171 assertKind(elements_kind.fast, a); 176 assertKind(elements_kind.fast, a);
172 assertTrue(2 != %GetOptimizationStatus(barn)); 177 assertOptimized(barn);
173 })(); 178 })();
174 179
175 180
176 // Test: When a method with array constructor is crankshafted, the type 181 // Test: When a method with array constructor is crankshafted, the type
177 // feedback for elements kind is baked in. Verify that transitions don't 182 // feedback for elements kind is baked in. Verify that transitions don't
178 // change it anymore 183 // change it anymore
179 (function() { 184 (function() {
180 function bar() { 185 function bar() {
181 return new Array(); 186 return new Array();
182 } 187 }
183 a = bar(); 188 a = bar();
184 bar(); 189 bar();
185 %OptimizeFunctionOnNextCall(bar); 190 %OptimizeFunctionOnNextCall(bar);
186 b = bar(); 191 b = bar();
187 // This only makes sense to test if we allow crankshafting 192 // This only makes sense to test if we allow crankshafting
188 if (4 != %GetOptimizationStatus(bar)) { 193 if (4 != %GetOptimizationStatus(bar)) {
189 assertTrue(2 != %GetOptimizationStatus(bar)); 194 assertOptimized(bar);
190 %DebugPrint(3); 195 %DebugPrint(3);
191 b[0] = 3.5; 196 b[0] = 3.5;
192 c = bar(); 197 c = bar();
193 assertKind(elements_kind.fast_smi_only, c); 198 assertKind(elements_kind.fast_smi_only, c);
194 assertTrue(2 != %GetOptimizationStatus(bar)); 199 assertOptimized(bar);
195 } 200 }
196 })(); 201 })();
197 202
198 203
199 // Test: create arrays in two contexts, verifying that the correct 204 // Test: create arrays in two contexts, verifying that the correct
200 // map for Array in that context will be used. 205 // map for Array in that context will be used.
201 (function() { 206 (function() {
202 function bar() { return new Array(); } 207 function bar() { return new Array(); }
203 bar(); 208 bar();
204 bar(); 209 bar();
205 %OptimizeFunctionOnNextCall(bar); 210 %OptimizeFunctionOnNextCall(bar);
206 a = bar(); 211 a = bar();
207 assertTrue(a instanceof Array); 212 assertTrue(a instanceof Array);
208 213
209 var contextB = Realm.create(); 214 var contextB = Realm.create();
210 Realm.eval(contextB, "function bar2() { return new Array(); };"); 215 Realm.eval(contextB, "function bar2() { return new Array(); };");
211 Realm.eval(contextB, "bar2(); bar2();"); 216 Realm.eval(contextB, "bar2(); bar2();");
212 Realm.eval(contextB, "%OptimizeFunctionOnNextCall(bar2);"); 217 Realm.eval(contextB, "%OptimizeFunctionOnNextCall(bar2);");
213 Realm.eval(contextB, "bar2();"); 218 Realm.eval(contextB, "bar2();");
214 assertFalse(Realm.eval(contextB, "bar2();") instanceof Array); 219 assertFalse(Realm.eval(contextB, "bar2();") instanceof Array);
215 assertTrue(Realm.eval(contextB, "bar2() instanceof Array")); 220 assertTrue(Realm.eval(contextB, "bar2() instanceof Array"));
216 })(); 221 })();
217 } 222 }
OLDNEW
« no previous file with comments | « test/mjsunit/array-bounds-check-removal.js ('k') | test/mjsunit/array-feedback.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698