Chromium Code Reviews| Index: src/spaces.cc |
| diff --git a/src/spaces.cc b/src/spaces.cc |
| index d527c732a36f6cc00c054bf2e92987caa9fe1f15..bb04762b874da0f99d605571b1ae450e130ec7bf 100644 |
| --- a/src/spaces.cc |
| +++ b/src/spaces.cc |
| @@ -228,10 +228,10 @@ Address CodeRange::AllocateRawMemory(const size_t requested_size, |
| } |
| ASSERT(*allocated <= current.size); |
| ASSERT(IsAddressAligned(current.start, MemoryChunk::kAlignment)); |
| - if (!MemoryAllocator::CommitExecutableMemory(code_range_, |
| - current.start, |
| - commit_size, |
| - *allocated)) { |
| + if (!isolate_->memory_allocator()->CommitExecutableMemory(code_range_, |
| + current.start, |
| + commit_size, |
| + *allocated)) { |
| *allocated = 0; |
| return NULL; |
| } |
| @@ -245,7 +245,7 @@ Address CodeRange::AllocateRawMemory(const size_t requested_size, |
| bool CodeRange::CommitRawMemory(Address start, size_t length) { |
| - return code_range_->Commit(start, length, true); |
| + return isolate_->memory_allocator()->CommitMemory(start, length, EXECUTABLE); |
| } |
| @@ -278,7 +278,9 @@ MemoryAllocator::MemoryAllocator(Isolate* isolate) |
| capacity_(0), |
| capacity_executable_(0), |
| size_(0), |
| - size_executable_(0) { |
| + size_executable_(0), |
| + lowest_ever_allocated_(reinterpret_cast<void*>(-1)), |
| + highest_ever_allocated_(reinterpret_cast<void*>(0)) { |
| } |
| @@ -304,6 +306,17 @@ void MemoryAllocator::TearDown() { |
| } |
| +bool MemoryAllocator::CommitMemory(Address base, |
| + size_t size, |
| + Executability executable) { |
| + if (!VirtualMemory::CommitRegion(base, size, executable == EXECUTABLE)) { |
| + return false; |
| + } |
| + UpdateAllocatedSpaceLimits(base, reinterpret_cast<char*>(base) + size); |
|
Michael Starzinger
2013/09/04 15:49:25
No need for a reinterpret_cast here, our Address t
Benedikt Meurer
2013/09/05 08:06:46
Done.
|
| + return true; |
| +} |
| + |
| + |
| void MemoryAllocator::FreeMemory(VirtualMemory* reservation, |
| Executability executable) { |
| // TODO(gc) make code_range part of memory allocator? |
| @@ -383,7 +396,9 @@ Address MemoryAllocator::AllocateAlignedMemory(size_t reserve_size, |
| base = NULL; |
| } |
| } else { |
| - if (!reservation.Commit(base, commit_size, false)) { |
| + if (reservation.Commit(base, commit_size, false)) { |
| + UpdateAllocatedSpaceLimits(base, base + commit_size); |
| + } else { |
| base = NULL; |
| } |
| } |
| @@ -509,7 +524,10 @@ bool MemoryChunk::CommitArea(size_t requested) { |
| Address start = address() + committed_size + guard_size; |
| size_t length = commit_size - committed_size; |
| if (reservation_.IsReserved()) { |
| - if (!reservation_.Commit(start, length, IsFlagSet(IS_EXECUTABLE))) { |
| + Executability executable = IsFlagSet(IS_EXECUTABLE) |
| + ? EXECUTABLE : NOT_EXECUTABLE; |
| + if (!heap()->isolate()->memory_allocator()->CommitMemory( |
| + start, length, executable)) { |
| return false; |
| } |
| } else { |
| @@ -763,7 +781,7 @@ void MemoryAllocator::Free(MemoryChunk* chunk) { |
| bool MemoryAllocator::CommitBlock(Address start, |
| size_t size, |
| Executability executable) { |
| - if (!VirtualMemory::CommitRegion(start, size, executable)) return false; |
| + if (!CommitMemory(start, size, executable)) return false; |
| if (Heap::ShouldZapGarbage()) { |
| ZapBlock(start, size); |
| @@ -899,6 +917,7 @@ bool MemoryAllocator::CommitExecutableMemory(VirtualMemory* vm, |
| return false; |
| } |
| + UpdateAllocatedSpaceLimits(start, start + commit_size); |
| return true; |
| } |