Reviewers: danno, Sven Panne,

Message:
PPC opt 2, does not overlap with ppc directory update so we can review in
parallel

Description:
Contribution of PowerPC port (continuation of 422063005) - PPC opt 2

Contribution of PowerPC port (continuation of 422063005, 817143002,
866843003, and 901083004. The bulk of the changes are to remove some
hard coded assumptions about heap page size within existing tests.
The remaining change is to use a larger heap page size for PPC linux
as this provides a performance benefit due to the larger memory page size.

        modified:   src/base/build_config.h
        modified:   src/heap/heap.cc
        modified:   test/cctest/test-alloc.cc
        modified:   test/cctest/test-constantpool.cc
        modified:   test/cctest/test-heap.cc
        modified:   test/cctest/test-spaces.cc
        modified:   test/cctest/test-weakmaps.cc
        modified:   test/cctest/test-weaksets.cc

[email protected], [email protected]

BUG=

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

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

Affected files (+44, -23 lines):
  M src/base/build_config.h
  M src/heap/heap.cc
  M test/cctest/test-alloc.cc
  M test/cctest/test-constantpool.cc
  M test/cctest/test-heap.cc
  M test/cctest/test-spaces.cc
  M test/cctest/test-weakmaps.cc
  M test/cctest/test-weaksets.cc


Index: src/base/build_config.h
diff --git a/src/base/build_config.h b/src/base/build_config.h
index 661bf80e6e579311841ff27aa76ba31b3b49ebbd..485364fdc2f23a6c44c6c16fc1676e78200e5a8b 100644
--- a/src/base/build_config.h
+++ b/src/base/build_config.h
@@ -177,6 +177,11 @@

// Number of bits to represent the page size for paged spaces. The value of 20
 // gives 1Mb bytes per page.
+#if V8_TARGET_ARCH_PPC && V8_OS_LINUX
+// Bump up for Power Linux due to larger (64K) page size.
+const int kPageSizeBits = 22;
+#else
 const int kPageSizeBits = 20;
+#endif

 #endif  // V8_BASE_BUILD_CONFIG_H_
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index a67bf050b2ee2aa6c677aff8d1cd308d05f654ea..1ebd7611dd1b8225589d471668f1782e3b3bb9b1 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -151,7 +151,7 @@ Heap::Heap()
 #endif

   // Ensure old_generation_size_ is a multiple of kPageSize.
-  DCHECK(MB >= Page::kPageSize);
+  DCHECK((max_old_generation_size_ & (Page::kPageSize - 1)) == 0);

   memset(roots_, 0, sizeof(roots_[0]) * kRootListLength);
   set_native_contexts_list(NULL);
@@ -5189,6 +5189,13 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size, max_executable_size_ = static_cast<intptr_t>(FLAG_max_executable_size) * MB;
   }

+  if (Page::kPageSize > MB) {
+    max_semi_space_size_ = ROUND_UP(max_semi_space_size_, Page::kPageSize);
+    max_old_generation_size_ =
+        ROUND_UP(max_old_generation_size_, Page::kPageSize);
+    max_executable_size_ = ROUND_UP(max_executable_size_, Page::kPageSize);
+  }
+
   if (FLAG_stress_compaction) {
     // This will cause more frequent GCs when stressing.
     max_semi_space_size_ = Page::kPageSize;
@@ -5213,12 +5220,6 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
     reserved_semispace_size_ = max_semi_space_size_;
   }

-  // The max executable size must be less than or equal to the max old
-  // generation size.
-  if (max_executable_size_ > max_old_generation_size_) {
-    max_executable_size_ = max_old_generation_size_;
-  }
-
// The new space size must be a power of two to support single-bit testing
   // for containment.
   max_semi_space_size_ =
@@ -5237,7 +5238,8 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
             max_semi_space_size_ / MB);
       }
     } else {
-      initial_semispace_size_ = initial_semispace_size;
+      initial_semispace_size_ =
+          ROUND_UP(initial_semispace_size, Page::kPageSize);
     }
   }

@@ -5262,7 +5264,7 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
             max_semi_space_size_ / MB);
       }
     } else {
-      target_semispace_size_ = target_semispace_size;
+ target_semispace_size_ = ROUND_UP(target_semispace_size, Page::kPageSize);
     }
   }

