Correctly setup the freelist of the coderange on Win64
authorjochen <jochen@chromium.org>
Fri, 9 Jan 2015 13:07:29 +0000 (05:07 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 9 Jan 2015 13:07:42 +0000 (13:07 +0000)
Since we have a special guard page at the beginning of the code range on
win64, we need to make sure to adjust the size of the free list
accordingly when creating it.

BUG=chromium:447555
R=hpayer@chromium.org
LOG=y

Review URL: https://codereview.chromium.org/843973002

Cr-Commit-Position: refs/heads/master@{#26012}

src/heap/spaces.cc
test/cctest/test-alloc.cc

index 37a123d..3802e47 100644 (file)
@@ -140,7 +140,8 @@ bool CodeRange::SetUp(size_t requested) {
     base += kReservedCodeRangePages * base::OS::CommitPageSize();
   }
   Address aligned_base = RoundUp(base, MemoryChunk::kAlignment);
-  size_t size = code_range_->size() - (aligned_base - base);
+  size_t size = code_range_->size() - (aligned_base - base) -
+                kReservedCodeRangePages * base::OS::CommitPageSize();
   allocation_list_.Add(FreeBlock(aligned_base, size));
   current_allocation_block_index_ = 0;
 
index 54d516e..2e071ac 100644 (file)
@@ -198,7 +198,8 @@ TEST(CodeRange) {
   const size_t code_range_size = 32*MB;
   CcTest::InitializeVM();
   CodeRange code_range(reinterpret_cast<Isolate*>(CcTest::isolate()));
-  code_range.SetUp(code_range_size);
+  code_range.SetUp(code_range_size +
+                   kReservedCodeRangePages * v8::base::OS::CommitPageSize());
   size_t current_allocated = 0;
   size_t total_allocated = 0;
   List< ::Block> blocks(1000);