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

Unified Diff: src/spaces.cc

Issue 7352007: Add guard pages in front of platform allocations (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
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
« no previous file with comments | « 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 8619)
+++ src/spaces.cc (working copy)
@@ -380,7 +380,14 @@
if (isolate_->code_range()->exists()) {
mem = isolate_->code_range()->AllocateRawMemory(requested, allocated);
} else {
+#ifdef ENABLE_HEAP_PROTECTION
+ mem = OS::Allocate(requested + Page::kPageSize, allocated, true);
+ OS::Guard(mem, Page::kPageSize);
+ *allocated -= Page::kPageSize;
+ mem = static_cast<char*>(mem) + Page::kPageSize;
+#else // ENABLE_HEAP_PROTECTION
mem = OS::Allocate(requested, allocated, true);
+#endif // ENABLE_HEAP_PROTECTION
}
// Update executable memory size.
size_executable_ += static_cast<int>(*allocated);
@@ -407,7 +414,12 @@
if (isolate_->code_range()->contains(static_cast<Address>(mem))) {
isolate_->code_range()->FreeRawMemory(mem, length);
} else {
- OS::Free(mem, length);
+#ifdef ENABLE_HEAP_PROTECTION
+ size_t guardsize = (executable == EXECUTABLE) ? Page::kPageSize : 0;
+ OS::Free(static_cast<char*>(mem) - guardsize, length + guardsize);
+#else // ENABLE_HEAP_PROTECTION
+ OS::Free(static_cast<char*>(mem), length);
+#endif // ENABLE_HEAP_PROTECTION
}
isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(length));
size_ -= static_cast<int>(length);
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698