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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (length > 0) { | 295 if (length > 0) { |
296 Heap* heap = from_base->GetHeap(); | 296 Heap* heap = from_base->GetHeap(); |
297 MemsetPointer(Handle<FixedArray>::cast(to_base)->data_start() + start, | 297 MemsetPointer(Handle<FixedArray>::cast(to_base)->data_start() + start, |
298 heap->the_hole_value(), length); | 298 heap->the_hole_value(), length); |
299 } | 299 } |
300 } | 300 } |
301 } | 301 } |
302 ASSERT((copy_size + static_cast<int>(to_start)) <= to_base->length() && | 302 ASSERT((copy_size + static_cast<int>(to_start)) <= to_base->length() && |
303 (copy_size + static_cast<int>(from_start)) <= from_base->length()); | 303 (copy_size + static_cast<int>(from_start)) <= from_base->length()); |
304 if (copy_size == 0) return; | 304 if (copy_size == 0) return; |
| 305 Isolate* isolate = from_base->GetIsolate(); |
305 Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base); | 306 Handle<FixedDoubleArray> from = Handle<FixedDoubleArray>::cast(from_base); |
306 Handle<FixedArray> to = Handle<FixedArray>::cast(to_base); | 307 Handle<FixedArray> to = Handle<FixedArray>::cast(to_base); |
307 for (int i = 0; i < copy_size; ++i) { | 308 for (int i = 0; i < copy_size; ++i) { |
308 HandleScope scope(from_base->GetIsolate()); | 309 HandleScope scope(isolate); |
309 if (IsFastSmiElementsKind(to_kind)) { | 310 if (IsFastSmiElementsKind(to_kind)) { |
310 UNIMPLEMENTED(); | 311 UNIMPLEMENTED(); |
311 } else { | 312 } else { |
312 ASSERT(IsFastObjectElementsKind(to_kind)); | 313 ASSERT(IsFastObjectElementsKind(to_kind)); |
313 Handle<Object> value = from->get_as_handle(i + from_start); | 314 Handle<Object> value = from->get_as_handle(i + from_start); |
314 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER); | 315 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER); |
315 } | 316 } |
316 } | 317 } |
317 } | 318 } |
318 | 319 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 receiver, holder, key, backing_store); | 633 receiver, holder, key, backing_store); |
633 } | 634 } |
634 | 635 |
635 // TODO(ishell): Temporary wrapper until handlified. | 636 // TODO(ishell): Temporary wrapper until handlified. |
636 MUST_USE_RESULT virtual Handle<Object> Get( | 637 MUST_USE_RESULT virtual Handle<Object> Get( |
637 Handle<Object> receiver, | 638 Handle<Object> receiver, |
638 Handle<JSObject> holder, | 639 Handle<JSObject> holder, |
639 uint32_t key, | 640 uint32_t key, |
640 Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE { | 641 Handle<FixedArrayBase> backing_store) V8_FINAL V8_OVERRIDE { |
641 CALL_HEAP_FUNCTION(holder->GetIsolate(), | 642 CALL_HEAP_FUNCTION(holder->GetIsolate(), |
642 Get(*receiver, *holder, key, | 643 Get(*receiver, *holder, key, *backing_store), |
643 backing_store.is_null() | |
644 ? NULL : *backing_store), | |
645 Object); | 644 Object); |
646 } | 645 } |
647 | 646 |
| 647 // TODO(ishell): Temporary wrapper until handlified. |
| 648 MUST_USE_RESULT virtual Handle<Object> Get( |
| 649 Handle<Object> receiver, |
| 650 Handle<JSObject> holder, |
| 651 uint32_t key) V8_FINAL V8_OVERRIDE { |
| 652 CALL_HEAP_FUNCTION(holder->GetIsolate(), |
| 653 Get(*receiver, *holder, key, NULL), |
| 654 Object); |
| 655 } |
| 656 |
648 MUST_USE_RESULT virtual MaybeObject* Get( | 657 MUST_USE_RESULT virtual MaybeObject* Get( |
649 Object* receiver, | 658 Object* receiver, |
650 JSObject* holder, | 659 JSObject* holder, |
651 uint32_t key, | 660 uint32_t key, |
652 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { | 661 FixedArrayBase* backing_store) V8_FINAL V8_OVERRIDE { |
653 if (backing_store == NULL) { | 662 if (backing_store == NULL) { |
654 backing_store = holder->elements(); | 663 backing_store = holder->elements(); |
655 } | 664 } |
656 | 665 |
657 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && | 666 if (!IsExternalArrayElementsKind(ElementsTraits::Kind) && |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 uint32_t from_start, | 789 uint32_t from_start, |
781 Handle<FixedArrayBase> to, | 790 Handle<FixedArrayBase> to, |
782 ElementsKind from_kind, | 791 ElementsKind from_kind, |
783 uint32_t to_start, | 792 uint32_t to_start, |
784 int packed_size, | 793 int packed_size, |
785 int copy_size) { | 794 int copy_size) { |
786 UNREACHABLE(); | 795 UNREACHABLE(); |
787 } | 796 } |
788 | 797 |
789 virtual void CopyElements( | 798 virtual void CopyElements( |
790 Handle<JSObject> from_holder, | 799 Handle<FixedArrayBase> from, |
791 uint32_t from_start, | 800 uint32_t from_start, |
792 ElementsKind from_kind, | 801 ElementsKind from_kind, |
793 Handle<FixedArrayBase> to, | 802 Handle<FixedArrayBase> to, |
794 uint32_t to_start, | 803 uint32_t to_start, |
795 int copy_size, | 804 int copy_size) V8_FINAL V8_OVERRIDE { |
796 Handle<FixedArrayBase> from) V8_FINAL V8_OVERRIDE { | 805 ASSERT(!from.is_null()); |
| 806 ElementsAccessorSubclass::CopyElementsImpl( |
| 807 from, from_start, to, from_kind, to_start, kPackedSizeNotKnown, |
| 808 copy_size); |
| 809 } |
| 810 |
| 811 virtual void CopyElements( |
| 812 JSObject* from_holder, |
| 813 uint32_t from_start, |
| 814 ElementsKind from_kind, |
| 815 Handle<FixedArrayBase> to, |
| 816 uint32_t to_start, |
| 817 int copy_size) V8_FINAL V8_OVERRIDE { |
797 int packed_size = kPackedSizeNotKnown; | 818 int packed_size = kPackedSizeNotKnown; |
798 if (from.is_null()) { | 819 bool is_packed = IsFastPackedElementsKind(from_kind) && |
799 from = handle(from_holder->elements()); | 820 from_holder->IsJSArray(); |
800 } | 821 if (is_packed) { |
801 | 822 packed_size = |
802 if (!from_holder.is_null()) { | 823 Smi::cast(JSArray::cast(from_holder)->length())->value(); |
803 bool is_packed = IsFastPackedElementsKind(from_kind) && | 824 if (copy_size >= 0 && packed_size > copy_size) { |
804 from_holder->IsJSArray(); | 825 packed_size = copy_size; |
805 if (is_packed) { | |
806 packed_size = | |
807 Smi::cast(Handle<JSArray>::cast(from_holder)->length())->value(); | |
808 if (copy_size >= 0 && packed_size > copy_size) { | |
809 packed_size = copy_size; | |
810 } | |
811 } | 826 } |
812 } | 827 } |
| 828 Handle<FixedArrayBase> from(from_holder->elements()); |
813 ElementsAccessorSubclass::CopyElementsImpl( | 829 ElementsAccessorSubclass::CopyElementsImpl( |
814 from, from_start, to, from_kind, to_start, packed_size, copy_size); | 830 from, from_start, to, from_kind, to_start, packed_size, copy_size); |
815 } | 831 } |
816 | 832 |
817 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( | 833 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( |
818 Object* receiver, | 834 Object* receiver, |
819 JSObject* holder, | 835 JSObject* holder, |
820 FixedArray* to, | 836 FixedArray* to, |
821 FixedArrayBase* from) V8_FINAL V8_OVERRIDE { | 837 FixedArrayBase* from) V8_FINAL V8_OVERRIDE { |
822 int len0 = to->length(); | 838 int len0 = to->length(); |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 UNREACHABLE(); | 2053 UNREACHABLE(); |
2038 break; | 2054 break; |
2039 } | 2055 } |
2040 | 2056 |
2041 array->set_elements(*elms); | 2057 array->set_elements(*elms); |
2042 array->set_length(Smi::FromInt(number_of_elements)); | 2058 array->set_length(Smi::FromInt(number_of_elements)); |
2043 return array; | 2059 return array; |
2044 } | 2060 } |
2045 | 2061 |
2046 } } // namespace v8::internal | 2062 } } // namespace v8::internal |
OLD | NEW |