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 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 // Either the garbage collector is clearing the cell or we are simply | 1952 // Either the garbage collector is clearing the cell or we are simply |
1953 // initializing the root empty weak cell. | 1953 // initializing the root empty weak cell. |
1954 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT || | 1954 DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT || |
1955 this == GetHeap()->empty_weak_cell()); | 1955 this == GetHeap()->empty_weak_cell()); |
1956 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); | 1956 WRITE_FIELD(this, kValueOffset, Smi::FromInt(0)); |
1957 } | 1957 } |
1958 | 1958 |
1959 | 1959 |
1960 void WeakCell::initialize(HeapObject* val) { | 1960 void WeakCell::initialize(HeapObject* val) { |
1961 WRITE_FIELD(this, kValueOffset, val); | 1961 WRITE_FIELD(this, kValueOffset, val); |
1962 Heap* heap = GetHeap(); | |
1963 // We just have to execute the generational barrier here because we never | 1962 // We just have to execute the generational barrier here because we never |
1964 // mark through a weak cell and collect evacuation candidates when we process | 1963 // mark through a weak cell and collect evacuation candidates when we process |
1965 // all weak cells. | 1964 // all weak cells. |
1966 heap->RecordWrite(this, kValueOffset, val); | 1965 WriteBarrierMode mode = |
| 1966 Page::FromAddress(this->address())->IsFlagSet(Page::BLACK_PAGE) |
| 1967 ? UPDATE_WRITE_BARRIER |
| 1968 : UPDATE_WEAK_WRITE_BARRIER; |
| 1969 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kValueOffset, val, mode); |
1967 } | 1970 } |
1968 | 1971 |
1969 | 1972 |
1970 bool WeakCell::cleared() const { return value() == Smi::FromInt(0); } | 1973 bool WeakCell::cleared() const { return value() == Smi::FromInt(0); } |
1971 | 1974 |
1972 | 1975 |
1973 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); } | 1976 Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); } |
1974 | 1977 |
1975 | 1978 |
1976 void WeakCell::set_next(Object* val, WriteBarrierMode mode) { | 1979 void WeakCell::set_next(Object* val, WriteBarrierMode mode) { |
(...skipping 5809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7786 #undef WRITE_INT64_FIELD | 7789 #undef WRITE_INT64_FIELD |
7787 #undef READ_BYTE_FIELD | 7790 #undef READ_BYTE_FIELD |
7788 #undef WRITE_BYTE_FIELD | 7791 #undef WRITE_BYTE_FIELD |
7789 #undef NOBARRIER_READ_BYTE_FIELD | 7792 #undef NOBARRIER_READ_BYTE_FIELD |
7790 #undef NOBARRIER_WRITE_BYTE_FIELD | 7793 #undef NOBARRIER_WRITE_BYTE_FIELD |
7791 | 7794 |
7792 } // namespace internal | 7795 } // namespace internal |
7793 } // namespace v8 | 7796 } // namespace v8 |
7794 | 7797 |
7795 #endif // V8_OBJECTS_INL_H_ | 7798 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |