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/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 195 } |
196 current_allocation_block_index_ = 0; | 196 current_allocation_block_index_ = 0; |
197 // Code range is full or too fragmented. | 197 // Code range is full or too fragmented. |
198 return false; | 198 return false; |
199 } | 199 } |
200 | 200 |
201 | 201 |
202 Address CodeRange::AllocateRawMemory(const size_t requested_size, | 202 Address CodeRange::AllocateRawMemory(const size_t requested_size, |
203 const size_t commit_size, | 203 const size_t commit_size, |
204 size_t* allocated) { | 204 size_t* allocated) { |
205 DCHECK(commit_size <= requested_size); | 205 // request_size includes guards while committed_size does not. Make sure |
| 206 // callers know about the invariant. |
| 207 CHECK_LE(commit_size, |
| 208 requested_size - 2 * MemoryAllocator::CodePageGuardSize()); |
206 FreeBlock current; | 209 FreeBlock current; |
207 if (!ReserveBlock(requested_size, ¤t)) { | 210 if (!ReserveBlock(requested_size, ¤t)) { |
208 *allocated = 0; | 211 *allocated = 0; |
209 return NULL; | 212 return NULL; |
210 } | 213 } |
211 *allocated = current.size; | 214 *allocated = current.size; |
212 DCHECK(*allocated <= current.size); | 215 DCHECK(*allocated <= current.size); |
213 DCHECK(IsAddressAligned(current.start, MemoryChunk::kAlignment)); | 216 DCHECK(IsAddressAligned(current.start, MemoryChunk::kAlignment)); |
214 if (!isolate_->memory_allocator()->CommitExecutableMemory( | 217 if (!isolate_->memory_allocator()->CommitExecutableMemory( |
215 code_range_, current.start, commit_size, *allocated)) { | 218 code_range_, current.start, commit_size, *allocated)) { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 // | Reserved but not committed | | 632 // | Reserved but not committed | |
630 // +----------------------------+<- base + chunk_size | 633 // +----------------------------+<- base + chunk_size |
631 // | 634 // |
632 | 635 |
633 if (executable == EXECUTABLE) { | 636 if (executable == EXECUTABLE) { |
634 chunk_size = RoundUp(CodePageAreaStartOffset() + reserve_area_size, | 637 chunk_size = RoundUp(CodePageAreaStartOffset() + reserve_area_size, |
635 base::OS::CommitPageSize()) + | 638 base::OS::CommitPageSize()) + |
636 CodePageGuardSize(); | 639 CodePageGuardSize(); |
637 | 640 |
638 // Check executable memory limit. | 641 // Check executable memory limit. |
639 if (size_executable_ + chunk_size > capacity_executable_) { | 642 if ((size_executable_ + chunk_size) > capacity_executable_) { |
640 LOG(isolate_, StringEvent("MemoryAllocator::AllocateRawMemory", | 643 LOG(isolate_, StringEvent("MemoryAllocator::AllocateRawMemory", |
641 "V8 Executable Allocation capacity exceeded")); | 644 "V8 Executable Allocation capacity exceeded")); |
642 return NULL; | 645 return NULL; |
643 } | 646 } |
644 | 647 |
645 // Size of header (not executable) plus area (executable). | 648 // Size of header (not executable) plus area (executable). |
646 size_t commit_size = RoundUp(CodePageGuardStartOffset() + commit_area_size, | 649 size_t commit_size = RoundUp(CodePageGuardStartOffset() + commit_area_size, |
647 base::OS::CommitPageSize()); | 650 base::OS::CommitPageSize()); |
648 // Allocate executable memory either from code range or from the | 651 // Allocate executable memory either from code range or from the |
649 // OS. | 652 // OS. |
(...skipping 2533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3183 object->ShortPrint(); | 3186 object->ShortPrint(); |
3184 PrintF("\n"); | 3187 PrintF("\n"); |
3185 } | 3188 } |
3186 printf(" --------------------------------------\n"); | 3189 printf(" --------------------------------------\n"); |
3187 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3190 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3188 } | 3191 } |
3189 | 3192 |
3190 #endif // DEBUG | 3193 #endif // DEBUG |
3191 } // namespace internal | 3194 } // namespace internal |
3192 } // namespace v8 | 3195 } // namespace v8 |
OLD | NEW |