Index: src/platform-linux.cc |
=================================================================== |
--- src/platform-linux.cc (revision 1577) |
+++ src/platform-linux.cc (working copy) |
@@ -238,9 +238,9 @@ |
void* OS::Allocate(const size_t requested, |
size_t* allocated, |
- bool executable) { |
+ bool is_executable) { |
const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); |
- int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); |
+ int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
if (mbase == MAP_FAILED) { |
LOG(StringEvent("OS::Allocate", "mmap failed")); |
@@ -252,12 +252,29 @@ |
} |
-void OS::Free(void* buf, const size_t length) { |
+void OS::Free(void* address, const size_t size) { |
// TODO(1240712): munmap has a return value which is ignored here. |
Søren Thygesen Gjesse
2009/03/24 11:43:55
Move this issue to code.google.com/p/v8.
|
- munmap(buf, length); |
+ munmap(address, size); |
} |
+#ifdef ENABLE_HEAP_PROTECTION |
+ |
+void OS::Protect(void* address, size_t size) { |
+ // TODO(1240712): mprotect has a return value which is ignored here. |
+ mprotect(address, size, PROT_READ); |
+} |
+ |
+ |
+void OS::Unprotect(void* address, size_t size, bool is_executable) { |
+ // TODO(1240712): mprotect has a return value which is ignored here. |
+ int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
+ mprotect(address, size, prot); |
+} |
+ |
+#endif |
+ |
+ |
void OS::Sleep(int milliseconds) { |
unsigned int ms = static_cast<unsigned int>(milliseconds); |
usleep(1000 * ms); |
@@ -271,7 +288,7 @@ |
void OS::DebugBreak() { |
-#if defined (__arm__) || defined(__thumb__) |
+#ifdef ARM |
asm("bkpt 0"); |
#else |
asm("int $3"); |
@@ -422,8 +439,8 @@ |
} |
-bool VirtualMemory::Commit(void* address, size_t size, bool executable) { |
- int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); |
+bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) { |
+ int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
if (MAP_FAILED == mmap(address, size, prot, |
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, |
kMmapFd, kMmapFdOffset)) { |