Commit a32c97cc authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Clean up space names in the heap

- Remove AllocationSpaceName() which was in SHOUTY_CASE and did not
  actually handle CODE_LO_SPACE.
- Make GetSpaceName() static because it is.
- Change callers of old AllocationSpaceName() to use GetSpaceName().
- Change the input type to a AllocationSpace rather than int given the
  function crashes on invalid values.

Space::name() now returns a lower case result but this is only used by
functions guarded by gc_verbose or trace_fragmentation so I don't think
this will break anything.

Change-Id: Ice9a955365d4a22233af7ba39126ad8e5cff2aab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1565474
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Auto-Submit: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60842}
parent fd8ce365
......@@ -8413,7 +8413,8 @@ bool Isolate::GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
i::Heap* heap = isolate->heap();
i::Space* space = heap->space(static_cast<int>(index));
space_statistics->space_name_ = heap->GetSpaceName(static_cast<int>(index));
space_statistics->space_name_ =
i::Heap::GetSpaceName(static_cast<i::AllocationSpace>(index));
space_statistics->space_size_ = space->CommittedMemory();
space_statistics->space_used_size_ = space->SizeOfObjects();
space_statistics->space_available_size_ = space->Available();
......
......@@ -652,9 +652,9 @@ size_t Heap::SizeOfObjects() {
return total;
}
const char* Heap::GetSpaceName(int idx) {
switch (idx) {
// static
const char* Heap::GetSpaceName(AllocationSpace space) {
switch (space) {
case NEW_SPACE:
return "new_space";
case OLD_SPACE:
......@@ -671,10 +671,8 @@ const char* Heap::GetSpaceName(int idx) {
return "code_large_object_space";
case RO_SPACE:
return "read_only_space";
default:
UNREACHABLE();
}
return nullptr;
UNREACHABLE();
}
void Heap::MergeAllocationSitePretenuringFeedback(
......@@ -5622,28 +5620,6 @@ size_t Heap::NumberOfDetachedContexts() {
return detached_contexts()->length() / 2;
}
const char* AllocationSpaceName(AllocationSpace space) {
switch (space) {
case NEW_SPACE:
return "NEW_SPACE";
case OLD_SPACE:
return "OLD_SPACE";
case CODE_SPACE:
return "CODE_SPACE";
case MAP_SPACE:
return "MAP_SPACE";
case LO_SPACE:
return "LO_SPACE";
case NEW_LO_SPACE:
return "NEW_LO_SPACE";
case RO_SPACE:
return "RO_SPACE";
default:
UNREACHABLE();
}
return nullptr;
}
void VerifyPointersVisitor::VisitPointers(HeapObject host, ObjectSlot start,
ObjectSlot end) {
VerifyPointers(host, MaybeObjectSlot(start), MaybeObjectSlot(end));
......
......@@ -664,7 +664,7 @@ class Heap {
inline Space* space(int idx);
// Returns name of the space.
const char* GetSpaceName(int idx);
V8_EXPORT_PRIVATE static const char* GetSpaceName(AllocationSpace space);
// ===========================================================================
// Getters to other components. ==============================================
......@@ -2325,8 +2325,6 @@ class AllocationObserver {
DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
};
V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space);
// -----------------------------------------------------------------------------
// Allows observation of heap object allocations.
class HeapObjectAllocationTracker {
......
......@@ -1005,7 +1005,7 @@ class V8_EXPORT_PRIVATE Space : public Malloced {
// Identity used in error reporting.
AllocationSpace identity() { return id_; }
const char* name() { return AllocationSpaceName(id_); }
const char* name() { return Heap::GetSpaceName(id_); }
virtual void AddAllocationObserver(AllocationObserver* observer);
......
......@@ -137,7 +137,7 @@ void SerializerAllocator::OutputStatistics() {
PrintF(" Spaces (bytes):\n");
for (int space = FIRST_SPACE; space < kNumberOfSpaces; space++) {
PrintF("%16s", AllocationSpaceName(static_cast<AllocationSpace>(space)));
PrintF("%16s", Heap::GetSpaceName(static_cast<AllocationSpace>(space)));
}
PrintF("\n");
......
......@@ -72,14 +72,14 @@ void Serializer::OutputStatistics(const char* name) {
#ifdef OBJECT_PRINT
PrintF(" Instance types (count and bytes):\n");
#define PRINT_INSTANCE_TYPE(Name) \
for (int space = 0; space < LAST_SPACE; ++space) { \
if (instance_type_count_[space][Name]) { \
PrintF("%10d %10" PRIuS " %-10s %s\n", \
instance_type_count_[space][Name], \
instance_type_size_[space][Name], \
AllocationSpaceName(static_cast<AllocationSpace>(space)), #Name); \
} \
#define PRINT_INSTANCE_TYPE(Name) \
for (int space = 0; space < LAST_SPACE; ++space) { \
if (instance_type_count_[space][Name]) { \
PrintF("%10d %10" PRIuS " %-10s %s\n", \
instance_type_count_[space][Name], \
instance_type_size_[space][Name], \
Heap::GetSpaceName(static_cast<AllocationSpace>(space)), #Name); \
} \
}
INSTANCE_TYPE_LIST(PRINT_INSTANCE_TYPE)
#undef PRINT_INSTANCE_TYPE
......
This diff is collapsed.
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