OLD | NEW |
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 --no-always-opt | 5 // Flags: --turbo --turbo-escape --allow-natives-syntax --no-always-opt |
6 // Flags: --opt --turbo-filter=* | 6 // Flags: --opt --turbo-filter=* |
7 | 7 |
8 "use strict"; | 8 "use strict"; |
9 | 9 |
10 let global = this; | 10 let global = this; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 for (let key of Object.keys(runners)) { | 95 for (let key of Object.keys(runners)) { |
96 let fn = runners[key]; | 96 let fn = runners[key]; |
97 let { array, expected, array2, expected2 } = tests[key]; | 97 let { array, expected, array2, expected2 } = tests[key]; |
98 | 98 |
99 // Warmup: | 99 // Warmup: |
100 fn(array); | 100 fn(array); |
101 fn(array); | 101 fn(array); |
102 %OptimizeFunctionOnNextCall(fn); | 102 %OptimizeFunctionOnNextCall(fn); |
103 fn(array); | 103 fn(array); |
104 | 104 |
105 // TODO(bmeurer): FAST_HOLEY_DOUBLE_ELEMENTS maps generally deopt when | 105 assertOptimized(fn, '', key); |
106 // a hole is encountered. Test should be fixed once that is corrected. | |
107 let expect_deopt = /HOLEY_DOUBLE/.test(key); | |
108 | |
109 if (expect_deopt) { | |
110 assertUnoptimized(fn, '', key); | |
111 } else { | |
112 assertOptimized(fn, '', key); | |
113 } | |
114 assertEquals(expected, fn(array), key); | 106 assertEquals(expected, fn(array), key); |
115 if (expect_deopt) { | 107 assertOptimized(fn, '', key); |
116 assertUnoptimized(fn, '', key); | |
117 } else { | |
118 assertOptimized(fn, '', key); | |
119 } | |
120 | 108 |
121 // Check no deopt when another array with the same map is used | 109 // Check no deopt when another array with the same map is used |
122 assertTrue(%HaveSameMap(array, array2), key); | 110 assertTrue(%HaveSameMap(array, array2), key); |
123 if (expect_deopt) { | 111 assertOptimized(fn, '', key); |
124 assertUnoptimized(fn, '', key); | |
125 } else { | |
126 assertOptimized(fn, '', key); | |
127 } | |
128 assertEquals(expected2, fn(array2), key); | 112 assertEquals(expected2, fn(array2), key); |
129 | 113 |
130 // CheckMaps bailout | 114 // CheckMaps bailout |
131 let newArray = Object.defineProperty( | 115 let newArray = Object.defineProperty( |
132 [1, 2, 3], 2, { enumerable: false, configurable: false, | 116 [1, 2, 3], 2, { enumerable: false, configurable: false, |
133 get() { return 7; } }); | 117 get() { return 7; } }); |
134 fn(newArray); | 118 fn(newArray); |
135 assertUnoptimized(fn, '', key); | 119 assertUnoptimized(fn, '', key); |
136 } | 120 } |
137 }, | 121 }, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 208 |
225 // Not deoptimized when called on typed array of same type / map | 209 // Not deoptimized when called on typed array of same type / map |
226 assertTrue(%HaveSameMap(array, array2)); | 210 assertTrue(%HaveSameMap(array, array2)); |
227 assertEquals(expected2, sum(array2), key); | 211 assertEquals(expected2, sum(array2), key); |
228 assertOptimized(sum, '', key); | 212 assertOptimized(sum, '', key); |
229 | 213 |
230 // Throw when detached | 214 // Throw when detached |
231 let clone = new array.constructor(array); | 215 let clone = new array.constructor(array); |
232 %ArrayBufferNeuter(clone.buffer); | 216 %ArrayBufferNeuter(clone.buffer); |
233 assertThrows(() => sum(clone), TypeError); | 217 assertThrows(() => sum(clone), TypeError); |
| 218 |
| 219 // Clear the slate for the next iteration. |
| 220 %DeoptimizeFunction(sum); |
| 221 %ClearFunctionFeedback(sum); |
234 } | 222 } |
235 } | 223 } |
236 }; | 224 }; |
237 | 225 |
238 for (let name of Object.keys(tests)) { | 226 for (let name of Object.keys(tests)) { |
239 let test = tests[name]; | 227 let test = tests[name]; |
240 test(); | 228 test(); |
241 } | 229 } |
OLD | NEW |