[heap] Fix immovable {Code} allocation in no-snap builds.

R=mlippautz@chromium.org
BUG=v8:6792

Change-Id: I4b148b4bcb6e3cb73bc58eaad61d52a14da19a35
Reviewed-on: https://chromium-review.googlesource.com/760739
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49278}
This commit is contained in:
Michael Starzinger 2017-11-09 18:23:01 +01:00 committed by Commit Bot
parent 667555c6b8
commit 62a720354c
3 changed files with 7 additions and 9 deletions

View File

@ -172,8 +172,7 @@ Handle<Code> CodeStub::GetCode() {
}
Activate(code);
DCHECK(!NeedsImmovableCode() || Heap::IsImmovable(code) ||
heap->code_space()->FirstPage()->Contains(code->address()));
DCHECK(!NeedsImmovableCode() || Heap::IsImmovable(code));
return Handle<Code>(code, isolate());
}

View File

@ -1795,7 +1795,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate,
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::STUB, Handle<Object>(), MaybeHandle<HandlerTable>(),
MaybeHandle<ByteArray>(), MaybeHandle<DeoptimizationData>(), true);
CHECK(isolate->heap()->IsImmovable(*code));
CHECK(Heap::IsImmovable(*code));
CHECK_NULL(data->deopt_entry_code_[type]);
data->deopt_entry_code_[type] = *code;

View File

@ -3031,12 +3031,11 @@ AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
Address address = result->address();
MemoryChunk* chunk = MemoryChunk::FromAddress(address);
// Code objects which should stay at a fixed address are allocated either
// in the first page of code space (objects on the first page of each space
// are never moved), in large object space, or (during snapshot creation)
// the containing page is marked as immovable.
if (!Heap::IsImmovable(result) &&
!code_space_->FirstPage()->Contains(address)) {
if (isolate()->serializer_enabled()) {
// in the first page of code space, in large object space, or (during
// snapshot creation) the containing page is marked as immovable.
if (!Heap::IsImmovable(result)) {
if (isolate()->serializer_enabled() ||
code_space_->FirstPage()->Contains(address)) {
chunk->MarkNeverEvacuate();
} else {
// Discard the first code allocation, which was on a page where it could