Commit 9ae3dd86 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Make printing of a JSObject's properties less confusing

A JSObject's own properties were always printed as if all were stored
in the 'properties' backing store, even if some of them were stored in
the descriptor array and/or in-object. This CL tries to make the output
a bit clearer.

Change-Id: I03d05bdd530cc4c534c945aa08bad20edc3bbcd7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2466119
Auto-Submit: Georg Neis <neis@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70475}
parent 509802fd
...@@ -311,11 +311,16 @@ bool JSObject::PrintProperties(std::ostream& os) { // NOLINT ...@@ -311,11 +311,16 @@ bool JSObject::PrintProperties(std::ostream& os) { // NOLINT
} }
os << " "; os << " ";
details.PrintAsFastTo(os, PropertyDetails::kForProperties); details.PrintAsFastTo(os, PropertyDetails::kForProperties);
if (details.location() != kField) continue; if (details.location() == kField) {
int field_index = details.field_index(); int field_index = details.field_index();
if (nof_inobject_properties <= field_index) { if (field_index < nof_inobject_properties) {
field_index -= nof_inobject_properties; os << ", location: in-object";
os << " properties[" << field_index << "]"; } else {
field_index -= nof_inobject_properties;
os << ", location: properties[" << field_index << "]";
}
} else {
os << ", location: descriptor";
} }
} }
return map().NumberOfOwnDescriptors() > 0; return map().NumberOfOwnDescriptors() > 0;
...@@ -572,9 +577,10 @@ static void JSObjectPrintBody(std::ostream& os, ...@@ -572,9 +577,10 @@ static void JSObjectPrintBody(std::ostream& os,
if (!properties_or_hash.IsSmi()) { if (!properties_or_hash.IsSmi()) {
os << Brief(properties_or_hash); os << Brief(properties_or_hash);
} }
os << " {"; os << "\n - All own properties (excluding elements): {";
if (obj.PrintProperties(os)) os << "\n "; if (obj.PrintProperties(os)) os << "\n ";
os << "}\n"; os << "}\n";
if (print_elements) { if (print_elements) {
size_t length = obj.IsJSTypedArray() ? JSTypedArray::cast(obj).length() size_t length = obj.IsJSTypedArray() ? JSTypedArray::cast(obj).length()
: obj.elements().length(); : obj.elements().length();
......
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