OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include "src/disasm.h" | 7 #include "src/disasm.h" |
8 #include "src/disassembler.h" | 8 #include "src/disassembler.h" |
9 #include "src/interpreter/bytecodes.h" | 9 #include "src/interpreter/bytecodes.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY) | 88 TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY) |
89 #undef PRINT_FIXED_TYPED_ARRAY | 89 #undef PRINT_FIXED_TYPED_ARRAY |
90 | 90 |
91 case FILLER_TYPE: | 91 case FILLER_TYPE: |
92 os << "filler"; | 92 os << "filler"; |
93 break; | 93 break; |
94 case JS_OBJECT_TYPE: // fall through | 94 case JS_OBJECT_TYPE: // fall through |
95 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 95 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
96 case JS_ARRAY_TYPE: | 96 case JS_ARRAY_TYPE: |
97 case JS_GENERATOR_OBJECT_TYPE: | 97 case JS_GENERATOR_OBJECT_TYPE: |
| 98 JSObject::cast(this)->JSObjectPrint(os); |
| 99 break; |
98 case JS_REGEXP_TYPE: | 100 case JS_REGEXP_TYPE: |
99 JSObject::cast(this)->JSObjectPrint(os); | 101 JSRegExp::cast(this)->JSRegExpPrint(os); |
100 break; | 102 break; |
101 case ODDBALL_TYPE: | 103 case ODDBALL_TYPE: |
102 Oddball::cast(this)->to_string()->Print(os); | 104 Oddball::cast(this)->to_string()->Print(os); |
103 break; | 105 break; |
104 case JS_MODULE_TYPE: | 106 case JS_MODULE_TYPE: |
105 JSModule::cast(this)->JSModulePrint(os); | 107 JSModule::cast(this)->JSModulePrint(os); |
106 break; | 108 break; |
107 case JS_FUNCTION_TYPE: | 109 case JS_FUNCTION_TYPE: |
108 JSFunction::cast(this)->JSFunctionPrint(os); | 110 JSFunction::cast(this)->JSFunctionPrint(os); |
109 break; | 111 break; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void FixedTypedArray<Traits>::FixedTypedArrayPrint( | 264 void FixedTypedArray<Traits>::FixedTypedArrayPrint( |
263 std::ostream& os) { // NOLINT | 265 std::ostream& os) { // NOLINT |
264 os << "fixed " << Traits::Designator(); | 266 os << "fixed " << Traits::Designator(); |
265 } | 267 } |
266 | 268 |
267 | 269 |
268 void JSObject::PrintProperties(std::ostream& os) { // NOLINT | 270 void JSObject::PrintProperties(std::ostream& os) { // NOLINT |
269 if (HasFastProperties()) { | 271 if (HasFastProperties()) { |
270 DescriptorArray* descs = map()->instance_descriptors(); | 272 DescriptorArray* descs = map()->instance_descriptors(); |
271 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { | 273 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { |
272 os << " "; | 274 os << "\n "; |
273 descs->GetKey(i)->NamePrint(os); | 275 descs->GetKey(i)->NamePrint(os); |
274 os << ": "; | 276 os << ": "; |
275 switch (descs->GetType(i)) { | 277 switch (descs->GetType(i)) { |
276 case DATA: { | 278 case DATA: { |
277 FieldIndex index = FieldIndex::ForDescriptor(map(), i); | 279 FieldIndex index = FieldIndex::ForDescriptor(map(), i); |
278 if (IsUnboxedDoubleField(index)) { | 280 if (IsUnboxedDoubleField(index)) { |
279 os << "<unboxed double> " << RawFastDoublePropertyAt(index); | 281 os << "<unboxed double> " << RawFastDoublePropertyAt(index); |
280 } else { | 282 } else { |
281 os << Brief(RawFastPropertyAt(index)); | 283 os << Brief(RawFastPropertyAt(index)); |
282 } | 284 } |
283 os << " (data field at offset " << index.property_index() << ")\n"; | 285 os << " (data field at offset " << index.property_index() << ")"; |
284 break; | 286 break; |
285 } | 287 } |
286 case ACCESSOR: { | 288 case ACCESSOR: { |
287 FieldIndex index = FieldIndex::ForDescriptor(map(), i); | 289 FieldIndex index = FieldIndex::ForDescriptor(map(), i); |
288 os << " (accessor field at offset " << index.property_index() | 290 os << " (accessor field at offset " << index.property_index() << ")"; |
289 << ")\n"; | |
290 break; | 291 break; |
291 } | 292 } |
292 case DATA_CONSTANT: | 293 case DATA_CONSTANT: |
293 os << Brief(descs->GetConstant(i)) << " (data constant)\n"; | 294 os << Brief(descs->GetConstant(i)) << " (data constant)"; |
294 break; | 295 break; |
295 case ACCESSOR_CONSTANT: | 296 case ACCESSOR_CONSTANT: |
296 os << Brief(descs->GetCallbacksObject(i)) << " (accessor constant)\n"; | 297 os << Brief(descs->GetCallbacksObject(i)) << " (accessor constant)"; |
297 break; | 298 break; |
298 } | 299 } |
299 } | 300 } |
300 } else if (IsJSGlobalObject()) { | 301 } else if (IsJSGlobalObject()) { |
301 global_dictionary()->Print(os); | 302 global_dictionary()->Print(os); |
302 } else { | 303 } else { |
303 property_dictionary()->Print(os); | 304 property_dictionary()->Print(os); |
304 } | 305 } |
305 } | 306 } |
306 | 307 |
307 | 308 |
308 template <class T> | 309 template <class T> |
309 static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT | 310 static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT |
310 T* p = T::cast(object); | 311 T* p = T::cast(object); |
311 for (int i = 0; i < p->length(); i++) { | 312 for (int i = 0; i < p->length(); i++) { |
312 os << " " << i << ": " << p->get_scalar(i) << "\n"; | 313 os << "\n " << i << ": " << p->get_scalar(i); |
313 } | 314 } |
314 } | 315 } |
315 | 316 |
316 | 317 |
317 void JSObject::PrintElements(std::ostream& os) { // NOLINT | 318 void JSObject::PrintElements(std::ostream& os) { // NOLINT |
318 // Don't call GetElementsKind, its validation code can cause the printer to | 319 // Don't call GetElementsKind, its validation code can cause the printer to |
319 // fail when debugging. | 320 // fail when debugging. |
320 switch (map()->elements_kind()) { | 321 switch (map()->elements_kind()) { |
321 case FAST_HOLEY_SMI_ELEMENTS: | 322 case FAST_HOLEY_SMI_ELEMENTS: |
322 case FAST_SMI_ELEMENTS: | 323 case FAST_SMI_ELEMENTS: |
323 case FAST_HOLEY_ELEMENTS: | 324 case FAST_HOLEY_ELEMENTS: |
324 case FAST_ELEMENTS: { | 325 case FAST_ELEMENTS: { |
325 // Print in array notation for non-sparse arrays. | 326 // Print in array notation for non-sparse arrays. |
326 FixedArray* p = FixedArray::cast(elements()); | 327 FixedArray* p = FixedArray::cast(elements()); |
327 for (int i = 0; i < p->length(); i++) { | 328 for (int i = 0; i < p->length(); i++) { |
328 os << " " << i << ": " << Brief(p->get(i)) << "\n"; | 329 os << "\n " << i << ": " << Brief(p->get(i)); |
329 } | 330 } |
330 break; | 331 break; |
331 } | 332 } |
332 case FAST_HOLEY_DOUBLE_ELEMENTS: | 333 case FAST_HOLEY_DOUBLE_ELEMENTS: |
333 case FAST_DOUBLE_ELEMENTS: { | 334 case FAST_DOUBLE_ELEMENTS: { |
334 // Print in array notation for non-sparse arrays. | 335 // Print in array notation for non-sparse arrays. |
335 if (elements()->length() > 0) { | 336 if (elements()->length() > 0) { |
336 FixedDoubleArray* p = FixedDoubleArray::cast(elements()); | 337 FixedDoubleArray* p = FixedDoubleArray::cast(elements()); |
337 for (int i = 0; i < p->length(); i++) { | 338 for (int i = 0; i < p->length(); i++) { |
338 os << " " << i << ": "; | 339 os << "\n " << i << ": "; |
339 if (p->is_the_hole(i)) { | 340 if (p->is_the_hole(i)) { |
340 os << "<the hole>"; | 341 os << "<the hole>"; |
341 } else { | 342 } else { |
342 os << p->get_scalar(i); | 343 os << p->get_scalar(i); |
343 } | 344 } |
344 os << "\n"; | |
345 } | 345 } |
346 } | 346 } |
347 break; | 347 break; |
348 } | 348 } |
349 | 349 |
350 | 350 |
351 #define PRINT_ELEMENTS(Kind, Type) \ | 351 #define PRINT_ELEMENTS(Kind, Type) \ |
352 case Kind: { \ | 352 case Kind: { \ |
353 DoPrintElements<Type>(os, elements()); \ | 353 DoPrintElements<Type>(os, elements()); \ |
354 break; \ | 354 break; \ |
(...skipping 10 matching lines...) Expand all Loading... |
365 PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array) | 365 PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array) |
366 | 366 |
367 #undef PRINT_ELEMENTS | 367 #undef PRINT_ELEMENTS |
368 | 368 |
369 case DICTIONARY_ELEMENTS: | 369 case DICTIONARY_ELEMENTS: |
370 elements()->Print(os); | 370 elements()->Print(os); |
371 break; | 371 break; |
372 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 372 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
373 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { | 373 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { |
374 FixedArray* p = FixedArray::cast(elements()); | 374 FixedArray* p = FixedArray::cast(elements()); |
375 os << " parameter map:"; | 375 os << "\n parameter map:"; |
376 for (int i = 2; i < p->length(); i++) { | 376 for (int i = 2; i < p->length(); i++) { |
377 os << " " << (i - 2) << ":" << Brief(p->get(i)); | 377 os << " " << (i - 2) << ":" << Brief(p->get(i)); |
378 } | 378 } |
379 os << "\n context: " << Brief(p->get(0)) | 379 os << "\n context: " << Brief(p->get(0)) |
380 << "\n arguments: " << Brief(p->get(1)) << "\n"; | 380 << "\n arguments: " << Brief(p->get(1)); |
381 break; | 381 break; |
382 } | 382 } |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 | 386 |
387 static void JSObjectPrintHeader(std::ostream& os, JSObject* obj, | 387 static void JSObjectPrintHeader(std::ostream& os, JSObject* obj, |
388 const char* id) { // NOLINT | 388 const char* id) { // NOLINT |
389 obj->PrintHeader(os, id); | 389 obj->PrintHeader(os, id); |
390 // Don't call GetElementsKind, its validation code can cause the printer to | 390 // Don't call GetElementsKind, its validation code can cause the printer to |
391 // fail when debugging. | 391 // fail when debugging. |
392 PrototypeIterator iter(obj->GetIsolate(), obj); | 392 PrototypeIterator iter(obj->GetIsolate(), obj); |
393 os << " - map = " << reinterpret_cast<void*>(obj->map()) << " [" | 393 os << " - map = " << reinterpret_cast<void*>(obj->map()) << " [" |
394 << ElementsKindToString(obj->map()->elements_kind()) | 394 << ElementsKindToString(obj->map()->elements_kind()) |
395 << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent()); | 395 << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent()); |
396 } | 396 } |
397 | 397 |
398 | 398 |
399 static void JSObjectPrintBody(std::ostream& os, JSObject* obj) { // NOLINT | 399 static void JSObjectPrintBody(std::ostream& os, JSObject* obj, // NOLINT |
400 os << "\n {\n"; | 400 bool print_elements = true) { |
| 401 os << "\n {"; |
401 obj->PrintProperties(os); | 402 obj->PrintProperties(os); |
402 obj->PrintTransitions(os); | 403 obj->PrintTransitions(os); |
403 obj->PrintElements(os); | 404 if (print_elements) obj->PrintElements(os); |
404 os << " }\n"; | 405 os << "\n }\n"; |
405 } | 406 } |
406 | 407 |
407 | 408 |
408 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT | 409 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT |
409 JSObjectPrintHeader(os, this, "JSObject"); | 410 JSObjectPrintHeader(os, this, "JSObject"); |
410 JSObjectPrintBody(os, this); | 411 JSObjectPrintBody(os, this); |
411 } | 412 } |
412 | 413 |
413 | 414 |
| 415 void JSRegExp::JSRegExpPrint(std::ostream& os) { // NOLINT |
| 416 JSObjectPrintHeader(os, this, "JSRegExp"); |
| 417 os << "\n - data = " << Brief(data()); |
| 418 JSObjectPrintBody(os, this); |
| 419 } |
| 420 |
| 421 |
414 void JSModule::JSModulePrint(std::ostream& os) { // NOLINT | 422 void JSModule::JSModulePrint(std::ostream& os) { // NOLINT |
415 HeapObject::PrintHeader(os, "JSModule"); | 423 JSObjectPrintHeader(os, this, "JSModule"); |
416 os << " - map = " << reinterpret_cast<void*>(map()) << "\n" | 424 os << "\n - context = " << Brief(context()); |
417 << " - context = "; | 425 os << " - scope_info = " << Brief(scope_info()); |
418 context()->Print(os); | 426 JSObjectPrintBody(os, this); |
419 os << " - scope_info = " << Brief(scope_info()) | |
420 << ElementsKindToString(this->map()->elements_kind()) << " {\n"; | |
421 PrintProperties(os); | |
422 PrintElements(os); | |
423 os << " }\n"; | |
424 } | 427 } |
425 | 428 |
426 | 429 |
427 static const char* TypeToString(InstanceType type) { | 430 static const char* TypeToString(InstanceType type) { |
428 switch (type) { | 431 switch (type) { |
429 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE; | 432 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE; |
430 INSTANCE_TYPE_LIST(TYPE_TO_STRING) | 433 INSTANCE_TYPE_LIST(TYPE_TO_STRING) |
431 #undef TYPE_TO_STRING | 434 #undef TYPE_TO_STRING |
432 } | 435 } |
433 UNREACHABLE(); | 436 UNREACHABLE(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 os << " - prototype info: " << Brief(prototype_info()); | 477 os << " - prototype info: " << Brief(prototype_info()); |
475 } else { | 478 } else { |
476 os << " - back pointer: " << Brief(GetBackPointer()); | 479 os << " - back pointer: " << Brief(GetBackPointer()); |
477 } | 480 } |
478 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "") | 481 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "") |
479 << "#" << NumberOfOwnDescriptors() << ": " | 482 << "#" << NumberOfOwnDescriptors() << ": " |
480 << Brief(instance_descriptors()); | 483 << Brief(instance_descriptors()); |
481 if (FLAG_unbox_double_fields) { | 484 if (FLAG_unbox_double_fields) { |
482 os << "\n - layout descriptor: " << Brief(layout_descriptor()); | 485 os << "\n - layout descriptor: " << Brief(layout_descriptor()); |
483 } | 486 } |
484 if (TransitionArray::NumberOfTransitions(raw_transitions()) > 0) { | 487 int nof_transitions = TransitionArray::NumberOfTransitions(raw_transitions()); |
485 os << "\n - transitions: "; | 488 if (nof_transitions > 0) { |
486 TransitionArray::PrintTransitions(os, raw_transitions()); | 489 os << "\n - transitions #" << nof_transitions << ": " |
| 490 << Brief(raw_transitions()); |
| 491 TransitionArray::PrintTransitions(os, raw_transitions(), false); |
487 } | 492 } |
488 os << "\n - prototype: " << Brief(prototype()); | 493 os << "\n - prototype: " << Brief(prototype()); |
489 os << "\n - constructor: " << Brief(GetConstructor()); | 494 os << "\n - constructor: " << Brief(GetConstructor()); |
490 os << "\n - code cache: " << Brief(code_cache()); | 495 os << "\n - code cache: " << Brief(code_cache()); |
491 os << "\n - dependent code: " << Brief(dependent_code()); | 496 os << "\n - dependent code: " << Brief(dependent_code()); |
492 os << "\n"; | 497 os << "\n"; |
493 } | 498 } |
494 | 499 |
495 | 500 |
496 void CodeCache::CodeCachePrint(std::ostream& os) { // NOLINT | 501 void CodeCache::CodeCachePrint(std::ostream& os) { // NOLINT |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 } | 702 } |
698 } | 703 } |
699 | 704 |
700 | 705 |
701 static const char* const weekdays[] = { | 706 static const char* const weekdays[] = { |
702 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" | 707 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" |
703 }; | 708 }; |
704 | 709 |
705 | 710 |
706 void JSDate::JSDatePrint(std::ostream& os) { // NOLINT | 711 void JSDate::JSDatePrint(std::ostream& os) { // NOLINT |
707 HeapObject::PrintHeader(os, "JSDate"); | 712 JSObjectPrintHeader(os, this, "JSDate"); |
708 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 713 os << "\n - value = " << Brief(value()); |
709 os << " - value = "; | |
710 value()->Print(os); | |
711 if (!year()->IsSmi()) { | 714 if (!year()->IsSmi()) { |
712 os << " - time = NaN\n"; | 715 os << "\n - time = NaN\n"; |
713 } else { | 716 } else { |
714 // TODO(svenpanne) Add some basic formatting to our streams. | 717 // TODO(svenpanne) Add some basic formatting to our streams. |
715 ScopedVector<char> buf(100); | 718 ScopedVector<char> buf(100); |
716 SNPrintF( | 719 SNPrintF( |
717 buf, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n", | 720 buf, "\n - time = %s %04d/%02d/%02d %02d:%02d:%02d\n", |
718 weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0], | 721 weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0], |
719 year()->IsSmi() ? Smi::cast(year())->value() : -1, | 722 year()->IsSmi() ? Smi::cast(year())->value() : -1, |
720 month()->IsSmi() ? Smi::cast(month())->value() : -1, | 723 month()->IsSmi() ? Smi::cast(month())->value() : -1, |
721 day()->IsSmi() ? Smi::cast(day())->value() : -1, | 724 day()->IsSmi() ? Smi::cast(day())->value() : -1, |
722 hour()->IsSmi() ? Smi::cast(hour())->value() : -1, | 725 hour()->IsSmi() ? Smi::cast(hour())->value() : -1, |
723 min()->IsSmi() ? Smi::cast(min())->value() : -1, | 726 min()->IsSmi() ? Smi::cast(min())->value() : -1, |
724 sec()->IsSmi() ? Smi::cast(sec())->value() : -1); | 727 sec()->IsSmi() ? Smi::cast(sec())->value() : -1); |
725 os << buf.start(); | 728 os << buf.start(); |
726 } | 729 } |
| 730 JSObjectPrintBody(os, this); |
727 } | 731 } |
728 | 732 |
729 | 733 |
730 void JSProxy::JSProxyPrint(std::ostream& os) { // NOLINT | 734 void JSProxy::JSProxyPrint(std::ostream& os) { // NOLINT |
731 HeapObject::PrintHeader(os, "JSProxy"); | 735 HeapObject::PrintHeader(os, "JSProxy"); |
732 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 736 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; |
733 os << " - handler = "; | 737 os << " - handler = "; |
734 handler()->Print(os); | 738 handler()->Print(os); |
735 os << "\n - hash = "; | 739 os << "\n - hash = "; |
736 hash()->Print(os); | 740 hash()->Print(os); |
737 os << "\n"; | 741 os << "\n"; |
738 } | 742 } |
739 | 743 |
740 | 744 |
741 void JSFunctionProxy::JSFunctionProxyPrint(std::ostream& os) { // NOLINT | 745 void JSFunctionProxy::JSFunctionProxyPrint(std::ostream& os) { // NOLINT |
742 HeapObject::PrintHeader(os, "JSFunctionProxy"); | 746 HeapObject::PrintHeader(os, "JSFunctionProxy"); |
743 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 747 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; |
744 os << " - handler = "; | 748 os << " - handler = "; |
745 handler()->Print(os); | 749 handler()->Print(os); |
746 os << "\n - call_trap = "; | 750 os << "\n - call_trap = "; |
747 call_trap()->Print(os); | 751 call_trap()->Print(os); |
748 os << "\n - construct_trap = "; | 752 os << "\n - construct_trap = "; |
749 construct_trap()->Print(os); | 753 construct_trap()->Print(os); |
750 os << "\n"; | 754 os << "\n"; |
751 } | 755 } |
752 | 756 |
753 | 757 |
754 void JSSet::JSSetPrint(std::ostream& os) { // NOLINT | 758 void JSSet::JSSetPrint(std::ostream& os) { // NOLINT |
755 HeapObject::PrintHeader(os, "JSSet"); | 759 JSObjectPrintHeader(os, this, "JSSet"); |
756 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | |
757 os << " - table = " << Brief(table()); | 760 os << " - table = " << Brief(table()); |
758 os << "\n"; | 761 JSObjectPrintBody(os, this); |
759 } | 762 } |
760 | 763 |
761 | 764 |
762 void JSMap::JSMapPrint(std::ostream& os) { // NOLINT | 765 void JSMap::JSMapPrint(std::ostream& os) { // NOLINT |
763 HeapObject::PrintHeader(os, "JSMap"); | 766 JSObjectPrintHeader(os, this, "JSMap"); |
764 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | |
765 os << " - table = " << Brief(table()); | 767 os << " - table = " << Brief(table()); |
766 os << "\n"; | 768 JSObjectPrintBody(os, this); |
767 } | 769 } |
768 | 770 |
769 | 771 |
770 template <class Derived, class TableType> | 772 template <class Derived, class TableType> |
771 void | 773 void |
772 OrderedHashTableIterator<Derived, TableType>::OrderedHashTableIteratorPrint( | 774 OrderedHashTableIterator<Derived, TableType>::OrderedHashTableIteratorPrint( |
773 std::ostream& os) { // NOLINT | 775 std::ostream& os) { // NOLINT |
774 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 776 os << "\n - table = " << Brief(table()); |
775 os << " - table = " << Brief(table()); | |
776 os << "\n - index = " << Brief(index()); | 777 os << "\n - index = " << Brief(index()); |
777 os << "\n - kind = " << Brief(kind()); | 778 os << "\n - kind = " << Brief(kind()); |
778 os << "\n"; | 779 os << "\n"; |
779 } | 780 } |
780 | 781 |
781 | 782 |
782 template void OrderedHashTableIterator< | 783 template void OrderedHashTableIterator< |
783 JSSetIterator, | 784 JSSetIterator, |
784 OrderedHashSet>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT | 785 OrderedHashSet>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT |
785 | 786 |
786 | 787 |
787 template void OrderedHashTableIterator< | 788 template void OrderedHashTableIterator< |
788 JSMapIterator, | 789 JSMapIterator, |
789 OrderedHashMap>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT | 790 OrderedHashMap>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT |
790 | 791 |
791 | 792 |
792 void JSSetIterator::JSSetIteratorPrint(std::ostream& os) { // NOLINT | 793 void JSSetIterator::JSSetIteratorPrint(std::ostream& os) { // NOLINT |
793 HeapObject::PrintHeader(os, "JSSetIterator"); | 794 JSObjectPrintHeader(os, this, "JSSetIterator"); |
794 OrderedHashTableIteratorPrint(os); | 795 OrderedHashTableIteratorPrint(os); |
795 } | 796 } |
796 | 797 |
797 | 798 |
798 void JSMapIterator::JSMapIteratorPrint(std::ostream& os) { // NOLINT | 799 void JSMapIterator::JSMapIteratorPrint(std::ostream& os) { // NOLINT |
799 HeapObject::PrintHeader(os, "JSMapIterator"); | 800 JSObjectPrintHeader(os, this, "JSMapIterator"); |
800 OrderedHashTableIteratorPrint(os); | 801 OrderedHashTableIteratorPrint(os); |
801 } | 802 } |
802 | 803 |
803 | 804 |
804 void JSIteratorResult::JSIteratorResultPrint(std::ostream& os) { // NOLINT | 805 void JSIteratorResult::JSIteratorResultPrint(std::ostream& os) { // NOLINT |
805 HeapObject::PrintHeader(os, "JSIteratorResult"); | 806 JSObjectPrintHeader(os, this, "JSIteratorResult"); |
806 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 807 os << "\n - done = " << Brief(done()); |
807 os << " - done = " << Brief(done()) << "\n"; | 808 os << "\n - value = " << Brief(value()); |
808 os << " - value = " << Brief(value()) << "\n"; | |
809 os << "\n"; | 809 os << "\n"; |
810 } | 810 } |
811 | 811 |
812 | 812 |
813 void JSWeakMap::JSWeakMapPrint(std::ostream& os) { // NOLINT | 813 void JSWeakMap::JSWeakMapPrint(std::ostream& os) { // NOLINT |
814 HeapObject::PrintHeader(os, "JSWeakMap"); | 814 JSObjectPrintHeader(os, this, "JSWeakMap"); |
815 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 815 os << "\n - table = " << Brief(table()); |
816 os << " - table = " << Brief(table()); | 816 JSObjectPrintBody(os, this); |
817 os << "\n"; | |
818 } | 817 } |
819 | 818 |
820 | 819 |
821 void JSWeakSet::JSWeakSetPrint(std::ostream& os) { // NOLINT | 820 void JSWeakSet::JSWeakSetPrint(std::ostream& os) { // NOLINT |
822 HeapObject::PrintHeader(os, "JSWeakSet"); | 821 JSObjectPrintHeader(os, this, "JSWeakSet"); |
823 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 822 os << "\n - table = " << Brief(table()); |
824 os << " - table = " << Brief(table()); | 823 JSObjectPrintBody(os, this); |
825 os << "\n"; | |
826 } | 824 } |
827 | 825 |
828 | 826 |
829 void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT | 827 void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT |
830 HeapObject::PrintHeader(os, "JSArrayBuffer"); | 828 JSObjectPrintHeader(os, this, "JSArrayBuffer"); |
831 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 829 os << "\n - backing_store = " << backing_store(); |
832 os << " - backing_store = " << backing_store() << "\n"; | 830 os << "\n - byte_length = " << Brief(byte_length()); |
833 os << " - byte_length = " << Brief(byte_length()); | |
834 if (was_neutered()) os << " - neutered\n"; | 831 if (was_neutered()) os << " - neutered\n"; |
835 os << "\n"; | 832 JSObjectPrintBody(os, this, !was_neutered()); |
836 } | 833 } |
837 | 834 |
838 | 835 |
839 void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT | 836 void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT |
840 HeapObject::PrintHeader(os, "JSTypedArray"); | 837 JSObjectPrintHeader(os, this, "JSTypedArray"); |
841 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 838 os << "\n - buffer = " << Brief(buffer()); |
842 os << " - buffer = " << Brief(buffer()); | |
843 os << "\n - byte_offset = " << Brief(byte_offset()); | 839 os << "\n - byte_offset = " << Brief(byte_offset()); |
844 os << "\n - byte_length = " << Brief(byte_length()); | 840 os << "\n - byte_length = " << Brief(byte_length()); |
845 os << "\n - length = " << Brief(length()); | 841 os << "\n - length = " << Brief(length()); |
846 if (WasNeutered()) os << " - neutered\n"; | 842 if (WasNeutered()) os << " - neutered\n"; |
847 os << "\n"; | 843 JSObjectPrintBody(os, this, !WasNeutered()); |
848 if (!WasNeutered()) PrintElements(os); | |
849 } | 844 } |
850 | 845 |
851 | 846 |
852 void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT | 847 void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT |
853 HeapObject::PrintHeader(os, "JSDataView"); | 848 JSObjectPrintHeader(os, this, "JSDataView"); |
854 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 849 os << "\n - buffer =" << Brief(buffer()); |
855 os << " - buffer =" << Brief(buffer()); | |
856 os << "\n - byte_offset = " << Brief(byte_offset()); | 850 os << "\n - byte_offset = " << Brief(byte_offset()); |
857 os << "\n - byte_length = " << Brief(byte_length()); | 851 os << "\n - byte_length = " << Brief(byte_length()); |
858 if (WasNeutered()) os << " - neutered\n"; | 852 if (WasNeutered()) os << " - neutered\n"; |
859 os << "\n"; | 853 JSObjectPrintBody(os, this, !WasNeutered()); |
860 } | 854 } |
861 | 855 |
862 | 856 |
863 void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT | 857 void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT |
864 HeapObject::PrintHeader(os, "Function"); | 858 JSObjectPrintHeader(os, this, "Function"); |
865 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"; | 859 os << "\n - initial_map = "; |
866 os << " - initial_map = "; | |
867 if (has_initial_map()) os << Brief(initial_map()); | 860 if (has_initial_map()) os << Brief(initial_map()); |
868 os << "\n - shared_info = " << Brief(shared()); | 861 os << "\n - shared_info = " << Brief(shared()); |
869 os << "\n - name = " << Brief(shared()->name()); | 862 os << "\n - name = " << Brief(shared()->name()); |
870 os << "\n - context = " << Brief(context()); | 863 os << "\n - context = " << Brief(context()); |
871 if (shared()->bound()) { | 864 if (shared()->bound()) { |
872 os << "\n - bindings = " << Brief(function_bindings()); | 865 os << "\n - bindings = " << Brief(function_bindings()); |
873 } else { | 866 } else { |
874 os << "\n - literals = " << Brief(literals()); | 867 os << "\n - literals = " << Brief(literals()); |
875 } | 868 } |
876 os << "\n - code = " << Brief(code()); | 869 os << "\n - code = " << Brief(code()); |
877 os << "\n"; | 870 JSObjectPrintBody(os, this); |
878 PrintProperties(os); | |
879 PrintElements(os); | |
880 os << "\n"; | |
881 } | 871 } |
882 | 872 |
883 | 873 |
884 void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT | 874 void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT |
885 HeapObject::PrintHeader(os, "SharedFunctionInfo"); | 875 HeapObject::PrintHeader(os, "SharedFunctionInfo"); |
886 os << " - name: " << Brief(name()); | 876 os << " - name: " << Brief(name()); |
887 os << "\n - expected_nof_properties: " << expected_nof_properties(); | 877 os << "\n - expected_nof_properties: " << expected_nof_properties(); |
888 os << "\n - ast_node_count: " << ast_node_count(); | 878 os << "\n - ast_node_count: " << ast_node_count(); |
889 os << "\n - instance class name = "; | 879 os << "\n - instance class name = "; |
890 instance_class_name()->Print(os); | 880 instance_class_name()->Print(os); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) { // NOLINT | 918 void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) { // NOLINT |
929 os << "global "; | 919 os << "global "; |
930 JSObjectPrint(os); | 920 JSObjectPrint(os); |
931 os << "native context : " << Brief(native_context()); | 921 os << "native context : " << Brief(native_context()); |
932 os << "\n"; | 922 os << "\n"; |
933 } | 923 } |
934 | 924 |
935 | 925 |
936 void Cell::CellPrint(std::ostream& os) { // NOLINT | 926 void Cell::CellPrint(std::ostream& os) { // NOLINT |
937 HeapObject::PrintHeader(os, "Cell"); | 927 HeapObject::PrintHeader(os, "Cell"); |
| 928 os << " - value: " << Brief(value()); |
| 929 os << "\n"; |
938 } | 930 } |
939 | 931 |
940 | 932 |
941 void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT | 933 void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT |
942 HeapObject::PrintHeader(os, "PropertyCell"); | 934 HeapObject::PrintHeader(os, "PropertyCell"); |
| 935 os << " - value: " << Brief(value()); |
| 936 os << "\n - details: " << property_details(); |
| 937 os << "\n"; |
943 } | 938 } |
944 | 939 |
945 | 940 |
946 void WeakCell::WeakCellPrint(std::ostream& os) { // NOLINT | 941 void WeakCell::WeakCellPrint(std::ostream& os) { // NOLINT |
947 HeapObject::PrintHeader(os, "WeakCell"); | 942 HeapObject::PrintHeader(os, "WeakCell"); |
948 if (cleared()) { | 943 if (cleared()) { |
949 os << "\n - cleared"; | 944 os << "\n - cleared"; |
950 } else { | 945 } else { |
951 os << "\n - value: " << Brief(value()); | 946 os << "\n - value: " << Brief(value()); |
952 } | 947 } |
| 948 os << "\n"; |
953 } | 949 } |
954 | 950 |
955 | 951 |
956 void Code::CodePrint(std::ostream& os) { // NOLINT | 952 void Code::CodePrint(std::ostream& os) { // NOLINT |
957 HeapObject::PrintHeader(os, "Code"); | 953 HeapObject::PrintHeader(os, "Code"); |
958 #ifdef ENABLE_DISASSEMBLER | 954 #ifdef ENABLE_DISASSEMBLER |
959 if (FLAG_use_verbose_printer) { | 955 if (FLAG_use_verbose_printer) { |
960 Disassemble(NULL, os); | 956 Disassemble(NULL, os); |
961 } | 957 } |
962 #endif | 958 #endif |
963 } | 959 } |
964 | 960 |
965 | 961 |
966 void Foreign::ForeignPrint(std::ostream& os) { // NOLINT | 962 void Foreign::ForeignPrint(std::ostream& os) { // NOLINT |
967 os << "foreign address : " << foreign_address(); | 963 os << "foreign address : " << foreign_address(); |
| 964 os << "\n"; |
968 } | 965 } |
969 | 966 |
970 | 967 |
971 void ExecutableAccessorInfo::ExecutableAccessorInfoPrint( | 968 void ExecutableAccessorInfo::ExecutableAccessorInfoPrint( |
972 std::ostream& os) { // NOLINT | 969 std::ostream& os) { // NOLINT |
973 HeapObject::PrintHeader(os, "ExecutableAccessorInfo"); | 970 HeapObject::PrintHeader(os, "ExecutableAccessorInfo"); |
974 os << "\n - name: " << Brief(name()); | 971 os << "\n - name: " << Brief(name()); |
975 os << "\n - flag: " << flag(); | 972 os << "\n - flag: " << flag(); |
976 os << "\n - getter: " << Brief(getter()); | 973 os << "\n - getter: " << Brief(getter()); |
977 os << "\n - setter: " << Brief(setter()); | 974 os << "\n - setter: " << Brief(setter()); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 | 1251 |
1255 void DescriptorArray::Print() { | 1252 void DescriptorArray::Print() { |
1256 OFStream os(stdout); | 1253 OFStream os(stdout); |
1257 this->PrintDescriptors(os); | 1254 this->PrintDescriptors(os); |
1258 os << std::flush; | 1255 os << std::flush; |
1259 } | 1256 } |
1260 | 1257 |
1261 | 1258 |
1262 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT | 1259 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT |
1263 HandleScope scope(GetIsolate()); | 1260 HandleScope scope(GetIsolate()); |
1264 os << "Descriptor array " << number_of_descriptors() << "\n"; | 1261 os << "Descriptor array #" << number_of_descriptors(); |
1265 for (int i = 0; i < number_of_descriptors(); i++) { | 1262 for (int i = 0; i < number_of_descriptors(); i++) { |
1266 Descriptor desc; | 1263 Descriptor desc; |
1267 Get(i, &desc); | 1264 Get(i, &desc); |
1268 os << " " << i << ": " << desc << "\n"; | 1265 os << "\n " << i << ": " << desc; |
1269 } | 1266 } |
1270 os << "\n"; | 1267 os << "\n"; |
1271 } | 1268 } |
1272 | 1269 |
1273 | 1270 |
1274 void TransitionArray::Print() { | 1271 void TransitionArray::Print() { |
1275 OFStream os(stdout); | 1272 OFStream os(stdout); |
1276 TransitionArray::PrintTransitions(os, this); | 1273 TransitionArray::PrintTransitions(os, this); |
1277 os << std::flush; | 1274 os << "\n" << std::flush; |
1278 } | 1275 } |
1279 | 1276 |
1280 | 1277 |
1281 void TransitionArray::PrintTransitions(std::ostream& os, Object* transitions, | 1278 void TransitionArray::PrintTransitions(std::ostream& os, Object* transitions, |
1282 bool print_header) { // NOLINT | 1279 bool print_header) { // NOLINT |
1283 int num_transitions = NumberOfTransitions(transitions); | 1280 int num_transitions = NumberOfTransitions(transitions); |
1284 if (print_header) { | 1281 if (print_header) { |
1285 os << "Transition array " << num_transitions << "\n"; | 1282 os << "Transition array #" << num_transitions << ":"; |
1286 } | 1283 } |
1287 for (int i = 0; i < num_transitions; i++) { | 1284 for (int i = 0; i < num_transitions; i++) { |
1288 Name* key = GetKey(transitions, i); | 1285 Name* key = GetKey(transitions, i); |
1289 Map* target = GetTarget(transitions, i); | 1286 Map* target = GetTarget(transitions, i); |
1290 os << " "; | 1287 os << "\n "; |
1291 #ifdef OBJECT_PRINT | 1288 #ifdef OBJECT_PRINT |
1292 key->NamePrint(os); | 1289 key->NamePrint(os); |
1293 #else | 1290 #else |
1294 key->ShortPrint(os); | 1291 key->ShortPrint(os); |
1295 #endif | 1292 #endif |
1296 os << ": "; | 1293 os << ": "; |
1297 Heap* heap = key->GetHeap(); | 1294 Heap* heap = key->GetHeap(); |
1298 if (key == heap->nonextensible_symbol()) { | 1295 if (key == heap->nonextensible_symbol()) { |
1299 os << " (transition to non-extensible)"; | 1296 os << "(transition to non-extensible)"; |
1300 } else if (key == heap->sealed_symbol()) { | 1297 } else if (key == heap->sealed_symbol()) { |
1301 os << " (transition to sealed)"; | 1298 os << "(transition to sealed)"; |
1302 } else if (key == heap->frozen_symbol()) { | 1299 } else if (key == heap->frozen_symbol()) { |
1303 os << " (transition to frozen)"; | 1300 os << "(transition to frozen)"; |
1304 } else if (key == heap->elements_transition_symbol()) { | 1301 } else if (key == heap->elements_transition_symbol()) { |
1305 os << " (transition to " << ElementsKindToString(target->elements_kind()) | 1302 os << "(transition to " << ElementsKindToString(target->elements_kind()) |
1306 << ")"; | 1303 << ")"; |
1307 } else if (key == heap->observed_symbol()) { | 1304 } else if (key == heap->observed_symbol()) { |
1308 os << " (transition to Object.observe)"; | 1305 os << " (transition to Object.observe)"; |
1309 } else { | 1306 } else { |
1310 PropertyDetails details = GetTargetDetails(key, target); | 1307 PropertyDetails details = GetTargetDetails(key, target); |
1311 os << " (transition to "; | 1308 os << "(transition to "; |
1312 if (details.location() == kDescriptor) { | 1309 if (details.location() == kDescriptor) { |
1313 os << "immutable "; | 1310 os << "immutable "; |
1314 } | 1311 } |
1315 os << (details.kind() == kData ? "data" : "accessor"); | 1312 os << (details.kind() == kData ? "data" : "accessor"); |
1316 if (details.location() == kDescriptor) { | 1313 if (details.location() == kDescriptor) { |
1317 Object* value = | 1314 Object* value = |
1318 target->instance_descriptors()->GetValue(target->LastAdded()); | 1315 target->instance_descriptors()->GetValue(target->LastAdded()); |
1319 os << " " << Brief(value); | 1316 os << " " << Brief(value); |
1320 } | 1317 } |
1321 os << "), attrs: " << details.attributes(); | 1318 os << "), attrs: " << details.attributes(); |
1322 } | 1319 } |
1323 os << " -> " << Brief(target) << "\n"; | 1320 os << " -> " << Brief(target); |
1324 } | 1321 } |
1325 } | 1322 } |
1326 | 1323 |
1327 | 1324 |
1328 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT | 1325 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT |
1329 TransitionArray::PrintTransitions(os, map()->raw_transitions()); | 1326 Object* transitions = map()->raw_transitions(); |
| 1327 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
| 1328 if (num_transitions == 0) return; |
| 1329 os << "\n - transitions"; |
| 1330 TransitionArray::PrintTransitions(os, transitions, false); |
1330 } | 1331 } |
1331 #endif // defined(DEBUG) || defined(OBJECT_PRINT) | 1332 #endif // defined(DEBUG) || defined(OBJECT_PRINT) |
1332 } // namespace internal | 1333 } // namespace internal |
1333 } // namespace v8 | 1334 } // namespace v8 |
OLD | NEW |