Reviewers: Benedikt Meurer,

Message:
PTAL

Description:
Fix NaCl regression caused by pepper revision 28.

Patch from [email protected].

Prevents use of PROT_EXEC for NaCl builds


Please review this at https://codereview.chromium.org/19729003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/deoptimizer.cc
  M src/platform-linux.cc
  M src/platform-posix.cc


Index: src/deoptimizer.cc
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc
index 5f59fd9ab05584e96fec88e23ed8598ab5a0bc9b..428495027276a34605e137000c0f0380b64a277d 100644
--- a/src/deoptimizer.cc
+++ b/src/deoptimizer.cc
@@ -43,7 +43,13 @@ namespace internal {
 static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) {
   return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(),
                                   OS::CommitPageSize(),
+#if defined(__native_client__)
+  // The Native Client port of V8 uses an interpreter,
+  // so code pages don't need PROT_EXEC.
+                                  NOT_EXECUTABLE,
+#else
                                   EXECUTABLE,
+#endif
                                   NULL);
 }

Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index ace4056d3969a3e8d3b60347adb2178bd6273883..613d2434b9b8dfc8b580fab57c89bb3e35399906 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -594,7 +594,13 @@ void OS::SignalCodeMovingGC() {
   }
   void* addr = mmap(OS::GetRandomMmapAddr(),
                     size,
+#if defined(__native_client__)
+                    // The Native Client port of V8 uses an interpreter,
+                    // so code pages don't need PROT_EXEC.
+                    PROT_READ,
+#else
                     PROT_READ | PROT_EXEC,
+#endif
                     MAP_PRIVATE,
                     fileno(f),
                     0);
@@ -717,7 +723,13 @@ void* VirtualMemory::ReserveRegion(size_t size) {


bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
+#if defined(__native_client__)
+  // The Native Client port of V8 uses an interpreter,
+  // so code pages don't need PROT_EXEC.
+  int prot = PROT_READ | PROT_WRITE;
+#else
   int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
+#endif
   if (MAP_FAILED == mmap(base,
                          size,
                          prot,
Index: src/platform-posix.cc
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index bd8a33fabd13e2ec5d65be929e3c4b1fcd5e5a20..9d3d7695f0955b1f84d0b0310dda815909aec726 100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -84,7 +84,13 @@ intptr_t OS::CommitPageSize() {
 #ifndef __CYGWIN__
 // Get rid of writable permission on code allocations.
 void OS::ProtectCode(void* address, const size_t size) {
+#if defined(__native_client__)
+  // The Native Client port of V8 uses an interpreter, so
+  // code pages don't need PROT_EXEC.
+  mprotect(address, size, PROT_READ);
+#else
   mprotect(address, size, PROT_READ | PROT_EXEC);
+#endif
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to