| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 } | 619 } |
| 620 | 620 |
| 621 | 621 |
| 622 // Observing array length (including truncation) | 622 // Observing array length (including truncation) |
| 623 reset(); | 623 reset(); |
| 624 var arr = ['a', 'b', 'c', 'd']; | 624 var arr = ['a', 'b', 'c', 'd']; |
| 625 var arr2 = ['alpha', 'beta']; | 625 var arr2 = ['alpha', 'beta']; |
| 626 var arr3 = ['hello']; | 626 var arr3 = ['hello']; |
| 627 arr3[2] = 'goodbye'; | 627 arr3[2] = 'goodbye'; |
| 628 arr3.length = 6; | 628 arr3.length = 6; |
| 629 // TODO(adamk): Enable this test case when it can run in a reasonable | 629 var slow_arr = new Array(1000000000); |
| 630 // amount of time. | 630 slow_arr[500000000] = 'hello'; |
| 631 //var slow_arr = new Array(1000000000); | |
| 632 //slow_arr[500000000] = 'hello'; | |
| 633 Object.defineProperty(arr, '0', {configurable: false}); | 631 Object.defineProperty(arr, '0', {configurable: false}); |
| 634 Object.defineProperty(arr, '2', {get: function(){}}); | 632 Object.defineProperty(arr, '2', {get: function(){}}); |
| 635 Object.defineProperty(arr2, '0', {get: function(){}, configurable: false}); | 633 Object.defineProperty(arr2, '0', {get: function(){}, configurable: false}); |
| 636 Object.observe(arr, observer.callback); | 634 Object.observe(arr, observer.callback); |
| 637 Object.observe(arr2, observer.callback); | 635 Object.observe(arr2, observer.callback); |
| 638 Object.observe(arr3, observer.callback); | 636 Object.observe(arr3, observer.callback); |
| 637 Object.observe(slow_arr, observer.callback); |
| 639 arr.length = 2; | 638 arr.length = 2; |
| 640 arr.length = 0; | 639 arr.length = 0; |
| 641 arr.length = 10; | 640 arr.length = 10; |
| 642 Object.defineProperty(arr, 'length', {writable: false}); | 641 Object.defineProperty(arr, 'length', {writable: false}); |
| 643 arr2.length = 0; | 642 arr2.length = 0; |
| 644 arr2.length = 1; // no change expected | 643 arr2.length = 1; // no change expected |
| 645 Object.defineProperty(arr2, 'length', {value: 1, writable: false}); | 644 Object.defineProperty(arr2, 'length', {value: 1, writable: false}); |
| 646 arr3.length = 0; | 645 arr3.length = 0; |
| 647 ++arr3.length; | 646 ++arr3.length; |
| 648 arr3.length++; | 647 arr3.length++; |
| 649 arr3.length /= 2; | 648 arr3.length /= 2; |
| 650 Object.defineProperty(arr3, 'length', {value: 5}); | 649 Object.defineProperty(arr3, 'length', {value: 5}); |
| 651 Object.defineProperty(arr3, 'length', {value: 10, writable: false}); | 650 Object.defineProperty(arr3, 'length', {value: 10, writable: false}); |
| 651 slow_arr.length = 100; |
| 652 Object.deliverChangeRecords(observer.callback); | 652 Object.deliverChangeRecords(observer.callback); |
| 653 observer.assertCallbackRecords([ | 653 observer.assertCallbackRecords([ |
| 654 { object: arr, name: '3', type: 'deleted', oldValue: 'd' }, | 654 { object: arr, name: '3', type: 'deleted', oldValue: 'd' }, |
| 655 { object: arr, name: '2', type: 'deleted' }, | 655 { object: arr, name: '2', type: 'deleted' }, |
| 656 { object: arr, name: 'length', type: 'updated', oldValue: 4 }, | 656 { object: arr, name: 'length', type: 'updated', oldValue: 4 }, |
| 657 { object: arr, name: '1', type: 'deleted', oldValue: 'b' }, | 657 { object: arr, name: '1', type: 'deleted', oldValue: 'b' }, |
| 658 { object: arr, name: 'length', type: 'updated', oldValue: 2 }, | 658 { object: arr, name: 'length', type: 'updated', oldValue: 2 }, |
| 659 { object: arr, name: 'length', type: 'updated', oldValue: 1 }, | 659 { object: arr, name: 'length', type: 'updated', oldValue: 1 }, |
| 660 { object: arr, name: 'length', type: 'reconfigured', oldValue: 10 }, | 660 { object: arr, name: 'length', type: 'reconfigured', oldValue: 10 }, |
| 661 { object: arr2, name: '1', type: 'deleted', oldValue: 'beta' }, | 661 { object: arr2, name: '1', type: 'deleted', oldValue: 'beta' }, |
| 662 { object: arr2, name: 'length', type: 'updated', oldValue: 2 }, | 662 { object: arr2, name: 'length', type: 'updated', oldValue: 2 }, |
| 663 { object: arr2, name: 'length', type: 'reconfigured', oldValue: 1 }, | 663 { object: arr2, name: 'length', type: 'reconfigured', oldValue: 1 }, |
| 664 { object: arr3, name: '2', type: 'deleted', oldValue: 'goodbye' }, | 664 { object: arr3, name: '2', type: 'deleted', oldValue: 'goodbye' }, |
| 665 { object: arr3, name: '0', type: 'deleted', oldValue: 'hello' }, | 665 { object: arr3, name: '0', type: 'deleted', oldValue: 'hello' }, |
| 666 { object: arr3, name: 'length', type: 'updated', oldValue: 6 }, | 666 { object: arr3, name: 'length', type: 'updated', oldValue: 6 }, |
| 667 { object: arr3, name: 'length', type: 'updated', oldValue: 0 }, | 667 { object: arr3, name: 'length', type: 'updated', oldValue: 0 }, |
| 668 { object: arr3, name: 'length', type: 'updated', oldValue: 1 }, | 668 { object: arr3, name: 'length', type: 'updated', oldValue: 1 }, |
| 669 { object: arr3, name: 'length', type: 'updated', oldValue: 2 }, | 669 { object: arr3, name: 'length', type: 'updated', oldValue: 2 }, |
| 670 { object: arr3, name: 'length', type: 'updated', oldValue: 1 }, | 670 { object: arr3, name: 'length', type: 'updated', oldValue: 1 }, |
| 671 { object: arr3, name: 'length', type: 'reconfigured', oldValue: 5 }, | 671 { object: arr3, name: 'length', type: 'reconfigured', oldValue: 5 }, |
| 672 { object: slow_arr, name: '500000000', type: 'deleted', oldValue: 'hello' }, |
| 673 { object: slow_arr, name: 'length', type: 'updated', oldValue: 1000000000 }, |
| 672 ]); | 674 ]); |
| 673 | 675 |
| 674 | 676 |
| 675 // Assignments in loops (checking different IC states). | 677 // Assignments in loops (checking different IC states). |
| 676 reset(); | 678 reset(); |
| 677 var obj = {}; | 679 var obj = {}; |
| 678 Object.observe(obj, observer.callback); | 680 Object.observe(obj, observer.callback); |
| 679 for (var i = 0; i < 5; i++) { | 681 for (var i = 0; i < 5; i++) { |
| 680 obj["a" + i] = i; | 682 obj["a" + i] = i; |
| 681 } | 683 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 for (var n1 = 0; n1 < 3; ++n1) | 1047 for (var n1 = 0; n1 < 3; ++n1) |
| 1046 for (var n2 = 0; n2 < 3; ++n2) | 1048 for (var n2 = 0; n2 < 3; ++n2) |
| 1047 for (var i in mutation) | 1049 for (var i in mutation) |
| 1048 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); | 1050 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); |
| 1049 | 1051 |
| 1050 for (var b1 = 0; b1 < 2; ++b1) | 1052 for (var b1 = 0; b1 < 2; ++b1) |
| 1051 for (var b2 = 0; b2 < 2; ++b2) | 1053 for (var b2 = 0; b2 < 2; ++b2) |
| 1052 for (var n = 0; n < 3; ++n) | 1054 for (var n = 0; n < 3; ++n) |
| 1053 for (var i in mutationByIncr) | 1055 for (var i in mutationByIncr) |
| 1054 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); | 1056 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); |
| OLD | NEW |