diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc index 37a123d91d..3802e470bd 100644 --- a/src/heap/spaces.cc +++ b/src/heap/spaces.cc @@ -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; diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc index 54d516e13e..2e071acc73 100644 --- a/test/cctest/test-alloc.cc +++ b/test/cctest/test-alloc.cc @@ -198,7 +198,8 @@ TEST(CodeRange) { const size_t code_range_size = 32*MB; CcTest::InitializeVM(); CodeRange code_range(reinterpret_cast(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);