From 49d1c8663e94e44a35ed20dd958b42e2aec79114 Mon Sep 17 00:00:00 2001 From: Florian Sattler Date: Thu, 13 Sep 2018 10:48:03 +0200 Subject: [PATCH] [cleanup] Refactor heap classes to use default members. Fixing clang-tidy warning. Bug: v8:8015 Change-Id: Ibe5906fa96f2d7327bce1eff70637a2d00f99668 Reviewed-on: https://chromium-review.googlesource.com/1224030 Reviewed-by: Hannes Payer Commit-Queue: Florian Sattler Cr-Commit-Position: refs/heads/master@{#55865} --- src/heap/array-buffer-collector.cc | 2 +- src/heap/concurrent-marking.cc | 2 +- src/heap/factory.h | 2 +- src/heap/heap-controller.h | 2 +- src/heap/heap.cc | 17 +++++--------- src/heap/heap.h | 4 ++-- src/heap/mark-compact.cc | 22 +++++++++---------- src/heap/mark-compact.h | 2 +- src/heap/spaces.h | 2 +- src/heap/store-buffer.h | 2 +- src/heap/sweeper.cc | 6 ++--- test/cctest/heap/test-heap.cc | 2 +- .../heap/gc-idle-time-handler-unittest.cc | 4 ++-- .../heap/item-parallel-job-unittest.cc | 8 +++---- 14 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/heap/array-buffer-collector.cc b/src/heap/array-buffer-collector.cc index 5e8d15df31..5d5fce2b47 100644 --- a/src/heap/array-buffer-collector.cc +++ b/src/heap/array-buffer-collector.cc @@ -47,7 +47,7 @@ class ArrayBufferCollector::FreeingTask final : public CancelableTask { explicit FreeingTask(Heap* heap) : CancelableTask(heap->isolate()), heap_(heap) {} - virtual ~FreeingTask() {} + virtual ~FreeingTask() = default; private: void RunInternal() final { diff --git a/src/heap/concurrent-marking.cc b/src/heap/concurrent-marking.cc index f6eabbb021..75d46f7c66 100644 --- a/src/heap/concurrent-marking.cc +++ b/src/heap/concurrent-marking.cc @@ -524,7 +524,7 @@ class ConcurrentMarking::Task : public CancelableTask { task_state_(task_state), task_id_(task_id) {} - virtual ~Task() {} + virtual ~Task() = default; private: // v8::internal::CancelableTask overrides. diff --git a/src/heap/factory.h b/src/heap/factory.h index b6c5cf8b1c..ae984b2a90 100644 --- a/src/heap/factory.h +++ b/src/heap/factory.h @@ -1053,7 +1053,7 @@ class NewFunctionArgs final { Handle GetMap(Isolate* isolate) const; private: - NewFunctionArgs() {} // Use the static factory constructors. + NewFunctionArgs() = default; // Use the static factory constructors. void SetShouldCreateAndSetInitialMap(); void SetShouldSetPrototype(); diff --git a/src/heap/heap-controller.h b/src/heap/heap-controller.h index 10384a0535..627853c5b4 100644 --- a/src/heap/heap-controller.h +++ b/src/heap/heap-controller.h @@ -24,7 +24,7 @@ class V8_EXPORT_PRIVATE MemoryController { max_growing_factor_(max_growing_factor), conservative_growing_factor_(conservative_growing_factor), target_mutator_utilization_(target_mutator_utilization) {} - virtual ~MemoryController() {} + virtual ~MemoryController() = default; // Computes the allocation limit to trigger the next garbage collection. size_t CalculateAllocationLimit(size_t curr_size, size_t max_size, diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 1ba17c0651..234bbec32c 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -108,12 +108,7 @@ bool Heap::GCCallbackTuple::operator==( } Heap::GCCallbackTuple& Heap::GCCallbackTuple::operator=( - const Heap::GCCallbackTuple& other) { - callback = other.callback; - gc_type = other.gc_type; - data = other.data; - return *this; -} + const Heap::GCCallbackTuple& other) = default; struct Heap::StrongRootsList { Object** start; @@ -2021,7 +2016,7 @@ static bool IsLogging(Isolate* isolate) { class PageScavengingItem final : public ItemParallelJob::Item { public: explicit PageScavengingItem(MemoryChunk* chunk) : chunk_(chunk) {} - virtual ~PageScavengingItem() {} + virtual ~PageScavengingItem() = default; void Process(Scavenger* scavenger) { scavenger->ScavengePage(chunk_); } @@ -3532,7 +3527,7 @@ class MemoryPressureInterruptTask : public CancelableTask { explicit MemoryPressureInterruptTask(Heap* heap) : CancelableTask(heap->isolate()), heap_(heap) {} - virtual ~MemoryPressureInterruptTask() {} + virtual ~MemoryPressureInterruptTask() = default; private: // v8::internal::CancelableTask overrides. @@ -5313,9 +5308,7 @@ PagedSpace* PagedSpaces::next() { SpaceIterator::SpaceIterator(Heap* heap) : heap_(heap), current_space_(FIRST_SPACE - 1) {} -SpaceIterator::~SpaceIterator() { -} - +SpaceIterator::~SpaceIterator() = default; bool SpaceIterator::has_next() { // Iterate until no more spaces. @@ -5330,7 +5323,7 @@ Space* SpaceIterator::next() { class HeapObjectsFilter { public: - virtual ~HeapObjectsFilter() {} + virtual ~HeapObjectsFilter() = default; virtual bool SkipObject(HeapObject* object) = 0; }; diff --git a/src/heap/heap.h b/src/heap/heap.h index 8040e7a690..f799bf281d 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -2505,7 +2505,7 @@ class HeapIterator { // Abstract base class for checking whether a weak object should be retained. class WeakObjectRetainer { public: - virtual ~WeakObjectRetainer() {} + virtual ~WeakObjectRetainer() = default; // Return whether this object should be retained. If nullptr is returned the // object has no references. Otherwise the address of the retained object @@ -2521,7 +2521,7 @@ class AllocationObserver { : step_size_(step_size), bytes_to_next_step_(step_size) { DCHECK_LE(kPointerSize, step_size); } - virtual ~AllocationObserver() {} + virtual ~AllocationObserver() = default; // Called each time the observed space does an allocation step. This may be // more frequently than the step_size we are monitoring (e.g. when there are diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index d7889fda7d..bda041a0f3 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -1133,7 +1133,7 @@ class MigrationObserver { public: explicit MigrationObserver(Heap* heap) : heap_(heap) {} - virtual ~MigrationObserver() {} + virtual ~MigrationObserver() = default; virtual void Move(AllocationSpace dest, HeapObject* src, HeapObject* dst, int size) = 0; @@ -1157,7 +1157,7 @@ class ProfilingMigrationObserver final : public MigrationObserver { class HeapObjectVisitor { public: - virtual ~HeapObjectVisitor() {} + virtual ~HeapObjectVisitor() = default; virtual bool Visit(HeapObject* object, int size) = 0; }; @@ -2366,7 +2366,7 @@ class Evacuator : public Malloced { duration_(0.0), bytes_compacted_(0) {} - virtual ~Evacuator() {} + virtual ~Evacuator() = default; void EvacuatePage(Page* page); @@ -2522,7 +2522,7 @@ void FullEvacuator::RawEvacuatePage(Page* page, intptr_t* live_bytes) { class PageEvacuationItem : public ItemParallelJob::Item { public: explicit PageEvacuationItem(Page* page) : page_(page) {} - virtual ~PageEvacuationItem() {} + virtual ~PageEvacuationItem() = default; Page* page() const { return page_; } private: @@ -2819,7 +2819,7 @@ void MarkCompactCollector::Evacuate() { class UpdatingItem : public ItemParallelJob::Item { public: - virtual ~UpdatingItem() {} + virtual ~UpdatingItem() = default; virtual void Process() = 0; }; @@ -2854,7 +2854,7 @@ class ToSpaceUpdatingItem : public UpdatingItem { start_(start), end_(end), marking_state_(marking_state) {} - virtual ~ToSpaceUpdatingItem() {} + virtual ~ToSpaceUpdatingItem() = default; void Process() override { if (chunk_->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION)) { @@ -2908,7 +2908,7 @@ class RememberedSetUpdatingItem : public UpdatingItem { marking_state_(marking_state), chunk_(chunk), updating_mode_(updating_mode) {} - virtual ~RememberedSetUpdatingItem() {} + virtual ~RememberedSetUpdatingItem() = default; void Process() override { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), @@ -3056,7 +3056,7 @@ class GlobalHandlesUpdatingItem : public UpdatingItem { global_handles_(global_handles), start_(start), end_(end) {} - virtual ~GlobalHandlesUpdatingItem() {} + virtual ~GlobalHandlesUpdatingItem() = default; void Process() override { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), @@ -3083,7 +3083,7 @@ class ArrayBufferTrackerUpdatingItem : public UpdatingItem { explicit ArrayBufferTrackerUpdatingItem(Page* page, EvacuationState state) : page_(page), state_(state) {} - virtual ~ArrayBufferTrackerUpdatingItem() {} + virtual ~ArrayBufferTrackerUpdatingItem() = default; void Process() override { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.gc"), @@ -4027,7 +4027,7 @@ class YoungGenerationMarkingTask; class MarkingItem : public ItemParallelJob::Item { public: - virtual ~MarkingItem() {} + virtual ~MarkingItem() = default; virtual void Process(YoungGenerationMarkingTask* task) = 0; }; @@ -4175,7 +4175,7 @@ class GlobalHandlesMarkingItem : public MarkingItem { GlobalHandlesMarkingItem(Heap* heap, GlobalHandles* global_handles, size_t start, size_t end) : global_handles_(global_handles), start_(start), end_(end) {} - virtual ~GlobalHandlesMarkingItem() {} + virtual ~GlobalHandlesMarkingItem() = default; void Process(YoungGenerationMarkingTask* task) override { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h index 1836b7f364..eb91089257 100644 --- a/src/heap/mark-compact.h +++ b/src/heap/mark-compact.h @@ -250,7 +250,7 @@ enum class RememberedSetUpdatingMode { ALL, OLD_TO_NEW_ONLY }; // Base class for minor and full MC collectors. class MarkCompactCollectorBase { public: - virtual ~MarkCompactCollectorBase() {} + virtual ~MarkCompactCollectorBase() = default; virtual void SetUp() = 0; virtual void TearDown() = 0; diff --git a/src/heap/spaces.h b/src/heap/spaces.h index b4e94133b0..be875ef793 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -1588,7 +1588,7 @@ MemoryAllocator::AllocatePage( class V8_EXPORT_PRIVATE ObjectIterator : public Malloced { public: - virtual ~ObjectIterator() {} + virtual ~ObjectIterator() = default; virtual HeapObject* Next() = 0; }; diff --git a/src/heap/store-buffer.h b/src/heap/store-buffer.h index d2c0f9b75f..528bd55f56 100644 --- a/src/heap/store-buffer.h +++ b/src/heap/store-buffer.h @@ -123,7 +123,7 @@ class StoreBuffer { : CancelableTask(isolate), store_buffer_(store_buffer), tracer_(isolate->heap()->tracer()) {} - virtual ~Task() {} + virtual ~Task() = default; private: void RunInternal() override { diff --git a/src/heap/sweeper.cc b/src/heap/sweeper.cc index 9e622c3385..dd5ddee827 100644 --- a/src/heap/sweeper.cc +++ b/src/heap/sweeper.cc @@ -76,7 +76,7 @@ class Sweeper::SweeperTask final : public CancelableTask { space_to_start_(space_to_start), tracer_(isolate->heap()->tracer()) {} - virtual ~SweeperTask() {} + virtual ~SweeperTask() = default; private: void RunInternal() final { @@ -111,7 +111,7 @@ class Sweeper::IncrementalSweeperTask final : public CancelableTask { IncrementalSweeperTask(Isolate* isolate, Sweeper* sweeper) : CancelableTask(isolate), isolate_(isolate), sweeper_(sweeper) {} - virtual ~IncrementalSweeperTask() {} + virtual ~IncrementalSweeperTask() = default; private: void RunInternal() final { @@ -530,7 +530,7 @@ class Sweeper::IterabilityTask final : public CancelableTask { pending_iterability_task_(pending_iterability_task), tracer_(isolate->heap()->tracer()) {} - virtual ~IterabilityTask() {} + virtual ~IterabilityTask() = default; private: void RunInternal() final { diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index f73f6f0195..89427e1143 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -5427,7 +5427,7 @@ class StaticOneByteResource : public v8::String::ExternalOneByteStringResource { public: explicit StaticOneByteResource(const char* data) : data_(data) {} - ~StaticOneByteResource() {} + ~StaticOneByteResource() = default; const char* data() const { return data_; } diff --git a/test/unittests/heap/gc-idle-time-handler-unittest.cc b/test/unittests/heap/gc-idle-time-handler-unittest.cc index 573be833af..08855726f3 100644 --- a/test/unittests/heap/gc-idle-time-handler-unittest.cc +++ b/test/unittests/heap/gc-idle-time-handler-unittest.cc @@ -14,8 +14,8 @@ namespace { class GCIdleTimeHandlerTest : public ::testing::Test { public: - GCIdleTimeHandlerTest() {} - virtual ~GCIdleTimeHandlerTest() {} + GCIdleTimeHandlerTest() = default; + virtual ~GCIdleTimeHandlerTest() = default; GCIdleTimeHandler* handler() { return &handler_; } diff --git a/test/unittests/heap/item-parallel-job-unittest.cc b/test/unittests/heap/item-parallel-job-unittest.cc index adeae2b593..17125e61a1 100644 --- a/test/unittests/heap/item-parallel-job-unittest.cc +++ b/test/unittests/heap/item-parallel-job-unittest.cc @@ -151,7 +151,7 @@ class TaskForDifferentItems; class BaseItem : public ItemParallelJob::Item { public: - virtual ~BaseItem() {} + virtual ~BaseItem() = default; virtual void ProcessItem(TaskForDifferentItems* task) = 0; }; @@ -162,7 +162,7 @@ class TaskForDifferentItems : public ItemParallelJob::Task { : ItemParallelJob::Task(isolate), processed_a_(processed_a), processed_b_(processed_b) {} - virtual ~TaskForDifferentItems() {} + virtual ~TaskForDifferentItems() = default; void RunInParallel() override { BaseItem* item = nullptr; @@ -182,13 +182,13 @@ class TaskForDifferentItems : public ItemParallelJob::Task { class ItemA : public BaseItem { public: - virtual ~ItemA() {} + virtual ~ItemA() = default; void ProcessItem(TaskForDifferentItems* task) override { task->ProcessA(); } }; class ItemB : public BaseItem { public: - virtual ~ItemB() {} + virtual ~ItemB() = default; void ProcessItem(TaskForDifferentItems* task) override { task->ProcessB(); } };