| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()->TearDown(); | 314 unmapper()->TearDown(); |
| 315 | 315 |
| 316 // Check that spaces were torn down before MemoryAllocator. | 316 // Check that spaces were torn down before MemoryAllocator. |
| 317 DCHECK_EQ(size_.Value(), 0); | 317 DCHECK_EQ(size_.Value(), 0u); |
| 318 // TODO(gc) this will be true again when we fix FreeMemory. | 318 // TODO(gc) this will be true again when we fix FreeMemory. |
| 319 // DCHECK(size_executable_ == 0); | 319 // DCHECK(size_executable_ == 0); |
| 320 capacity_ = 0; | 320 capacity_ = 0; |
| 321 capacity_executable_ = 0; | 321 capacity_executable_ = 0; |
| 322 | 322 |
| 323 if (last_chunk_.IsReserved()) { | 323 if (last_chunk_.IsReserved()) { |
| 324 last_chunk_.Release(); | 324 last_chunk_.Release(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 delete code_range_; | 327 delete code_range_; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 MemoryChunk* next_element = next_chunk(); | 612 MemoryChunk* next_element = next_chunk(); |
| 613 MemoryChunk* prev_element = prev_chunk(); | 613 MemoryChunk* prev_element = prev_chunk(); |
| 614 next_element->set_prev_chunk(prev_element); | 614 next_element->set_prev_chunk(prev_element); |
| 615 prev_element->set_next_chunk(next_element); | 615 prev_element->set_next_chunk(next_element); |
| 616 set_prev_chunk(NULL); | 616 set_prev_chunk(NULL); |
| 617 set_next_chunk(NULL); | 617 set_next_chunk(NULL); |
| 618 } | 618 } |
| 619 | 619 |
| 620 void MemoryAllocator::ShrinkChunk(MemoryChunk* chunk, size_t bytes_to_shrink) { | 620 void MemoryAllocator::ShrinkChunk(MemoryChunk* chunk, size_t bytes_to_shrink) { |
| 621 DCHECK_GE(bytes_to_shrink, static_cast<size_t>(base::OS::CommitPageSize())); | 621 DCHECK_GE(bytes_to_shrink, static_cast<size_t>(base::OS::CommitPageSize())); |
| 622 DCHECK_EQ(0, bytes_to_shrink % base::OS::CommitPageSize()); | 622 DCHECK_EQ(0u, bytes_to_shrink % base::OS::CommitPageSize()); |
| 623 Address free_start = chunk->area_end_ - bytes_to_shrink; | 623 Address free_start = chunk->area_end_ - bytes_to_shrink; |
| 624 // Don't adjust the size of the page. The area is just uncomitted but not | 624 // Don't adjust the size of the page. The area is just uncomitted but not |
| 625 // released. | 625 // released. |
| 626 chunk->area_end_ -= bytes_to_shrink; | 626 chunk->area_end_ -= bytes_to_shrink; |
| 627 UncommitBlock(free_start, bytes_to_shrink); | 627 UncommitBlock(free_start, bytes_to_shrink); |
| 628 if (chunk->IsFlagSet(MemoryChunk::IS_EXECUTABLE)) { | 628 if (chunk->IsFlagSet(MemoryChunk::IS_EXECUTABLE)) { |
| 629 if (chunk->reservation_.IsReserved()) | 629 if (chunk->reservation_.IsReserved()) |
| 630 chunk->reservation_.Guard(chunk->area_end_); | 630 chunk->reservation_.Guard(chunk->area_end_); |
| 631 else | 631 else |
| 632 base::OS::Guard(chunk->area_end_, base::OS::CommitPageSize()); | 632 base::OS::Guard(chunk->area_end_, base::OS::CommitPageSize()); |
| (...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 object->ShortPrint(); | 3232 object->ShortPrint(); |
| 3233 PrintF("\n"); | 3233 PrintF("\n"); |
| 3234 } | 3234 } |
| 3235 printf(" --------------------------------------\n"); | 3235 printf(" --------------------------------------\n"); |
| 3236 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3236 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3237 } | 3237 } |
| 3238 | 3238 |
| 3239 #endif // DEBUG | 3239 #endif // DEBUG |
| 3240 } // namespace internal | 3240 } // namespace internal |
| 3241 } // namespace v8 | 3241 } // namespace v8 |
| OLD | NEW |