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/v8.h" | 5 #include "src/v8.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.h" | 9 #include "src/full-codegen.h" |
10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 if (executable == EXECUTABLE) { | 356 if (executable == EXECUTABLE) { |
357 DCHECK(size_executable_ >= size); | 357 DCHECK(size_executable_ >= size); |
358 size_executable_ -= size; | 358 size_executable_ -= size; |
359 } | 359 } |
360 // Code which is part of the code-range does not have its own VirtualMemory. | 360 // Code which is part of the code-range does not have its own VirtualMemory. |
361 DCHECK(isolate_->code_range() == NULL || | 361 DCHECK(isolate_->code_range() == NULL || |
362 !isolate_->code_range()->contains( | 362 !isolate_->code_range()->contains( |
363 static_cast<Address>(reservation->address()))); | 363 static_cast<Address>(reservation->address()))); |
364 DCHECK(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL || | 364 DCHECK(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL || |
365 !isolate_->code_range()->valid()); | 365 !isolate_->code_range()->valid() || size <= Page::kPageSize); |
| 366 |
366 reservation->Release(); | 367 reservation->Release(); |
367 } | 368 } |
368 | 369 |
369 | 370 |
370 void MemoryAllocator::FreeMemory(Address base, size_t size, | 371 void MemoryAllocator::FreeMemory(Address base, size_t size, |
371 Executability executable) { | 372 Executability executable) { |
372 // TODO(gc) make code_range part of memory allocator? | 373 // TODO(gc) make code_range part of memory allocator? |
373 DCHECK(size_ >= size); | 374 DCHECK(size_ >= size); |
374 size_ -= size; | 375 size_ -= size; |
375 | 376 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 650 |
650 // Size of header (not executable) plus area (executable). | 651 // Size of header (not executable) plus area (executable). |
651 size_t commit_size = RoundUp(CodePageGuardStartOffset() + commit_area_size, | 652 size_t commit_size = RoundUp(CodePageGuardStartOffset() + commit_area_size, |
652 base::OS::CommitPageSize()); | 653 base::OS::CommitPageSize()); |
653 // Allocate executable memory either from code range or from the | 654 // Allocate executable memory either from code range or from the |
654 // OS. | 655 // OS. |
655 #ifdef V8_TARGET_ARCH_MIPS64 | 656 #ifdef V8_TARGET_ARCH_MIPS64 |
656 // Use code range only for large object space on mips64 to keep address | 657 // Use code range only for large object space on mips64 to keep address |
657 // range within 256-MB memory region. | 658 // range within 256-MB memory region. |
658 if (isolate_->code_range() != NULL && isolate_->code_range()->valid() && | 659 if (isolate_->code_range() != NULL && isolate_->code_range()->valid() && |
659 commit_area_size > CodePageAreaSize()) { | 660 reserve_area_size > CodePageAreaSize()) { |
660 #else | 661 #else |
661 if (isolate_->code_range() != NULL && isolate_->code_range()->valid()) { | 662 if (isolate_->code_range() != NULL && isolate_->code_range()->valid()) { |
662 #endif | 663 #endif |
663 base = isolate_->code_range()->AllocateRawMemory(chunk_size, commit_size, | 664 base = isolate_->code_range()->AllocateRawMemory(chunk_size, commit_size, |
664 &chunk_size); | 665 &chunk_size); |
665 DCHECK( | 666 DCHECK( |
666 IsAligned(reinterpret_cast<intptr_t>(base), MemoryChunk::kAlignment)); | 667 IsAligned(reinterpret_cast<intptr_t>(base), MemoryChunk::kAlignment)); |
667 if (base == NULL) return NULL; | 668 if (base == NULL) return NULL; |
668 size_ += chunk_size; | 669 size_ += chunk_size; |
669 // Update executable memory size. | 670 // Update executable memory size. |
(...skipping 2463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3133 object->ShortPrint(); | 3134 object->ShortPrint(); |
3134 PrintF("\n"); | 3135 PrintF("\n"); |
3135 } | 3136 } |
3136 printf(" --------------------------------------\n"); | 3137 printf(" --------------------------------------\n"); |
3137 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3138 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3138 } | 3139 } |
3139 | 3140 |
3140 #endif // DEBUG | 3141 #endif // DEBUG |
3141 } // namespace internal | 3142 } // namespace internal |
3142 } // namespace v8 | 3143 } // namespace v8 |
OLD | NEW |