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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 ElementsKind elements_kind = from_holder->GetElementsKind(); | 689 ElementsKind elements_kind = from_holder->GetElementsKind(); |
690 bool is_packed = IsFastPackedElementsKind(elements_kind) && | 690 bool is_packed = IsFastPackedElementsKind(elements_kind) && |
691 from_holder->IsJSArray(); | 691 from_holder->IsJSArray(); |
692 if (is_packed) { | 692 if (is_packed) { |
693 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value(); | 693 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value(); |
694 if (copy_size >= 0 && packed_size > copy_size) { | 694 if (copy_size >= 0 && packed_size > copy_size) { |
695 packed_size = copy_size; | 695 packed_size = copy_size; |
696 } | 696 } |
697 } | 697 } |
698 } | 698 } |
699 if (from->length() == 0) { | 699 if (from->length() == 0 || copy_size == 0) { |
700 return from; | 700 return from; |
701 } | 701 } |
702 return ElementsAccessorSubclass::CopyElementsImpl( | 702 return ElementsAccessorSubclass::CopyElementsImpl( |
703 from, from_start, to, to_kind, to_start, packed_size, copy_size); | 703 from, from_start, to, to_kind, to_start, packed_size, copy_size); |
704 } | 704 } |
705 | 705 |
706 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( | 706 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( |
707 Object* receiver, | 707 Object* receiver, |
708 JSObject* holder, | 708 JSObject* holder, |
709 FixedArray* to, | 709 FixedArray* to, |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1858 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1859 new_backing_store->set(0, length); | 1859 new_backing_store->set(0, length); |
1860 { MaybeObject* result = array->SetContent(new_backing_store); | 1860 { MaybeObject* result = array->SetContent(new_backing_store); |
1861 if (result->IsFailure()) return result; | 1861 if (result->IsFailure()) return result; |
1862 } | 1862 } |
1863 return array; | 1863 return array; |
1864 } | 1864 } |
1865 | 1865 |
1866 | 1866 |
1867 } } // namespace v8::internal | 1867 } } // namespace v8::internal |
OLD | NEW |