OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 559 |
560 result.length = end_i - start_i; | 560 result.length = end_i - start_i; |
561 | 561 |
562 return result; | 562 return result; |
563 } | 563 } |
564 | 564 |
565 | 565 |
566 function ArraySplice(start, delete_count) { | 566 function ArraySplice(start, delete_count) { |
567 var num_arguments = %_ArgumentsLength(); | 567 var num_arguments = %_ArgumentsLength(); |
568 | 568 |
569 // SpiderMonkey and KJS return undefined in the case where no | 569 // SpiderMonkey and JSC return undefined in the case where no |
570 // arguments are given instead of using the implicit undefined | 570 // arguments are given instead of using the implicit undefined |
571 // arguments. This does not follow ECMA-262, but we do the same for | 571 // arguments. This does not follow ECMA-262, but we do the same for |
572 // compatibility. | 572 // compatibility. |
| 573 // TraceMonkey follows ECMA-262 though. |
573 if (num_arguments == 0) return; | 574 if (num_arguments == 0) return; |
574 | 575 |
575 var len = TO_UINT32(this.length); | 576 var len = TO_UINT32(this.length); |
576 var start_i = TO_INTEGER(start); | 577 var start_i = TO_INTEGER(start); |
577 | 578 |
578 if (start_i < 0) { | 579 if (start_i < 0) { |
579 start_i += len; | 580 start_i += len; |
580 if (start_i < 0) start_i = 0; | 581 if (start_i < 0) start_i = 0; |
581 } else { | 582 } else { |
582 if (start_i > len) start_i = len; | 583 if (start_i > len) start_i = len; |
583 } | 584 } |
584 | 585 |
585 // SpiderMonkey and KJS treat the case where no delete count is | 586 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is |
586 // given differently from when an undefined delete count is given. | 587 // given differently from when an undefined delete count is given. |
587 // This does not follow ECMA-262, but we do the same for | 588 // This does not follow ECMA-262, but we do the same for |
588 // compatibility. | 589 // compatibility. |
589 var del_count = 0; | 590 var del_count = 0; |
590 if (num_arguments > 1) { | 591 if (num_arguments > 1) { |
591 del_count = TO_INTEGER(delete_count); | 592 del_count = TO_INTEGER(delete_count); |
592 if (del_count < 0) del_count = 0; | 593 if (del_count < 0) del_count = 0; |
593 if (del_count > len - start_i) del_count = len - start_i; | 594 if (del_count > len - start_i) del_count = len - start_i; |
594 } else { | 595 } else { |
595 del_count = len - start_i; | 596 del_count = len - start_i; |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 ArrayIndexOf: 1, | 1146 ArrayIndexOf: 1, |
1146 ArrayLastIndexOf: 1, | 1147 ArrayLastIndexOf: 1, |
1147 ArrayPush: 1, | 1148 ArrayPush: 1, |
1148 ArrayReduce: 1, | 1149 ArrayReduce: 1, |
1149 ArrayReduceRight: 1 | 1150 ArrayReduceRight: 1 |
1150 }); | 1151 }); |
1151 } | 1152 } |
1152 | 1153 |
1153 | 1154 |
1154 SetupArray(); | 1155 SetupArray(); |
OLD | NEW |