From 2cbc81a5ce7cafd4216986aea4cb5da84d564a6e Mon Sep 17 00:00:00 2001 From: "hpayer@chromium.org" Date: Thu, 23 May 2013 08:17:03 +0000 Subject: [PATCH] Move global pretenuring flag check to ShouldGloballyPretenure(). BUG= Review URL: https://codereview.chromium.org/15734007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14763 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/code-stubs-hydrogen.cc | 2 +- src/flag-definitions.h | 2 +- src/heap.cc | 8 ++++---- src/heap.h | 7 ++++++- src/hydrogen.cc | 5 ++--- test/cctest/test-heap.cc | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 6e837dd..fdfd059 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -383,7 +383,7 @@ HValue* CodeStubGraphBuilder::BuildCodeStub() { HValue* size_in_bytes = AddInstruction(new(zone) HConstant(size, Representation::Integer32())); HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; - if (FLAG_pretenure_literals) { + if (isolate()->heap()->ShouldGloballyPretenure()) { flags = static_cast( flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); } diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 58f29b4..7b5ba1e 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -192,7 +192,7 @@ DEFINE_bool(compiled_keyed_stores, true, "use optimizing compiler to " DEFINE_bool(clever_optimizations, true, "Optimize object size, Array shift, DOM strings and string +") -DEFINE_bool(pretenure_literals, true, "allocate literals in old space") +DEFINE_bool(pretenuring, true, "allocate objects in old space") DEFINE_bool(track_fields, true, "track fields with only smi values") DEFINE_bool(track_double_fields, true, "track fields with double values") DEFINE_bool(track_heap_object_fields, true, "track fields with heap values") diff --git a/src/heap.cc b/src/heap.cc index 424edd4..16d1f24 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -938,7 +938,7 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, // maximum capacity indicates that most objects will be promoted. // To decrease scavenger pauses and final mark-sweep pauses, we // have to limit maximal capacity of the young generation. - new_space_high_promotion_mode_active_ = true; + SetNewSpaceHighPromotionModeActive(true); if (FLAG_trace_gc) { PrintPID("Limited new space size due to high promotion rate: %d MB\n", new_space_.InitialCapacity() / MB); @@ -947,7 +947,7 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, // heuristic indicator of whether to pretenure or not, we trigger // deoptimization here to take advantage of pre-tenuring as soon as // possible. - if (FLAG_pretenure_literals) { + if (FLAG_pretenuring) { isolate_->stack_guard()->FullDeopt(); } } else if (new_space_high_promotion_mode_active_ && @@ -956,14 +956,14 @@ bool Heap::PerformGarbageCollection(GarbageCollector collector, // Decreasing low survival rates might indicate that the above high // promotion mode is over and we should allow the young generation // to grow again. - new_space_high_promotion_mode_active_ = false; + SetNewSpaceHighPromotionModeActive(false); if (FLAG_trace_gc) { PrintPID("Unlimited new space size due to low promotion rate: %d MB\n", new_space_.MaximumCapacity() / MB); } // Trigger deoptimization here to turn off pre-tenuring as soon as // possible. - if (FLAG_pretenure_literals) { + if (FLAG_pretenuring) { isolate_->stack_guard()->FullDeopt(); } } diff --git a/src/heap.h b/src/heap.h index 99b14bd..d39423e 100644 --- a/src/heap.h +++ b/src/heap.h @@ -1549,7 +1549,12 @@ class Heap { // Predicate that governs global pre-tenuring decisions based on observed // promotion rates of previous collections. inline bool ShouldGloballyPretenure() { - return new_space_high_promotion_mode_active_; + return FLAG_pretenuring && new_space_high_promotion_mode_active_; + } + + // This is only needed for testing high promotion mode. + void SetNewSpaceHighPromotionModeActive(bool mode) { + new_space_high_promotion_mode_active_ = mode; } inline PretenureFlag GetPretenureMode() { diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 4cf8613..f25efbf 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -1391,7 +1391,7 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context, total_size->ClearFlag(HValue::kCanOverflow); HAllocate::Flags flags = HAllocate::DefaultFlags(kind); - if (FLAG_pretenure_literals) { + if (isolate()->heap()->ShouldGloballyPretenure()) { // TODO(hpayer): When pretenuring can be internalized, flags can become // private to HAllocate. if (IsFastDoubleElementsKind(kind)) { @@ -10867,8 +10867,7 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; // TODO(hpayer): add support for old data space - if (FLAG_pretenure_literals && - isolate()->heap()->ShouldGloballyPretenure() && + if (isolate()->heap()->ShouldGloballyPretenure() && data_size == 0) { flags = static_cast( flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc index ca173c2..8967ff5 100644 --- a/test/cctest/test-heap.cc +++ b/test/cctest/test-heap.cc @@ -2078,11 +2078,11 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { // Test pretenuring of array literals allocated with HAllocate. TEST(OptimizedPretenuringArrayLiterals) { i::FLAG_allow_natives_syntax = true; - i::FLAG_pretenure_literals = true; CcTest::InitializeVM(); if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); + HEAP->SetNewSpaceHighPromotionModeActive(true); AlwaysAllocateScope always_allocate; v8::Local res = CompileRun( @@ -2104,7 +2104,7 @@ TEST(OptimizedPretenuringArrayLiterals) { TEST(OptimizedPretenuringSimpleArrayLiterals) { i::FLAG_allow_natives_syntax = true; - i::FLAG_pretenure_literals = false; + i::FLAG_pretenuring = false; CcTest::InitializeVM(); if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; -- 2.7.4