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

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: Created 6 years, 2 months 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";
455 } 425 }
456 os << " - back pointer: " << Brief(GetBackPointer()); 426 os << " - back pointer: " << Brief(GetBackPointer());
457 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "") 427 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
458 << "#" << NumberOfOwnDescriptors() << ": " 428 << "#" << NumberOfOwnDescriptors() << ": "
459 << Brief(instance_descriptors()); 429 << Brief(instance_descriptors());
460 if (HasTransitionArray()) { 430 if (HasTransitionArray()) {
461 os << "\n - transitions: " << Brief(transitions()); 431 os << "\n - transitions: " << Brief(transitions());
462 } 432 }
463 os << "\n - prototype: " << Brief(prototype()); 433 os << "\n - prototype: " << Brief(prototype());
464 os << "\n - constructor: " << Brief(constructor()); 434 os << "\n - constructor: " << Brief(constructor());
465 os << "\n - code cache: " << Brief(code_cache()); 435 os << "\n - code cache: " << Brief(code_cache());
466 os << "\n - dependent code: " << Brief(dependent_code()); 436 os << "\n - dependent code: " << Brief(dependent_code());
467 os << "\n"; 437 os << "\n";
438 instance_descriptors()->PrintDescriptors(os);
439 if (HasTransitionArray()) {
440 transitions()->PrintTransitions(os);
441 }
Toon Verwaest 2014/10/23 09:54:51 This is a bit too much info I think.
Igor Sheludko 2014/10/23 11:21:27 Done.
442 os << "\n";
468 } 443 }
469 444
470 445
471 void CodeCache::CodeCachePrint(std::ostream& os) { // NOLINT 446 void CodeCache::CodeCachePrint(std::ostream& os) { // NOLINT
472 HeapObject::PrintHeader(os, "CodeCache"); 447 HeapObject::PrintHeader(os, "CodeCache");
473 os << "\n - default_cache: " << Brief(default_cache()); 448 os << "\n - default_cache: " << Brief(default_cache());
474 os << "\n - normal_type_cache: " << Brief(normal_type_cache()); 449 os << "\n - normal_type_cache: " << Brief(normal_type_cache());
475 } 450 }
476 451
477 452
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 573 }
599 if (len != length()) { 574 if (len != length()) {
600 os << truncated_epilogue; 575 os << truncated_epilogue;
601 } 576 }
602 577
603 if (!StringShape(this).IsInternalized()) os << "\""; 578 if (!StringShape(this).IsInternalized()) os << "\"";
604 } 579 }
605 580
606 581
607 void Name::NamePrint(std::ostream& os) { // NOLINT 582 void Name::NamePrint(std::ostream& os) { // NOLINT
608 if (IsString()) 583 if (IsString()) {
609 String::cast(this)->StringPrint(os); 584 String::cast(this)->StringPrint(os);
610 else 585 } else if (IsSymbol()) {
586 Symbol::cast(this)->name()->Print(os);
587 } else {
611 os << Brief(this); 588 os << Brief(this);
589 }
612 } 590 }
613 591
614 592
615 // This method is only meant to be called from gdb for debugging purposes. 593 // 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 594 // Since the string can also be in two-byte encoding, non-Latin1 characters
617 // will be ignored in the output. 595 // will be ignored in the output.
618 char* String::ToAsciiArray() { 596 char* String::ToAsciiArray() {
619 // Static so that subsequent calls frees previously allocated space. 597 // Static so that subsequent calls frees previously allocated space.
620 // This also means that previous results will be overwritten. 598 // This also means that previous results will be overwritten.
621 static char* buffer = NULL; 599 static char* buffer = NULL;
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 HeapObject::PrintHeader(os, "BreakPointInfo"); 1054 HeapObject::PrintHeader(os, "BreakPointInfo");
1077 os << "\n - code_position: " << code_position()->value(); 1055 os << "\n - code_position: " << code_position()->value();
1078 os << "\n - source_position: " << source_position()->value(); 1056 os << "\n - source_position: " << source_position()->value();
1079 os << "\n - statement_position: " << statement_position()->value(); 1057 os << "\n - statement_position: " << statement_position()->value();
1080 os << "\n - break_point_objects: " << Brief(break_point_objects()); 1058 os << "\n - break_point_objects: " << Brief(break_point_objects());
1081 os << "\n"; 1059 os << "\n";
1082 } 1060 }
1083 1061
1084 1062
1085 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT 1063 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
1086 os << "Descriptor array " << number_of_descriptors() << "\n"; 1064 os << "Descriptor array " << number_of_descriptors() << "\n";
1087 for (int i = 0; i < number_of_descriptors(); i++) { 1065 for (int i = 0; i < number_of_descriptors(); i++) {
1088 Descriptor desc; 1066 Descriptor desc;
1089 Get(i, &desc); 1067 Get(i, &desc);
1090 os << " " << i << ": " << desc; 1068 os << " " << i << ": " << desc << "\n";
1091 } 1069 }
1092 os << "\n"; 1070 os << "\n";
1093 } 1071 }
1094 1072
1095 1073
1096 void TransitionArray::PrintTransitions(std::ostream& os) { // NOLINT 1074 void TransitionArray::PrintTransitions(std::ostream& os,
1097 os << "Transition array %d\n", number_of_transitions(); 1075 bool print_header) { // NOLINT
1076 if (print_header) {
1077 os << "Transition array " << number_of_transitions() << "\n";
1078 }
1098 for (int i = 0; i < number_of_transitions(); i++) { 1079 for (int i = 0; i < number_of_transitions(); i++) {
1099 os << " " << i << ": "; 1080 Name* key = GetKey(i);
1100 GetKey(i)->NamePrint(os); 1081 os << " ";
1082 key->NamePrint(os);
1101 os << ": "; 1083 os << ": ";
1102 switch (GetTargetDetails(i).type()) { 1084 if (key == GetHeap()->frozen_symbol()) {
1103 case FIELD: { 1085 os << " (transition to frozen)";
1104 os << " (transition to field)\n"; 1086 } else if (key == GetHeap()->elements_transition_symbol()) {
1105 break; 1087 os << " (transition to "
1088 << ElementsKindToString(GetTarget(i)->elements_kind()) << ")";
1089 } else if (key == GetHeap()->observed_symbol()) {
1090 os << " (transition to Object.observe)";
1091 } else {
1092 PropertyDetails details = GetTargetDetails(i);
1093 switch (details.type()) {
1094 case FIELD: {
1095 os << " (transition to field)";
1096 break;
1097 }
1098 case CONSTANT:
1099 os << " (transition to constant " << Brief(GetTargetValue(i)) << ")";
1100 break;
1101 case CALLBACKS:
1102 os << " (transition to callback " << Brief(GetTargetValue(i)) << ")";
1103 break;
1104 // Values below are never in the target descriptor array.
1105 case NORMAL:
1106 UNREACHABLE();
1107 break;
1106 } 1108 }
1107 case CONSTANT: 1109 os << ", attrs: " << details.attributes();
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 } 1110 }
1111 os << " -> " << Brief(GetTarget(i)) << "\n";
1118 } 1112 }
1119 os << "\n";
1120 } 1113 }
1121 1114
1122 1115
1123 #endif // OBJECT_PRINT 1116 #endif // OBJECT_PRINT
1124 1117
1125 1118
1126 } } // namespace v8::internal 1119 } } // 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