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 // Boolean indicates whether an operator can be part of a compound assignment. | 9 // Boolean indicates whether an operator can be part of a compound assignment. |
10 let strongNumberBinops = [ | 10 let strongNumberBinops = [ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 "'0'", | 54 "'0'", |
55 "'NaN'" | 55 "'NaN'" |
56 ]; | 56 ]; |
57 | 57 |
58 let nonNumberValues = nonStringOrNumberValues.concat(stringValues); | 58 let nonNumberValues = nonStringOrNumberValues.concat(stringValues); |
59 | 59 |
60 let numberValues = [ | 60 let numberValues = [ |
61 "0", | 61 "0", |
62 "(-0)", | 62 "(-0)", |
63 "1", | 63 "1", |
64 "0.79", | |
rossberg
2015/06/30 12:53:52
Why did you remove these cases?
conradw
2015/06/30 14:01:10
The runtime of this test was beginning to get exce
| |
65 "(-0.79)", | |
66 "4294967295", | |
67 "4294967296", | |
68 "(-4294967295)", | 64 "(-4294967295)", |
69 "(-4294967296)", | 65 "(-4294967296)", |
70 "9999999999999", | 66 "9999999999999", |
71 "(-9999999999999)", | 67 "(-9999999999999)", |
72 "1.5e10", | |
73 "(-1.5e10)", | |
74 "0xFFF", | |
75 "(-0xFFF)", | |
76 "NaN", | 68 "NaN", |
77 "Infinity", | 69 "Infinity", |
78 "(-Infinity)" | 70 "(-Infinity)" |
79 ]; | 71 ]; |
80 | 72 |
73 //****************************************************************************** | |
74 // Relational comparison function declarations | |
81 function add_strong(x, y) { | 75 function add_strong(x, y) { |
82 "use strong"; | 76 "use strong"; |
83 return x + y; | 77 return x + y; |
84 } | 78 } |
85 | 79 |
86 function add_num_strong(x, y) { | 80 function add_num_strong(x, y) { |
87 "use strong"; | 81 "use strong"; |
88 return x + y; | 82 return x + y; |
89 } | 83 } |
90 | 84 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 function typed_less_equal_strong(x, y) { | 240 function typed_less_equal_strong(x, y) { |
247 "use strong"; | 241 "use strong"; |
248 return (+x) <= (+y); | 242 return (+x) <= (+y); |
249 } | 243 } |
250 | 244 |
251 function typed_greater_equal_strong(x, y) { | 245 function typed_greater_equal_strong(x, y) { |
252 "use strong"; | 246 "use strong"; |
253 return (+x) >= (+y); | 247 return (+x) >= (+y); |
254 } | 248 } |
255 | 249 |
250 //****************************************************************************** | |
251 // (in)equality function declarations | |
252 function str_equal_strong(x, y) { | |
253 "use strong"; | |
254 return x === y; | |
255 } | |
256 | |
257 function str_ineq_strong(x, y) { | |
258 "use strong"; | |
259 return x !== y; | |
260 } | |
261 | |
256 let strongNumberFuncs = [add_num_strong, sub_strong, mul_strong, div_strong, | 262 let strongNumberFuncs = [add_num_strong, sub_strong, mul_strong, div_strong, |
257 mod_strong, or_strong, and_strong, xor_strong, | 263 mod_strong, or_strong, and_strong, xor_strong, |
258 shl_strong, shr_strong, sar_strong, less_num_strong, | 264 shl_strong, shr_strong, sar_strong, less_num_strong, |
259 greater_num_strong, less_equal_num_strong, | 265 greater_num_strong, less_equal_num_strong, |
260 greater_equal_num_strong, typed_add_strong, | 266 greater_equal_num_strong, typed_add_strong, |
261 typed_sub_strong, typed_mul_strong, typed_div_strong, | 267 typed_sub_strong, typed_mul_strong, typed_div_strong, |
262 typed_mod_strong, typed_or_strong, typed_and_strong, | 268 typed_mod_strong, typed_or_strong, typed_and_strong, |
263 typed_xor_strong, typed_shl_strong, typed_shr_strong, | 269 typed_xor_strong, typed_shl_strong, typed_shr_strong, |
264 typed_sar_strong, typed_less_strong, | 270 typed_sar_strong, typed_less_strong, |
265 typed_greater_strong, typed_less_equal_strong, | 271 typed_greater_strong, typed_less_equal_strong, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 for (let value of numberValues) { | 331 for (let value of numberValues) { |
326 assertStrongNonThrowBehaviour("(" + op + value + ")"); | 332 assertStrongNonThrowBehaviour("(" + op + value + ")"); |
327 } | 333 } |
328 for (let value of nonNumberValues) { | 334 for (let value of nonNumberValues) { |
329 assertStrongThrowBehaviour("(" + op + value + ")"); | 335 assertStrongThrowBehaviour("(" + op + value + ")"); |
330 } | 336 } |
331 } | 337 } |
332 | 338 |
333 for (let func of strongNumberFuncs) { | 339 for (let func of strongNumberFuncs) { |
334 // Check IC None*None->None throws | 340 // Check IC None*None->None throws |
335 assertThrows(function(){func(2, "foo");}, TypeError); | 341 for (let v of nonNumberValues) { |
336 %OptimizeFunctionOnNextCall(func); | 342 let value = eval(v); |
337 assertThrows(function(){func(2, "foo");}, TypeError); | 343 assertThrows(function(){func(2, value);}, TypeError); |
338 %DeoptimizeFunction(func); | 344 %OptimizeFunctionOnNextCall(func); |
345 print(func); | |
rossberg
2015/06/30 12:53:52
Stray debug output?
conradw
2015/06/30 14:01:10
Done.
| |
346 print(value); | |
347 assertThrows(function(){func(2, value);}, TypeError); | |
348 %DeoptimizeFunction(func); | |
349 } | |
339 func(4, 5); | 350 func(4, 5); |
340 func(4, 5); | 351 func(4, 5); |
341 // Check IC Smi*Smi->Smi throws | 352 // Check IC Smi*Smi->Smi throws |
342 assertThrows(function(){func(2, "foo");}, TypeError); | 353 for (let v of nonNumberValues) { |
343 %OptimizeFunctionOnNextCall(func); | 354 let value = eval(v); |
344 assertThrows(function(){func(2, "foo");}, TypeError); | 355 assertThrows(function(){func(2, value);}, TypeError); |
345 %DeoptimizeFunction(func); | 356 %OptimizeFunctionOnNextCall(func); |
357 assertThrows(function(){func(2, value);}, TypeError); | |
358 %DeoptimizeFunction(func); | |
359 } | |
346 func(NaN, NaN); | 360 func(NaN, NaN); |
347 func(NaN, NaN); | 361 func(NaN, NaN); |
348 // Check IC Number*Number->Number throws | 362 // Check IC Number*Number->Number throws |
349 assertThrows(function(){func(2, "foo");}, TypeError); | 363 for (let v of nonNumberValues) { |
350 %OptimizeFunctionOnNextCall(func); | 364 let value = eval(v); |
351 assertThrows(function(){func(2, "foo");}, TypeError); | 365 assertThrows(function(){func(2, value);}, TypeError); |
352 %DeoptimizeFunction(func); | 366 %OptimizeFunctionOnNextCall(func); |
367 assertThrows(function(){func(2, value);}, TypeError); | |
368 %DeoptimizeFunction(func); | |
369 } | |
353 } | 370 } |
354 | 371 |
355 for (let func of strongStringOrNumberFuncs) { | 372 for (let func of strongStringOrNumberFuncs) { |
356 // Check IC None*None->None throws | 373 // Check IC None*None->None throws |
357 assertThrows(function(){func(2, "foo");}, TypeError); | 374 for (let v of nonNumberValues) { |
358 %OptimizeFunctionOnNextCall(func); | 375 let value = eval(v); |
359 assertThrows(function(){func(2, "foo");}, TypeError); | 376 assertThrows(function(){func(2, value);}, TypeError); |
360 %DeoptimizeFunction(func); | 377 %OptimizeFunctionOnNextCall(func); |
378 assertThrows(function(){func(2, value);}, TypeError); | |
379 %DeoptimizeFunction(func); | |
380 } | |
361 func("foo", "bar"); | 381 func("foo", "bar"); |
362 func("foo", "bar"); | 382 func("foo", "bar"); |
363 // Check IC String*String->String throws | 383 // Check IC String*String->String throws |
364 assertThrows(function(){func(2, "foo");}, TypeError); | 384 for (let v of nonNumberValues) { |
365 %OptimizeFunctionOnNextCall(func); | 385 let value = eval(v); |
366 assertThrows(function(){func(2, "foo");}, TypeError); | 386 assertThrows(function(){func(2, value);}, TypeError); |
367 %DeoptimizeFunction(func); | 387 %OptimizeFunctionOnNextCall(func); |
388 assertThrows(function(){func(2, value);}, TypeError); | |
389 %DeoptimizeFunction(func); | |
390 } | |
368 func(NaN, NaN); | 391 func(NaN, NaN); |
369 func(NaN, NaN); | 392 func(NaN, NaN); |
370 // Check IC Generic*Generic->Generic throws | 393 // Check IC Generic*Generic->Generic throws |
371 assertThrows(function(){func(2, "foo");}, TypeError); | 394 for (let v of nonNumberValues) { |
395 let value = eval(v); | |
396 assertThrows(function(){func(2, value);}, TypeError); | |
397 %OptimizeFunctionOnNextCall(func); | |
398 assertThrows(function(){func(2, value);}, TypeError); | |
399 %DeoptimizeFunction(func); | |
400 } | |
401 } | |
402 | |
403 for (let func of [str_equal_strong, str_ineq_strong]) { | |
404 assertDoesNotThrow(function(){func(2, undefined)}); | |
405 assertDoesNotThrow(function(){func(2, undefined)}); | |
372 %OptimizeFunctionOnNextCall(func); | 406 %OptimizeFunctionOnNextCall(func); |
373 assertThrows(function(){func(2, "foo");}, TypeError); | 407 assertDoesNotThrow(function(){func(2, undefined)}); |
408 %DeoptimizeFunction(func); | |
409 assertDoesNotThrow(function(){func(true, {})}); | |
410 assertDoesNotThrow(function(){func(true, {})}); | |
411 %OptimizeFunctionOnNextCall(func); | |
412 assertDoesNotThrow(function(){func(true, {})}); | |
374 %DeoptimizeFunction(func); | 413 %DeoptimizeFunction(func); |
375 } | 414 } |
OLD | NEW |