fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 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"; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame^] | 398 | case LAST_STRING_TYPE: return "LAST_STRING_TYPE"; |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 399 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 400 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 401 | #undef MAKE_STRUCT_CASE |
| 402 | } |
| 403 | return "UNKNOWN"; |
| 404 | } |
| 405 | |
| 406 | |
| 407 | void Map::MapPrint(FILE* out) { |
| 408 | HeapObject::PrintHeader(out, "Map"); |
| 409 | PrintF(out, " - type: %s\n", TypeToString(instance_type())); |
| 410 | PrintF(out, " - instance size: %d\n", instance_size()); |
| 411 | PrintF(out, " - inobject properties: %d\n", inobject_properties()); |
| 412 | PrintF(out, " - pre-allocated property fields: %d\n", |
| 413 | pre_allocated_property_fields()); |
| 414 | PrintF(out, " - unused property fields: %d\n", unused_property_fields()); |
| 415 | if (is_hidden_prototype()) { |
| 416 | PrintF(out, " - hidden_prototype\n"); |
| 417 | } |
| 418 | if (has_named_interceptor()) { |
| 419 | PrintF(out, " - named_interceptor\n"); |
| 420 | } |
| 421 | if (has_indexed_interceptor()) { |
| 422 | PrintF(out, " - indexed_interceptor\n"); |
| 423 | } |
| 424 | if (is_undetectable()) { |
| 425 | PrintF(out, " - undetectable\n"); |
| 426 | } |
| 427 | if (has_instance_call_handler()) { |
| 428 | PrintF(out, " - instance_call_handler\n"); |
| 429 | } |
| 430 | if (is_access_check_needed()) { |
| 431 | PrintF(out, " - access_check_needed\n"); |
| 432 | } |
| 433 | PrintF(out, " - instance descriptors: "); |
| 434 | instance_descriptors()->ShortPrint(out); |
| 435 | PrintF(out, "\n - prototype: "); |
| 436 | prototype()->ShortPrint(out); |
| 437 | PrintF(out, "\n - constructor: "); |
| 438 | constructor()->ShortPrint(out); |
| 439 | PrintF(out, "\n"); |
| 440 | } |
| 441 | |
| 442 | |
| 443 | void CodeCache::CodeCachePrint(FILE* out) { |
| 444 | HeapObject::PrintHeader(out, "CodeCache"); |
| 445 | PrintF(out, "\n - default_cache: "); |
| 446 | default_cache()->ShortPrint(out); |
| 447 | PrintF(out, "\n - normal_type_cache: "); |
| 448 | normal_type_cache()->ShortPrint(out); |
| 449 | } |
| 450 | |
| 451 | |
| 452 | void FixedArray::FixedArrayPrint(FILE* out) { |
| 453 | HeapObject::PrintHeader(out, "FixedArray"); |
| 454 | PrintF(out, " - length: %d", length()); |
| 455 | for (int i = 0; i < length(); i++) { |
| 456 | PrintF(out, "\n [%d]: ", i); |
| 457 | get(i)->ShortPrint(out); |
| 458 | } |
| 459 | PrintF(out, "\n"); |
| 460 | } |
| 461 | |
| 462 | |
| 463 | void JSValue::JSValuePrint(FILE* out) { |
| 464 | HeapObject::PrintHeader(out, "ValueObject"); |
| 465 | value()->Print(out); |
| 466 | } |
| 467 | |
| 468 | |
| 469 | void String::StringPrint(FILE* out) { |
| 470 | if (StringShape(this).IsSymbol()) { |
| 471 | PrintF(out, "#"); |
| 472 | } else if (StringShape(this).IsCons()) { |
| 473 | PrintF(out, "c\""); |
| 474 | } else { |
| 475 | PrintF(out, "\""); |
| 476 | } |
| 477 | |
| 478 | const char truncated_epilogue[] = "...<truncated>"; |
| 479 | int len = length(); |
| 480 | if (!FLAG_use_verbose_printer) { |
| 481 | if (len > 100) { |
| 482 | len = 100 - sizeof(truncated_epilogue); |
| 483 | } |
| 484 | } |
| 485 | for (int i = 0; i < len; i++) { |
| 486 | PrintF(out, "%c", Get(i)); |
| 487 | } |
| 488 | if (len != length()) { |
| 489 | PrintF(out, "%s", truncated_epilogue); |
| 490 | } |
| 491 | |
| 492 | if (!StringShape(this).IsSymbol()) PrintF(out, "\""); |
| 493 | } |
| 494 | |
| 495 | |
| 496 | void JSFunction::JSFunctionPrint(FILE* out) { |
| 497 | HeapObject::PrintHeader(out, "Function"); |
| 498 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 499 | PrintF(out, " - initial_map = "); |
| 500 | if (has_initial_map()) { |
| 501 | initial_map()->ShortPrint(out); |
| 502 | } |
| 503 | PrintF(out, "\n - shared_info = "); |
| 504 | shared()->ShortPrint(out); |
| 505 | PrintF(out, "\n - name = "); |
| 506 | shared()->name()->Print(out); |
| 507 | PrintF(out, "\n - context = "); |
| 508 | unchecked_context()->ShortPrint(out); |
| 509 | PrintF(out, "\n - code = "); |
| 510 | code()->ShortPrint(out); |
| 511 | PrintF(out, "\n"); |
| 512 | |
| 513 | PrintProperties(out); |
| 514 | PrintElements(out); |
| 515 | |
| 516 | PrintF(out, "\n"); |
| 517 | } |
| 518 | |
| 519 | |
| 520 | void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) { |
| 521 | HeapObject::PrintHeader(out, "SharedFunctionInfo"); |
| 522 | PrintF(out, " - name: "); |
| 523 | name()->ShortPrint(out); |
| 524 | PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties()); |
| 525 | PrintF(out, "\n - instance class name = "); |
| 526 | instance_class_name()->Print(out); |
| 527 | PrintF(out, "\n - code = "); |
| 528 | code()->ShortPrint(out); |
| 529 | PrintF(out, "\n - source code = "); |
| 530 | GetSourceCode()->ShortPrint(out); |
| 531 | // Script files are often large, hard to read. |
| 532 | // PrintF(out, "\n - script ="); |
| 533 | // script()->Print(out); |
| 534 | PrintF(out, "\n - function token position = %d", function_token_position()); |
| 535 | PrintF(out, "\n - start position = %d", start_position()); |
| 536 | PrintF(out, "\n - end position = %d", end_position()); |
| 537 | PrintF(out, "\n - is expression = %d", is_expression()); |
| 538 | PrintF(out, "\n - debug info = "); |
| 539 | debug_info()->ShortPrint(out); |
| 540 | PrintF(out, "\n - length = %d", length()); |
| 541 | PrintF(out, "\n - has_only_simple_this_property_assignments = %d", |
| 542 | has_only_simple_this_property_assignments()); |
| 543 | PrintF(out, "\n - this_property_assignments = "); |
| 544 | this_property_assignments()->ShortPrint(out); |
| 545 | PrintF(out, "\n"); |
| 546 | } |
| 547 | |
| 548 | |
| 549 | void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) { |
| 550 | PrintF(out, "global_proxy"); |
| 551 | JSObjectPrint(out); |
| 552 | PrintF(out, "context : "); |
| 553 | context()->ShortPrint(out); |
| 554 | PrintF(out, "\n"); |
| 555 | } |
| 556 | |
| 557 | |
| 558 | void JSGlobalObject::JSGlobalObjectPrint(FILE* out) { |
| 559 | PrintF(out, "global "); |
| 560 | JSObjectPrint(out); |
| 561 | PrintF(out, "global context : "); |
| 562 | global_context()->ShortPrint(out); |
| 563 | PrintF(out, "\n"); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) { |
| 568 | PrintF(out, "builtins "); |
| 569 | JSObjectPrint(out); |
| 570 | } |
| 571 | |
| 572 | |
| 573 | void JSGlobalPropertyCell::JSGlobalPropertyCellPrint(FILE* out) { |
| 574 | HeapObject::PrintHeader(out, "JSGlobalPropertyCell"); |
| 575 | } |
| 576 | |
| 577 | |
| 578 | void Code::CodePrint(FILE* out) { |
| 579 | HeapObject::PrintHeader(out, "Code"); |
| 580 | #ifdef ENABLE_DISASSEMBLER |
| 581 | if (FLAG_use_verbose_printer) { |
| 582 | Disassemble(NULL, out); |
| 583 | } |
| 584 | #endif |
| 585 | } |
| 586 | |
| 587 | |
| 588 | void Proxy::ProxyPrint(FILE* out) { |
| 589 | PrintF(out, "proxy to %p", proxy()); |
| 590 | } |
| 591 | |
| 592 | |
| 593 | void AccessorInfo::AccessorInfoPrint(FILE* out) { |
| 594 | HeapObject::PrintHeader(out, "AccessorInfo"); |
| 595 | PrintF(out, "\n - getter: "); |
| 596 | getter()->ShortPrint(out); |
| 597 | PrintF(out, "\n - setter: "); |
| 598 | setter()->ShortPrint(out); |
| 599 | PrintF(out, "\n - name: "); |
| 600 | name()->ShortPrint(out); |
| 601 | PrintF(out, "\n - data: "); |
| 602 | data()->ShortPrint(out); |
| 603 | PrintF(out, "\n - flag: "); |
| 604 | flag()->ShortPrint(out); |
| 605 | } |
| 606 | |
| 607 | |
| 608 | void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) { |
| 609 | HeapObject::PrintHeader(out, "AccessCheckInfo"); |
| 610 | PrintF(out, "\n - named_callback: "); |
| 611 | named_callback()->ShortPrint(out); |
| 612 | PrintF(out, "\n - indexed_callback: "); |
| 613 | indexed_callback()->ShortPrint(out); |
| 614 | PrintF(out, "\n - data: "); |
| 615 | data()->ShortPrint(out); |
| 616 | } |
| 617 | |
| 618 | |
| 619 | void InterceptorInfo::InterceptorInfoPrint(FILE* out) { |
| 620 | HeapObject::PrintHeader(out, "InterceptorInfo"); |
| 621 | PrintF(out, "\n - getter: "); |
| 622 | getter()->ShortPrint(out); |
| 623 | PrintF(out, "\n - setter: "); |
| 624 | setter()->ShortPrint(out); |
| 625 | PrintF(out, "\n - query: "); |
| 626 | query()->ShortPrint(out); |
| 627 | PrintF(out, "\n - deleter: "); |
| 628 | deleter()->ShortPrint(out); |
| 629 | PrintF(out, "\n - enumerator: "); |
| 630 | enumerator()->ShortPrint(out); |
| 631 | PrintF(out, "\n - data: "); |
| 632 | data()->ShortPrint(out); |
| 633 | } |
| 634 | |
| 635 | |
| 636 | void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) { |
| 637 | HeapObject::PrintHeader(out, "CallHandlerInfo"); |
| 638 | PrintF(out, "\n - callback: "); |
| 639 | callback()->ShortPrint(out); |
| 640 | PrintF(out, "\n - data: "); |
| 641 | data()->ShortPrint(out); |
| 642 | PrintF(out, "\n - call_stub_cache: "); |
| 643 | } |
| 644 | |
| 645 | |
| 646 | void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) { |
| 647 | HeapObject::PrintHeader(out, "FunctionTemplateInfo"); |
| 648 | PrintF(out, "\n - class name: "); |
| 649 | class_name()->ShortPrint(out); |
| 650 | PrintF(out, "\n - tag: "); |
| 651 | tag()->ShortPrint(out); |
| 652 | PrintF(out, "\n - property_list: "); |
| 653 | property_list()->ShortPrint(out); |
| 654 | PrintF(out, "\n - serial_number: "); |
| 655 | serial_number()->ShortPrint(out); |
| 656 | PrintF(out, "\n - call_code: "); |
| 657 | call_code()->ShortPrint(out); |
| 658 | PrintF(out, "\n - property_accessors: "); |
| 659 | property_accessors()->ShortPrint(out); |
| 660 | PrintF(out, "\n - prototype_template: "); |
| 661 | prototype_template()->ShortPrint(out); |
| 662 | PrintF(out, "\n - parent_template: "); |
| 663 | parent_template()->ShortPrint(out); |
| 664 | PrintF(out, "\n - named_property_handler: "); |
| 665 | named_property_handler()->ShortPrint(out); |
| 666 | PrintF(out, "\n - indexed_property_handler: "); |
| 667 | indexed_property_handler()->ShortPrint(out); |
| 668 | PrintF(out, "\n - instance_template: "); |
| 669 | instance_template()->ShortPrint(out); |
| 670 | PrintF(out, "\n - signature: "); |
| 671 | signature()->ShortPrint(out); |
| 672 | PrintF(out, "\n - access_check_info: "); |
| 673 | access_check_info()->ShortPrint(out); |
| 674 | PrintF(out, "\n - hidden_prototype: %s", |
| 675 | hidden_prototype() ? "true" : "false"); |
| 676 | PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 677 | PrintF(out, "\n - need_access_check: %s", |
| 678 | needs_access_check() ? "true" : "false"); |
| 679 | } |
| 680 | |
| 681 | |
| 682 | void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) { |
| 683 | HeapObject::PrintHeader(out, "ObjectTemplateInfo"); |
| 684 | PrintF(out, "\n - constructor: "); |
| 685 | constructor()->ShortPrint(out); |
| 686 | PrintF(out, "\n - internal_field_count: "); |
| 687 | internal_field_count()->ShortPrint(out); |
| 688 | } |
| 689 | |
| 690 | |
| 691 | void SignatureInfo::SignatureInfoPrint(FILE* out) { |
| 692 | HeapObject::PrintHeader(out, "SignatureInfo"); |
| 693 | PrintF(out, "\n - receiver: "); |
| 694 | receiver()->ShortPrint(out); |
| 695 | PrintF(out, "\n - args: "); |
| 696 | args()->ShortPrint(out); |
| 697 | } |
| 698 | |
| 699 | |
| 700 | void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 701 | HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 702 | PrintF(out, "\n - types: "); |
| 703 | types()->ShortPrint(out); |
| 704 | } |
| 705 | |
| 706 | |
| 707 | void Script::ScriptPrint(FILE* out) { |
| 708 | HeapObject::PrintHeader(out, "Script"); |
| 709 | PrintF(out, "\n - source: "); |
| 710 | source()->ShortPrint(out); |
| 711 | PrintF(out, "\n - name: "); |
| 712 | name()->ShortPrint(out); |
| 713 | PrintF(out, "\n - line_offset: "); |
| 714 | line_offset()->ShortPrint(out); |
| 715 | PrintF(out, "\n - column_offset: "); |
| 716 | column_offset()->ShortPrint(out); |
| 717 | PrintF(out, "\n - type: "); |
| 718 | type()->ShortPrint(out); |
| 719 | PrintF(out, "\n - id: "); |
| 720 | id()->ShortPrint(out); |
| 721 | PrintF(out, "\n - data: "); |
| 722 | data()->ShortPrint(out); |
| 723 | PrintF(out, "\n - context data: "); |
| 724 | context_data()->ShortPrint(out); |
| 725 | PrintF(out, "\n - wrapper: "); |
| 726 | wrapper()->ShortPrint(out); |
| 727 | PrintF(out, "\n - compilation type: "); |
| 728 | compilation_type()->ShortPrint(out); |
| 729 | PrintF(out, "\n - line ends: "); |
| 730 | line_ends()->ShortPrint(out); |
| 731 | PrintF(out, "\n - eval from shared: "); |
| 732 | eval_from_shared()->ShortPrint(out); |
| 733 | PrintF(out, "\n - eval from instructions offset: "); |
| 734 | eval_from_instructions_offset()->ShortPrint(out); |
| 735 | PrintF(out, "\n"); |
| 736 | } |
| 737 | |
| 738 | |
| 739 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 740 | void DebugInfo::DebugInfoPrint(FILE* out) { |
| 741 | HeapObject::PrintHeader(out, "DebugInfo"); |
| 742 | PrintF(out, "\n - shared: "); |
| 743 | shared()->ShortPrint(out); |
| 744 | PrintF(out, "\n - original_code: "); |
| 745 | original_code()->ShortPrint(out); |
| 746 | PrintF(out, "\n - code: "); |
| 747 | code()->ShortPrint(out); |
| 748 | PrintF(out, "\n - break_points: "); |
| 749 | break_points()->Print(out); |
| 750 | } |
| 751 | |
| 752 | |
| 753 | void BreakPointInfo::BreakPointInfoPrint(FILE* out) { |
| 754 | HeapObject::PrintHeader(out, "BreakPointInfo"); |
| 755 | PrintF(out, "\n - code_position: %d", code_position()->value()); |
| 756 | PrintF(out, "\n - source_position: %d", source_position()->value()); |
| 757 | PrintF(out, "\n - statement_position: %d", statement_position()->value()); |
| 758 | PrintF(out, "\n - break_point_objects: "); |
| 759 | break_point_objects()->ShortPrint(out); |
| 760 | } |
| 761 | #endif // ENABLE_DEBUGGER_SUPPORT |
| 762 | |
| 763 | |
| 764 | void DescriptorArray::PrintDescriptors(FILE* out) { |
| 765 | PrintF(out, "Descriptor array %d\n", number_of_descriptors()); |
| 766 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 767 | PrintF(out, " %d: ", i); |
| 768 | Descriptor desc; |
| 769 | Get(i, &desc); |
| 770 | desc.Print(out); |
| 771 | } |
| 772 | PrintF(out, "\n"); |
| 773 | } |
| 774 | |
| 775 | |
| 776 | #endif // OBJECT_PRINT |
| 777 | |
| 778 | |
| 779 | } } // namespace v8::internal |