Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1631)

Unified Diff: src/spaces.cc

Issue 7379004: Add guard pages in front of platform allocations (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/spaces.h ('K') | « src/spaces.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.cc
===================================================================
--- src/spaces.cc (revision 8657)
+++ src/spaces.cc (working copy)
@@ -380,7 +380,10 @@
if (isolate_->code_range()->exists()) {
mem = isolate_->code_range()->AllocateRawMemory(requested, allocated);
} else {
- mem = OS::Allocate(requested, allocated, true);
+ mem = OS::Allocate(requested + Page::kPageSize, allocated, true);
+ OS::Guard(mem, Page::kPageSize);
Vyacheslav Egorov (Chromium) 2011/07/15 11:59:14 You have decreased kPagesPerChunk for all spaces b
Cris Neckar 2011/07/15 18:51:29 Done.
+ *allocated -= Page::kPageSize;
+ mem = static_cast<char*>(mem) + Page::kPageSize;
Vyacheslav Egorov (Chromium) 2011/07/15 11:59:14 we use Address type instead of char* in such cases
Cris Neckar 2011/07/15 18:51:29 Done.
}
// Update executable memory size.
size_executable_ += static_cast<int>(*allocated);
@@ -407,7 +410,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);
Vyacheslav Egorov (Chromium) 2011/07/15 11:59:14 we use Address type instead of char* in such cases
Cris Neckar 2011/07/15 18:51:29 Done.
}
isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(length));
size_ -= static_cast<int>(length);
« src/spaces.h ('K') | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698