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

Side by Side Diff: src/objects-printer.cc

Issue 659363002: More details printed for Map, DescriptorArray and TransitionArray. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: gdbinit updated Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | src/property.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/disasm.h" 7 #include "src/disasm.h"
8 #include "src/disassembler.h" 8 #include "src/disassembler.h"
9 #include "src/heap/objects-visiting.h" 9 #include "src/heap/objects-visiting.h"
10 #include "src/jsregexp.h" 10 #include "src/jsregexp.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 os << "\n context: " << Brief(p->get(0)) 340 os << "\n context: " << Brief(p->get(0))
341 << "\n arguments: " << Brief(p->get(1)) << "\n"; 341 << "\n arguments: " << Brief(p->get(1)) << "\n";
342 break; 342 break;
343 } 343 }
344 } 344 }
345 } 345 }
346 346
347 347
348 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT 348 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
349 if (!map()->HasTransitionArray()) return; 349 if (!map()->HasTransitionArray()) return;
350 TransitionArray* transitions = map()->transitions(); 350 map()->transitions()->PrintTransitions(os, false);
351 for (int i = 0; i < transitions->number_of_transitions(); i++) {
352 Name* key = transitions->GetKey(i);
353 os << " ";
354 key->NamePrint(os);
355 os << ": ";
356 if (key == GetHeap()->frozen_symbol()) {
357 os << " (transition to frozen)\n";
358 } else if (key == GetHeap()->elements_transition_symbol()) {
359 os << " (transition to "
360 << ElementsKindToString(transitions->GetTarget(i)->elements_kind())
361 << ")\n";
362 } else if (key == GetHeap()->observed_symbol()) {
363 os << " (transition to Object.observe)\n";
364 } else {
365 switch (transitions->GetTargetDetails(i).type()) {
366 case FIELD: {
367 os << " (transition to field)\n";
368 break;
369 }
370 case CONSTANT:
371 os << " (transition to constant)\n";
372 break;
373 case CALLBACKS:
374 os << " (transition to callback)\n";
375 break;
376 // Values below are never in the target descriptor array.
377 case NORMAL:
378 UNREACHABLE();
379 break;
380 }
381 }
382 }
383 } 351 }
384 352
385 353
386 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT 354 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT
387 HeapObject::PrintHeader(os, "JSObject"); 355 HeapObject::PrintHeader(os, "JSObject");
388 // Don't call GetElementsKind, its validation code can cause the printer to 356 // Don't call GetElementsKind, its validation code can cause the printer to
389 // fail when debugging. 357 // fail when debugging.
390 PrototypeIterator iter(GetIsolate(), this); 358 PrototypeIterator iter(GetIsolate(), this);
391 os << " - map = " << reinterpret_cast<void*>(map()) << " [" 359 os << " - map = " << reinterpret_cast<void*>(map()) << " ["
392 << ElementsKindToString(this->map()->elements_kind()) 360 << ElementsKindToString(this->map()->elements_kind())
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 403
436 void Map::MapPrint(std::ostream& os) { // NOLINT 404 void Map::MapPrint(std::ostream& os) { // NOLINT
437 HeapObject::PrintHeader(os, "Map"); 405 HeapObject::PrintHeader(os, "Map");
438 os << " - type: " << TypeToString(instance_type()) << "\n"; 406 os << " - type: " << TypeToString(instance_type()) << "\n";
439 os << " - instance size: " << instance_size() << "\n"; 407 os << " - instance size: " << instance_size() << "\n";
440 os << " - inobject properties: " << inobject_properties() << "\n"; 408 os << " - inobject properties: " << inobject_properties() << "\n";
441 os << " - elements kind: " << ElementsKindToString(elements_kind()); 409 os << " - elements kind: " << ElementsKindToString(elements_kind());
442 os << "\n - pre-allocated property fields: " 410 os << "\n - pre-allocated property fields: "
443 << pre_allocated_property_fields() << "\n"; 411 << pre_allocated_property_fields() << "\n";
444 os << " - unused property fields: " << unused_property_fields() << "\n"; 412 os << " - unused property fields: " << unused_property_fields() << "\n";
413 if (is_dictionary_map()) os << " - dictionary_map\n";
414 if (is_prototype_map()) os << " - prototype_map\n";
445 if (is_hidden_prototype()) os << " - hidden_prototype\n"; 415 if (is_hidden_prototype()) os << " - hidden_prototype\n";
446 if (has_named_interceptor()) os << " - named_interceptor\n"; 416 if (has_named_interceptor()) os << " - named_interceptor\n";
447 if (has_indexed_interceptor()) os << " - indexed_interceptor\n"; 417 if (has_indexed_interceptor()) os << " - indexed_interceptor\n";
448 if (is_undetectable()) os << " - undetectable\n"; 418 if (is_undetectable()) os << " - undetectable\n";
449 if (has_instance_call_handler()) os << " - instance_call_handler\n"; 419 if (has_instance_call_handler()) os << " - instance_call_handler\n";
450 if (is_access_check_needed()) os << " - access_check_needed\n"; 420 if (is_access_check_needed()) os << " - access_check_needed\n";
451 if (is_frozen()) { 421 if (is_frozen()) {
452 os << " - frozen\n"; 422 os << " - frozen\n";
453 } else if (!is_extensible()) { 423 } else if (!is_extensible()) {
454 os << " - sealed\n"; 424 os << " - sealed\n";
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 568 }
599 if (len != length()) { 569 if (len != length()) {
600 os << truncated_epilogue; 570 os << truncated_epilogue;
601 } 571 }
602 572
603 if (!StringShape(this).IsInternalized()) os << "\""; 573 if (!StringShape(this).IsInternalized()) os << "\"";
604 } 574 }
605 575
606 576
607 void Name::NamePrint(std::ostream& os) { // NOLINT 577 void Name::NamePrint(std::ostream& os) { // NOLINT
608 if (IsString()) 578 if (IsString()) {
609 String::cast(this)->StringPrint(os); 579 String::cast(this)->StringPrint(os);
610 else 580 } else if (IsSymbol()) {
581 Symbol::cast(this)->name()->Print(os);
582 } else {
611 os << Brief(this); 583 os << Brief(this);
584 }
612 } 585 }
613 586
614 587
615 // This method is only meant to be called from gdb for debugging purposes. 588 // This method is only meant to be called from gdb for debugging purposes.
616 // Since the string can also be in two-byte encoding, non-Latin1 characters 589 // Since the string can also be in two-byte encoding, non-Latin1 characters
617 // will be ignored in the output. 590 // will be ignored in the output.
618 char* String::ToAsciiArray() { 591 char* String::ToAsciiArray() {
619 // Static so that subsequent calls frees previously allocated space. 592 // Static so that subsequent calls frees previously allocated space.
620 // This also means that previous results will be overwritten. 593 // This also means that previous results will be overwritten.
621 static char* buffer = NULL; 594 static char* buffer = NULL;
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 void BreakPointInfo::BreakPointInfoPrint(std::ostream& os) { // NOLINT 1048 void BreakPointInfo::BreakPointInfoPrint(std::ostream& os) { // NOLINT
1076 HeapObject::PrintHeader(os, "BreakPointInfo"); 1049 HeapObject::PrintHeader(os, "BreakPointInfo");
1077 os << "\n - code_position: " << code_position()->value(); 1050 os << "\n - code_position: " << code_position()->value();
1078 os << "\n - source_position: " << source_position()->value(); 1051 os << "\n - source_position: " << source_position()->value();
1079 os << "\n - statement_position: " << statement_position()->value(); 1052 os << "\n - statement_position: " << statement_position()->value();
1080 os << "\n - break_point_objects: " << Brief(break_point_objects()); 1053 os << "\n - break_point_objects: " << Brief(break_point_objects());
1081 os << "\n"; 1054 os << "\n";
1082 } 1055 }
1083 1056
1084 1057
1058 void DescriptorArray::Print() {
1059 OFStream os(stdout);
1060 this->PrintDescriptors(os);
1061 os << std::flush;
1062 }
1063
1064
1085 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT 1065 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
1086 os << "Descriptor array " << number_of_descriptors() << "\n"; 1066 os << "Descriptor array " << number_of_descriptors() << "\n";
1087 for (int i = 0; i < number_of_descriptors(); i++) { 1067 for (int i = 0; i < number_of_descriptors(); i++) {
1088 Descriptor desc; 1068 Descriptor desc;
1089 Get(i, &desc); 1069 Get(i, &desc);
1090 os << " " << i << ": " << desc; 1070 os << " " << i << ": " << desc << "\n";
1091 } 1071 }
1092 os << "\n"; 1072 os << "\n";
1093 } 1073 }
1094 1074
1095 1075
1096 void TransitionArray::PrintTransitions(std::ostream& os) { // NOLINT 1076 void TransitionArray::Print() {
1097 os << "Transition array %d\n", number_of_transitions(); 1077 OFStream os(stdout);
1098 for (int i = 0; i < number_of_transitions(); i++) { 1078 this->PrintTransitions(os);
1099 os << " " << i << ": "; 1079 os << std::flush;
1100 GetKey(i)->NamePrint(os);
1101 os << ": ";
1102 switch (GetTargetDetails(i).type()) {
1103 case FIELD: {
1104 os << " (transition to field)\n";
1105 break;
1106 }
1107 case CONSTANT:
1108 os << " (transition to constant)\n";
1109 break;
1110 case CALLBACKS:
1111 os << " (transition to callback)\n";
1112 break;
1113 // Values below are never in the target descriptor array.
1114 case NORMAL:
1115 UNREACHABLE();
1116 break;
1117 }
1118 }
1119 os << "\n";
1120 } 1080 }
1121 1081
1122 1082
1083 void TransitionArray::PrintTransitions(std::ostream& os,
1084 bool print_header) { // NOLINT
1085 if (print_header) {
1086 os << "Transition array " << number_of_transitions() << "\n";
1087 }
1088 for (int i = 0; i < number_of_transitions(); i++) {
1089 Name* key = GetKey(i);
1090 os << " ";
1091 key->NamePrint(os);
1092 os << ": ";
1093 if (key == GetHeap()->frozen_symbol()) {
1094 os << " (transition to frozen)";
1095 } else if (key == GetHeap()->elements_transition_symbol()) {
1096 os << " (transition to "
1097 << ElementsKindToString(GetTarget(i)->elements_kind()) << ")";
1098 } else if (key == GetHeap()->observed_symbol()) {
1099 os << " (transition to Object.observe)";
1100 } else {
1101 PropertyDetails details = GetTargetDetails(i);
1102 switch (details.type()) {
1103 case FIELD: {
1104 os << " (transition to field)";
1105 break;
1106 }
1107 case CONSTANT:
1108 os << " (transition to constant " << Brief(GetTargetValue(i)) << ")";
1109 break;
1110 case CALLBACKS:
1111 os << " (transition to callback " << Brief(GetTargetValue(i)) << ")";
1112 break;
1113 // Values below are never in the target descriptor array.
1114 case NORMAL:
1115 UNREACHABLE();
1116 break;
1117 }
1118 os << ", attrs: " << details.attributes();
1119 }
1120 os << " -> " << Brief(GetTarget(i)) << "\n";
1121 }
1122 }
1123
1124
1123 #endif // OBJECT_PRINT 1125 #endif // OBJECT_PRINT
1124 1126
1125 1127
1126 } } // namespace v8::internal 1128 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/property.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698