Chromium Code Reviews| Index: src/spaces.cc |
| =================================================================== |
| --- src/spaces.cc (revision 5792) |
| +++ src/spaces.cc (working copy) |
| @@ -271,6 +271,7 @@ |
| // MemoryAllocator |
| // |
| intptr_t MemoryAllocator::capacity_ = 0; |
| +intptr_t MemoryAllocator::capacity_executable_ = 0; |
| intptr_t MemoryAllocator::size_ = 0; |
| intptr_t MemoryAllocator::size_executable_ = 0; |
| @@ -302,8 +303,10 @@ |
| } |
| -bool MemoryAllocator::Setup(intptr_t capacity) { |
| +bool MemoryAllocator::Setup(intptr_t capacity, intptr_t capacity_executable) { |
| capacity_ = RoundUp(capacity, Page::kPageSize); |
| + capacity_executable_ = RoundUp(capacity_executable, Page::kPageSize); |
| + ASSERT_GE(capacity_, capacity_executable_); |
| // Over-estimate the size of chunks_ array. It assumes the expansion of old |
| // space is always in the unit of a chunk (kChunkSize) except the last |
| @@ -346,6 +349,7 @@ |
| ASSERT(top_ == max_nof_chunks_); // all chunks are free |
| top_ = 0; |
| capacity_ = 0; |
| + capacity_executable_ = 0; |
| size_ = 0; |
| max_nof_chunks_ = 0; |
| } |
| @@ -359,14 +363,21 @@ |
| } |
| void* mem; |
| if (executable == EXECUTABLE && CodeRange::exists()) { |
| + if (size_executable_ + requested > |
| + static_cast<size_t>(capacity_executable_)) { |
| + LOG(StringEvent("MemoryAllocator::AllocateRawMemory", |
| + "V8 Executable Allocation capacity exceeded")); |
|
Mads Ager (chromium)
2010/11/10 08:14:24
Indentation off by one space it seems?
|
| + return NULL; |
| + } |
| mem = CodeRange::AllocateRawMemory(requested, allocated); |
| + size_executable_ += static_cast<int>(*allocated); |
|
Mads Ager (chromium)
2010/11/10 08:23:26
This only get's updated when CodeRange::exists().
|
| + |
| } else { |
| mem = OS::Allocate(requested, allocated, (executable == EXECUTABLE)); |
| } |
| int alloced = static_cast<int>(*allocated); |
| size_ += alloced; |
| - if (executable == EXECUTABLE) size_executable_ += alloced; |
| #ifdef DEBUG |
| ZapBlock(reinterpret_cast<Address>(mem), alloced); |
| #endif |
| @@ -391,6 +402,7 @@ |
| if (executable == EXECUTABLE) size_executable_ -= static_cast<int>(length); |
| ASSERT(size_ >= 0); |
| + ASSERT(size_executable_ >= 0); |
| } |