OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 11 matching lines...) Expand all Loading... | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Test dictionary -> double elements -> dictionary elements round trip | 28 // Test dictionary -> double elements -> dictionary elements round trip |
29 | 29 |
30 // Flags: --allow-natives-syntax --unbox-double-arrays --expose-gc | 30 // Flags: --allow-natives-syntax --unbox-double-arrays --expose-gc |
31 var large_array_size = 100000; | 31 var large_array_size = 100000; |
32 var approx_dict_to_elements_threshold = 75000; | 32 var approx_dict_to_elements_threshold = 70000; |
33 | 33 |
34 var name = 0; | 34 var name = 0; |
35 | 35 |
36 function expected_array_value(i) { | 36 function expected_array_value(i) { |
37 if ((i % 2) == 0) { | 37 if ((i % 50) != 0) { |
38 return i; | 38 return i; |
39 } else { | 39 } else { |
40 return i + 0.5; | 40 return i + 0.5; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 function force_to_fast_double_array(a) { | 44 function force_to_fast_double_array(a) { |
45 a[large_array_size - 2] = 1; | 45 a[large_array_size - 2] = 1; |
46 for (var i= 0; i < approx_dict_to_elements_threshold; ++i ) { | 46 for (var i= 0; i < approx_dict_to_elements_threshold; ++i ) { |
47 a[i] = expected_array_value(i); | 47 a[i] = expected_array_value(i); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 } | 460 } |
461 | 461 |
462 test_for_in(); | 462 test_for_in(); |
463 test_for_in(); | 463 test_for_in(); |
464 test_for_in(); | 464 test_for_in(); |
465 %OptimizeFunctionOnNextCall(test_for_in); | 465 %OptimizeFunctionOnNextCall(test_for_in); |
466 test_for_in(); | 466 test_for_in(); |
467 test_for_in(); | 467 test_for_in(); |
468 test_for_in(); | 468 test_for_in(); |
469 | 469 |
470 function test_get_property_names() { | |
471 names = %GetPropertyNames(large_array3); | |
472 property_name_count = 0; | |
473 for (x in names) { property_name_count++}; | |
Mads Ager (chromium)
2011/07/22 08:29:20
++} -> ++; }
| |
474 assertEquals(26, property_name_count); | |
475 } | |
476 | |
477 test_get_property_names(); | |
478 test_get_property_names(); | |
479 test_get_property_names(); | |
480 | |
470 // Test elements getters. | 481 // Test elements getters. |
471 assertEquals(expected_array_value(10), large_array3[10]); | 482 assertEquals(expected_array_value(10), large_array3[10]); |
472 assertEquals(expected_array_value(-NaN), large_array3[2]); | 483 assertEquals(expected_array_value(-NaN), large_array3[2]); |
473 large_array3.__defineGetter__("2", function(){ | 484 large_array3.__defineGetter__("2", function(){ |
474 return expected_array_value(10); | 485 return expected_array_value(10); |
475 }); | 486 }); |
476 | 487 |
477 function test_getter() { | 488 function test_getter() { |
478 assertEquals(expected_array_value(10), large_array3[10]); | 489 assertEquals(expected_array_value(10), large_array3[10]); |
479 assertEquals(expected_array_value(10), large_array3[2]); | 490 assertEquals(expected_array_value(10), large_array3[2]); |
(...skipping 27 matching lines...) Expand all Loading... | |
507 assertEquals(expected_array_value(2), large_array4[2]); | 518 assertEquals(expected_array_value(2), large_array4[2]); |
508 } | 519 } |
509 | 520 |
510 test_setter(); | 521 test_setter(); |
511 test_setter(); | 522 test_setter(); |
512 test_setter(); | 523 test_setter(); |
513 %OptimizeFunctionOnNextCall(test_setter); | 524 %OptimizeFunctionOnNextCall(test_setter); |
514 test_setter(); | 525 test_setter(); |
515 test_setter(); | 526 test_setter(); |
516 test_setter(); | 527 test_setter(); |
OLD | NEW |