Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(843)

Unified Diff: src/objects-printer.cc

Issue 1870433003: Improve elements validation and object printing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressing nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-printer.cc
diff --git a/src/objects-printer.cc b/src/objects-printer.cc
index def2cd85ba151fc7311fd0a409dcb065e8c517cf..f63bfc415a7ea326aa858bf0ea1efaa41a8c10bc 100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -33,7 +33,13 @@ void Object::Print(std::ostream& os) { // NOLINT
void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT
- os << reinterpret_cast<void*>(this) << ": [" << id << "]";
+ os << reinterpret_cast<void*>(this) << ": [";
+ if (id != nullptr) {
+ os << id;
+ } else {
+ os << map()->instance_type();
+ }
+ os << "]";
}
@@ -97,11 +103,13 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
case JS_OBJECT_TYPE: // fall through
case JS_SPECIAL_API_OBJECT_TYPE:
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
- case JS_ARRAY_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
case JS_PROMISE_TYPE:
JSObject::cast(this)->JSObjectPrint(os);
break;
+ case JS_ARRAY_TYPE:
+ JSArray::cast(this)->JSArrayPrint(os);
+ break;
case JS_REGEXP_TYPE:
JSRegExp::cast(this)->JSRegExpPrint(os);
break;
@@ -396,16 +404,20 @@ static void JSObjectPrintHeader(std::ostream& os, JSObject* obj,
obj->PrintHeader(os, id);
// Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging.
- os << "\n - map = " << reinterpret_cast<void*>(obj->map()) << " ["
- << ElementsKindToString(obj->map()->elements_kind());
- if (obj->elements()->map() == obj->GetHeap()->fixed_cow_array_map()) {
- os << " (COW)";
+ os << "\n - map = " << reinterpret_cast<void*>(obj->map()) << " [";
+ if (obj->HasFastProperties()) {
+ os << "FastProperties";
+ } else {
+ os << "DictionaryProperties";
}
PrototypeIterator iter(obj->GetIsolate(), obj);
os << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent());
- if (obj->elements()->length() > 0) {
- os << "\n - elements = " << Brief(obj->elements());
+ os << "\n - elements = " << Brief(obj->elements()) << " ["
+ << ElementsKindToString(obj->map()->elements_kind());
+ if (obj->elements()->map() == obj->GetHeap()->fixed_cow_array_map()) {
+ os << " (COW)";
}
+ os << "]";
}
@@ -413,14 +425,19 @@ static void JSObjectPrintBody(std::ostream& os, JSObject* obj, // NOLINT
bool print_elements = true) {
os << "\n {";
obj->PrintProperties(os);
- obj->PrintTransitions(os);
if (print_elements) obj->PrintElements(os);
os << "\n }\n";
}
void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT
- JSObjectPrintHeader(os, this, "JSObject");
+ JSObjectPrintHeader(os, this, nullptr);
+ JSObjectPrintBody(os, this);
+}
+
+void JSArray::JSArrayPrint(std::ostream& os) { // NOLINT
+ JSObjectPrintHeader(os, this, "JSArray");
+ os << "\n - length = " << Brief(this->length());
JSObjectPrintBody(os, this);
}
@@ -1279,7 +1296,7 @@ void TransitionArray::PrintTransitions(std::ostream& os, Object* transitions,
for (int i = 0; i < num_transitions; i++) {
Name* key = GetKey(transitions, i);
Map* target = GetTarget(transitions, i);
- os << "\n ";
+ os << "\n ";
#ifdef OBJECT_PRINT
key->NamePrint(os);
#else
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698