OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include "v8.h" |
| 29 |
| 30 #include "disassembler.h" |
| 31 #include "disasm.h" |
| 32 #include "jsregexp.h" |
| 33 #include "objects-visiting.h" |
| 34 |
| 35 namespace v8 { |
| 36 namespace internal { |
| 37 |
| 38 #ifdef OBJECT_PRINT |
| 39 |
| 40 static const char* TypeToString(InstanceType type); |
| 41 |
| 42 |
| 43 void MaybeObject::Print(FILE* out) { |
| 44 Object* this_as_object; |
| 45 if (ToObject(&this_as_object)) { |
| 46 if (this_as_object->IsSmi()) { |
| 47 Smi::cast(this_as_object)->SmiPrint(out); |
| 48 } else { |
| 49 HeapObject::cast(this_as_object)->HeapObjectPrint(out); |
| 50 } |
| 51 } else { |
| 52 Failure::cast(this)->FailurePrint(out); |
| 53 } |
| 54 Flush(out); |
| 55 } |
| 56 |
| 57 |
| 58 void MaybeObject::PrintLn(FILE* out) { |
| 59 Print(out); |
| 60 PrintF(out, "\n"); |
| 61 } |
| 62 |
| 63 |
| 64 void HeapObject::PrintHeader(FILE* out, const char* id) { |
| 65 PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id); |
| 66 } |
| 67 |
| 68 |
| 69 void HeapObject::HeapObjectPrint(FILE* out) { |
| 70 InstanceType instance_type = map()->instance_type(); |
| 71 |
| 72 HandleScope scope; |
| 73 if (instance_type < FIRST_NONSTRING_TYPE) { |
| 74 String::cast(this)->StringPrint(out); |
| 75 return; |
| 76 } |
| 77 |
| 78 switch (instance_type) { |
| 79 case MAP_TYPE: |
| 80 Map::cast(this)->MapPrint(out); |
| 81 break; |
| 82 case HEAP_NUMBER_TYPE: |
| 83 HeapNumber::cast(this)->HeapNumberPrint(out); |
| 84 break; |
| 85 case FIXED_ARRAY_TYPE: |
| 86 FixedArray::cast(this)->FixedArrayPrint(out); |
| 87 break; |
| 88 case BYTE_ARRAY_TYPE: |
| 89 ByteArray::cast(this)->ByteArrayPrint(out); |
| 90 break; |
| 91 case PIXEL_ARRAY_TYPE: |
| 92 PixelArray::cast(this)->PixelArrayPrint(out); |
| 93 break; |
| 94 case EXTERNAL_BYTE_ARRAY_TYPE: |
| 95 ExternalByteArray::cast(this)->ExternalByteArrayPrint(out); |
| 96 break; |
| 97 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 98 ExternalUnsignedByteArray::cast(this) |
| 99 ->ExternalUnsignedByteArrayPrint(out); |
| 100 break; |
| 101 case EXTERNAL_SHORT_ARRAY_TYPE: |
| 102 ExternalShortArray::cast(this)->ExternalShortArrayPrint(out); |
| 103 break; |
| 104 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 105 ExternalUnsignedShortArray::cast(this) |
| 106 ->ExternalUnsignedShortArrayPrint(out); |
| 107 break; |
| 108 case EXTERNAL_INT_ARRAY_TYPE: |
| 109 ExternalIntArray::cast(this)->ExternalIntArrayPrint(out); |
| 110 break; |
| 111 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 112 ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); |
| 113 break; |
| 114 case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 115 ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); |
| 116 break; |
| 117 case FILLER_TYPE: |
| 118 PrintF(out, "filler"); |
| 119 break; |
| 120 case JS_OBJECT_TYPE: // fall through |
| 121 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 122 case JS_ARRAY_TYPE: |
| 123 case JS_REGEXP_TYPE: |
| 124 JSObject::cast(this)->JSObjectPrint(out); |
| 125 break; |
| 126 case ODDBALL_TYPE: |
| 127 Oddball::cast(this)->to_string()->Print(out); |
| 128 break; |
| 129 case JS_FUNCTION_TYPE: |
| 130 JSFunction::cast(this)->JSFunctionPrint(out); |
| 131 break; |
| 132 case JS_GLOBAL_PROXY_TYPE: |
| 133 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out); |
| 134 break; |
| 135 case JS_GLOBAL_OBJECT_TYPE: |
| 136 JSGlobalObject::cast(this)->JSGlobalObjectPrint(out); |
| 137 break; |
| 138 case JS_BUILTINS_OBJECT_TYPE: |
| 139 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out); |
| 140 break; |
| 141 case JS_VALUE_TYPE: |
| 142 PrintF(out, "Value wrapper around:"); |
| 143 JSValue::cast(this)->value()->Print(out); |
| 144 break; |
| 145 case CODE_TYPE: |
| 146 Code::cast(this)->CodePrint(out); |
| 147 break; |
| 148 case PROXY_TYPE: |
| 149 Proxy::cast(this)->ProxyPrint(out); |
| 150 break; |
| 151 case SHARED_FUNCTION_INFO_TYPE: |
| 152 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); |
| 153 break; |
| 154 case JS_GLOBAL_PROPERTY_CELL_TYPE: |
| 155 JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellPrint(out); |
| 156 break; |
| 157 #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 158 case NAME##_TYPE: \ |
| 159 Name::cast(this)->Name##Print(out); \ |
| 160 break; |
| 161 STRUCT_LIST(MAKE_STRUCT_CASE) |
| 162 #undef MAKE_STRUCT_CASE |
| 163 |
| 164 default: |
| 165 PrintF(out, "UNKNOWN TYPE %d", map()->instance_type()); |
| 166 UNREACHABLE(); |
| 167 break; |
| 168 } |
| 169 } |
| 170 |
| 171 |
| 172 void ByteArray::ByteArrayPrint(FILE* out) { |
| 173 PrintF(out, "byte array, data starts at %p", GetDataStartAddress()); |
| 174 } |
| 175 |
| 176 |
| 177 void PixelArray::PixelArrayPrint(FILE* out) { |
| 178 PrintF(out, "pixel array"); |
| 179 } |
| 180 |
| 181 |
| 182 void ExternalByteArray::ExternalByteArrayPrint(FILE* out) { |
| 183 PrintF(out, "external byte array"); |
| 184 } |
| 185 |
| 186 |
| 187 void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) { |
| 188 PrintF(out, "external unsigned byte array"); |
| 189 } |
| 190 |
| 191 |
| 192 void ExternalShortArray::ExternalShortArrayPrint(FILE* out) { |
| 193 PrintF(out, "external short array"); |
| 194 } |
| 195 |
| 196 |
| 197 void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) { |
| 198 PrintF(out, "external unsigned short array"); |
| 199 } |
| 200 |
| 201 |
| 202 void ExternalIntArray::ExternalIntArrayPrint(FILE* out) { |
| 203 PrintF(out, "external int array"); |
| 204 } |
| 205 |
| 206 |
| 207 void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) { |
| 208 PrintF(out, "external unsigned int array"); |
| 209 } |
| 210 |
| 211 |
| 212 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { |
| 213 PrintF(out, "external float array"); |
| 214 } |
| 215 |
| 216 |
| 217 void JSObject::PrintProperties(FILE* out) { |
| 218 if (HasFastProperties()) { |
| 219 DescriptorArray* descs = map()->instance_descriptors(); |
| 220 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 221 PrintF(out, " "); |
| 222 descs->GetKey(i)->StringPrint(out); |
| 223 PrintF(out, ": "); |
| 224 switch (descs->GetType(i)) { |
| 225 case FIELD: { |
| 226 int index = descs->GetFieldIndex(i); |
| 227 FastPropertyAt(index)->ShortPrint(out); |
| 228 PrintF(out, " (field at offset %d)\n", index); |
| 229 break; |
| 230 } |
| 231 case CONSTANT_FUNCTION: |
| 232 descs->GetConstantFunction(i)->ShortPrint(out); |
| 233 PrintF(out, " (constant function)\n"); |
| 234 break; |
| 235 case CALLBACKS: |
| 236 descs->GetCallbacksObject(i)->ShortPrint(out); |
| 237 PrintF(out, " (callback)\n"); |
| 238 break; |
| 239 case MAP_TRANSITION: |
| 240 PrintF(out, " (map transition)\n"); |
| 241 break; |
| 242 case CONSTANT_TRANSITION: |
| 243 PrintF(out, " (constant transition)\n"); |
| 244 break; |
| 245 case NULL_DESCRIPTOR: |
| 246 PrintF(out, " (null descriptor)\n"); |
| 247 break; |
| 248 default: |
| 249 UNREACHABLE(); |
| 250 break; |
| 251 } |
| 252 } |
| 253 } else { |
| 254 property_dictionary()->Print(out); |
| 255 } |
| 256 } |
| 257 |
| 258 |
| 259 void JSObject::PrintElements(FILE* out) { |
| 260 switch (GetElementsKind()) { |
| 261 case FAST_ELEMENTS: { |
| 262 // Print in array notation for non-sparse arrays. |
| 263 FixedArray* p = FixedArray::cast(elements()); |
| 264 for (int i = 0; i < p->length(); i++) { |
| 265 PrintF(out, " %d: ", i); |
| 266 p->get(i)->ShortPrint(out); |
| 267 PrintF(out, "\n"); |
| 268 } |
| 269 break; |
| 270 } |
| 271 case PIXEL_ELEMENTS: { |
| 272 PixelArray* p = PixelArray::cast(elements()); |
| 273 for (int i = 0; i < p->length(); i++) { |
| 274 PrintF(out, " %d: %d\n", i, p->get(i)); |
| 275 } |
| 276 break; |
| 277 } |
| 278 case EXTERNAL_BYTE_ELEMENTS: { |
| 279 ExternalByteArray* p = ExternalByteArray::cast(elements()); |
| 280 for (int i = 0; i < p->length(); i++) { |
| 281 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
| 282 } |
| 283 break; |
| 284 } |
| 285 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 286 ExternalUnsignedByteArray* p = |
| 287 ExternalUnsignedByteArray::cast(elements()); |
| 288 for (int i = 0; i < p->length(); i++) { |
| 289 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
| 290 } |
| 291 break; |
| 292 } |
| 293 case EXTERNAL_SHORT_ELEMENTS: { |
| 294 ExternalShortArray* p = ExternalShortArray::cast(elements()); |
| 295 for (int i = 0; i < p->length(); i++) { |
| 296 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
| 297 } |
| 298 break; |
| 299 } |
| 300 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 301 ExternalUnsignedShortArray* p = |
| 302 ExternalUnsignedShortArray::cast(elements()); |
| 303 for (int i = 0; i < p->length(); i++) { |
| 304 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
| 305 } |
| 306 break; |
| 307 } |
| 308 case EXTERNAL_INT_ELEMENTS: { |
| 309 ExternalIntArray* p = ExternalIntArray::cast(elements()); |
| 310 for (int i = 0; i < p->length(); i++) { |
| 311 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
| 312 } |
| 313 break; |
| 314 } |
| 315 case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 316 ExternalUnsignedIntArray* p = |
| 317 ExternalUnsignedIntArray::cast(elements()); |
| 318 for (int i = 0; i < p->length(); i++) { |
| 319 PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
| 320 } |
| 321 break; |
| 322 } |
| 323 case EXTERNAL_FLOAT_ELEMENTS: { |
| 324 ExternalFloatArray* p = ExternalFloatArray::cast(elements()); |
| 325 for (int i = 0; i < p->length(); i++) { |
| 326 PrintF(out, " %d: %f\n", i, p->get(i)); |
| 327 } |
| 328 break; |
| 329 } |
| 330 case DICTIONARY_ELEMENTS: |
| 331 elements()->Print(out); |
| 332 break; |
| 333 default: |
| 334 UNREACHABLE(); |
| 335 break; |
| 336 } |
| 337 } |
| 338 |
| 339 |
| 340 void JSObject::JSObjectPrint(FILE* out) { |
| 341 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
| 342 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); |
| 343 PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); |
| 344 PrintF(out, " {\n"); |
| 345 PrintProperties(out); |
| 346 PrintElements(out); |
| 347 PrintF(out, " }\n"); |
| 348 } |
| 349 |
| 350 |
| 351 static const char* TypeToString(InstanceType type) { |
| 352 switch (type) { |
| 353 case INVALID_TYPE: return "INVALID"; |
| 354 case MAP_TYPE: return "MAP"; |
| 355 case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
| 356 case SYMBOL_TYPE: return "SYMBOL"; |
| 357 case ASCII_SYMBOL_TYPE: return "ASCII_SYMBOL"; |
| 358 case CONS_SYMBOL_TYPE: return "CONS_SYMBOL"; |
| 359 case CONS_ASCII_SYMBOL_TYPE: return "CONS_ASCII_SYMBOL"; |
| 360 case EXTERNAL_ASCII_SYMBOL_TYPE: |
| 361 case EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE: |
| 362 case EXTERNAL_SYMBOL_TYPE: return "EXTERNAL_SYMBOL"; |
| 363 case ASCII_STRING_TYPE: return "ASCII_STRING"; |
| 364 case STRING_TYPE: return "TWO_BYTE_STRING"; |
| 365 case CONS_STRING_TYPE: |
| 366 case CONS_ASCII_STRING_TYPE: return "CONS_STRING"; |
| 367 case EXTERNAL_ASCII_STRING_TYPE: |
| 368 case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
| 369 case EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
| 370 case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 371 case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
| 372 case PIXEL_ARRAY_TYPE: return "PIXEL_ARRAY"; |
| 373 case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; |
| 374 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 375 return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; |
| 376 case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; |
| 377 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 378 return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; |
| 379 case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; |
| 380 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 381 return "EXTERNAL_UNSIGNED_INT_ARRAY"; |
| 382 case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; |
| 383 case FILLER_TYPE: return "FILLER"; |
| 384 case JS_OBJECT_TYPE: return "JS_OBJECT"; |
| 385 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
| 386 case ODDBALL_TYPE: return "ODDBALL"; |
| 387 case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; |
| 388 case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 389 case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 390 case CODE_TYPE: return "CODE"; |
| 391 case JS_ARRAY_TYPE: return "JS_ARRAY"; |
| 392 case JS_REGEXP_TYPE: return "JS_REGEXP"; |
| 393 case JS_VALUE_TYPE: return "JS_VALUE"; |
| 394 case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 395 case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
| 396 case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
| 397 case PROXY_TYPE: return "PROXY"; |
| 398 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 399 STRUCT_LIST(MAKE_STRUCT_CASE) |
| 400 #undef MAKE_STRUCT_CASE |
| 401 } |
| 402 return "UNKNOWN"; |
| 403 } |
| 404 |
| 405 |
| 406 void Map::MapPrint(FILE* out) { |
| 407 HeapObject::PrintHeader(out, "Map"); |
| 408 PrintF(out, " - type: %s\n", TypeToString(instance_type())); |
| 409 PrintF(out, " - instance size: %d\n", instance_size()); |
| 410 PrintF(out, " - inobject properties: %d\n", inobject_properties()); |
| 411 PrintF(out, " - pre-allocated property fields: %d\n", |
| 412 pre_allocated_property_fields()); |
| 413 PrintF(out, " - unused property fields: %d\n", unused_property_fields()); |
| 414 if (is_hidden_prototype()) { |
| 415 PrintF(out, " - hidden_prototype\n"); |
| 416 } |
| 417 if (has_named_interceptor()) { |
| 418 PrintF(out, " - named_interceptor\n"); |
| 419 } |
| 420 if (has_indexed_interceptor()) { |
| 421 PrintF(out, " - indexed_interceptor\n"); |
| 422 } |
| 423 if (is_undetectable()) { |
| 424 PrintF(out, " - undetectable\n"); |
| 425 } |
| 426 if (has_instance_call_handler()) { |
| 427 PrintF(out, " - instance_call_handler\n"); |
| 428 } |
| 429 if (is_access_check_needed()) { |
| 430 PrintF(out, " - access_check_needed\n"); |
| 431 } |
| 432 PrintF(out, " - instance descriptors: "); |
| 433 instance_descriptors()->ShortPrint(out); |
| 434 PrintF(out, "\n - prototype: "); |
| 435 prototype()->ShortPrint(out); |
| 436 PrintF(out, "\n - constructor: "); |
| 437 constructor()->ShortPrint(out); |
| 438 PrintF(out, "\n"); |
| 439 } |
| 440 |
| 441 |
| 442 void CodeCache::CodeCachePrint(FILE* out) { |
| 443 HeapObject::PrintHeader(out, "CodeCache"); |
| 444 PrintF(out, "\n - default_cache: "); |
| 445 default_cache()->ShortPrint(out); |
| 446 PrintF(out, "\n - normal_type_cache: "); |
| 447 normal_type_cache()->ShortPrint(out); |
| 448 } |
| 449 |
| 450 |
| 451 void FixedArray::FixedArrayPrint(FILE* out) { |
| 452 HeapObject::PrintHeader(out, "FixedArray"); |
| 453 PrintF(out, " - length: %d", length()); |
| 454 for (int i = 0; i < length(); i++) { |
| 455 PrintF(out, "\n [%d]: ", i); |
| 456 get(i)->ShortPrint(out); |
| 457 } |
| 458 PrintF(out, "\n"); |
| 459 } |
| 460 |
| 461 |
| 462 void JSValue::JSValuePrint(FILE* out) { |
| 463 HeapObject::PrintHeader(out, "ValueObject"); |
| 464 value()->Print(out); |
| 465 } |
| 466 |
| 467 |
| 468 void String::StringPrint(FILE* out) { |
| 469 if (StringShape(this).IsSymbol()) { |
| 470 PrintF(out, "#"); |
| 471 } else if (StringShape(this).IsCons()) { |
| 472 PrintF(out, "c\""); |
| 473 } else { |
| 474 PrintF(out, "\""); |
| 475 } |
| 476 |
| 477 const char truncated_epilogue[] = "...<truncated>"; |
| 478 int len = length(); |
| 479 if (!FLAG_use_verbose_printer) { |
| 480 if (len > 100) { |
| 481 len = 100 - sizeof(truncated_epilogue); |
| 482 } |
| 483 } |
| 484 for (int i = 0; i < len; i++) { |
| 485 PrintF(out, "%c", Get(i)); |
| 486 } |
| 487 if (len != length()) { |
| 488 PrintF(out, "%s", truncated_epilogue); |
| 489 } |
| 490 |
| 491 if (!StringShape(this).IsSymbol()) PrintF(out, "\""); |
| 492 } |
| 493 |
| 494 |
| 495 void JSFunction::JSFunctionPrint(FILE* out) { |
| 496 HeapObject::PrintHeader(out, "Function"); |
| 497 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 498 PrintF(out, " - initial_map = "); |
| 499 if (has_initial_map()) { |
| 500 initial_map()->ShortPrint(out); |
| 501 } |
| 502 PrintF(out, "\n - shared_info = "); |
| 503 shared()->ShortPrint(out); |
| 504 PrintF(out, "\n - name = "); |
| 505 shared()->name()->Print(out); |
| 506 PrintF(out, "\n - context = "); |
| 507 unchecked_context()->ShortPrint(out); |
| 508 PrintF(out, "\n - code = "); |
| 509 code()->ShortPrint(out); |
| 510 PrintF(out, "\n"); |
| 511 |
| 512 PrintProperties(out); |
| 513 PrintElements(out); |
| 514 |
| 515 PrintF(out, "\n"); |
| 516 } |
| 517 |
| 518 |
| 519 void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) { |
| 520 HeapObject::PrintHeader(out, "SharedFunctionInfo"); |
| 521 PrintF(out, " - name: "); |
| 522 name()->ShortPrint(out); |
| 523 PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties()); |
| 524 PrintF(out, "\n - instance class name = "); |
| 525 instance_class_name()->Print(out); |
| 526 PrintF(out, "\n - code = "); |
| 527 code()->ShortPrint(out); |
| 528 PrintF(out, "\n - source code = "); |
| 529 GetSourceCode()->ShortPrint(out); |
| 530 // Script files are often large, hard to read. |
| 531 // PrintF(out, "\n - script ="); |
| 532 // script()->Print(out); |
| 533 PrintF(out, "\n - function token position = %d", function_token_position()); |
| 534 PrintF(out, "\n - start position = %d", start_position()); |
| 535 PrintF(out, "\n - end position = %d", end_position()); |
| 536 PrintF(out, "\n - is expression = %d", is_expression()); |
| 537 PrintF(out, "\n - debug info = "); |
| 538 debug_info()->ShortPrint(out); |
| 539 PrintF(out, "\n - length = %d", length()); |
| 540 PrintF(out, "\n - has_only_simple_this_property_assignments = %d", |
| 541 has_only_simple_this_property_assignments()); |
| 542 PrintF(out, "\n - this_property_assignments = "); |
| 543 this_property_assignments()->ShortPrint(out); |
| 544 PrintF(out, "\n"); |
| 545 } |
| 546 |
| 547 |
| 548 void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) { |
| 549 PrintF(out, "global_proxy"); |
| 550 JSObjectPrint(out); |
| 551 PrintF(out, "context : "); |
| 552 context()->ShortPrint(out); |
| 553 PrintF(out, "\n"); |
| 554 } |
| 555 |
| 556 |
| 557 void JSGlobalObject::JSGlobalObjectPrint(FILE* out) { |
| 558 PrintF(out, "global "); |
| 559 JSObjectPrint(out); |
| 560 PrintF(out, "global context : "); |
| 561 global_context()->ShortPrint(out); |
| 562 PrintF(out, "\n"); |
| 563 } |
| 564 |
| 565 |
| 566 void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) { |
| 567 PrintF(out, "builtins "); |
| 568 JSObjectPrint(out); |
| 569 } |
| 570 |
| 571 |
| 572 void JSGlobalPropertyCell::JSGlobalPropertyCellPrint(FILE* out) { |
| 573 HeapObject::PrintHeader(out, "JSGlobalPropertyCell"); |
| 574 } |
| 575 |
| 576 |
| 577 void Code::CodePrint(FILE* out) { |
| 578 HeapObject::PrintHeader(out, "Code"); |
| 579 #ifdef ENABLE_DISASSEMBLER |
| 580 if (FLAG_use_verbose_printer) { |
| 581 Disassemble(NULL, out); |
| 582 } |
| 583 #endif |
| 584 } |
| 585 |
| 586 |
| 587 void Proxy::ProxyPrint(FILE* out) { |
| 588 PrintF(out, "proxy to %p", proxy()); |
| 589 } |
| 590 |
| 591 |
| 592 void AccessorInfo::AccessorInfoPrint(FILE* out) { |
| 593 HeapObject::PrintHeader(out, "AccessorInfo"); |
| 594 PrintF(out, "\n - getter: "); |
| 595 getter()->ShortPrint(out); |
| 596 PrintF(out, "\n - setter: "); |
| 597 setter()->ShortPrint(out); |
| 598 PrintF(out, "\n - name: "); |
| 599 name()->ShortPrint(out); |
| 600 PrintF(out, "\n - data: "); |
| 601 data()->ShortPrint(out); |
| 602 PrintF(out, "\n - flag: "); |
| 603 flag()->ShortPrint(out); |
| 604 } |
| 605 |
| 606 |
| 607 void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) { |
| 608 HeapObject::PrintHeader(out, "AccessCheckInfo"); |
| 609 PrintF(out, "\n - named_callback: "); |
| 610 named_callback()->ShortPrint(out); |
| 611 PrintF(out, "\n - indexed_callback: "); |
| 612 indexed_callback()->ShortPrint(out); |
| 613 PrintF(out, "\n - data: "); |
| 614 data()->ShortPrint(out); |
| 615 } |
| 616 |
| 617 |
| 618 void InterceptorInfo::InterceptorInfoPrint(FILE* out) { |
| 619 HeapObject::PrintHeader(out, "InterceptorInfo"); |
| 620 PrintF(out, "\n - getter: "); |
| 621 getter()->ShortPrint(out); |
| 622 PrintF(out, "\n - setter: "); |
| 623 setter()->ShortPrint(out); |
| 624 PrintF(out, "\n - query: "); |
| 625 query()->ShortPrint(out); |
| 626 PrintF(out, "\n - deleter: "); |
| 627 deleter()->ShortPrint(out); |
| 628 PrintF(out, "\n - enumerator: "); |
| 629 enumerator()->ShortPrint(out); |
| 630 PrintF(out, "\n - data: "); |
| 631 data()->ShortPrint(out); |
| 632 } |
| 633 |
| 634 |
| 635 void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) { |
| 636 HeapObject::PrintHeader(out, "CallHandlerInfo"); |
| 637 PrintF(out, "\n - callback: "); |
| 638 callback()->ShortPrint(out); |
| 639 PrintF(out, "\n - data: "); |
| 640 data()->ShortPrint(out); |
| 641 PrintF(out, "\n - call_stub_cache: "); |
| 642 } |
| 643 |
| 644 |
| 645 void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) { |
| 646 HeapObject::PrintHeader(out, "FunctionTemplateInfo"); |
| 647 PrintF(out, "\n - class name: "); |
| 648 class_name()->ShortPrint(out); |
| 649 PrintF(out, "\n - tag: "); |
| 650 tag()->ShortPrint(out); |
| 651 PrintF(out, "\n - property_list: "); |
| 652 property_list()->ShortPrint(out); |
| 653 PrintF(out, "\n - serial_number: "); |
| 654 serial_number()->ShortPrint(out); |
| 655 PrintF(out, "\n - call_code: "); |
| 656 call_code()->ShortPrint(out); |
| 657 PrintF(out, "\n - property_accessors: "); |
| 658 property_accessors()->ShortPrint(out); |
| 659 PrintF(out, "\n - prototype_template: "); |
| 660 prototype_template()->ShortPrint(out); |
| 661 PrintF(out, "\n - parent_template: "); |
| 662 parent_template()->ShortPrint(out); |
| 663 PrintF(out, "\n - named_property_handler: "); |
| 664 named_property_handler()->ShortPrint(out); |
| 665 PrintF(out, "\n - indexed_property_handler: "); |
| 666 indexed_property_handler()->ShortPrint(out); |
| 667 PrintF(out, "\n - instance_template: "); |
| 668 instance_template()->ShortPrint(out); |
| 669 PrintF(out, "\n - signature: "); |
| 670 signature()->ShortPrint(out); |
| 671 PrintF(out, "\n - access_check_info: "); |
| 672 access_check_info()->ShortPrint(out); |
| 673 PrintF(out, "\n - hidden_prototype: %s", |
| 674 hidden_prototype() ? "true" : "false"); |
| 675 PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 676 PrintF(out, "\n - need_access_check: %s", |
| 677 needs_access_check() ? "true" : "false"); |
| 678 } |
| 679 |
| 680 |
| 681 void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) { |
| 682 HeapObject::PrintHeader(out, "ObjectTemplateInfo"); |
| 683 PrintF(out, "\n - constructor: "); |
| 684 constructor()->ShortPrint(out); |
| 685 PrintF(out, "\n - internal_field_count: "); |
| 686 internal_field_count()->ShortPrint(out); |
| 687 } |
| 688 |
| 689 |
| 690 void SignatureInfo::SignatureInfoPrint(FILE* out) { |
| 691 HeapObject::PrintHeader(out, "SignatureInfo"); |
| 692 PrintF(out, "\n - receiver: "); |
| 693 receiver()->ShortPrint(out); |
| 694 PrintF(out, "\n - args: "); |
| 695 args()->ShortPrint(out); |
| 696 } |
| 697 |
| 698 |
| 699 void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 700 HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 701 PrintF(out, "\n - types: "); |
| 702 types()->ShortPrint(out); |
| 703 } |
| 704 |
| 705 |
| 706 void Script::ScriptPrint(FILE* out) { |
| 707 HeapObject::PrintHeader(out, "Script"); |
| 708 PrintF(out, "\n - source: "); |
| 709 source()->ShortPrint(out); |
| 710 PrintF(out, "\n - name: "); |
| 711 name()->ShortPrint(out); |
| 712 PrintF(out, "\n - line_offset: "); |
| 713 line_offset()->ShortPrint(out); |
| 714 PrintF(out, "\n - column_offset: "); |
| 715 column_offset()->ShortPrint(out); |
| 716 PrintF(out, "\n - type: "); |
| 717 type()->ShortPrint(out); |
| 718 PrintF(out, "\n - id: "); |
| 719 id()->ShortPrint(out); |
| 720 PrintF(out, "\n - data: "); |
| 721 data()->ShortPrint(out); |
| 722 PrintF(out, "\n - context data: "); |
| 723 context_data()->ShortPrint(out); |
| 724 PrintF(out, "\n - wrapper: "); |
| 725 wrapper()->ShortPrint(out); |
| 726 PrintF(out, "\n - compilation type: "); |
| 727 compilation_type()->ShortPrint(out); |
| 728 PrintF(out, "\n - line ends: "); |
| 729 line_ends()->ShortPrint(out); |
| 730 PrintF(out, "\n - eval from shared: "); |
| 731 eval_from_shared()->ShortPrint(out); |
| 732 PrintF(out, "\n - eval from instructions offset: "); |
| 733 eval_from_instructions_offset()->ShortPrint(out); |
| 734 PrintF(out, "\n"); |
| 735 } |
| 736 |
| 737 |
| 738 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 739 void DebugInfo::DebugInfoPrint(FILE* out) { |
| 740 HeapObject::PrintHeader(out, "DebugInfo"); |
| 741 PrintF(out, "\n - shared: "); |
| 742 shared()->ShortPrint(out); |
| 743 PrintF(out, "\n - original_code: "); |
| 744 original_code()->ShortPrint(out); |
| 745 PrintF(out, "\n - code: "); |
| 746 code()->ShortPrint(out); |
| 747 PrintF(out, "\n - break_points: "); |
| 748 break_points()->Print(out); |
| 749 } |
| 750 |
| 751 |
| 752 void BreakPointInfo::BreakPointInfoPrint(FILE* out) { |
| 753 HeapObject::PrintHeader(out, "BreakPointInfo"); |
| 754 PrintF(out, "\n - code_position: %d", code_position()->value()); |
| 755 PrintF(out, "\n - source_position: %d", source_position()->value()); |
| 756 PrintF(out, "\n - statement_position: %d", statement_position()->value()); |
| 757 PrintF(out, "\n - break_point_objects: "); |
| 758 break_point_objects()->ShortPrint(out); |
| 759 } |
| 760 #endif // ENABLE_DEBUGGER_SUPPORT |
| 761 |
| 762 |
| 763 void DescriptorArray::PrintDescriptors(FILE* out) { |
| 764 PrintF(out, "Descriptor array %d\n", number_of_descriptors()); |
| 765 for (int i = 0; i < number_of_descriptors(); i++) { |
| 766 PrintF(out, " %d: ", i); |
| 767 Descriptor desc; |
| 768 Get(i, &desc); |
| 769 desc.Print(out); |
| 770 } |
| 771 PrintF(out, "\n"); |
| 772 } |
| 773 |
| 774 |
| 775 #endif // OBJECT_PRINT |
| 776 |
| 777 |
| 778 } } // namespace v8::internal |
OLD | NEW |