diff --git a/src/heap/heap.h b/src/heap/heap.h index 936d0fa919..f247aa38f5 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -238,10 +238,11 @@ class Heap { #endif // Semi-space size needs to be a multiple of page size. - static const size_t kMinSemiSpaceSizeInKB = - 1 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); - static const size_t kMaxSemiSpaceSizeInKB = - 16 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); + static const size_t kMinSemiSpaceSizeInKB = 512 * kPointerMultiplier; + static const size_t kMaxSemiSpaceSizeInKB = 8192 * kPointerMultiplier; + + STATIC_ASSERT(kMinSemiSpaceSizeInKB* KB % (1 << kPageSizeBits) == 0); + STATIC_ASSERT(kMaxSemiSpaceSizeInKB* KB % (1 << kPageSizeBits) == 0); static const int kTraceRingBufferSize = 512; static const int kStacktraceBufferSize = 512; diff --git a/test/unittests/heap/heap-unittest.cc b/test/unittests/heap/heap-unittest.cc index 2f588a843e..12bd46886d 100644 --- a/test/unittests/heap/heap-unittest.cc +++ b/test/unittests/heap/heap-unittest.cc @@ -20,14 +20,13 @@ typedef TestWithIsolate HeapTest; typedef TestWithIsolateAndPointerCompression HeapWithPointerCompressionTest; TEST(Heap, SemiSpaceSize) { - const size_t KB = static_cast(i::KB); const size_t MB = static_cast(i::MB); const size_t pm = i::Heap::kPointerMultiplier; - ASSERT_EQ(1u * pm * MB / 2, i::Heap::ComputeMaxSemiSpaceSize(0u) * KB); - ASSERT_EQ(1u * pm * MB / 2, i::Heap::ComputeMaxSemiSpaceSize(512u * MB) * KB); - ASSERT_EQ(2u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(1024u * MB) * KB); - ASSERT_EQ(5u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(2024u * MB) * KB); - ASSERT_EQ(8u * pm * MB, i::Heap::ComputeMaxSemiSpaceSize(4095u * MB) * KB); + ASSERT_EQ(512u * pm, i::Heap::ComputeMaxSemiSpaceSize(0u)); + ASSERT_EQ(512u * pm, i::Heap::ComputeMaxSemiSpaceSize(512u * MB)); + ASSERT_EQ(2048u * pm, i::Heap::ComputeMaxSemiSpaceSize(1024u * MB)); + ASSERT_EQ(5120u * pm, i::Heap::ComputeMaxSemiSpaceSize(2024u * MB)); + ASSERT_EQ(8192u * pm, i::Heap::ComputeMaxSemiSpaceSize(4095u * MB)); } TEST_F(HeapTest, ASLR) {