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

Unified Diff: src/objects-printer.cc

Issue 760213005: Turn on DCHECKs and other debugging code if dcheck_always_on is 1 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updaets Created 6 years 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') | src/transitions.h » ('j') | 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 d0ea0346579bee9151feea83bc0958c54459299d..89dd06157686995d4241513fcb774e8c1b09664b 100644
--- a/src/objects-printer.cc
+++ b/src/objects-printer.cc
@@ -346,12 +346,6 @@ void JSObject::PrintElements(std::ostream& os) { // NOLINT
}
-void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
- if (!map()->HasTransitionArray()) return;
- map()->transitions()->PrintTransitions(os, false);
-}
-
-
void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "JSObject");
// Don't call GetElementsKind, its validation code can cause the printer to
@@ -592,21 +586,6 @@ void Name::NamePrint(std::ostream& os) { // NOLINT
}
-// This method is only meant to be called from gdb for debugging purposes.
-// Since the string can also be in two-byte encoding, non-Latin1 characters
-// will be ignored in the output.
-char* String::ToAsciiArray() {
- // Static so that subsequent calls frees previously allocated space.
- // This also means that previous results will be overwritten.
- static char* buffer = NULL;
- if (buffer != NULL) delete[] buffer;
- buffer = new char[length()+1];
- WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
- buffer[length()] = 0;
- return buffer;
-}
-
-
static const char* const weekdays[] = {
"???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};
@@ -1067,25 +1046,6 @@ void BreakPointInfo::BreakPointInfoPrint(std::ostream& os) { // NOLINT
}
-void DescriptorArray::Print() {
- OFStream os(stdout);
- this->PrintDescriptors(os);
- os << std::flush;
-}
-
-
-void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
- HandleScope scope(GetIsolate());
- os << "Descriptor array " << number_of_descriptors() << "\n";
- for (int i = 0; i < number_of_descriptors(); i++) {
- Descriptor desc;
- Get(i, &desc);
- os << " " << i << ": " << desc << "\n";
- }
- os << "\n";
-}
-
-
static void PrintBitMask(std::ostream& os, uint32_t value) { // NOLINT
for (int i = 0; i < 32; i++) {
if ((i & 7) == 0) os << " ";
@@ -1123,6 +1083,80 @@ void LayoutDescriptor::Print(std::ostream& os) { // NOLINT
}
+#endif // OBJECT_PRINT
+
+
+#if TRACE_MAPS
+
+
+void Name::NameShortPrint() {
+ if (this->IsString()) {
+ PrintF("%s", String::cast(this)->ToCString().get());
+ } else {
+ DCHECK(this->IsSymbol());
+ Symbol* s = Symbol::cast(this);
+ if (s->name()->IsUndefined()) {
+ PrintF("#<%s>", s->PrivateSymbolToName());
+ } else {
+ PrintF("<%s>", String::cast(s->name())->ToCString().get());
+ }
+ }
+}
+
+
+int Name::NameShortPrint(Vector<char> str) {
+ if (this->IsString()) {
+ return SNPrintF(str, "%s", String::cast(this)->ToCString().get());
+ } else {
+ DCHECK(this->IsSymbol());
+ Symbol* s = Symbol::cast(this);
+ if (s->name()->IsUndefined()) {
+ return SNPrintF(str, "#<%s>", s->PrivateSymbolToName());
+ } else {
+ return SNPrintF(str, "<%s>", String::cast(s->name())->ToCString().get());
+ }
+ }
+}
+
+
+#endif // TRACE_MAPS
+
+
+#ifdef DEBUG
+// This method is only meant to be called from gdb for debugging purposes.
+// Since the string can also be in two-byte encoding, non-Latin1 characters
+// will be ignored in the output.
+char* String::ToAsciiArray() {
+ // Static so that subsequent calls frees previously allocated space.
+ // This also means that previous results will be overwritten.
+ static char* buffer = NULL;
+ if (buffer != NULL) delete[] buffer;
+ buffer = new char[length() + 1];
+ WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
+ buffer[length()] = 0;
+ return buffer;
+}
+
+
+void DescriptorArray::Print() {
+ OFStream os(stdout);
+ this->PrintDescriptors(os);
+ os << std::flush;
+}
+
+
+void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
+ HandleScope scope(GetIsolate());
+ os << "Descriptor array " << number_of_descriptors() << "\n";
+ for (int i = 0; i < number_of_descriptors(); i++) {
+ Descriptor desc;
+ Get(i, &desc);
+ os << " " << i << ": " << desc << "\n";
+ }
+ os << "\n";
+}
+
+
void TransitionArray::Print() {
OFStream os(stdout);
this->PrintTransitions(os);
@@ -1138,7 +1172,11 @@ void TransitionArray::PrintTransitions(std::ostream& os,
for (int i = 0; i < number_of_transitions(); i++) {
Name* key = GetKey(i);
os << " ";
+#ifdef OBJECT_PRINT
key->NamePrint(os);
+#else
+ key->ShortPrint(os);
+#endif
os << ": ";
if (key == GetHeap()->frozen_symbol()) {
os << " (transition to frozen)";
@@ -1168,41 +1206,9 @@ void TransitionArray::PrintTransitions(std::ostream& os,
}
-#endif // OBJECT_PRINT
-
-
-#if TRACE_MAPS
-
-
-void Name::NameShortPrint() {
- if (this->IsString()) {
- PrintF("%s", String::cast(this)->ToCString().get());
- } else {
- DCHECK(this->IsSymbol());
- Symbol* s = Symbol::cast(this);
- if (s->name()->IsUndefined()) {
- PrintF("#<%s>", s->PrivateSymbolToName());
- } else {
- PrintF("<%s>", String::cast(s->name())->ToCString().get());
- }
- }
-}
-
-
-int Name::NameShortPrint(Vector<char> str) {
- if (this->IsString()) {
- return SNPrintF(str, "%s", String::cast(this)->ToCString().get());
- } else {
- DCHECK(this->IsSymbol());
- Symbol* s = Symbol::cast(this);
- if (s->name()->IsUndefined()) {
- return SNPrintF(str, "#<%s>", s->PrivateSymbolToName());
- } else {
- return SNPrintF(str, "<%s>", String::cast(s->name())->ToCString().get());
- }
- }
+void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
+ if (!map()->HasTransitionArray()) return;
+ map()->transitions()->PrintTransitions(os, false);
}
-
-
-#endif // TRACE_MAPS
+#endif // DEBUG
} } // namespace v8::internal
« no previous file with comments | « src/objects-inl.h ('k') | src/transitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698