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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 } else if (!arg1->IsUndefined()) { | 746 } else if (!arg1->IsUndefined()) { |
747 return CallJsBuiltin("ArraySplice", args); | 747 return CallJsBuiltin("ArraySplice", args); |
748 } | 748 } |
749 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0) | 749 int actual_start = (relative_start < 0) ? Max(len + relative_start, 0) |
750 : Min(relative_start, len); | 750 : Min(relative_start, len); |
751 | 751 |
752 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is | 752 // SpiderMonkey, TraceMonkey and JSC treat the case where no delete count is |
753 // given differently from when an undefined delete count is given. | 753 // given differently from when an undefined delete count is given. |
754 // This does not follow ECMA-262, but we do the same for | 754 // This does not follow ECMA-262, but we do the same for |
755 // compatibility. | 755 // compatibility. |
756 int delete_count = len; | 756 int actual_delete_count; |
757 if (n_arguments > 1) { | 757 if (n_arguments != 1) { |
758 Object* arg2 = args[2]; | 758 int value = 0; // ToInteger(undefined) == 0 |
759 if (arg2->IsSmi()) { | 759 if (n_arguments > 1) { |
760 delete_count = Smi::cast(arg2)->value(); | 760 Object* arg2 = args[2]; |
761 } else { | 761 if (arg2->IsSmi()) { |
762 return CallJsBuiltin("ArraySplice", args); | 762 value = Smi::cast(arg2)->value(); |
| 763 } else { |
| 764 return CallJsBuiltin("ArraySplice", args); |
| 765 } |
763 } | 766 } |
| 767 actual_delete_count = Min(Max(value, 0), len - actual_start); |
| 768 } else { |
| 769 ASSERT(len - actual_start >= 0); |
| 770 actual_delete_count = len - actual_start; |
764 } | 771 } |
765 int actual_delete_count = Min(Max(delete_count, 0), len - actual_start); | |
766 | 772 |
767 JSArray* result_array = NULL; | 773 JSArray* result_array = NULL; |
768 if (actual_delete_count == 0) { | 774 if (actual_delete_count == 0) { |
769 Object* result; | 775 Object* result; |
770 { MaybeObject* maybe_result = AllocateEmptyJSArray(); | 776 { MaybeObject* maybe_result = AllocateEmptyJSArray(); |
771 if (!maybe_result->ToObject(&result)) return maybe_result; | 777 if (!maybe_result->ToObject(&result)) return maybe_result; |
772 } | 778 } |
773 result_array = JSArray::cast(result); | 779 result_array = JSArray::cast(result); |
774 } else { | 780 } else { |
775 // Allocate result array. | 781 // Allocate result array. |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 if (entry->contains(pc)) { | 1542 if (entry->contains(pc)) { |
1537 return names_[i]; | 1543 return names_[i]; |
1538 } | 1544 } |
1539 } | 1545 } |
1540 } | 1546 } |
1541 return NULL; | 1547 return NULL; |
1542 } | 1548 } |
1543 | 1549 |
1544 | 1550 |
1545 } } // namespace v8::internal | 1551 } } // namespace v8::internal |
OLD | NEW |