OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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: --strong-mode --allow-natives-syntax | 5 // Flags: --strong-mode --allow-natives-syntax |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 // TODO(conradw): Implement other strong operators | 9 // TODO(conradw): Implement other strong operators |
10 let strongNumberBinops = [ | 10 let strongNumberBinops = [ |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 shl_strong, shr_strong, sar_strong, typed_add_strong, | 192 shl_strong, shr_strong, sar_strong, typed_add_strong, |
193 typed_sub_strong, typed_mul_strong, typed_div_strong, | 193 typed_sub_strong, typed_mul_strong, typed_div_strong, |
194 typed_mod_strong, typed_or_strong, typed_and_strong, | 194 typed_mod_strong, typed_or_strong, typed_and_strong, |
195 typed_xor_strong, typed_shl_strong, typed_shr_strong, | 195 typed_xor_strong, typed_shl_strong, typed_shr_strong, |
196 typed_sar_strong]; | 196 typed_sar_strong]; |
197 | 197 |
198 let strongStringOrNumberFuncs = [add_strong]; | 198 let strongStringOrNumberFuncs = [add_strong]; |
199 | 199 |
200 let strongFuncs = strongNumberFuncs.concat(strongStringOrNumberFuncs); | 200 let strongFuncs = strongNumberFuncs.concat(strongStringOrNumberFuncs); |
201 | 201 |
202 function inline_sub_strong(x, y) { | |
203 "use strong"; | |
204 let v = x - y; | |
205 return v; | |
206 } | |
207 | |
208 function inline_outer(x, y) { | |
209 return inline_sub_strong(x, y); | |
210 } | |
211 | |
212 function inline_sub(x, y) { | |
213 let v = x - y; | |
214 return v; | |
215 } | |
216 | |
217 function inline_outer_strong(x, y) { | |
218 "use strong"; | |
219 return inline_sub(x, y); | |
220 } | |
221 | |
222 function assertStrongNonThrowBehaviour(expr) { | 202 function assertStrongNonThrowBehaviour(expr) { |
223 assertEquals(eval(expr), eval("'use strong';" + expr)); | 203 assertEquals(eval(expr), eval("'use strong';" + expr)); |
224 assertDoesNotThrow("'use strong'; " + expr + ";"); | 204 assertDoesNotThrow("'use strong'; " + expr + ";"); |
225 assertDoesNotThrow("'use strong'; let v = " + expr + ";"); | 205 assertDoesNotThrow("'use strong'; let v = " + expr + ";"); |
226 } | 206 } |
227 | 207 |
228 function assertStrongThrowBehaviour(expr) { | 208 function assertStrongThrowBehaviour(expr) { |
229 assertDoesNotThrow("'use strict'; " + expr + ";"); | 209 assertDoesNotThrow("'use strict'; " + expr + ";"); |
230 assertDoesNotThrow("'use strict'; let v = " + expr + ";"); | 210 assertDoesNotThrow("'use strict'; let v = " + expr + ";"); |
231 assertThrows("'use strong'; " + expr + ";", TypeError); | 211 assertThrows("'use strong'; " + expr + ";", TypeError); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 assertThrows(function(){func(2, "foo");}, TypeError); | 291 assertThrows(function(){func(2, "foo");}, TypeError); |
312 %DeoptimizeFunction(func); | 292 %DeoptimizeFunction(func); |
313 func(NaN, NaN); | 293 func(NaN, NaN); |
314 func(NaN, NaN); | 294 func(NaN, NaN); |
315 // Check IC Generic*Generic->Generic throws | 295 // Check IC Generic*Generic->Generic throws |
316 assertThrows(function(){func(2, "foo");}, TypeError); | 296 assertThrows(function(){func(2, "foo");}, TypeError); |
317 %OptimizeFunctionOnNextCall(func); | 297 %OptimizeFunctionOnNextCall(func); |
318 assertThrows(function(){func(2, "foo");}, TypeError); | 298 assertThrows(function(){func(2, "foo");}, TypeError); |
319 %DeoptimizeFunction(func); | 299 %DeoptimizeFunction(func); |
320 } | 300 } |
321 | |
322 assertThrows(function(){inline_outer(1, {})}, TypeError); | |
323 for (var i = 0; i < 100; i++) { | |
324 inline_outer(1, 2); | |
325 } | |
326 assertThrows(function(){inline_outer(1, {})}, TypeError); | |
327 | |
328 assertDoesNotThrow(function(){inline_outer_strong(1, {})}); | |
329 for (var i = 0; i < 100; i++) { | |
330 inline_outer_strong(1, 2); | |
331 } | |
332 assertDoesNotThrow(function(){inline_outer_strong(1, {})}); | |
OLD | NEW |