Commit 33148af2 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[heap][cleanup] Using 'using' instead of 'typedef'

Even though both are allowed in the style guide, it recommends to use
'using', as its syntax is more consistent with the rest of C++.
This CL turns all typedefs in heap code to 'using' declarations.

R=mstarzinger@chromium.org

Bug: v8:8834
Change-Id: I8a9f6e1eebdd0adca4373c866e95ebab0a1e992d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545892Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60523}
parent 8ab941a0
......@@ -110,8 +110,8 @@ class LocalArrayBufferTracker {
// HeapNumber. The reason for tracking the length is that in the case of
// length being a HeapNumber, the buffer and its length may be stored on
// different memory pages, making it impossible to guarantee order of freeing.
typedef std::unordered_map<JSArrayBuffer, JSArrayBuffer::Allocation, Hasher>
TrackingData;
using TrackingData =
std::unordered_map<JSArrayBuffer, JSArrayBuffer::Allocation, Hasher>;
// Internal version of add that does not update counters. Requires separate
// logic for updating external memory counters.
......
......@@ -17,8 +17,8 @@ class JSObject;
class V8_EXPORT_PRIVATE LocalEmbedderHeapTracer final {
public:
typedef std::pair<void*, void*> WrapperInfo;
typedef std::vector<WrapperInfo> WrapperCache;
using WrapperInfo = std::pair<void*, void*>;
using WrapperCache = std::vector<WrapperInfo>;
class V8_EXPORT_PRIVATE ProcessingScope {
public:
......
......@@ -17,7 +17,7 @@
namespace v8 {
namespace internal {
typedef std::pair<uint64_t, double> BytesAndDuration;
using BytesAndDuration = std::pair<uint64_t, double>;
inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) {
return std::make_pair(bytes, duration);
......
......@@ -34,7 +34,7 @@
namespace v8 {
namespace debug {
typedef void (*OutOfMemoryCallback)(void* data);
using OutOfMemoryCallback = void (*)(void* data);
} // namespace debug
namespace internal {
......@@ -225,7 +225,7 @@ class Heap {
Address start;
Address end;
};
typedef std::vector<Chunk> Reservation;
using Reservation = std::vector<Chunk>;
static const int kInitalOldGenerationLimitFactor = 2;
......@@ -748,8 +748,8 @@ class Heap {
// completes incremental marking in order to free external resources.
void ReportExternalMemoryPressure();
typedef v8::Isolate::GetExternallyAllocatedMemoryInBytesCallback
GetExternallyAllocatedMemoryInBytesCallback;
using GetExternallyAllocatedMemoryInBytesCallback =
v8::Isolate::GetExternallyAllocatedMemoryInBytesCallback;
void SetGetExternallyAllocatedMemoryInBytesCallback(
GetExternallyAllocatedMemoryInBytesCallback callback) {
......@@ -1290,8 +1290,8 @@ class Heap {
private:
class SkipStoreBufferScope;
typedef String (*ExternalStringTableUpdaterCallback)(Heap* heap,
FullObjectSlot pointer);
using ExternalStringTableUpdaterCallback = String (*)(Heap* heap,
FullObjectSlot pointer);
// External strings table is a place where all external strings are
// registered. We need to keep track of such strings to properly
......
......@@ -631,7 +631,7 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
size_t area_size = space->AreaSize();
// Pairs of (live_bytes_in_page, page).
typedef std::pair<size_t, Page*> LiveBytesPagePair;
using LiveBytesPagePair = std::pair<size_t, Page*>;
std::vector<LiveBytesPagePair> pages;
pages.reserve(number_of_pages);
......@@ -1201,9 +1201,9 @@ class EvacuateVisitorBase : public HeapObjectVisitor {
protected:
enum MigrationMode { kFast, kObserved };
typedef void (*MigrateFunction)(EvacuateVisitorBase* base, HeapObject dst,
HeapObject src, int size,
AllocationSpace dest);
using MigrateFunction = void (*)(EvacuateVisitorBase* base, HeapObject dst,
HeapObject src, int size,
AllocationSpace dest);
template <MigrationMode mode>
static void RawMigrateObject(EvacuateVisitorBase* base, HeapObject dst,
......
......@@ -414,7 +414,7 @@ struct Ephemeron {
HeapObject value;
};
typedef Worklist<Ephemeron, 64> EphemeronWorklist;
using EphemeronWorklist = Worklist<Ephemeron, 64>;
// Weak objects encountered during marking.
struct WeakObjects {
......@@ -923,9 +923,8 @@ class MarkingVisitor final
int,
MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>> {
public:
typedef HeapVisitor<
int, MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>>
Parent;
using Parent = HeapVisitor<
int, MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>>;
V8_INLINE MarkingVisitor(MarkCompactCollector* collector,
MarkingState* marking_state);
......
......@@ -13,7 +13,7 @@ namespace internal {
class MarkBit {
public:
typedef uint32_t CellType;
using CellType = uint32_t;
STATIC_ASSERT(sizeof(CellType) == sizeof(base::Atomic32));
inline MarkBit(CellType* cell, CellType mask) : cell_(cell), mask_(mask) {}
......
......@@ -265,7 +265,7 @@ class SlotSet : public Malloced {
}
private:
typedef uint32_t* Bucket;
using Bucket = uint32_t*;
static const int kMaxSlots = (1 << kPageSizeBits) / kTaggedSize;
static const int kCellsPerBucket = 32;
static const int kCellsPerBucketLog2 = 5;
......
......@@ -1596,12 +1596,12 @@ class PageIteratorImpl
PAGE_TYPE* p_;
};
typedef PageIteratorImpl<Page> PageIterator;
typedef PageIteratorImpl<LargePage> LargePageIterator;
using PageIterator = PageIteratorImpl<Page>;
using LargePageIterator = PageIteratorImpl<LargePage>;
class PageRange {
public:
typedef PageIterator iterator;
using iterator = PageIterator;
PageRange(Page* begin, Page* end) : begin_(begin), end_(end) {}
explicit PageRange(Page* page) : PageRange(page, page->next_page()) {}
inline PageRange(Address start, Address limit);
......@@ -2112,7 +2112,7 @@ class SpaceWithLinearArea : public Space {
class V8_EXPORT_PRIVATE PagedSpace
: NON_EXPORTED_BASE(public SpaceWithLinearArea) {
public:
typedef PageIterator iterator;
using iterator = PageIterator;
static const size_t kCompactionMemoryWanted = 500 * KB;
......@@ -2423,7 +2423,7 @@ enum SemiSpaceId { kFromSpace = 0, kToSpace = 1 };
// space as a marking stack when tracing live objects.
class SemiSpace : public Space {
public:
typedef PageIterator iterator;
using iterator = PageIterator;
static void Swap(SemiSpace* from, SemiSpace* to);
......@@ -2617,7 +2617,7 @@ class SemiSpaceIterator : public ObjectIterator {
class NewSpace : public SpaceWithLinearArea {
public:
typedef PageIterator iterator;
using iterator = PageIterator;
NewSpace(Heap* heap, v8::PageAllocator* page_allocator,
size_t initial_semispace_capacity, size_t max_semispace_capacity);
......@@ -3019,7 +3019,7 @@ class ReadOnlySpace : public PagedSpace {
class LargeObjectSpace : public Space {
public:
typedef LargePageIterator iterator;
using iterator = LargePageIterator;
explicit LargeObjectSpace(Heap* heap);
LargeObjectSpace(Heap* heap, AllocationSpace id);
......
......@@ -23,9 +23,9 @@ enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE };
class Sweeper {
public:
typedef std::vector<Page*> IterabilityList;
typedef std::deque<Page*> SweepingList;
typedef std::vector<Page*> SweptList;
using IterabilityList = std::vector<Page*>;
using SweepingList = std::deque<Page*>;
using SweptList = std::vector<Page*>;
// Pauses the sweeper tasks or completes sweeping.
class PauseOrCompleteScope final {
......
......@@ -14,7 +14,7 @@
namespace {
typedef i::LocalArrayBufferTracker LocalTracker;
using LocalTracker = i::LocalArrayBufferTracker;
bool IsTracked(i::JSArrayBuffer buf) {
return i::ArrayBufferTracker::IsTracked(buf);
......
......@@ -15,7 +15,7 @@
namespace v8 {
namespace internal {
typedef TestWithContext GCTracerTest;
using GCTracerTest = TestWithContext;
TEST(GCTracer, AverageSpeed) {
base::RingBuffer<BytesAndDuration> buffer;
......
......@@ -19,7 +19,7 @@
namespace v8 {
namespace internal {
typedef TestWithIsolate HeapControllerTest;
using HeapControllerTest = TestWithIsolate;
double Round(double x) {
// Round to three digits.
......
......@@ -16,8 +16,8 @@
namespace v8 {
namespace internal {
typedef TestWithIsolate HeapTest;
typedef TestWithIsolateAndPointerCompression HeapWithPointerCompressionTest;
using HeapTest = TestWithIsolate;
using HeapWithPointerCompressionTest = TestWithIsolateAndPointerCompression;
TEST(Heap, SemiSpaceSize) {
const size_t MB = static_cast<size_t>(i::MB);
......
......@@ -11,7 +11,7 @@
namespace v8 {
namespace internal {
typedef TestWithIsolate SpacesTest;
using SpacesTest = TestWithIsolate;
TEST_F(SpacesTest, CompactionSpaceMerge) {
Heap* heap = i_isolate()->heap();
......
......@@ -161,8 +161,8 @@ class TrackingPageAllocator : public ::v8::PageAllocator {
}
private:
typedef std::map<Address, PageAllocator::Permission> PagePermissionsMap;
typedef std::function<void(PagePermissionsMap::value_type*)> ForEachFn;
using PagePermissionsMap = std::map<Address, PageAllocator::Permission>;
using ForEachFn = std::function<void(PagePermissionsMap::value_type*)>;
static void PrintRegion(std::ostream& os, Address start, Address end,
PageAllocator::Permission access) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment