From 6e3d7ee6cb8d2ad2b4052ce84e03ae0181840d49 Mon Sep 17 00:00:00 2001 From: Ulan Degenbaev Date: Tue, 25 Jul 2017 08:22:28 +0000 Subject: [PATCH] Revert "[heap] Remove clearing of caches and counter of shared function info in" This reverts commit 858052930221bf05230d8e0eb0e681bf9b532980. Reason for revert: increased memory usage on benchmarks. BUG=chromium:747806 Original change's description: > [heap] Remove clearing of caches and counter of shared function info in > marking visitors. > > This makes incremental and concurrent visitors of share function infos > side-effect free. > > BUG=chromium:694255 > > Change-Id: I85ee7bac17f17bdbc101ef64ecfb46020b5b3458 > Reviewed-on: https://chromium-review.googlesource.com/574851 > Commit-Queue: Ulan Degenbaev > Reviewed-by: Michael Lippautz > Cr-Commit-Position: refs/heads/master@{#46796} TBR=ulan@chromium.org,mlippautz@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: chromium:694255 Change-Id: Id28551ce8378820b0272721b7efb388727c442d4 Reviewed-on: https://chromium-review.googlesource.com/584288 Reviewed-by: Ulan Degenbaev Reviewed-by: Michael Lippautz Commit-Queue: Ulan Degenbaev Cr-Commit-Position: refs/heads/master@{#46864} --- src/heap/concurrent-marking.cc | 12 +++++++++ src/heap/mark-compact.cc | 9 ------- src/heap/objects-visiting-inl.h | 12 +++++++++ src/heap/objects-visiting.h | 1 + test/cctest/heap/test-heap.cc | 46 +++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 9 deletions(-) diff --git a/src/heap/concurrent-marking.cc b/src/heap/concurrent-marking.cc index 86770a1cad..98e711bfec 100644 --- a/src/heap/concurrent-marking.cc +++ b/src/heap/concurrent-marking.cc @@ -179,6 +179,18 @@ class ConcurrentMarkingVisitor final return 0; } + int VisitSharedFunctionInfo(Map* map, SharedFunctionInfo* object) { + if (ObjectMarking::IsGrey(object, + marking_state(object))) { + int size = SharedFunctionInfo::BodyDescriptorWeak::SizeOf(map, object); + VisitMapPointer(object, object->map_slot()); + SharedFunctionInfo::BodyDescriptorWeak::IterateBody(object, size, this); + // Resetting of IC age counter is done on the main thread. + bailout_.Push(object); + } + return 0; + } + int VisitTransitionArray(Map* map, TransitionArray* object) { // TODO(ulan): implement iteration of strong fields. bailout_.Push(object); diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 7f1a1530c4..60cd50da41 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -1063,15 +1063,6 @@ class MarkCompactMarkingVisitor final } } - int VisitSharedFunctionInfo(Map* map, SharedFunctionInfo* sfi) { - if (sfi->ic_age() != heap_->global_ic_age()) { - sfi->ResetForNewContext(heap_->global_ic_age()); - } - int size = SharedFunctionInfo::BodyDescriptor::SizeOf(map, sfi); - SharedFunctionInfo::BodyDescriptor::IterateBody(sfi, size, this); - return size; - } - // Marks the object black and pushes it on the marking stack. V8_INLINE void MarkObject(HeapObject* host, HeapObject* object) { collector_->MarkObject(host, object); diff --git a/src/heap/objects-visiting-inl.h b/src/heap/objects-visiting-inl.h index 7e05d5e0a9..6423e9e249 100644 --- a/src/heap/objects-visiting-inl.h +++ b/src/heap/objects-visiting-inl.h @@ -277,6 +277,18 @@ int MarkingVisitor::VisitJSWeakCollection( return size; } +template +int MarkingVisitor::VisitSharedFunctionInfo( + Map* map, SharedFunctionInfo* sfi) { + ConcreteVisitor* visitor = static_cast(this); + if (sfi->ic_age() != heap_->global_ic_age()) { + sfi->ResetForNewContext(heap_->global_ic_age()); + } + int size = SharedFunctionInfo::BodyDescriptor::SizeOf(map, sfi); + SharedFunctionInfo::BodyDescriptor::IterateBody(sfi, size, visitor); + return size; +} + template int MarkingVisitor::VisitBytecodeArray(Map* map, BytecodeArray* array) { diff --git a/src/heap/objects-visiting.h b/src/heap/objects-visiting.h index e985b44e24..0716b098e4 100644 --- a/src/heap/objects-visiting.h +++ b/src/heap/objects-visiting.h @@ -119,6 +119,7 @@ class MarkingVisitor : public HeapVisitor { V8_INLINE int VisitTransitionArray(Map* map, TransitionArray* object); V8_INLINE int VisitNativeContext(Map* map, Context* object); V8_INLINE int VisitJSWeakCollection(Map* map, JSWeakCollection* object); + V8_INLINE int VisitSharedFunctionInfo(Map* map, SharedFunctionInfo* object); V8_INLINE int VisitBytecodeArray(Map* map, BytecodeArray* object); V8_INLINE int VisitCode(Map* map, Code* object); V8_INLINE int VisitMap(Map* map, Map* object); diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index f8c7acb148..6ce42a58c0 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -2223,6 +2223,52 @@ TEST(InstanceOfStubWriteBarrier) { CcTest::CollectGarbage(OLD_SPACE); } +TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { + if (!FLAG_incremental_marking) return; + FLAG_stress_compaction = false; + FLAG_stress_incremental_marking = false; + FLAG_allow_natives_syntax = true; +#ifdef VERIFY_HEAP + FLAG_verify_heap = true; +#endif + + CcTest::InitializeVM(); + if (!CcTest::i_isolate()->use_optimizer()) return; + v8::HandleScope outer_scope(CcTest::isolate()); + v8::Local ctx = CcTest::isolate()->GetCurrentContext(); + + { + v8::HandleScope scope(CcTest::isolate()); + CompileRun( + "function f () {" + " var s = 0;" + " for (var i = 0; i < 100; i++) s += i;" + " return s;" + "}" + "f(); f();" + "%OptimizeFunctionOnNextCall(f);" + "f();"); + } + i::Handle f = i::Handle::cast( + v8::Utils::OpenHandle(*v8::Local::Cast( + CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked()))); + CHECK(f->IsOptimized()); + + // Make sure incremental marking it not running. + CcTest::heap()->incremental_marking()->Stop(); + + CcTest::heap()->StartIncrementalMarking(i::Heap::kNoGCFlags, + i::GarbageCollectionReason::kTesting); + // The following calls will increment CcTest::heap()->global_ic_age(). + CcTest::isolate()->ContextDisposedNotification(); + heap::SimulateIncrementalMarking(CcTest::heap()); + CcTest::CollectAllGarbage(); + + CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); + CHECK_EQ(0, f->shared()->opt_count()); + CHECK_EQ(0, f->shared()->profiler_ticks()); +} + TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { FLAG_stress_compaction = false;