Revision: 24353
Author:   [email protected]
Date:     Wed Oct  1 09:16:57 2014 UTC
Log:      Reserve a page at the beginning of the code range on Win64 for SEH

BUG=v8:3597
[email protected]
LOG=n
https://code.google.com/p/v8/source/detail?r=24353

Modified:
 /branches/bleeding_edge/src/globals.h
 /branches/bleeding_edge/src/heap/spaces.cc

=======================================
--- /branches/bleeding_edge/src/globals.h       Mon Sep 29 13:23:27 2014 UTC
+++ /branches/bleeding_edge/src/globals.h       Wed Oct  1 09:16:57 2014 UTC
@@ -147,6 +147,13 @@
 const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF);
 const bool kRequiresCodeRange = true;
 const size_t kMaximalCodeRangeSize = 512 * MB;
+#if V8_OS_WIN
+const size_t kMinimumCodeRangeSize = 2 * MB;
+const size_t kReservedCodeRangePages = 1;
+#else
+const size_t kMinimumCodeRangeSize = 1 * MB;
+const size_t kReservedCodeRangePages = 0;
+#endif
 #else
 const int kPointerSizeLog2 = 2;
 const intptr_t kIntptrSignBit = 0x80000000;
@@ -155,9 +162,13 @@
 // x32 port also requires code range.
 const bool kRequiresCodeRange = true;
 const size_t kMaximalCodeRangeSize = 256 * MB;
+const size_t kMinimumCodeRangeSize = 1 * MB;
+const size_t kReservedCodeRangePages = 0;
 #else
 const bool kRequiresCodeRange = false;
 const size_t kMaximalCodeRangeSize = 0 * MB;
+const size_t kMinimumCodeRangeSize = 0 * MB;
+const size_t kReservedCodeRangePages = 0;
 #endif
 #endif

=======================================
--- /branches/bleeding_edge/src/heap/spaces.cc  Thu Sep 25 07:32:13 2014 UTC
+++ /branches/bleeding_edge/src/heap/spaces.cc  Wed Oct  1 09:16:57 2014 UTC
@@ -109,6 +109,10 @@
       return true;
     }
   }
+
+  if (requested < kMinimumCodeRangeSize) {
+    requested = kMinimumCodeRangeSize;
+  }

   DCHECK(!kRequiresCodeRange || requested <= kMaximalCodeRangeSize);
   code_range_ = new base::VirtualMemory(requested);
@@ -121,14 +125,25 @@

   // We are sure that we have mapped a block of requested addresses.
   DCHECK(code_range_->size() == requested);
-  LOG(isolate_, NewEvent("CodeRange", code_range_->address(), requested));
   Address base = reinterpret_cast<Address>(code_range_->address());
-  Address aligned_base =
-      RoundUp(reinterpret_cast<Address>(code_range_->address()),
-              MemoryChunk::kAlignment);
+
+ // On some platforms, specifically Win64, we need to reserve some pages at
+  // the beginning of an executable space.
+  if (kReservedCodeRangePages) {
+    if (!code_range_->Commit(
+ base, kReservedCodeRangePages * base::OS::CommitPageSize(), true)) {
+      delete code_range_;
+      code_range_ = NULL;
+      return false;
+    }
+    base += kReservedCodeRangePages * base::OS::CommitPageSize();
+  }
+  Address aligned_base = RoundUp(base, MemoryChunk::kAlignment);
   size_t size = code_range_->size() - (aligned_base - base);
   allocation_list_.Add(FreeBlock(aligned_base, size));
   current_allocation_block_index_ = 0;
+
+  LOG(isolate_, NewEvent("CodeRange", code_range_->address(), requested));
   return true;
 }

--
--
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/d/optout.

Reply via email to