@@ -5278,6 +5280,12 @@ bool Heap::ConfigureHeap(int max_semi_space_size, int max_old_space_size,
       Max(static_cast<intptr_t>(paged_space_count * Page::kPageSize),
           max_old_generation_size_);

+  // The max executable size must be less than or equal to the max old
+  // generation size.
+  if (max_executable_size_ > max_old_generation_size_) {
+    max_executable_size_ = max_old_generation_size_;
+  }
+
   if (FLAG_initial_old_space_size > 0) {
     initial_old_generation_size_ = FLAG_initial_old_space_size * MB;
   } else {
Index: test/cctest/test-alloc.cc
diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc
index 79ba4a486e421aa8eb0832d5479324c325c160ee..0ec99346445d3612f9369675db1ea00744c52985 100644
--- a/test/cctest/test-alloc.cc
+++ b/test/cctest/test-alloc.cc
@@ -63,7 +63,7 @@ static AllocationResult AllocateAfterFailures() {
   heap->AllocateFixedArray(10000, TENURED).ToObjectChecked();

   // Large object space.
-  static const int kLargeObjectSpaceFillerLength = 300000;
+ static const int kLargeObjectSpaceFillerLength = 3 * (Page::kPageSize / 10);
   static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor(
       kLargeObjectSpaceFillerLength);
DCHECK(kLargeObjectSpaceFillerSize > heap->old_pointer_space()->AreaSize());
@@ -210,7 +210,7 @@ TEST(CodeRange) {
       // Geometrically distributed sizes, greater than
// Page::kMaxRegularHeapObjectSize (which is greater than code page area). // TODO(gc): instead of using 3 use some contant based on code_range_size
-      // kMaxHeapObjectSize.
+      // kMaxRegularHeapObjectSize.
       size_t requested =
           (Page::kMaxRegularHeapObjectSize << (Pseudorandom() % 3)) +
           Pseudorandom() % 5000 + 1;
Index: test/cctest/test-constantpool.cc
diff --git a/test/cctest/test-constantpool.cc b/test/cctest/test-constantpool.cc index 453657609eb1532b1a2714e5541c5467e0b9747f..8b9b2cf73a6cb1d640871efcbdc51beeca40af83 100644
--- a/test/cctest/test-constantpool.cc
+++ b/test/cctest/test-constantpool.cc
@@ -284,8 +284,9 @@ TEST(ConstantPoolCompacting) {
   Page* first_page = heap->old_data_space()->anchor()->next_page();
   {
     HandleScope scope(isolate);
+    int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB;
     Handle<HeapObject> temp =
-        factory->NewFixedDoubleArray(900 * KB / kDoubleSize, TENURED);
+ factory->NewFixedDoubleArray(dummy_array_size / kDoubleSize, TENURED);
     CHECK(heap->InOldDataSpace(temp->address()));
     Handle<HeapObject> heap_ptr =
         factory->NewHeapNumber(5.0, IMMUTABLE, TENURED);
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index e80f4f1d06dd86cc00b194f4cd66161ce6be09bb..478108481fbb39b10369c55d3e15ff225c4f7359 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -4778,7 +4778,7 @@ TEST(ArrayShiftSweeping) {

 UNINITIALIZED_TEST(PromotionQueue) {
   i::FLAG_expose_gc = true;
-  i::FLAG_max_semi_space_size = 2;
+  i::FLAG_max_semi_space_size = 2 * (Page::kPageSize / MB);
   v8::Isolate* isolate = v8::Isolate::New();
   i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
   {
Index: test/cctest/test-spaces.cc
diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc
index 331ea025109dd4112eb5f2176dec9dc6c479a268..a11485be1a14039d1b8d1ce9f7dec258f6b93b5f 100644
--- a/test/cctest/test-spaces.cc
+++ b/test/cctest/test-spaces.cc
@@ -207,12 +207,13 @@ static void VerifyMemoryChunk(Isolate* isolate,
 TEST(Regress3540) {
   Isolate* isolate = CcTest::i_isolate();
   Heap* heap = isolate->heap();
+  const int pageSize = Page::kPageSize;
   MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
   CHECK(
memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize()));
   TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator);
   CodeRange* code_range = new CodeRange(isolate);
-  const size_t code_range_size = 4 * MB;
+  const size_t code_range_size = 4 * pageSize;
   if (!code_range->SetUp(
           code_range_size +
           RoundUp(v8::base::OS::CommitPageSize() * kReservedCodeRangePages,
@@ -222,13 +223,13 @@ TEST(Regress3540) {
   }
   Address address;
   size_t size;
-  address = code_range->AllocateRawMemory(code_range_size - 2 * MB,
-                                          code_range_size - 2 * MB, &size);
+  address = code_range->AllocateRawMemory(
+ code_range_size - 2 * pageSize, code_range_size - 2 * pageSize, &size);
   CHECK(address != NULL);
   Address null_address;
   size_t null_size;
   null_address = code_range->AllocateRawMemory(
-      code_range_size - MB, code_range_size - MB, &null_size);
+      code_range_size - pageSize, code_range_size - pageSize, &null_size);
   CHECK(null_address == NULL);
   code_range->FreeRawMemory(address, size);
   delete code_range;
@@ -422,7 +423,9 @@ TEST(LargeObjectSpace) {
{ AllocationResult allocation = lo->AllocateRaw(lo_size, NOT_EXECUTABLE);
       if (allocation.IsRetry()) break;
     }
-    CHECK(lo->Available() < available);
+    // The available value is conservative such that it may report
+    // zero prior to heap exhaustion.
+    CHECK(lo->Available() < available || available == 0);
   }

   CHECK(!lo->IsEmpty());
@@ -460,7 +463,7 @@ TEST(SizeOfFirstPageIsLargeEnough) {


 UNINITIALIZED_TEST(NewSpaceGrowsToTargetCapacity) {
-  FLAG_target_semi_space_size = 2;
+  FLAG_target_semi_space_size = 2 * (Page::kPageSize / MB);
   if (FLAG_optimize_for_size) return;

   v8::Isolate* isolate = v8::Isolate::New();
Index: test/cctest/test-weakmaps.cc
diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc
index 04f41b9aee979161b05a6ebb2c74e5b6792c7459..2f947d76a5e24b79f52c7b78c422a7451cb22a4f 100644
--- a/test/cctest/test-weakmaps.cc
+++ b/test/cctest/test-weakmaps.cc
@@ -184,7 +184,8 @@ TEST(Regress2060a) {

// Start second old-space page so that values land on evacuation candidate.
   Page* first_page = heap->old_pointer_space()->anchor()->next_page();
-  factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
+  int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB;
+  factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);

   // Fill up weak map with values on an evacuation candidate.
   {
@@ -222,7 +223,8 @@ TEST(Regress2060b) {

   // Start second old-space page so that keys land on evacuation candidate.
   Page* first_page = heap->old_pointer_space()->anchor()->next_page();
-  factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
+  int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB;
+  factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);

   // Fill up weak map with keys on an evacuation candidate.
   Handle<JSObject> keys[32];
Index: test/cctest/test-weaksets.cc
diff --git a/test/cctest/test-weaksets.cc b/test/cctest/test-weaksets.cc
index f08a99bcbfa250f8f4c1584379c3bdf101bf17ab..a01d3152779639811b1fe0c7e03174b115933e4f 100644
--- a/test/cctest/test-weaksets.cc
+++ b/test/cctest/test-weaksets.cc
@@ -184,7 +184,8 @@ TEST(WeakSet_Regress2060a) {

// Start second old-space page so that values land on evacuation candidate.
   Page* first_page = heap->old_pointer_space()->anchor()->next_page();
-  factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
+  int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB;
+  factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);

   // Fill up weak set with values on an evacuation candidate.
   {
@@ -222,7 +223,8 @@ TEST(WeakSet_Regress2060b) {

   // Start second old-space page so that keys land on evacuation candidate.
   Page* first_page = heap->old_pointer_space()->anchor()->next_page();
-  factory->NewFixedArray(900 * KB / kPointerSize, TENURED);
+  int dummy_array_size = Page::kMaxRegularHeapObjectSize - 92 * KB;
+  factory->NewFixedArray(dummy_array_size / kPointerSize, TENURED);

   // Fill up weak set with keys on an evacuation candidate.
   Handle<JSObject> keys[32];


--
--
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