Commit 7b2cd8b9 authored by cbruni's avatar cbruni Committed by Commit bot

Revert of [debugging] print ranges for consecutive values with %DebugPrint...

Revert of [debugging] print ranges for consecutive values with %DebugPrint (patchset #2 id:20001 of https://codereview.chromium.org/2169143003/ )

Reason for revert:
breaks android build due to uninitialized variable.
https://build.chromium.org/p/client.v8.ports/builders/V8%20Arm%20-%20debug%20builder/builds/2034

Original issue's description:
> [debugging] print ranges for consecutive values with %DebugPrint
>
> With this CL repeated values in elements are combined into a single printout with a range.
>
> BEFORE:
> - elements = {
>   0: <undefined>
>   1: <undefined>
>   2: <the_hole>
> }
>
> AFTER:
>  - elements = {
>        0-1: <undefined>
>          2: <the_hole>
> }
>
> BUG=
>
> Committed: https://crrev.com/ec4165742088043d8fede38db21a281e16682adb
> Cr-Commit-Position: refs/heads/master@{#38069}

TBR=yangguo@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review-Url: https://codereview.chromium.org/2181093003
Cr-Commit-Position: refs/heads/master@{#38071}
parent 9a6ee8d6
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "src/objects.h" #include "src/objects.h"
#include <iomanip>
#include <memory> #include <memory>
#include "src/disasm.h" #include "src/disasm.h"
...@@ -318,35 +317,12 @@ void JSObject::PrintProperties(std::ostream& os) { // NOLINT ...@@ -318,35 +317,12 @@ void JSObject::PrintProperties(std::ostream& os) { // NOLINT
} }
} }
template <class T, bool print_the_hole>
template <class T>
static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
T* array = T::cast(object); T* p = T::cast(object);
if (array->length() == 0) return; for (int i = 0; i < p->length(); i++) {
int previous_index = 0; os << "\n " << i << ": " << p->get_scalar(i);
double previous_value = array->get_scalar(0);
double value;
int i;
for (i = 1; i <= array->length(); i++) {
if (i < array->length()) value = array->get_scalar(i);
bool values_are_nan = std::isnan(previous_value) && std::isnan(value);
if ((previous_value == value || values_are_nan) && 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() << ": ";
if (print_the_hole &&
FixedDoubleArray::cast(object)->is_the_hole(previous_index)) {
os << "<the_hole>";
} else {
os << previous_value;
}
previous_index = i;
previous_value = value;
} }
} }
...@@ -354,7 +330,6 @@ static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT ...@@ -354,7 +330,6 @@ static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
void JSObject::PrintElements(std::ostream& os) { // NOLINT void JSObject::PrintElements(std::ostream& os) { // NOLINT
// Don't call GetElementsKind, its validation code can cause the printer to // Don't call GetElementsKind, its validation code can cause the printer to
// fail when debugging. // fail when debugging.
if (elements()->length() == 0) return;
switch (map()->elements_kind()) { switch (map()->elements_kind()) {
case FAST_HOLEY_SMI_ELEMENTS: case FAST_HOLEY_SMI_ELEMENTS:
case FAST_SMI_ELEMENTS: case FAST_SMI_ELEMENTS:
...@@ -362,49 +337,45 @@ void JSObject::PrintElements(std::ostream& os) { // NOLINT ...@@ -362,49 +337,45 @@ void JSObject::PrintElements(std::ostream& os) { // NOLINT
case FAST_ELEMENTS: case FAST_ELEMENTS:
case FAST_STRING_WRAPPER_ELEMENTS: { case FAST_STRING_WRAPPER_ELEMENTS: {
// Print in array notation for non-sparse arrays. // Print in array notation for non-sparse arrays.
FixedArray* array = FixedArray::cast(elements()); FixedArray* p = FixedArray::cast(elements());
Object* previous_value = array->get(0); for (int i = 0; i < p->length(); i++) {
Object* value; os << "\n " << i << ": " << Brief(p->get(i));
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;
} }
break; break;
} }
case FAST_HOLEY_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS:
case FAST_DOUBLE_ELEMENTS: { case FAST_DOUBLE_ELEMENTS: {
DoPrintElements<FixedDoubleArray, true>(os, elements()); // Print in array notation for non-sparse arrays.
if (elements()->length() > 0) {
FixedDoubleArray* p = FixedDoubleArray::cast(elements());
for (int i = 0; i < p->length(); i++) {
os << "\n " << i << ": ";
if (p->is_the_hole(i)) {
os << "<the hole>";
} else {
os << p->get_scalar(i);
}
}
}
break; break;
} }
#define PRINT_ELEMENTS(Kind, Type) \
case Kind: { \ #define PRINT_ELEMENTS(Kind, Type) \
DoPrintElements<Type, false>(os, elements()); \ case Kind: { \
break; \ DoPrintElements<Type>(os, elements()); \
break; \
} }
PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array) PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray) PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array) PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array) PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array) PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array) PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array) PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array) PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array) PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
#undef PRINT_ELEMENTS #undef PRINT_ELEMENTS
......
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