|
|
Chromium Code Reviews|
Created:
3 years, 11 months ago by Camillo Bruni Modified:
3 years, 11 months ago Reviewers:
Igor Sheludko CC:
v8-reviews_googlegroups.com Target Ref:
refs/pending/heads/master Project:
v8 Visibility:
Public. |
Description[printing] Improve FixedArray debug printing
- condense repeated elements
- print map
BUG=
Review-Url: https://codereview.chromium.org/2626023002
Cr-Commit-Position: refs/heads/master@{#42330}
Committed: https://chromium.googlesource.com/v8/v8/+/aca17974f6811ba5132e8a47a94ae29ba912011a
Patch Set 1 #Patch Set 2 : merge with master #
Messages
Total messages: 21 (13 generated)
The CQ bit was checked by cbruni@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
cbruni@chromium.org changed reviewers: + ishell@chromium.org
PTAL
lgtm
The CQ bit was checked by cbruni@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for src/objects-printer.cc:
While running git apply --index -p1;
error: patch failed: src/objects-printer.cc:327
error: src/objects-printer.cc: patch does not apply
Patch: src/objects-printer.cc
Index: src/objects-printer.cc
diff --git a/src/objects-printer.cc b/src/objects-printer.cc
index
5e3aed7b7775083c972835969d1ed3722c454ed9..7fe8b23a2d60efca2f56dc3a0c0dd79341c7003b
100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -327,12 +327,12 @@ void FixedTypedArray<Traits>::FixedTypedArrayPrint(
os << "fixed " << Traits::Designator();
}
-
-void JSObject::PrintProperties(std::ostream& os) { // NOLINT
+bool JSObject::PrintProperties(std::ostream& os) { // NOLINT
if (HasFastProperties()) {
DescriptorArray* descs = map()->instance_descriptors();
- for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
- os << "\n ";
+ int i = 0;
+ for (; i < map()->NumberOfOwnDescriptors(); i++) {
+ os << "\n ";
descs->GetKey(i)->NamePrint(os);
os << ": ";
switch (descs->GetType(i)) {
@@ -359,11 +359,13 @@ void JSObject::PrintProperties(std::ostream& os) { //
NOLINT
break;
}
}
+ return i > 0;
} else if (IsJSGlobalObject()) {
global_dictionary()->Print(os);
} else {
property_dictionary()->Print(os);
}
+ return true;
}
namespace {
@@ -382,10 +384,8 @@ bool is_the_hole(double maybe_hole) {
return bit_cast<uint64_t>(maybe_hole) == kHoleNanInt64;
}
-} // namespace
-
template <class T, bool print_the_hole>
-static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
+void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
T* array = T::cast(object);
if (array->length() == 0) return;
int previous_index = 0;
@@ -416,38 +416,42 @@ static void DoPrintElements(std::ostream& os, Object*
object) { // NOLINT
}
}
+void PrintFixedArrayElements(std::ostream& os, FixedArray* array) {
+ // Print in array notation for non-sparse arrays.
+ Object* previous_value = array->get(0);
+ Object* value = nullptr;
+ int previous_index = 0;
+ int i;
+ for (i = 1; i <= array->length(); i++) {
+ if (i < array->length()) value = array->get(i);
+ if (previous_value == value && i != array->length()) {
+ continue;
+ }
+ os << "\n";
+ std::stringstream ss;
+ ss << previous_index;
+ if (previous_index != i - 1) {
+ ss << '-' << (i - 1);
+ }
+ os << std::setw(12) << ss.str() << ": " << Brief(previous_value);
+ previous_index = i;
+ previous_value = value;
+ }
+}
+
+} // namespace
-void JSObject::PrintElements(std::ostream& os) { // NOLINT
+bool JSObject::PrintElements(std::ostream& os) { // NOLINT
// Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging.
- if (elements()->length() == 0) return;
+ if (elements()->length() == 0) return false;
switch (map()->elements_kind()) {
case FAST_HOLEY_SMI_ELEMENTS:
case FAST_SMI_ELEMENTS:
case FAST_HOLEY_ELEMENTS:
case FAST_ELEMENTS:
case FAST_STRING_WRAPPER_ELEMENTS: {
- // Print in array notation for non-sparse arrays.
- FixedArray* array = FixedArray::cast(elements());
- Object* previous_value = array->get(0);
- Object* value = nullptr;
- int previous_index = 0;
- int i;
- for (i = 1; i <= array->length(); i++) {
- if (i < array->length()) value = array->get(i);
- if (previous_value == value && i != array->length()) {
- continue;
- }
- os << "\n";
- std::stringstream ss;
- ss << previous_index;
- if (previous_index != i - 1) {
- ss << '-' << (i - 1);
- }
- os << std::setw(12) << ss.str() << ": " << Brief(previous_value);
- previous_index = i;
- previous_value = value;
- }
+ PrintFixedArrayElements(os, FixedArray::cast(elements()));
break;
}
case FAST_HOLEY_DOUBLE_ELEMENTS:
@@ -482,6 +486,7 @@ void JSObject::PrintElements(std::ostream& os) { // NOLINT
case NO_ELEMENTS:
break;
}
+ return true;
}
@@ -513,12 +518,12 @@ static void JSObjectPrintHeader(std::ostream& os,
JSObject* obj,
static void JSObjectPrintBody(std::ostream& os, JSObject* obj, // NOLINT
bool print_elements = true) {
os << "\n - properties = " << Brief(obj->properties()) << " {";
- obj->PrintProperties(os);
- os << "\n }\n";
+ if (obj->PrintProperties(os)) os << "\n ";
+ os << "}\n";
if (print_elements && obj->elements()->length() > 0) {
- os << " - elements = {";
- obj->PrintElements(os);
- os << "\n }\n";
+ os << " - elements = " << Brief(obj->elements()) << " {";
+ if (obj->PrintElements(os)) os << "\n ";
+ os << "}\n";
}
int internal_fields = obj->GetInternalFieldCount();
if (internal_fields > 0) {
@@ -644,25 +649,18 @@ void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(
void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "FixedArray");
+ os << "\n - map = " << Brief(map());
os << "\n - length: " << length();
- for (int i = 0; i < length(); i++) {
- os << "\n [" << i << "]: " << Brief(get(i));
- }
+ PrintFixedArrayElements(os, this);
os << "\n";
}
void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "FixedDoubleArray");
+ os << "\n - map = " << Brief(map());
os << "\n - length: " << length();
- for (int i = 0; i < length(); i++) {
- os << "\n [" << i << "]: ";
- if (is_the_hole(i)) {
- os << "<the hole>";
- } else {
- os << get_scalar(i);
- }
- }
+ DoPrintElements<FixedDoubleArray, true>(os, this);
os << "\n";
}
The CQ bit was checked by cbruni@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from ishell@chromium.org Link to the patchset: https://codereview.chromium.org/2626023002/#ps20001 (title: "merge with master")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: v8_linux_rel_ng on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng/builds/19069) v8_linux_rel_ng_triggered on master.tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_rel_ng_triggered/b...)
The CQ bit was checked by cbruni@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 20001, "attempt_start_ts": 1484313946460400,
"parent_rev": "4caeb1e9eb306ca88886193edf5a4ae9db31c37a", "commit_rev":
"aca17974f6811ba5132e8a47a94ae29ba912011a"}
Message was sent while issue was closed.
Description was changed from ========== [printing] Improve FixedArray debug printing - condense repeated elements - print map BUG= ========== to ========== [printing] Improve FixedArray debug printing - condense repeated elements - print map BUG= Review-Url: https://codereview.chromium.org/2626023002 Cr-Commit-Position: refs/heads/master@{#42330} Committed: https://chromium.googlesource.com/v8/v8/+/aca17974f6811ba5132e8a47a94ae29ba91... ==========
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/v8/v8/+/aca17974f6811ba5132e8a47a94ae29ba91... |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
