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 @@ ...@@ -17,6 +17,7 @@
#include "src/objects/js-locale-inl.h" #include "src/objects/js-locale-inl.h"
#endif // V8_INTL_SUPPORT #endif // V8_INTL_SUPPORT
#include "src/objects/arguments-inl.h" #include "src/objects/arguments-inl.h"
#include "src/objects/hash-table-inl.h"
#include "src/objects/js-collection-inl.h" #include "src/objects/js-collection-inl.h"
#include "src/objects/js-regexp-inl.h" #include "src/objects/js-regexp-inl.h"
#include "src/objects/js-regexp-string-iterator-inl.h" #include "src/objects/js-regexp-string-iterator-inl.h"
...@@ -97,8 +98,6 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT ...@@ -97,8 +98,6 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case FIXED_DOUBLE_ARRAY_TYPE: case FIXED_DOUBLE_ARRAY_TYPE:
FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os); FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
break; break;
case HASH_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case FIXED_ARRAY_TYPE: case FIXED_ARRAY_TYPE:
case BLOCK_CONTEXT_TYPE: case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE: case CATCH_CONTEXT_TYPE:
...@@ -111,6 +110,12 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT ...@@ -111,6 +110,12 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case WITH_CONTEXT_TYPE: case WITH_CONTEXT_TYPE:
FixedArray::cast(this)->FixedArrayPrint(os); FixedArray::cast(this)->FixedArrayPrint(os);
break; 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: case BOILERPLATE_DESCRIPTION_TYPE:
BoilerplateDescription::cast(this)->BoilerplateDescriptionPrint(os); BoilerplateDescription::cast(this)->BoilerplateDescriptionPrint(os);
break; break;
...@@ -822,6 +827,23 @@ void PrintFixedArrayWithHeader(std::ostream& os, FixedArray* array, ...@@ -822,6 +827,23 @@ void PrintFixedArrayWithHeader(std::ostream& os, FixedArray* array,
os << "\n"; 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> template <typename T>
void PrintWeakArrayElements(std::ostream& os, T* array) { void PrintWeakArrayElements(std::ostream& os, T* array) {
// Print in array notation for non-sparse arrays. // Print in array notation for non-sparse arrays.
...@@ -864,15 +886,15 @@ void PrintWeakArrayListWithHeader(std::ostream& os, WeakArrayList* array) { ...@@ -864,15 +886,15 @@ void PrintWeakArrayListWithHeader(std::ostream& os, WeakArrayList* array) {
} // namespace } // namespace
void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
const char* name = "FixedArray"; PrintFixedArrayWithHeader(os, this, "FixedArray");
}
if (IsHashTable()) { void ObjectHashTable::ObjectHashTablePrint(std::ostream& os) {
name = "HashTable"; PrintHashTableWithHeader(os, this, "ObjectHashTable");
} else if (IsEphemeronHashTable()) { }
name = "EphemeronHashTable";
}
PrintFixedArrayWithHeader(os, this, name); void EphemeronHashTable::EphemeronHashTablePrint(std::ostream& os) {
PrintHashTableWithHeader(os, this, "EphemeronHashTable");
} }
void BoilerplateDescription::BoilerplateDescriptionPrint(std::ostream& os) { void BoilerplateDescription::BoilerplateDescriptionPrint(std::ostream& os) {
......
...@@ -310,6 +310,7 @@ class ObjectHashTable ...@@ -310,6 +310,7 @@ class ObjectHashTable
: public ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape> { : public ObjectHashTableBase<ObjectHashTable, ObjectHashTableShape> {
public: public:
DECL_CAST(ObjectHashTable) DECL_CAST(ObjectHashTable)
DECL_PRINTER(ObjectHashTable)
}; };
class EphemeronHashTableShape : public ObjectHashTableShape { class EphemeronHashTableShape : public ObjectHashTableShape {
...@@ -325,6 +326,7 @@ class EphemeronHashTable ...@@ -325,6 +326,7 @@ class EphemeronHashTable
: public ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape> { : public ObjectHashTableBase<EphemeronHashTable, EphemeronHashTableShape> {
public: public:
DECL_CAST(EphemeronHashTable) DECL_CAST(EphemeronHashTable)
DECL_PRINTER(EphemeronHashTable)
protected: protected:
friend class MarkCompactCollector; 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