OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 switch (instance_type) { | 78 switch (instance_type) { |
79 case MAP_TYPE: | 79 case MAP_TYPE: |
80 Map::cast(this)->MapPrint(out); | 80 Map::cast(this)->MapPrint(out); |
81 break; | 81 break; |
82 case HEAP_NUMBER_TYPE: | 82 case HEAP_NUMBER_TYPE: |
83 HeapNumber::cast(this)->HeapNumberPrint(out); | 83 HeapNumber::cast(this)->HeapNumberPrint(out); |
84 break; | 84 break; |
| 85 case FIXED_DOUBLE_ARRAY_TYPE: |
| 86 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out); |
| 87 break; |
85 case FIXED_ARRAY_TYPE: | 88 case FIXED_ARRAY_TYPE: |
86 FixedArray::cast(this)->FixedArrayPrint(out); | 89 FixedArray::cast(this)->FixedArrayPrint(out); |
87 break; | 90 break; |
88 case BYTE_ARRAY_TYPE: | 91 case BYTE_ARRAY_TYPE: |
89 ByteArray::cast(this)->ByteArrayPrint(out); | 92 ByteArray::cast(this)->ByteArrayPrint(out); |
90 break; | 93 break; |
91 case FREE_SPACE_TYPE: | 94 case FREE_SPACE_TYPE: |
92 FreeSpace::cast(this)->FreeSpacePrint(out); | 95 FreeSpace::cast(this)->FreeSpacePrint(out); |
93 break; | 96 break; |
94 case EXTERNAL_PIXEL_ARRAY_TYPE: | 97 case EXTERNAL_PIXEL_ARRAY_TYPE: |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { | 238 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { |
236 PrintF(out, "external float array"); | 239 PrintF(out, "external float array"); |
237 } | 240 } |
238 | 241 |
239 | 242 |
240 void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { | 243 void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { |
241 PrintF(out, "external double array"); | 244 PrintF(out, "external double array"); |
242 } | 245 } |
243 | 246 |
244 | 247 |
| 248 static void PrintElementsKind(FILE* out, ElementsKind kind) { |
| 249 switch (kind) { |
| 250 case FAST_SMI_ONLY_ELEMENTS: |
| 251 PrintF(out, "FAST_SMI_ONLY_ELEMENTS"); |
| 252 break; |
| 253 case FAST_ELEMENTS: |
| 254 PrintF(out, "FAST_ELEMENTS"); |
| 255 break; |
| 256 case FAST_DOUBLE_ELEMENTS: |
| 257 PrintF(out, "FAST_DOUBLE_ELEMENTS"); |
| 258 break; |
| 259 case DICTIONARY_ELEMENTS: |
| 260 PrintF(out, "DICTIONARY_ELEMENTS"); |
| 261 break; |
| 262 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 263 PrintF(out, "NON_STRICT_ARGUMENTS_ELEMENTS"); |
| 264 break; |
| 265 case EXTERNAL_BYTE_ELEMENTS: |
| 266 PrintF(out, "EXTERNAL_BYTE_ELEMENTS"); |
| 267 break; |
| 268 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 269 PrintF(out, "EXTERNAL_UNSIGNED_BYTE_ELEMENTS"); |
| 270 break; |
| 271 case EXTERNAL_SHORT_ELEMENTS: |
| 272 PrintF(out, "EXTERNAL_SHORT_ELEMENTS"); |
| 273 break; |
| 274 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 275 PrintF(out, "EXTERNAL_UNSIGNED_SHORT_ELEMENTS"); |
| 276 break; |
| 277 case EXTERNAL_INT_ELEMENTS: |
| 278 PrintF(out, "EXTERNAL_INT_ELEMENTS"); |
| 279 break; |
| 280 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 281 PrintF(out, "EXTERNAL_UNSIGNED_INT_ELEMENTS"); |
| 282 break; |
| 283 case EXTERNAL_FLOAT_ELEMENTS: |
| 284 PrintF(out, "EXTERNAL_FLOAT_ELEMENTS"); |
| 285 break; |
| 286 case EXTERNAL_DOUBLE_ELEMENTS: |
| 287 PrintF(out, "EXTERNAL_DOUBLE_ELEMENTS"); |
| 288 break; |
| 289 case EXTERNAL_PIXEL_ELEMENTS: |
| 290 PrintF(out, "EXTERNAL_DOUBLE_ELEMENTS"); |
| 291 break; |
| 292 } |
| 293 } |
| 294 |
| 295 |
245 void JSObject::PrintProperties(FILE* out) { | 296 void JSObject::PrintProperties(FILE* out) { |
246 if (HasFastProperties()) { | 297 if (HasFastProperties()) { |
247 DescriptorArray* descs = map()->instance_descriptors(); | 298 DescriptorArray* descs = map()->instance_descriptors(); |
248 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 299 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
249 PrintF(out, " "); | 300 PrintF(out, " "); |
250 descs->GetKey(i)->StringPrint(out); | 301 descs->GetKey(i)->StringPrint(out); |
251 PrintF(out, ": "); | 302 PrintF(out, ": "); |
252 switch (descs->GetType(i)) { | 303 switch (descs->GetType(i)) { |
253 case FIELD: { | 304 case FIELD: { |
254 int index = descs->GetFieldIndex(i); | 305 int index = descs->GetFieldIndex(i); |
255 FastPropertyAt(index)->ShortPrint(out); | 306 FastPropertyAt(index)->ShortPrint(out); |
256 PrintF(out, " (field at offset %d)\n", index); | 307 PrintF(out, " (field at offset %d)\n", index); |
257 break; | 308 break; |
258 } | 309 } |
259 case CONSTANT_FUNCTION: | 310 case CONSTANT_FUNCTION: |
260 descs->GetConstantFunction(i)->ShortPrint(out); | 311 descs->GetConstantFunction(i)->ShortPrint(out); |
261 PrintF(out, " (constant function)\n"); | 312 PrintF(out, " (constant function)\n"); |
262 break; | 313 break; |
263 case CALLBACKS: | 314 case CALLBACKS: |
264 descs->GetCallbacksObject(i)->ShortPrint(out); | 315 descs->GetCallbacksObject(i)->ShortPrint(out); |
265 PrintF(out, " (callback)\n"); | 316 PrintF(out, " (callback)\n"); |
266 break; | 317 break; |
267 case ELEMENTS_TRANSITION: | 318 case ELEMENTS_TRANSITION: |
268 PrintF(out, " (elements transition)\n"); | 319 PrintF(out, "(elements transition to "); |
| 320 PrintElementsKind(out, |
| 321 Map::cast(descs->GetValue(i))->elements_kind()); |
| 322 PrintF(out, ")\n"); |
269 break; | 323 break; |
270 case MAP_TRANSITION: | 324 case MAP_TRANSITION: |
271 PrintF(out, " (map transition)\n"); | 325 PrintF(out, "(map transition)\n"); |
272 break; | 326 break; |
273 case CONSTANT_TRANSITION: | 327 case CONSTANT_TRANSITION: |
274 PrintF(out, " (constant transition)\n"); | 328 PrintF(out, "(constant transition)\n"); |
275 break; | 329 break; |
276 case NULL_DESCRIPTOR: | 330 case NULL_DESCRIPTOR: |
277 PrintF(out, " (null descriptor)\n"); | 331 PrintF(out, "(null descriptor)\n"); |
278 break; | 332 break; |
279 default: | 333 default: |
280 UNREACHABLE(); | 334 UNREACHABLE(); |
281 break; | 335 break; |
282 } | 336 } |
283 } | 337 } |
284 } else { | 338 } else { |
285 property_dictionary()->Print(out); | 339 property_dictionary()->Print(out); |
286 } | 340 } |
287 } | 341 } |
288 | 342 |
289 | 343 |
290 void JSObject::PrintElements(FILE* out) { | 344 void JSObject::PrintElements(FILE* out) { |
291 switch (GetElementsKind()) { | 345 // Don't call GetElementsKind, it's validate code can cause the printer to |
| 346 // fail when debugging. |
| 347 switch (map()->elements_kind()) { |
| 348 case FAST_SMI_ONLY_ELEMENTS: |
292 case FAST_ELEMENTS: { | 349 case FAST_ELEMENTS: { |
293 // Print in array notation for non-sparse arrays. | 350 // Print in array notation for non-sparse arrays. |
294 FixedArray* p = FixedArray::cast(elements()); | 351 FixedArray* p = FixedArray::cast(elements()); |
295 for (int i = 0; i < p->length(); i++) { | 352 for (int i = 0; i < p->length(); i++) { |
296 PrintF(out, " %d: ", i); | 353 PrintF(out, " %d: ", i); |
297 p->get(i)->ShortPrint(out); | 354 p->get(i)->ShortPrint(out); |
298 PrintF(out, "\n"); | 355 PrintF(out, "\n"); |
299 } | 356 } |
300 break; | 357 break; |
301 } | 358 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 PrintF(out, "\n"); | 446 PrintF(out, "\n"); |
390 } | 447 } |
391 break; | 448 break; |
392 } | 449 } |
393 } | 450 } |
394 } | 451 } |
395 | 452 |
396 | 453 |
397 void JSObject::JSObjectPrint(FILE* out) { | 454 void JSObject::JSObjectPrint(FILE* out) { |
398 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); | 455 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
399 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); | 456 PrintF(out, " - map = %p [", reinterpret_cast<void*>(map())); |
400 PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); | 457 // Don't call GetElementsKind, it's validate code can cause the printer to |
| 458 // fail when debugging. |
| 459 PrintElementsKind(out, this->map()->elements_kind()); |
| 460 PrintF(out, |
| 461 "]\n - prototype = %p\n", |
| 462 reinterpret_cast<void*>(GetPrototype())); |
401 PrintF(out, " {\n"); | 463 PrintF(out, " {\n"); |
402 PrintProperties(out); | 464 PrintProperties(out); |
403 PrintElements(out); | 465 PrintElements(out); |
404 PrintF(out, " }\n"); | 466 PrintF(out, " }\n"); |
405 } | 467 } |
406 | 468 |
407 | 469 |
408 static const char* TypeToString(InstanceType type) { | 470 static const char* TypeToString(InstanceType type) { |
409 switch (type) { | 471 switch (type) { |
410 case INVALID_TYPE: return "INVALID"; | 472 case INVALID_TYPE: return "INVALID"; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 HeapObject::PrintHeader(out, "FixedArray"); | 583 HeapObject::PrintHeader(out, "FixedArray"); |
522 PrintF(out, " - length: %d", length()); | 584 PrintF(out, " - length: %d", length()); |
523 for (int i = 0; i < length(); i++) { | 585 for (int i = 0; i < length(); i++) { |
524 PrintF(out, "\n [%d]: ", i); | 586 PrintF(out, "\n [%d]: ", i); |
525 get(i)->ShortPrint(out); | 587 get(i)->ShortPrint(out); |
526 } | 588 } |
527 PrintF(out, "\n"); | 589 PrintF(out, "\n"); |
528 } | 590 } |
529 | 591 |
530 | 592 |
| 593 void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) { |
| 594 HeapObject::PrintHeader(out, "FixedDoubleArray"); |
| 595 PrintF(out, " - length: %d", length()); |
| 596 for (int i = 0; i < length(); i++) { |
| 597 PrintF(out, "\n [%d]: %g", i, get_scalar(i)); |
| 598 } |
| 599 PrintF(out, "\n"); |
| 600 } |
| 601 |
| 602 |
531 void JSValue::JSValuePrint(FILE* out) { | 603 void JSValue::JSValuePrint(FILE* out) { |
532 HeapObject::PrintHeader(out, "ValueObject"); | 604 HeapObject::PrintHeader(out, "ValueObject"); |
533 value()->Print(out); | 605 value()->Print(out); |
534 } | 606 } |
535 | 607 |
536 | 608 |
537 void JSMessageObject::JSMessageObjectPrint(FILE* out) { | 609 void JSMessageObject::JSMessageObjectPrint(FILE* out) { |
538 HeapObject::PrintHeader(out, "JSMessageObject"); | 610 HeapObject::PrintHeader(out, "JSMessageObject"); |
539 PrintF(out, " - type: "); | 611 PrintF(out, " - type: "); |
540 type()->ShortPrint(out); | 612 type()->ShortPrint(out); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 desc.Print(out); | 980 desc.Print(out); |
909 } | 981 } |
910 PrintF(out, "\n"); | 982 PrintF(out, "\n"); |
911 } | 983 } |
912 | 984 |
913 | 985 |
914 #endif // OBJECT_PRINT | 986 #endif // OBJECT_PRINT |
915 | 987 |
916 | 988 |
917 } } // namespace v8::internal | 989 } } // namespace v8::internal |
OLD | NEW |