Reviewers: Hannes Payer, ulan, Erik Corry Chromium.org, paul.l..., Jakob,

Description:
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=

Please review this at https://codereview.chromium.org/1172333002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+16, -1 lines):
  M src/factory.cc
  M src/heap/heap.cc
  M src/heap/spaces.cc


Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index a16e6fba05edbc7c63e16b54ca3d541531d85c43..7909e81810cac43069c90cba6644a6a79711a459 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1436,9 +1436,12 @@ Handle<Code> Factory::NewCode(const CodeDesc& desc,
   int obj_size = Code::SizeFor(body_size);

   Handle<Code> code = NewCodeRaw(obj_size, immovable);
+#ifndef V8_TARGET_ARCH_MIPS64
+  // Check is not valid on mips64.
   DCHECK(isolate()->code_range() == NULL ||
          !isolate()->code_range()->valid() ||
          isolate()->code_range()->contains(code->address()));
+#endif

   // The code object has not been fully initialized yet.  We rely on the
   // fact that no allocation will happen from this point on.
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 456fc34fc8cf8601d5902937d3451cc8a0205a58..bbd8cfd2f8cc434f498e17b39051e0a5dd19f255 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3846,8 +3846,11 @@ AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
   result->set_map_no_write_barrier(code_map());
   Code* code = Code::cast(result);
   DCHECK(IsAligned(bit_cast<intptr_t>(code->address()), kCodeAlignment));
+#ifndef V8_TARGET_ARCH_MIPS64
+  // Check is not valid on mips64.
DCHECK(isolate_->code_range() == NULL | | !isolate_->code_range()->valid() ||
          isolate_->code_range()->contains(code->address()));
+#endif
   code->set_gc_metadata(Smi::FromInt(0));
   code->set_ic_age(global_ic_age_);
   return code;
@@ -3871,8 +3874,11 @@ AllocationResult Heap::CopyCode(Code* code) {

   // Relocate the copy.
DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment));
+#ifndef V8_TARGET_ARCH_MIPS64
+  // Check is not valid on mips64.
DCHECK(isolate_->code_range() == NULL | | !isolate_->code_range()->valid() ||
          isolate_->code_range()->contains(code->address()));
+#endif
   new_code->Relocate(new_addr - old_addr);
   return new_code;
 }
@@ -3917,8 +3923,11 @@ AllocationResult Heap::CopyCode(Code* code, Vector<byte> reloc_info) {

   // Relocate the copy.
DCHECK(IsAligned(bit_cast<intptr_t>(new_code->address()), kCodeAlignment));
+#ifndef V8_TARGET_ARCH_MIPS64
+  // Check is not valid on mips64.
DCHECK(isolate_->code_range() == NULL | | !isolate_->code_range()->valid() ||
          isolate_->code_range()->contains(code->address()));
+#endif
   new_code->Relocate(new_addr - old_addr);

 #ifdef VERIFY_HEAP
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index c5f1a556f8469a9abbf676af206e2f118b6fd7be..f79152c47a21959280af38d9f342bcc1c192dfcc 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -361,8 +361,11 @@ void MemoryAllocator::FreeMemory(base::VirtualMemory* reservation,
   DCHECK(isolate_->code_range() == NULL ||
          !isolate_->code_range()->contains(
              static_cast<Address>(reservation->address())));
+#ifndef V8_TARGET_ARCH_MIPS64
+  // Check is not valid on mips64.
   DCHECK(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL ||
          !isolate_->code_range()->valid());
+#endif
   reservation->Release();
 }

@@ -656,7 +659,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


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to