| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2413 map() != GetHeap()->fixed_array_map()); | 2413 map() != GetHeap()->fixed_array_map()); |
| 2414 int offset = kHeaderSize + index * kDoubleSize; | 2414 int offset = kHeaderSize + index * kDoubleSize; |
| 2415 if (std::isnan(value)) { | 2415 if (std::isnan(value)) { |
| 2416 WRITE_DOUBLE_FIELD(this, offset, std::numeric_limits<double>::quiet_NaN()); | 2416 WRITE_DOUBLE_FIELD(this, offset, std::numeric_limits<double>::quiet_NaN()); |
| 2417 } else { | 2417 } else { |
| 2418 WRITE_DOUBLE_FIELD(this, offset, value); | 2418 WRITE_DOUBLE_FIELD(this, offset, value); |
| 2419 } | 2419 } |
| 2420 DCHECK(!is_the_hole(index)); | 2420 DCHECK(!is_the_hole(index)); |
| 2421 } | 2421 } |
| 2422 | 2422 |
| 2423 void FixedDoubleArray::set_the_hole(Isolate* isolate, int index) { |
| 2424 set_the_hole(index); |
| 2425 } |
| 2423 | 2426 |
| 2424 void FixedDoubleArray::set_the_hole(int index) { | 2427 void FixedDoubleArray::set_the_hole(int index) { |
| 2425 DCHECK(map() != GetHeap()->fixed_cow_array_map() && | 2428 DCHECK(map() != GetHeap()->fixed_cow_array_map() && |
| 2426 map() != GetHeap()->fixed_array_map()); | 2429 map() != GetHeap()->fixed_array_map()); |
| 2427 int offset = kHeaderSize + index * kDoubleSize; | 2430 int offset = kHeaderSize + index * kDoubleSize; |
| 2428 WRITE_UINT64_FIELD(this, offset, kHoleNanInt64); | 2431 WRITE_UINT64_FIELD(this, offset, kHoleNanInt64); |
| 2429 } | 2432 } |
| 2430 | 2433 |
| 2431 bool FixedDoubleArray::is_the_hole(Isolate* isolate, int index) { | 2434 bool FixedDoubleArray::is_the_hole(Isolate* isolate, int index) { |
| 2432 return is_the_hole(index); | 2435 return is_the_hole(index); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 if (IsHeapNumber()) return kDoubleUnaligned; | 2593 if (IsHeapNumber()) return kDoubleUnaligned; |
| 2591 if (IsSimd128Value()) return kSimd128Unaligned; | 2594 if (IsSimd128Value()) return kSimd128Unaligned; |
| 2592 #endif // V8_HOST_ARCH_32_BIT | 2595 #endif // V8_HOST_ARCH_32_BIT |
| 2593 return kWordAligned; | 2596 return kWordAligned; |
| 2594 } | 2597 } |
| 2595 | 2598 |
| 2596 | 2599 |
| 2597 void FixedArray::set(int index, | 2600 void FixedArray::set(int index, |
| 2598 Object* value, | 2601 Object* value, |
| 2599 WriteBarrierMode mode) { | 2602 WriteBarrierMode mode) { |
| 2600 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2603 DCHECK_NE(map(), GetHeap()->fixed_cow_array_map()); |
| 2601 DCHECK(index >= 0 && index < this->length()); | 2604 DCHECK_GE(index, 0); |
| 2605 DCHECK_LT(index, this->length()); |
| 2602 int offset = kHeaderSize + index * kPointerSize; | 2606 int offset = kHeaderSize + index * kPointerSize; |
| 2603 WRITE_FIELD(this, offset, value); | 2607 WRITE_FIELD(this, offset, value); |
| 2604 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 2608 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
| 2605 } | 2609 } |
| 2606 | 2610 |
| 2607 | 2611 |
| 2608 void FixedArray::NoWriteBarrierSet(FixedArray* array, | 2612 void FixedArray::NoWriteBarrierSet(FixedArray* array, |
| 2609 int index, | 2613 int index, |
| 2610 Object* value) { | 2614 Object* value) { |
| 2611 DCHECK(array->map() != array->GetHeap()->fixed_cow_array_map()); | 2615 DCHECK_NE(array->map(), array->GetHeap()->fixed_cow_array_map()); |
| 2612 DCHECK(index >= 0 && index < array->length()); | 2616 DCHECK_GE(index, 0); |
| 2617 DCHECK_LT(index, array->length()); |
| 2613 DCHECK(!array->GetHeap()->InNewSpace(value)); | 2618 DCHECK(!array->GetHeap()->InNewSpace(value)); |
| 2614 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); | 2619 WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value); |
| 2615 } | 2620 } |
| 2616 | 2621 |
| 2617 | |
| 2618 void FixedArray::set_undefined(int index) { | 2622 void FixedArray::set_undefined(int index) { |
| 2619 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2623 set_undefined(GetIsolate(), index); |
| 2620 DCHECK(index >= 0 && index < this->length()); | |
| 2621 DCHECK(!GetHeap()->InNewSpace(GetHeap()->undefined_value())); | |
| 2622 WRITE_FIELD(this, | |
| 2623 kHeaderSize + index * kPointerSize, | |
| 2624 GetHeap()->undefined_value()); | |
| 2625 } | 2624 } |
| 2626 | 2625 |
| 2627 | 2626 void FixedArray::set_undefined(Isolate* isolate, int index) { |
| 2628 void FixedArray::set_null(int index) { | 2627 FixedArray::NoWriteBarrierSet(this, index, |
| 2629 DCHECK(index >= 0 && index < this->length()); | 2628 isolate->heap()->undefined_value()); |
| 2630 DCHECK(!GetHeap()->InNewSpace(GetHeap()->null_value())); | |
| 2631 WRITE_FIELD(this, | |
| 2632 kHeaderSize + index * kPointerSize, | |
| 2633 GetHeap()->null_value()); | |
| 2634 } | 2629 } |
| 2635 | 2630 |
| 2631 void FixedArray::set_null(int index) { set_null(GetIsolate(), index); } |
| 2636 | 2632 |
| 2637 void FixedArray::set_the_hole(int index) { | 2633 void FixedArray::set_null(Isolate* isolate, int index) { |
| 2638 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2634 FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->null_value()); |
| 2639 DCHECK(index >= 0 && index < this->length()); | |
| 2640 DCHECK(!GetHeap()->InNewSpace(GetHeap()->the_hole_value())); | |
| 2641 WRITE_FIELD(this, | |
| 2642 kHeaderSize + index * kPointerSize, | |
| 2643 GetHeap()->the_hole_value()); | |
| 2644 } | 2635 } |
| 2645 | 2636 |
| 2637 void FixedArray::set_the_hole(int index) { set_the_hole(GetIsolate(), index); } |
| 2638 |
| 2639 void FixedArray::set_the_hole(Isolate* isolate, int index) { |
| 2640 FixedArray::NoWriteBarrierSet(this, index, isolate->heap()->the_hole_value()); |
| 2641 } |
| 2646 | 2642 |
| 2647 void FixedArray::FillWithHoles(int from, int to) { | 2643 void FixedArray::FillWithHoles(int from, int to) { |
| 2644 Isolate* isolate = GetIsolate(); |
| 2648 for (int i = from; i < to; i++) { | 2645 for (int i = from; i < to; i++) { |
| 2649 set_the_hole(i); | 2646 set_the_hole(isolate, i); |
| 2650 } | 2647 } |
| 2651 } | 2648 } |
| 2652 | 2649 |
| 2653 | 2650 |
| 2654 Object** FixedArray::data_start() { | 2651 Object** FixedArray::data_start() { |
| 2655 return HeapObject::RawField(this, kHeaderSize); | 2652 return HeapObject::RawField(this, kHeaderSize); |
| 2656 } | 2653 } |
| 2657 | 2654 |
| 2658 | 2655 |
| 2659 Object** FixedArray::RawFieldOfElementAt(int index) { | 2656 Object** FixedArray::RawFieldOfElementAt(int index) { |
| (...skipping 5784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8444 #undef WRITE_INT64_FIELD | 8441 #undef WRITE_INT64_FIELD |
| 8445 #undef READ_BYTE_FIELD | 8442 #undef READ_BYTE_FIELD |
| 8446 #undef WRITE_BYTE_FIELD | 8443 #undef WRITE_BYTE_FIELD |
| 8447 #undef NOBARRIER_READ_BYTE_FIELD | 8444 #undef NOBARRIER_READ_BYTE_FIELD |
| 8448 #undef NOBARRIER_WRITE_BYTE_FIELD | 8445 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8449 | 8446 |
| 8450 } // namespace internal | 8447 } // namespace internal |
| 8451 } // namespace v8 | 8448 } // namespace v8 |
| 8452 | 8449 |
| 8453 #endif // V8_OBJECTS_INL_H_ | 8450 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |