| 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 22 matching lines...) Expand all Loading... |
| 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); | 40 static const char* TypeToString(InstanceType type); |
| 41 | 41 |
| 42 | 42 |
| 43 void MaybeObject::Print() { |
| 44 Print(stdout); |
| 45 } |
| 46 |
| 47 |
| 43 void MaybeObject::Print(FILE* out) { | 48 void MaybeObject::Print(FILE* out) { |
| 44 Object* this_as_object; | 49 Object* this_as_object; |
| 45 if (ToObject(&this_as_object)) { | 50 if (ToObject(&this_as_object)) { |
| 46 if (this_as_object->IsSmi()) { | 51 if (this_as_object->IsSmi()) { |
| 47 Smi::cast(this_as_object)->SmiPrint(out); | 52 Smi::cast(this_as_object)->SmiPrint(out); |
| 48 } else { | 53 } else { |
| 49 HeapObject::cast(this_as_object)->HeapObjectPrint(out); | 54 HeapObject::cast(this_as_object)->HeapObjectPrint(out); |
| 50 } | 55 } |
| 51 } else { | 56 } else { |
| 52 Failure::cast(this)->FailurePrint(out); | 57 Failure::cast(this)->FailurePrint(out); |
| 53 } | 58 } |
| 54 Flush(out); | 59 Flush(out); |
| 55 } | 60 } |
| 56 | 61 |
| 57 | 62 |
| 63 void MaybeObject::PrintLn() { |
| 64 PrintLn(stdout); |
| 65 } |
| 66 |
| 67 |
| 58 void MaybeObject::PrintLn(FILE* out) { | 68 void MaybeObject::PrintLn(FILE* out) { |
| 59 Print(out); | 69 Print(out); |
| 60 PrintF(out, "\n"); | 70 PrintF(out, "\n"); |
| 61 } | 71 } |
| 62 | 72 |
| 63 | 73 |
| 64 void HeapObject::PrintHeader(FILE* out, const char* id) { | 74 void HeapObject::PrintHeader(FILE* out, const char* id) { |
| 65 PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id); | 75 PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id); |
| 66 } | 76 } |
| 67 | 77 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 break; | 176 break; |
| 167 case JS_PROXY_TYPE: | 177 case JS_PROXY_TYPE: |
| 168 JSProxy::cast(this)->JSProxyPrint(out); | 178 JSProxy::cast(this)->JSProxyPrint(out); |
| 169 break; | 179 break; |
| 170 case JS_FUNCTION_PROXY_TYPE: | 180 case JS_FUNCTION_PROXY_TYPE: |
| 171 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out); | 181 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out); |
| 172 break; | 182 break; |
| 173 case JS_WEAK_MAP_TYPE: | 183 case JS_WEAK_MAP_TYPE: |
| 174 JSWeakMap::cast(this)->JSWeakMapPrint(out); | 184 JSWeakMap::cast(this)->JSWeakMapPrint(out); |
| 175 break; | 185 break; |
| 186 case JS_WEAK_SET_TYPE: |
| 187 JSWeakSet::cast(this)->JSWeakSetPrint(out); |
| 188 break; |
| 176 case FOREIGN_TYPE: | 189 case FOREIGN_TYPE: |
| 177 Foreign::cast(this)->ForeignPrint(out); | 190 Foreign::cast(this)->ForeignPrint(out); |
| 178 break; | 191 break; |
| 179 case SHARED_FUNCTION_INFO_TYPE: | 192 case SHARED_FUNCTION_INFO_TYPE: |
| 180 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); | 193 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); |
| 181 break; | 194 break; |
| 182 case JS_MESSAGE_OBJECT_TYPE: | 195 case JS_MESSAGE_OBJECT_TYPE: |
| 183 JSMessageObject::cast(this)->JSMessageObjectPrint(out); | 196 JSMessageObject::cast(this)->JSMessageObjectPrint(out); |
| 184 break; | 197 break; |
| 185 case CELL_TYPE: | 198 case CELL_TYPE: |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 case CELL_TYPE: return "CELL"; | 555 case CELL_TYPE: return "CELL"; |
| 543 case PROPERTY_CELL_TYPE: return "PROPERTY_CELL"; | 556 case PROPERTY_CELL_TYPE: return "PROPERTY_CELL"; |
| 544 case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; | 557 case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 545 case JS_GENERATOR_OBJECT_TYPE: return "JS_GENERATOR_OBJECT"; | 558 case JS_GENERATOR_OBJECT_TYPE: return "JS_GENERATOR_OBJECT"; |
| 546 case JS_MODULE_TYPE: return "JS_MODULE"; | 559 case JS_MODULE_TYPE: return "JS_MODULE"; |
| 547 case JS_FUNCTION_TYPE: return "JS_FUNCTION"; | 560 case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 548 case CODE_TYPE: return "CODE"; | 561 case CODE_TYPE: return "CODE"; |
| 549 case JS_ARRAY_TYPE: return "JS_ARRAY"; | 562 case JS_ARRAY_TYPE: return "JS_ARRAY"; |
| 550 case JS_PROXY_TYPE: return "JS_PROXY"; | 563 case JS_PROXY_TYPE: return "JS_PROXY"; |
| 551 case JS_WEAK_MAP_TYPE: return "JS_WEAK_MAP"; | 564 case JS_WEAK_MAP_TYPE: return "JS_WEAK_MAP"; |
| 565 case JS_WEAK_SET_TYPE: return "JS_WEAK_SET"; |
| 552 case JS_REGEXP_TYPE: return "JS_REGEXP"; | 566 case JS_REGEXP_TYPE: return "JS_REGEXP"; |
| 553 case JS_VALUE_TYPE: return "JS_VALUE"; | 567 case JS_VALUE_TYPE: return "JS_VALUE"; |
| 554 case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; | 568 case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 555 case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; | 569 case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
| 556 case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; | 570 case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
| 557 case JS_ARRAY_BUFFER_TYPE: return "JS_ARRAY_BUFFER"; | 571 case JS_ARRAY_BUFFER_TYPE: return "JS_ARRAY_BUFFER"; |
| 558 case JS_TYPED_ARRAY_TYPE: return "JS_TYPED_ARRAY"; | 572 case JS_TYPED_ARRAY_TYPE: return "JS_TYPED_ARRAY"; |
| 559 case JS_DATA_VIEW_TYPE: return "JS_DATA_VIEW"; | 573 case JS_DATA_VIEW_TYPE: return "JS_DATA_VIEW"; |
| 560 case FOREIGN_TYPE: return "FOREIGN"; | 574 case FOREIGN_TYPE: return "FOREIGN"; |
| 561 case JS_MESSAGE_OBJECT_TYPE: return "JS_MESSAGE_OBJECT_TYPE"; | 575 case JS_MESSAGE_OBJECT_TYPE: return "JS_MESSAGE_OBJECT_TYPE"; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 821 |
| 808 void JSWeakMap::JSWeakMapPrint(FILE* out) { | 822 void JSWeakMap::JSWeakMapPrint(FILE* out) { |
| 809 HeapObject::PrintHeader(out, "JSWeakMap"); | 823 HeapObject::PrintHeader(out, "JSWeakMap"); |
| 810 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); | 824 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 811 PrintF(out, " - table = "); | 825 PrintF(out, " - table = "); |
| 812 table()->ShortPrint(out); | 826 table()->ShortPrint(out); |
| 813 PrintF(out, "\n"); | 827 PrintF(out, "\n"); |
| 814 } | 828 } |
| 815 | 829 |
| 816 | 830 |
| 831 void JSWeakSet::JSWeakSetPrint(FILE* out) { |
| 832 HeapObject::PrintHeader(out, "JSWeakSet"); |
| 833 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 834 PrintF(out, " - table = "); |
| 835 table()->ShortPrint(out); |
| 836 PrintF(out, "\n"); |
| 837 } |
| 838 |
| 839 |
| 817 void JSArrayBuffer::JSArrayBufferPrint(FILE* out) { | 840 void JSArrayBuffer::JSArrayBufferPrint(FILE* out) { |
| 818 HeapObject::PrintHeader(out, "JSArrayBuffer"); | 841 HeapObject::PrintHeader(out, "JSArrayBuffer"); |
| 819 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); | 842 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 820 PrintF(out, " - backing_store = -0x%p\n", backing_store()); | 843 PrintF(out, " - backing_store = -0x%p\n", backing_store()); |
| 821 PrintF(out, " - byte_length = "); | 844 PrintF(out, " - byte_length = "); |
| 822 byte_length()->ShortPrint(out); | 845 byte_length()->ShortPrint(out); |
| 823 PrintF(out, "\n"); | 846 PrintF(out, "\n"); |
| 824 } | 847 } |
| 825 | 848 |
| 826 | 849 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 | 1135 |
| 1113 void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { | 1136 void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 1114 HeapObject::PrintHeader(out, "TypeSwitchInfo"); | 1137 HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 1115 PrintF(out, "\n - types: "); | 1138 PrintF(out, "\n - types: "); |
| 1116 types()->ShortPrint(out); | 1139 types()->ShortPrint(out); |
| 1117 } | 1140 } |
| 1118 | 1141 |
| 1119 | 1142 |
| 1120 void AllocationSite::AllocationSitePrint(FILE* out) { | 1143 void AllocationSite::AllocationSitePrint(FILE* out) { |
| 1121 HeapObject::PrintHeader(out, "AllocationSite"); | 1144 HeapObject::PrintHeader(out, "AllocationSite"); |
| 1145 PrintF(out, " - weak_next: "); |
| 1146 weak_next()->ShortPrint(out); |
| 1147 PrintF(out, "\n"); |
| 1148 |
| 1122 PrintF(out, " - transition_info: "); | 1149 PrintF(out, " - transition_info: "); |
| 1123 if (transition_info()->IsCell()) { | 1150 if (transition_info()->IsCell()) { |
| 1124 Cell* cell = Cell::cast(transition_info()); | 1151 Cell* cell = Cell::cast(transition_info()); |
| 1125 Object* cell_contents = cell->value(); | 1152 Object* cell_contents = cell->value(); |
| 1126 if (cell_contents->IsSmi()) { | 1153 if (cell_contents->IsSmi()) { |
| 1127 ElementsKind kind = static_cast<ElementsKind>( | 1154 ElementsKind kind = static_cast<ElementsKind>( |
| 1128 Smi::cast(cell_contents)->value()); | 1155 Smi::cast(cell_contents)->value()); |
| 1129 PrintF(out, "Array allocation with ElementsKind "); | 1156 PrintF(out, "Array allocation with ElementsKind "); |
| 1130 PrintElementsKind(out, kind); | 1157 PrintElementsKind(out, kind); |
| 1131 PrintF(out, "\n"); | 1158 PrintF(out, "\n"); |
| 1132 return; | 1159 return; |
| 1133 } | 1160 } |
| 1134 } else if (transition_info()->IsJSArray()) { | 1161 } else if (transition_info()->IsJSArray()) { |
| 1135 PrintF(out, "Array literal "); | 1162 PrintF(out, "Array literal "); |
| 1136 transition_info()->ShortPrint(out); | 1163 transition_info()->ShortPrint(out); |
| 1137 PrintF(out, "\n"); | 1164 PrintF(out, "\n"); |
| 1138 return; | 1165 return; |
| 1139 } | 1166 } |
| 1140 | 1167 |
| 1141 PrintF(out, "unknown transition_info"); | 1168 PrintF(out, "unknown transition_info"); |
| 1142 transition_info()->ShortPrint(out); | 1169 transition_info()->ShortPrint(out); |
| 1143 PrintF(out, "\n"); | 1170 PrintF(out, "\n"); |
| 1144 } | 1171 } |
| 1145 | 1172 |
| 1146 | 1173 |
| 1147 void AllocationSiteInfo::AllocationSiteInfoPrint(FILE* out) { | 1174 void AllocationMemento::AllocationMementoPrint(FILE* out) { |
| 1148 HeapObject::PrintHeader(out, "AllocationSiteInfo"); | 1175 HeapObject::PrintHeader(out, "AllocationMemento"); |
| 1149 PrintF(out, " - allocation site: "); | 1176 PrintF(out, " - allocation site: "); |
| 1150 if (IsValid()) { | 1177 if (IsValid()) { |
| 1151 GetAllocationSite()->Print(); | 1178 GetAllocationSite()->Print(); |
| 1152 } else { | 1179 } else { |
| 1153 PrintF(out, "<invalid>\n"); | 1180 PrintF(out, "<invalid>\n"); |
| 1154 } | 1181 } |
| 1155 } | 1182 } |
| 1156 | 1183 |
| 1157 | 1184 |
| 1158 void Script::ScriptPrint(FILE* out) { | 1185 void Script::ScriptPrint(FILE* out) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 } | 1279 } |
| 1253 } | 1280 } |
| 1254 PrintF(out, "\n"); | 1281 PrintF(out, "\n"); |
| 1255 } | 1282 } |
| 1256 | 1283 |
| 1257 | 1284 |
| 1258 #endif // OBJECT_PRINT | 1285 #endif // OBJECT_PRINT |
| 1259 | 1286 |
| 1260 | 1287 |
| 1261 } } // namespace v8::internal | 1288 } } // namespace v8::internal |
| OLD | NEW |