| 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 "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 FreeMemory(reinterpret_cast<Address>(chunk), MemoryChunk::kPageSize, | 326 FreeMemory(reinterpret_cast<Address>(chunk), MemoryChunk::kPageSize, |
| 327 NOT_EXECUTABLE); | 327 NOT_EXECUTABLE); |
| 328 } | 328 } |
| 329 // Check that spaces were torn down before MemoryAllocator. | 329 // Check that spaces were torn down before MemoryAllocator. |
| 330 DCHECK_EQ(size_.Value(), 0); | 330 DCHECK_EQ(size_.Value(), 0); |
| 331 // TODO(gc) this will be true again when we fix FreeMemory. | 331 // TODO(gc) this will be true again when we fix FreeMemory. |
| 332 // DCHECK(size_executable_ == 0); | 332 // DCHECK(size_executable_ == 0); |
| 333 capacity_ = 0; | 333 capacity_ = 0; |
| 334 capacity_executable_ = 0; | 334 capacity_executable_ = 0; |
| 335 | 335 |
| 336 if (last_chunk_.IsReserved()) { |
| 337 last_chunk_.Release(); |
| 338 } |
| 339 |
| 336 delete code_range_; | 340 delete code_range_; |
| 337 code_range_ = nullptr; | 341 code_range_ = nullptr; |
| 338 } | 342 } |
| 339 | 343 |
| 340 bool MemoryAllocator::CommitMemory(Address base, size_t size, | 344 bool MemoryAllocator::CommitMemory(Address base, size_t size, |
| 341 Executability executable) { | 345 Executability executable) { |
| 342 if (!base::VirtualMemory::CommitRegion(base, size, | 346 if (!base::VirtualMemory::CommitRegion(base, size, |
| 343 executable == EXECUTABLE)) { | 347 executable == EXECUTABLE)) { |
| 344 return false; | 348 return false; |
| 345 } | 349 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // treat reserved but not-yet committed memory regions of chunks as allocated. | 677 // treat reserved but not-yet committed memory regions of chunks as allocated. |
| 674 isolate_->counters()->memory_allocated()->Increment( | 678 isolate_->counters()->memory_allocated()->Increment( |
| 675 static_cast<int>(chunk_size)); | 679 static_cast<int>(chunk_size)); |
| 676 | 680 |
| 677 LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size)); | 681 LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size)); |
| 678 if (owner != NULL) { | 682 if (owner != NULL) { |
| 679 ObjectSpace space = static_cast<ObjectSpace>(1 << owner->identity()); | 683 ObjectSpace space = static_cast<ObjectSpace>(1 << owner->identity()); |
| 680 PerformAllocationCallback(space, kAllocationActionAllocate, chunk_size); | 684 PerformAllocationCallback(space, kAllocationActionAllocate, chunk_size); |
| 681 } | 685 } |
| 682 | 686 |
| 687 // We cannot use the last chunk in the address space because we would |
| 688 // overflow when comparing top and limit if this chunk is used for a |
| 689 // linear allocation area. |
| 690 if ((reinterpret_cast<uintptr_t>(base) + chunk_size) == 0u) { |
| 691 CHECK(!last_chunk_.IsReserved()); |
| 692 last_chunk_.TakeControl(&reservation); |
| 693 UncommitBlock(reinterpret_cast<Address>(last_chunk_.address()), |
| 694 last_chunk_.size()); |
| 695 size_.Increment(-static_cast<intptr_t>(chunk_size)); |
| 696 if (executable == EXECUTABLE) { |
| 697 size_executable_.Increment(-static_cast<intptr_t>(chunk_size)); |
| 698 } |
| 699 CHECK(last_chunk_.IsReserved()); |
| 700 return AllocateChunk(reserve_area_size, commit_area_size, executable, |
| 701 owner); |
| 702 } |
| 703 |
| 683 return MemoryChunk::Initialize(heap, base, chunk_size, area_start, area_end, | 704 return MemoryChunk::Initialize(heap, base, chunk_size, area_start, area_end, |
| 684 executable, owner, &reservation); | 705 executable, owner, &reservation); |
| 685 } | 706 } |
| 686 | 707 |
| 687 | 708 |
| 688 void Page::ResetFreeListStatistics() { | 709 void Page::ResetFreeListStatistics() { |
| 689 wasted_memory_ = 0; | 710 wasted_memory_ = 0; |
| 690 available_in_free_list_ = 0; | 711 available_in_free_list_ = 0; |
| 691 } | 712 } |
| 692 | 713 |
| (...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3127 object->ShortPrint(); | 3148 object->ShortPrint(); |
| 3128 PrintF("\n"); | 3149 PrintF("\n"); |
| 3129 } | 3150 } |
| 3130 printf(" --------------------------------------\n"); | 3151 printf(" --------------------------------------\n"); |
| 3131 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3152 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3132 } | 3153 } |
| 3133 | 3154 |
| 3134 #endif // DEBUG | 3155 #endif // DEBUG |
| 3135 } // namespace internal | 3156 } // namespace internal |
| 3136 } // namespace v8 | 3157 } // namespace v8 |
| OLD | NEW |