| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/spaces.h" | 5 #include "src/heap/spaces.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 size_executable_ = 0; | 304 size_executable_ = 0; |
| 305 | 305 |
| 306 code_range_ = new CodeRange(isolate_); | 306 code_range_ = new CodeRange(isolate_); |
| 307 if (!code_range_->SetUp(static_cast<size_t>(code_range_size))) return false; | 307 if (!code_range_->SetUp(static_cast<size_t>(code_range_size))) return false; |
| 308 | 308 |
| 309 return true; | 309 return true; |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 void MemoryAllocator::TearDown() { | 313 void MemoryAllocator::TearDown() { |
| 314 unmapper()->WaitUntilCompleted(); | 314 unmapper()->TearDown(); |
| 315 | |
| 316 MemoryChunk* chunk = nullptr; | |
| 317 while ((chunk = unmapper()->TryGetPooledMemoryChunkSafe()) != nullptr) { | |
| 318 FreeMemory(reinterpret_cast<Address>(chunk), MemoryChunk::kPageSize, | |
| 319 NOT_EXECUTABLE); | |
| 320 } | |
| 321 | 315 |
| 322 // Check that spaces were torn down before MemoryAllocator. | 316 // Check that spaces were torn down before MemoryAllocator. |
| 323 DCHECK_EQ(size_.Value(), 0); | 317 DCHECK_EQ(size_.Value(), 0); |
| 324 // TODO(gc) this will be true again when we fix FreeMemory. | 318 // TODO(gc) this will be true again when we fix FreeMemory. |
| 325 // DCHECK(size_executable_ == 0); | 319 // DCHECK(size_executable_ == 0); |
| 326 capacity_ = 0; | 320 capacity_ = 0; |
| 327 capacity_executable_ = 0; | 321 capacity_executable_ = 0; |
| 328 | 322 |
| 329 if (last_chunk_.IsReserved()) { | 323 if (last_chunk_.IsReserved()) { |
| 330 last_chunk_.Release(); | 324 last_chunk_.Release(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 bool pooled = chunk->IsFlagSet(MemoryChunk::POOLED); | 371 bool pooled = chunk->IsFlagSet(MemoryChunk::POOLED); |
| 378 allocator_->PerformFreeMemory(chunk); | 372 allocator_->PerformFreeMemory(chunk); |
| 379 if (pooled) AddMemoryChunkSafe<kPooled>(chunk); | 373 if (pooled) AddMemoryChunkSafe<kPooled>(chunk); |
| 380 } | 374 } |
| 381 // Non-regular chunks. | 375 // Non-regular chunks. |
| 382 while ((chunk = GetMemoryChunkSafe<kNonRegular>()) != nullptr) { | 376 while ((chunk = GetMemoryChunkSafe<kNonRegular>()) != nullptr) { |
| 383 allocator_->PerformFreeMemory(chunk); | 377 allocator_->PerformFreeMemory(chunk); |
| 384 } | 378 } |
| 385 } | 379 } |
| 386 | 380 |
| 381 void MemoryAllocator::Unmapper::TearDown() { |
| 382 WaitUntilCompleted(); |
| 383 ReconsiderDelayedChunks(); |
| 384 CHECK(delayed_regular_chunks_.empty()); |
| 385 PerformFreeMemoryOnQueuedChunks(); |
| 386 } |
| 387 |
| 387 void MemoryAllocator::Unmapper::ReconsiderDelayedChunks() { | 388 void MemoryAllocator::Unmapper::ReconsiderDelayedChunks() { |
| 388 std::list<MemoryChunk*> delayed_chunks(std::move(delayed_regular_chunks_)); | 389 std::list<MemoryChunk*> delayed_chunks(std::move(delayed_regular_chunks_)); |
| 389 // Move constructed, so the permanent list should be empty. | 390 // Move constructed, so the permanent list should be empty. |
| 390 DCHECK(delayed_regular_chunks_.empty()); | 391 DCHECK(delayed_regular_chunks_.empty()); |
| 391 for (auto it = delayed_chunks.begin(); it != delayed_chunks.end(); ++it) { | 392 for (auto it = delayed_chunks.begin(); it != delayed_chunks.end(); ++it) { |
| 392 AddMemoryChunkSafe<kRegular>(*it); | 393 AddMemoryChunkSafe<kRegular>(*it); |
| 393 } | 394 } |
| 394 } | 395 } |
| 395 | 396 |
| 396 bool MemoryAllocator::CanFreeMemoryChunk(MemoryChunk* chunk) { | 397 bool MemoryAllocator::CanFreeMemoryChunk(MemoryChunk* chunk) { |
| (...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3245 object->ShortPrint(); | 3246 object->ShortPrint(); |
| 3246 PrintF("\n"); | 3247 PrintF("\n"); |
| 3247 } | 3248 } |
| 3248 printf(" --------------------------------------\n"); | 3249 printf(" --------------------------------------\n"); |
| 3249 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3250 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3250 } | 3251 } |
| 3251 | 3252 |
| 3252 #endif // DEBUG | 3253 #endif // DEBUG |
| 3253 } // namespace internal | 3254 } // namespace internal |
| 3254 } // namespace v8 | 3255 } // namespace v8 |
| OLD | NEW |