| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/heap/slots-buffer.h" | 5 #include "src/heap/slots-buffer.h" |
| 6 | 6 |
| 7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
| 8 #include "src/heap/heap.h" | 8 #include "src/heap/heap.h" |
| 9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 bool SlotsBuffer::IsTypedSlot(ObjectSlot slot) { | 14 bool SlotsBuffer::IsTypedSlot(ObjectSlot slot) { |
| 15 return reinterpret_cast<uintptr_t>(slot) < NUMBER_OF_SLOT_TYPES; | 15 return reinterpret_cast<uintptr_t>(slot) < NUMBER_OF_SLOT_TYPES; |
| 16 } | 16 } |
| 17 | 17 |
| 18 | 18 |
| 19 bool SlotsBuffer::AddToSynchronized(SlotsBufferAllocator* allocator, | |
| 20 SlotsBuffer** buffer_address, | |
| 21 base::Mutex* buffer_mutex, SlotType type, | |
| 22 Address addr, AdditionMode mode) { | |
| 23 base::LockGuard<base::Mutex> lock_guard(buffer_mutex); | |
| 24 return AddTo(allocator, buffer_address, type, addr, mode); | |
| 25 } | |
| 26 | |
| 27 | |
| 28 bool SlotsBuffer::AddTo(SlotsBufferAllocator* allocator, | 19 bool SlotsBuffer::AddTo(SlotsBufferAllocator* allocator, |
| 29 SlotsBuffer** buffer_address, SlotType type, | 20 SlotsBuffer** buffer_address, SlotType type, |
| 30 Address addr, AdditionMode mode) { | 21 Address addr, AdditionMode mode) { |
| 31 SlotsBuffer* buffer = *buffer_address; | 22 SlotsBuffer* buffer = *buffer_address; |
| 32 if (buffer == NULL || !buffer->HasSpaceForTypedSlot()) { | 23 if (buffer == NULL || !buffer->HasSpaceForTypedSlot()) { |
| 33 if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { | 24 if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { |
| 34 allocator->DeallocateChain(buffer_address); | 25 allocator->DeallocateChain(buffer_address); |
| 35 return false; | 26 return false; |
| 36 } | 27 } |
| 37 buffer = allocator->AllocateBuffer(buffer); | 28 buffer = allocator->AllocateBuffer(buffer); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 while (buffer != NULL) { | 152 while (buffer != NULL) { |
| 162 SlotsBuffer* next_buffer = buffer->next(); | 153 SlotsBuffer* next_buffer = buffer->next(); |
| 163 DeallocateBuffer(buffer); | 154 DeallocateBuffer(buffer); |
| 164 buffer = next_buffer; | 155 buffer = next_buffer; |
| 165 } | 156 } |
| 166 *buffer_address = NULL; | 157 *buffer_address = NULL; |
| 167 } | 158 } |
| 168 | 159 |
| 169 } // namespace internal | 160 } // namespace internal |
| 170 } // namespace v8 | 161 } // namespace v8 |
| OLD | NEW |