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

Side by Side Diff: test/mjsunit/es6/array-iterator-turbo.js

Issue 2655223003: Revert of [tests] Make assertOptimized()/assertUnoptimized() great again. (Closed)
Patch Set: Created 3 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
« no previous file with comments | « test/mjsunit/ensure-growing-store-learns.js ('k') | test/mjsunit/es6/block-let-crankshaft.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --turbo --turbo-escape --allow-natives-syntax 5 // Flags: --turbo --turbo-escape --allow-natives-syntax
6 6
7 "use strict"; 7 "use strict";
8 8
9 const kDeoptimized = 2;
10 const kTurbofanned = 7;
11 const kInterpreted = 8;
12
13 function GetOptimizationStatus(fn) {
14 let status = %GetOptimizationStatus(fn);
15 switch (status) {
16 case kInterpreted: // Treat interpreted frames as unoptimized
17 status = kDeoptimized;
18 break;
19 }
20
21 return status;
22 }
23
9 let global = this; 24 let global = this;
10 let tests = { 25 let tests = {
11 FastElementsKind() { 26 FastElementsKind() {
12 let runners = { 27 let runners = {
13 FAST_SMI_ELEMENTS(array) { 28 FAST_SMI_ELEMENTS(array) {
14 let sum = 0; 29 let sum = 0;
15 for (let x of array) sum += x; 30 for (let x of array) sum += x;
16 return sum; 31 return sum;
17 }, 32 },
18 33
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 let { array, expected, array2, expected2 } = tests[key]; 111 let { array, expected, array2, expected2 } = tests[key];
97 112
98 // Warmup: 113 // Warmup:
99 fn(array); 114 fn(array);
100 fn(array); 115 fn(array);
101 %OptimizeFunctionOnNextCall(fn); 116 %OptimizeFunctionOnNextCall(fn);
102 fn(array); 117 fn(array);
103 118
104 // TODO(bmeurer): FAST_HOLEY_DOUBLE_ELEMENTS maps generally deopt when 119 // TODO(bmeurer): FAST_HOLEY_DOUBLE_ELEMENTS maps generally deopt when
105 // a hole is encountered. Test should be fixed once that is corrected. 120 // a hole is encountered. Test should be fixed once that is corrected.
106 let expect_deopt = /HOLEY_DOUBLE/.test(key); 121 let status = /HOLEY_DOUBLE/.test(key) ? kDeoptimized : kTurbofanned;
107 122
108 if (expect_deopt) { 123 assertEquals(status, GetOptimizationStatus(fn), key);
109 assertUnoptimized(fn, '', key);
110 } else {
111 assertOptimized(fn, '', key);
112 }
113 assertEquals(expected, fn(array), key); 124 assertEquals(expected, fn(array), key);
114 if (expect_deopt) { 125 assertEquals(status, GetOptimizationStatus(fn), key);
115 assertUnoptimized(fn, '', key);
116 } else {
117 assertOptimized(fn, '', key);
118 }
119 126
120 // Check no deopt when another array with the same map is used 127 // Check no deopt when another arra with the same map is used
121 assertTrue(%HaveSameMap(array, array2), key); 128 assertTrue(%HaveSameMap(array, array2), key);
122 if (expect_deopt) { 129 assertEquals(status, GetOptimizationStatus(fn), key);
123 assertUnoptimized(fn, '', key);
124 } else {
125 assertOptimized(fn, '', key);
126 }
127 assertEquals(expected2, fn(array2), key); 130 assertEquals(expected2, fn(array2), key);
128 131
129 // CheckMaps bailout 132 // CheckMaps bailout
130 let newArray = Object.defineProperty( 133 let newArray = Object.defineProperty(
131 [1, 2, 3], 2, { enumerable: false, configurable: false, 134 [1, 2, 3], 2, { enumerable: false, configurable: false,
132 get() { return 7; } }); 135 get() { return 7; } });
133 fn(newArray); 136 fn(newArray);
134 assertUnoptimized(fn, '', key); 137 assertEquals(kDeoptimized, GetOptimizationStatus(fn), key);
135 } 138 }
136 }, 139 },
137 140
138 TypedArrays() { 141 TypedArrays() {
139 let tests = { 142 let tests = {
140 Uint8Array: { 143 Uint8Array: {
141 array: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, -1, 256]), 144 array: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, -1, 256]),
142 expected: 291, 145 expected: 291,
143 array2: new Uint8Array([1, 2, 3]), 146 array2: new Uint8Array([1, 2, 3]),
144 expected2: 6 147 expected2: 6
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 for (let x of array) ret += x; 215 for (let x of array) ret += x;
213 return ret; 216 return ret;
214 }; 217 };
215 218
216 // Warmup 219 // Warmup
217 sum(array); 220 sum(array);
218 sum(array); 221 sum(array);
219 %OptimizeFunctionOnNextCall(sum); 222 %OptimizeFunctionOnNextCall(sum);
220 assertEquals(expected, sum(array), key); 223 assertEquals(expected, sum(array), key);
221 224
222 assertOptimized(sum, '', key); 225 assertEquals(kTurbofanned, GetOptimizationStatus(sum), key);
223 226
224 // Not deoptimized when called on typed array of same type / map 227 // Not deoptimized when called on typed array of same type / map
225 assertTrue(%HaveSameMap(array, array2)); 228 assertTrue(%HaveSameMap(array, array2));
226 assertEquals(expected2, sum(array2), key); 229 assertEquals(expected2, sum(array2), key);
227 assertOptimized(sum, '', key); 230 assertEquals(kTurbofanned, GetOptimizationStatus(sum), key);
228 231
229 // Throw when detached 232 // Throw when detached
230 let clone = new array.constructor(array); 233 let clone = new array.constructor(array);
231 %ArrayBufferNeuter(clone.buffer); 234 %ArrayBufferNeuter(clone.buffer);
232 assertThrows(() => sum(clone), TypeError); 235 assertThrows(() => sum(clone), TypeError);
233 } 236 }
234 } 237 }
235 }; 238 };
236 239
237 for (let name of Object.keys(tests)) { 240 for (let name of Object.keys(tests)) {
238 let test = tests[name]; 241 let test = tests[name];
239 test(); 242 test();
240 } 243 }
OLDNEW
« no previous file with comments | « test/mjsunit/ensure-growing-store-learns.js ('k') | test/mjsunit/es6/block-let-crankshaft.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698