Commit a5b0a3e2 authored by dusan.milosavljevic's avatar dusan.milosavljevic Committed by Commit bot

MIPS64: Fix memory allocation when code range is used for LO space only.

Allocation must respect requested reserve size, not requested commit area size.

Additionally fix check failures in debug mode for mips64.
After CL: https://codereview.chromium.org/1147503002/
memory for large code objects is allocated from code range,
memory for regular code objects is allocated normally.

TEST=cctest/test-spaces/MemoryChunk
BUG=

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

Cr-Commit-Position: refs/heads/master@{#28995}
parent cfc764f4
......@@ -1443,9 +1443,9 @@ Handle<Code> Factory::NewCode(const CodeDesc& desc,
int obj_size = Code::SizeFor(body_size);
Handle<Code> code = NewCodeRaw(obj_size, immovable);
DCHECK(isolate()->code_range() == NULL ||
!isolate()->code_range()->valid() ||
isolate()->code_range()->contains(code->address()));
DCHECK(isolate()->code_range() == NULL || !isolate()->code_range()->valid() ||
isolate()->code_range()->contains(code->address()) ||
obj_size <= isolate()->heap()->code_space()->AreaSize());
// The code object has not been fully initialized yet. We rely on the
// fact that no allocation will happen from this point on.
......
......@@ -3937,7 +3937,8 @@ AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
Code* code = Code::cast(result);
DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment));
DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() ||
isolate_->code_range()->contains(code->address()));
isolate_->code_range()->contains(code->address()) ||
object_size <= code_space()->AreaSize());
code->set_gc_metadata(Smi::FromInt(0));
code->set_ic_age(global_ic_age_);
return code;
......@@ -3962,7 +3963,8 @@ AllocationResult Heap::CopyCode(Code* code) {
// Relocate the copy.
DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment));
DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() ||
isolate_->code_range()->contains(code->address()));
isolate_->code_range()->contains(code->address()) ||
obj_size <= code_space()->AreaSize());
new_code->Relocate(new_addr - old_addr);
return new_code;
}
......@@ -4008,7 +4010,9 @@ AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
// Relocate the copy.
DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment));
DCHECK(isolate_->code_range() == NULL || !isolate_->code_range()->valid() ||
isolate_->code_range()->contains(code->address()));
isolate_->code_range()->contains(code->address()) ||
new_obj_size <= code_space()->AreaSize());
new_code->Relocate(new_addr - old_addr);
#ifdef VERIFY_HEAP
......
......@@ -362,7 +362,8 @@ void MemoryAllocator::FreeMemory(base::VirtualMemory* reservation,
!isolate_->code_range()->contains(
static_cast<Address>(reservation->address())));
DCHECK(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL ||
!isolate_->code_range()->valid());
!isolate_->code_range()->valid() || size <= Page::kPageSize);
reservation->Release();
}
......@@ -656,7 +657,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size,
// Use code range only for large object space on mips64 to keep address
// range within 256-MB memory region.
if (isolate_->code_range() != NULL && isolate_->code_range()->valid() &&
commit_area_size > CodePageAreaSize()) {
reserve_area_size > CodePageAreaSize()) {
#else
if (isolate_->code_range() != NULL && isolate_->code_range()->valid()) {
#endif
......
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