Commit 5ed0f2ce authored by jochen@chromium.org's avatar jochen@chromium.org

Reserve a page at the beginning of the code range on Win64 for SEH

BUG=v8:3597
R=svenpanne@chromium.org
LOG=n

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24353 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 259126c0
......@@ -147,6 +147,13 @@ const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000);
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 @@ const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
// 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
......
......@@ -110,6 +110,10 @@ bool CodeRange::SetUp(size_t requested) {
}
}
if (requested < kMinimumCodeRangeSize) {
requested = kMinimumCodeRangeSize;
}
DCHECK(!kRequiresCodeRange || requested <= kMaximalCodeRangeSize);
code_range_ = new base::VirtualMemory(requested);
CHECK(code_range_ != NULL);
......@@ -121,14 +125,25 @@ bool CodeRange::SetUp(size_t requested) {
// 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment