| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
| 6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 | 10 |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 // Setup elements object. | 684 // Setup elements object. |
| 685 Node* elements = InnerAllocate(array, elements_offset); | 685 Node* elements = InnerAllocate(array, elements_offset); |
| 686 StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements); | 686 StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements); |
| 687 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map() | 687 Handle<Map> elements_map(is_double ? heap->fixed_double_array_map() |
| 688 : heap->fixed_array_map()); | 688 : heap->fixed_array_map()); |
| 689 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map)); | 689 StoreMapNoWriteBarrier(elements, HeapConstant(elements_map)); |
| 690 StoreObjectFieldNoWriteBarrier( | 690 StoreObjectFieldNoWriteBarrier( |
| 691 elements, FixedArray::kLengthOffset, | 691 elements, FixedArray::kLengthOffset, |
| 692 mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node)); | 692 mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node)); |
| 693 | 693 |
| 694 Node* double_hole = Float64Constant(bit_cast<double>(kHoleNanInt64)); | 694 int const first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; |
| 695 Node* hole = HeapConstant(Handle<HeapObject>(heap->the_hole_value())); | 695 Node* hole = HeapConstant(Handle<HeapObject>(heap->the_hole_value())); |
| 696 Node* double_hole = |
| 697 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32); |
| 698 DCHECK_EQ(kHoleNanLower32, kHoleNanUpper32); |
| 696 if (constant_capacity && capacity <= kElementLoopUnrollThreshold) { | 699 if (constant_capacity && capacity <= kElementLoopUnrollThreshold) { |
| 697 for (int i = 0; i < capacity; ++i) { | 700 for (int i = 0; i < capacity; ++i) { |
| 698 if (is_double) { | 701 if (is_double) { |
| 699 StoreFixedDoubleArrayElement(elements, Int32Constant(i), double_hole); | 702 Node* offset = ElementOffsetFromIndex(Int32Constant(i), kind, mode, |
| 703 first_element_offset); |
| 704 // Don't use doubles to store the hole double, since manipulating the |
| 705 // signaling NaN used for the hole in C++, e.g. with bit_cast, will |
| 706 // change its value on ia32 (the x87 stack is used to return values |
| 707 // and stores to the stack silently clear the signalling bit). |
| 708 // |
| 709 // TODO(danno): When we have a Float32/Float64 wrapper class that |
| 710 // preserves double bits during manipulation, remove this code/change |
| 711 // this to an indexed Float64 store. |
| 712 if (Is64()) { |
| 713 StoreNoWriteBarrier(MachineRepresentation::kWord64, elements, offset, |
| 714 double_hole); |
| 715 } else { |
| 716 StoreNoWriteBarrier(MachineRepresentation::kWord32, elements, offset, |
| 717 double_hole); |
| 718 offset = ElementOffsetFromIndex(Int32Constant(i), kind, mode, |
| 719 first_element_offset + kPointerSize); |
| 720 StoreNoWriteBarrier(MachineRepresentation::kWord32, elements, offset, |
| 721 double_hole); |
| 722 } |
| 700 } else { | 723 } else { |
| 701 StoreFixedArrayElement(elements, Int32Constant(i), hole, | 724 StoreFixedArrayElement(elements, Int32Constant(i), hole, |
| 702 SKIP_WRITE_BARRIER); | 725 SKIP_WRITE_BARRIER); |
| 703 } | 726 } |
| 704 } | 727 } |
| 705 } else { | 728 } else { |
| 706 // TODO(danno): Add a loop for initialization | 729 // TODO(danno): Add a loop for initialization |
| 707 UNIMPLEMENTED(); | 730 UNIMPLEMENTED(); |
| 708 } | 731 } |
| 709 | 732 |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 } | 1572 } |
| 1550 return IntPtrAdd( | 1573 return IntPtrAdd( |
| 1551 Int32Constant(base_size), | 1574 Int32Constant(base_size), |
| 1552 (element_size_shift >= 0) | 1575 (element_size_shift >= 0) |
| 1553 ? WordShl(index_node, IntPtrConstant(element_size_shift)) | 1576 ? WordShl(index_node, IntPtrConstant(element_size_shift)) |
| 1554 : WordShr(index_node, IntPtrConstant(-element_size_shift))); | 1577 : WordShr(index_node, IntPtrConstant(-element_size_shift))); |
| 1555 } | 1578 } |
| 1556 | 1579 |
| 1557 } // namespace internal | 1580 } // namespace internal |
| 1558 } // namespace v8 | 1581 } // namespace v8 |
| OLD | NEW |