OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "disassembler.h" | 30 #include "disassembler.h" |
31 #include "disasm.h" | 31 #include "disasm.h" |
32 #include "jsregexp.h" | 32 #include "jsregexp.h" |
33 #include "objects-visiting.h" | 33 #include "objects-visiting.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 #ifdef OBJECT_PRINT | 38 #ifdef OBJECT_PRINT |
39 | 39 |
40 static const char* TypeToString(InstanceType type); | |
41 | |
42 | |
43 void MaybeObject::Print() { | 40 void MaybeObject::Print() { |
44 Print(stdout); | 41 Print(stdout); |
45 } | 42 } |
46 | 43 |
47 | 44 |
48 void MaybeObject::Print(FILE* out) { | 45 void MaybeObject::Print(FILE* out) { |
49 Object* this_as_object; | 46 Object* this_as_object; |
50 if (ToObject(&this_as_object)) { | 47 if (ToObject(&this_as_object)) { |
51 if (this_as_object->IsSmi()) { | 48 if (this_as_object->IsSmi()) { |
52 Smi::cast(this_as_object)->SmiPrint(out); | 49 Smi::cast(this_as_object)->SmiPrint(out); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 PrintElementsKind(out, this->map()->elements_kind()); | 499 PrintElementsKind(out, this->map()->elements_kind()); |
503 PrintF(out, " {\n"); | 500 PrintF(out, " {\n"); |
504 PrintProperties(out); | 501 PrintProperties(out); |
505 PrintElements(out); | 502 PrintElements(out); |
506 PrintF(out, " }\n"); | 503 PrintF(out, " }\n"); |
507 } | 504 } |
508 | 505 |
509 | 506 |
510 static const char* TypeToString(InstanceType type) { | 507 static const char* TypeToString(InstanceType type) { |
511 switch (type) { | 508 switch (type) { |
512 case INVALID_TYPE: return "INVALID"; | 509 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE; |
513 case MAP_TYPE: return "MAP"; | 510 INSTANCE_TYPE_LIST(TYPE_TO_STRING) |
514 case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; | 511 #undef TYPE_TO_STRING |
515 case SYMBOL_TYPE: return "SYMBOL"; | |
516 case STRING_TYPE: return "TWO_BYTE_STRING"; | |
517 case ASCII_STRING_TYPE: return "ASCII_STRING"; | |
518 case CONS_STRING_TYPE: | |
519 case CONS_ASCII_STRING_TYPE: | |
520 return "CONS_STRING"; | |
521 case EXTERNAL_STRING_TYPE: | |
522 case EXTERNAL_ASCII_STRING_TYPE: | |
523 case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: | |
524 return "EXTERNAL_STRING"; | |
525 case SHORT_EXTERNAL_STRING_TYPE: | |
526 case SHORT_EXTERNAL_ASCII_STRING_TYPE: | |
527 case SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE: | |
528 return "SHORT_EXTERNAL_STRING"; | |
529 case INTERNALIZED_STRING_TYPE: return "INTERNALIZED_STRING"; | |
530 case ASCII_INTERNALIZED_STRING_TYPE: return "ASCII_INTERNALIZED_STRING"; | |
531 case CONS_INTERNALIZED_STRING_TYPE: return "CONS_INTERNALIZED_STRING"; | |
532 case CONS_ASCII_INTERNALIZED_STRING_TYPE: | |
533 return "CONS_ASCII_INTERNALIZED_STRING"; | |
534 case EXTERNAL_INTERNALIZED_STRING_TYPE: | |
535 case EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: | |
536 case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: | |
537 return "EXTERNAL_INTERNALIZED_STRING"; | |
538 case SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE: | |
539 case SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE: | |
540 case SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE: | |
541 return "SHORT_EXTERNAL_INTERNALIZED_STRING"; | |
542 case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; | |
543 case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; | |
544 case FREE_SPACE_TYPE: return "FREE_SPACE"; | |
545 case EXTERNAL_PIXEL_ARRAY_TYPE: return "EXTERNAL_PIXEL_ARRAY"; | |
546 case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; | |
547 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: | |
548 return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; | |
549 case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; | |
550 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: | |
551 return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; | |
552 case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; | |
553 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: | |
554 return "EXTERNAL_UNSIGNED_INT_ARRAY"; | |
555 case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; | |
556 case EXTERNAL_DOUBLE_ARRAY_TYPE: return "EXTERNAL_DOUBLE_ARRAY"; | |
557 case FILLER_TYPE: return "FILLER"; | |
558 case JS_OBJECT_TYPE: return "JS_OBJECT"; | |
559 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; | |
560 case ODDBALL_TYPE: return "ODDBALL"; | |
561 case CELL_TYPE: return "CELL"; | |
562 case PROPERTY_CELL_TYPE: return "PROPERTY_CELL"; | |
563 case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; | |
564 case JS_GENERATOR_OBJECT_TYPE: return "JS_GENERATOR_OBJECT"; | |
565 case JS_MODULE_TYPE: return "JS_MODULE"; | |
566 case JS_FUNCTION_TYPE: return "JS_FUNCTION"; | |
567 case CODE_TYPE: return "CODE"; | |
568 case JS_ARRAY_TYPE: return "JS_ARRAY"; | |
569 case JS_PROXY_TYPE: return "JS_PROXY"; | |
570 case JS_SET_TYPE: return "JS_SET"; | |
571 case JS_MAP_TYPE: return "JS_MAP"; | |
572 case JS_WEAK_MAP_TYPE: return "JS_WEAK_MAP"; | |
573 case JS_WEAK_SET_TYPE: return "JS_WEAK_SET"; | |
574 case JS_REGEXP_TYPE: return "JS_REGEXP"; | |
575 case JS_VALUE_TYPE: return "JS_VALUE"; | |
576 case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; | |
577 case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; | |
578 case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; | |
579 case JS_ARRAY_BUFFER_TYPE: return "JS_ARRAY_BUFFER"; | |
580 case JS_TYPED_ARRAY_TYPE: return "JS_TYPED_ARRAY"; | |
581 case JS_DATA_VIEW_TYPE: return "JS_DATA_VIEW"; | |
582 case FOREIGN_TYPE: return "FOREIGN"; | |
583 case JS_MESSAGE_OBJECT_TYPE: return "JS_MESSAGE_OBJECT_TYPE"; | |
584 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; | |
585 STRUCT_LIST(MAKE_STRUCT_CASE) | |
586 #undef MAKE_STRUCT_CASE | |
587 default: return "UNKNOWN"; | |
588 } | 512 } |
| 513 UNREACHABLE(); |
| 514 return "UNKNOWN"; // Keep the compiler happy. |
589 } | 515 } |
590 | 516 |
591 | 517 |
592 void Symbol::SymbolPrint(FILE* out) { | 518 void Symbol::SymbolPrint(FILE* out) { |
593 HeapObject::PrintHeader(out, "Symbol"); | 519 HeapObject::PrintHeader(out, "Symbol"); |
594 PrintF(out, " - hash: %d\n", Hash()); | 520 PrintF(out, " - hash: %d\n", Hash()); |
595 PrintF(out, " - name: "); | 521 PrintF(out, " - name: "); |
596 name()->ShortPrint(); | 522 name()->ShortPrint(); |
597 PrintF(out, "\n"); | 523 PrintF(out, "\n"); |
598 } | 524 } |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 } | 1230 } |
1305 } | 1231 } |
1306 PrintF(out, "\n"); | 1232 PrintF(out, "\n"); |
1307 } | 1233 } |
1308 | 1234 |
1309 | 1235 |
1310 #endif // OBJECT_PRINT | 1236 #endif // OBJECT_PRINT |
1311 | 1237 |
1312 | 1238 |
1313 } } // namespace v8::internal | 1239 } } // namespace v8::internal |
OLD | NEW |