| 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 #ifndef V8_SLOT_SET_H | 5 #ifndef V8_SLOT_SET_H |
| 6 #define V8_SLOT_SET_H | 6 #define V8_SLOT_SET_H |
| 7 | 7 |
| 8 #include <stack> | 8 #include <stack> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 chunk_.SetValue(new Chunk(nullptr, kInitialBufferSize)); | 318 chunk_.SetValue(new Chunk(nullptr, kInitialBufferSize)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 ~TypedSlotSet() { | 321 ~TypedSlotSet() { |
| 322 Chunk* chunk = chunk_.Value(); | 322 Chunk* chunk = chunk_.Value(); |
| 323 while (chunk != nullptr) { | 323 while (chunk != nullptr) { |
| 324 Chunk* next = chunk->next.Value(); | 324 Chunk* next = chunk->next.Value(); |
| 325 delete chunk; | 325 delete chunk; |
| 326 chunk = next; | 326 chunk = next; |
| 327 } | 327 } |
| 328 FreeToBeFreedChunks(); |
| 328 } | 329 } |
| 329 | 330 |
| 330 // The slot offset specifies a slot at address page_start_ + offset. | 331 // The slot offset specifies a slot at address page_start_ + offset. |
| 331 // This method can only be called on the main thread. | 332 // This method can only be called on the main thread. |
| 332 void Insert(SlotType type, uint32_t host_offset, uint32_t offset) { | 333 void Insert(SlotType type, uint32_t host_offset, uint32_t offset) { |
| 333 TypedSlot slot(type, host_offset, offset); | 334 TypedSlot slot(type, host_offset, offset); |
| 334 Chunk* top_chunk = chunk_.Value(); | 335 Chunk* top_chunk = chunk_.Value(); |
| 335 if (!top_chunk) { | 336 if (!top_chunk) { |
| 336 top_chunk = new Chunk(nullptr, kInitialBufferSize); | 337 top_chunk = new Chunk(nullptr, kInitialBufferSize); |
| 337 chunk_.SetValue(top_chunk); | 338 chunk_.SetValue(top_chunk); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 Address page_start_; | 449 Address page_start_; |
| 449 base::AtomicValue<Chunk*> chunk_; | 450 base::AtomicValue<Chunk*> chunk_; |
| 450 base::Mutex to_be_freed_chunks_mutex_; | 451 base::Mutex to_be_freed_chunks_mutex_; |
| 451 std::stack<Chunk*> to_be_freed_chunks_; | 452 std::stack<Chunk*> to_be_freed_chunks_; |
| 452 }; | 453 }; |
| 453 | 454 |
| 454 } // namespace internal | 455 } // namespace internal |
| 455 } // namespace v8 | 456 } // namespace v8 |
| 456 | 457 |
| 457 #endif // V8_SLOT_SET_H | 458 #endif // V8_SLOT_SET_H |
| OLD | NEW |