Chromium Code Reviews| Index: src/spaces.cc |
| =================================================================== |
| --- src/spaces.cc (revision 8657) |
| +++ src/spaces.cc (working copy) |
| @@ -407,7 +407,8 @@ |
| if (isolate_->code_range()->contains(static_cast<Address>(mem))) { |
| isolate_->code_range()->FreeRawMemory(mem, length); |
| } else { |
| - OS::Free(mem, length); |
| + size_t guardsize = (executable == EXECUTABLE) ? Page::kPageSize : 0; |
| + OS::Free(static_cast<char*>(mem) - guardsize, length + guardsize); |
|
Mads Ager (chromium)
2011/07/17 09:47:53
This looks nasty to me. Doesn't this mean that to
Cris Neckar
2011/07/18 23:55:12
Done.
|
| } |
| isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(length)); |
| size_ -= static_cast<int>(length); |
| @@ -503,6 +504,11 @@ |
| if (chunk == NULL) return Page::FromAddress(NULL); |
| LOG(isolate_, NewEvent("PagedChunk", chunk, chunk_size)); |
| + if (owner->executable() == EXECUTABLE) { |
| + OS::Guard(chunk, Page::kPageSize); |
| + chunk_size -= Page::kPageSize; |
| + chunk = static_cast<Address>(chunk) + Page::kPageSize; |
| + } |
| *allocated_pages = PagesInChunk(static_cast<Address>(chunk), chunk_size); |
| // We may 'lose' a page due to alignment. |
| ASSERT(*allocated_pages >= kPagesPerChunk - 1); |
| @@ -2672,9 +2678,10 @@ |
| Executability executable) { |
| size_t requested = ChunkSizeFor(size_in_bytes); |
| size_t size; |
| + size_t guardsize = (executable == EXECUTABLE) ? Page::kPageSize : 0; |
| Isolate* isolate = Isolate::Current(); |
| void* mem = isolate->memory_allocator()->AllocateRawMemory( |
| - requested, &size, executable); |
| + requested + guardsize, &size, executable); |
| if (mem == NULL) return NULL; |
| // The start of the chunk may be overlayed with a page so we have to |
| @@ -2684,11 +2691,17 @@ |
| LOG(isolate, NewEvent("LargeObjectChunk", mem, size)); |
| if (size < requested) { |
|
Mads Ager (chromium)
2011/07/17 09:47:53
Shouldn't you add guardsize to requested before yo
Cris Neckar
2011/07/18 23:55:12
Done.
|
| isolate->memory_allocator()->FreeRawMemory( |
| - mem, size, executable); |
| + static_cast<Address>(mem) - guardsize, size + guardsize, executable); |
|
Mads Ager (chromium)
2011/07/17 09:47:53
I'm getting confused here. Does this add up? FreeR
Cris Neckar
2011/07/18 23:55:12
Yeah this was a mistake, I had initially planned t
|
| LOG(isolate, DeleteEvent("LargeObjectChunk", mem)); |
| return NULL; |
| } |
| + if (guardsize != 0) { |
| + OS::Guard(mem, guardsize); |
| + size -= guardsize; |
| + mem = static_cast<Address>(mem) + guardsize; |
| + } |
| + |
| ObjectSpace space = (executable == EXECUTABLE) |
| ? kObjectSpaceCodeSpace |
| : kObjectSpaceLoSpace; |