Commit 310ba80b authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

Improve output for HashTables

Emit full header and key/value-pairs.

Bug: chromium:844008
Change-Id: Ia94b841ff97d024d6ba27b1bcc2f993f95fc11fa
Reviewed-on: https://chromium-review.googlesource.com/1092698Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@google.com>
Cr-Commit-Position: refs/heads/master@{#53613}
parent 656dce0c
......@@ -17,6 +17,7 @@
#include "src/objects/js-locale-inl.h"
#endif // V8_INTL_SUPPORT
#include "src/objects/arguments-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/js-regexp-inl.h"
#include "src/objects/js-regexp-string-iterator-inl.h"
......@@ -97,8 +98,6 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case FIXED_DOUBLE_ARRAY_TYPE:
FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
break;
case HASH_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case FIXED_ARRAY_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
......@@ -111,6 +110,12 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case WITH_CONTEXT_TYPE:
FixedArray::cast(this)->FixedArrayPrint(os);
break;
case HASH_TABLE_TYPE:
ObjectHashTable::cast(this)->ObjectHashTablePrint(os);
break;
case EPHEMERON_HASH_TABLE_TYPE:
EphemeronHashTable::cast(this)->EphemeronHashTablePrint(os);
break;
case BOILERPLATE_DESCRIPTION_TYPE:
BoilerplateDescription::cast(this)->BoilerplateDescriptionPrint(os);
break;
......@@ -822,6 +827,23 @@ void PrintFixedArrayWithHeader(std::ostream& os, FixedArray* array,
os << "\n";
}
template <typename T>
void PrintHashTableWithHeader(std::ostream& os, T* table, const char* type) {
table->PrintHeader(os, type);
os << "\n - length: " << table->length();
os << "\n - elements: " << table->NumberOfElements();
os << "\n - deleted: " << table->NumberOfDeletedElements();
os << "\n - capacity: " << table->Capacity();
os << "\n - elements: {";
for (int i = 0; i < table->Capacity(); i++) {
os << '\n'
<< std::setw(12) << i << ": " << Brief(table->KeyAt(i)) << " -> "
<< Brief(table->ValueAt(i));
}
os << "\n }\n";
}
template <typename T>
void PrintWeakArrayElements(std::ostream& os, T* array) {
// Print in array notation for non-sparse arrays.
......@@ -864,15 +886,15 @@ void PrintWeakArrayListWithHeader(std::ostream& os, WeakArrayList* array) {
} // namespace
void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
const char* name = "FixedArray";
PrintFixedArrayWithHeader(os, this, "FixedArray");
}
if (IsHashTable()) {
name = "HashTable";
} else if (IsEphemeronHashTable()) {
name = "EphemeronHashTable";
}
void ObjectHashTable::ObjectHashTablePrint(std::ostream& os) {
PrintHashTableWithHeader(os, this, "ObjectHashTable");
}
PrintFixedArrayWithHeader(os, this, name);
void EphemeronHashTable::EphemeronHashTablePrint(std::ostream& os) {
PrintHashTableWithHeader(os, this, "EphemeronHashTable");
}
void BoilerplateDescription::BoilerplateDescriptionPrint(std::ostream& os) {
......
......@@ -310,6 +310,7 @@ class ObjectHashTable
: public ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape> {
public:
DECL_CAST(ObjectHashTable)
DECL_PRINTER(ObjectHashTable)
};
class EphemeronHashTableShape : public ObjectHashTableShape {
......@@ -325,6 +326,7 @@ class EphemeronHashTable
: public ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape> {
public:
DECL_CAST(EphemeronHashTable)
DECL_PRINTER(EphemeronHashTable)
protected:
friend class MarkCompactCollector;
......
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