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
3 // found in the LICENSE file.
7 #include "src/disasm.h"
8 #include "src/disassembler.h"
9 #include "src/heap/objects-visiting.h"
10 #include "src/jsregexp.h"
11 #include "src/ostreams.h"
18 void Object::Print() {
25 void Object::Print(OStream& os) { // NOLINT
27 Smi::cast(this)->SmiPrint(os);
29 HeapObject::cast(this)->HeapObjectPrint(os);
34 void HeapObject::PrintHeader(OStream& os, const char* id) { // NOLINT
35 os << "" << reinterpret_cast<void*>(this) << ": [" << id << "]\n";
39 void HeapObject::HeapObjectPrint(OStream& os) { // NOLINT
40 InstanceType instance_type = map()->instance_type();
42 HandleScope scope(GetIsolate());
43 if (instance_type < FIRST_NONSTRING_TYPE) {
44 String::cast(this)->StringPrint(os);
48 switch (instance_type) {
50 Symbol::cast(this)->SymbolPrint(os);
53 Map::cast(this)->MapPrint(os);
55 case HEAP_NUMBER_TYPE:
56 HeapNumber::cast(this)->HeapNumberPrint(os);
58 case MUTABLE_HEAP_NUMBER_TYPE:
60 HeapNumber::cast(this)->HeapNumberPrint(os);
64 Float32x4::cast(this)->Float32x4Print(os);
67 Float64x2::cast(this)->Float64x2Print(os);
70 Int32x4::cast(this)->Int32x4Print(os);
72 case FIXED_DOUBLE_ARRAY_TYPE:
73 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
75 case CONSTANT_POOL_ARRAY_TYPE:
76 ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(os);
78 case FIXED_ARRAY_TYPE:
79 FixedArray::cast(this)->FixedArrayPrint(os);
82 ByteArray::cast(this)->ByteArrayPrint(os);
85 FreeSpace::cast(this)->FreeSpacePrint(os);
88 #define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
89 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
90 External##Type##Array::cast(this)->External##Type##ArrayPrint(os); \
93 TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
94 #undef PRINT_EXTERNAL_ARRAY
96 #define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
97 case Fixed##Type##Array::kInstanceType: \
98 Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(os); \
101 TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
102 #undef PRINT_FIXED_TYPED_ARRAY
107 case JS_OBJECT_TYPE: // fall through
108 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
110 case JS_GENERATOR_OBJECT_TYPE:
112 JSObject::cast(this)->JSObjectPrint(os);
115 Oddball::cast(this)->to_string()->Print(os);
118 JSModule::cast(this)->JSModulePrint(os);
120 case JS_FUNCTION_TYPE:
121 JSFunction::cast(this)->JSFunctionPrint(os);
123 case JS_GLOBAL_PROXY_TYPE:
124 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(os);
126 case JS_GLOBAL_OBJECT_TYPE:
127 JSGlobalObject::cast(this)->JSGlobalObjectPrint(os);
129 case JS_BUILTINS_OBJECT_TYPE:
130 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(os);
133 os << "Value wrapper around:";
134 JSValue::cast(this)->value()->Print(os);
137 JSDate::cast(this)->JSDatePrint(os);
140 Code::cast(this)->CodePrint(os);
143 JSProxy::cast(this)->JSProxyPrint(os);
145 case JS_FUNCTION_PROXY_TYPE:
146 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(os);
149 JSSet::cast(this)->JSSetPrint(os);
152 JSMap::cast(this)->JSMapPrint(os);
154 case JS_SET_ITERATOR_TYPE:
155 JSSetIterator::cast(this)->JSSetIteratorPrint(os);
157 case JS_MAP_ITERATOR_TYPE:
158 JSMapIterator::cast(this)->JSMapIteratorPrint(os);
160 case JS_WEAK_MAP_TYPE:
161 JSWeakMap::cast(this)->JSWeakMapPrint(os);
163 case JS_WEAK_SET_TYPE:
164 JSWeakSet::cast(this)->JSWeakSetPrint(os);
167 Foreign::cast(this)->ForeignPrint(os);
169 case SHARED_FUNCTION_INFO_TYPE:
170 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(os);
172 case JS_MESSAGE_OBJECT_TYPE:
173 JSMessageObject::cast(this)->JSMessageObjectPrint(os);
176 Cell::cast(this)->CellPrint(os);
178 case PROPERTY_CELL_TYPE:
179 PropertyCell::cast(this)->PropertyCellPrint(os);
181 case JS_ARRAY_BUFFER_TYPE:
182 JSArrayBuffer::cast(this)->JSArrayBufferPrint(os);
184 case JS_TYPED_ARRAY_TYPE:
185 JSTypedArray::cast(this)->JSTypedArrayPrint(os);
187 case JS_DATA_VIEW_TYPE:
188 JSDataView::cast(this)->JSDataViewPrint(os);
190 #define MAKE_STRUCT_CASE(NAME, Name, name) \
192 Name::cast(this)->Name##Print(os); \
194 STRUCT_LIST(MAKE_STRUCT_CASE)
195 #undef MAKE_STRUCT_CASE
198 os << "UNKNOWN TYPE " << map()->instance_type();
205 void ByteArray::ByteArrayPrint(OStream& os) { // NOLINT
206 os << "byte array, data starts at " << GetDataStartAddress();
210 void FreeSpace::FreeSpacePrint(OStream& os) { // NOLINT
211 os << "free space, size " << Size();
215 #define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
216 void External##Type##Array::External##Type##ArrayPrint(OStream& os) { \
217 os << "external " #type " array"; \
220 TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
222 #undef EXTERNAL_ARRAY_PRINTER
225 template <class Traits>
226 void FixedTypedArray<Traits>::FixedTypedArrayPrint(OStream& os) { // NOLINT
227 os << "fixed " << Traits::Designator();
231 void JSObject::PrintProperties(OStream& os) { // NOLINT
232 if (HasFastProperties()) {
233 DescriptorArray* descs = map()->instance_descriptors();
234 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
236 descs->GetKey(i)->NamePrint(os);
238 switch (descs->GetType(i)) {
240 FieldIndex index = FieldIndex::ForDescriptor(map(), i);
241 os << Brief(RawFastPropertyAt(index)) << " (field at offset "
242 << index.property_index() << ")\n";
246 os << Brief(descs->GetConstant(i)) << " (constant)\n";
249 os << Brief(descs->GetCallbacksObject(i)) << " (callback)\n";
251 case NORMAL: // only in slow mode
257 property_dictionary()->Print(os);
263 static void DoPrintElements(OStream& os, Object* object) { // NOLINT
264 T* p = T::cast(object);
265 for (int i = 0; i < p->length(); i++) {
266 os << " " << i << ": " << p->get_scalar(i) << "\n";
272 static void DoPrintFloat32x4Elements(OStream& os, Object* object) {
273 T* p = T::cast(object);
274 for (int i = 0; i < p->length(); i++) {
275 float32x4_value_t value = p->get_scalar(i);
276 os << " " << i << ": (" << value.storage[0] << value.storage[1] <<
277 value.storage[2] << value.storage[3] << ")\n";
283 static void DoPrintFloat64x2Elements(OStream& os, Object* object) {
284 T* p = T::cast(object);
285 for (int i = 0; i < p->length(); i++) {
286 float64x2_value_t value = p->get_scalar(i);
287 os << " " << i << ": (" << value.storage[0] << value.storage[1] << ")\n";
293 static void DoPrintInt32x4Elements(OStream& os, Object* object) {
294 T* p = T::cast(object);
295 for (int i = 0; i < p->length(); i++) {
296 int32x4_value_t value = p->get_scalar(i);
297 os << " " << i << ": (" << value.storage[0] << value.storage[1] <<
298 value.storage[2] << value.storage[3] << ")\n";
303 void JSObject::PrintElements(OStream& os) { // NOLINT
304 // Don't call GetElementsKind, its validation code can cause the printer to
305 // fail when debugging.
306 switch (map()->elements_kind()) {
307 case FAST_HOLEY_SMI_ELEMENTS:
308 case FAST_SMI_ELEMENTS:
309 case FAST_HOLEY_ELEMENTS:
310 case FAST_ELEMENTS: {
311 // Print in array notation for non-sparse arrays.
312 FixedArray* p = FixedArray::cast(elements());
313 for (int i = 0; i < p->length(); i++) {
314 os << " " << i << ": " << Brief(p->get(i)) << "\n";
318 case FAST_HOLEY_DOUBLE_ELEMENTS:
319 case FAST_DOUBLE_ELEMENTS: {
320 // Print in array notation for non-sparse arrays.
321 if (elements()->length() > 0) {
322 FixedDoubleArray* p = FixedDoubleArray::cast(elements());
323 for (int i = 0; i < p->length(); i++) {
324 os << " " << i << ": ";
325 if (p->is_the_hole(i)) {
328 os << p->get_scalar(i);
337 #define PRINT_ELEMENTS(Kind, Type) \
339 DoPrintElements<Type>(os, elements()); \
343 #define PRINT_FLOAT32x4_ELEMENTS(Kind, Type) \
345 DoPrintFloat32x4Elements<Type>(os, elements()); \
349 #define PRINT_FLOAT64x2_ELEMENTS(Kind, Type) \
351 DoPrintFloat64x2Elements<Type>(os, elements()); \
355 #define PRINT_INT32x4_ELEMENTS(Kind, Type) \
357 DoPrintInt32x4Elements<Type>(os, elements()); \
361 PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray)
362 PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array)
363 PRINT_ELEMENTS(EXTERNAL_UINT8_ELEMENTS,
365 PRINT_ELEMENTS(EXTERNAL_INT16_ELEMENTS, ExternalInt16Array)
366 PRINT_ELEMENTS(EXTERNAL_UINT16_ELEMENTS,
368 PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array)
369 PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS,
371 PRINT_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
372 PRINT_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
373 PRINT_FLOAT32x4_ELEMENTS(EXTERNAL_FLOAT32x4_ELEMENTS,
374 ExternalFloat32x4Array)
375 PRINT_FLOAT64x2_ELEMENTS(EXTERNAL_FLOAT64x2_ELEMENTS,
376 ExternalFloat64x2Array)
377 PRINT_INT32x4_ELEMENTS(EXTERNAL_INT32x4_ELEMENTS, ExternalInt32x4Array)
379 PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
380 PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
381 PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
382 PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
383 PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
384 PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
385 PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
386 PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
387 PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
388 PRINT_FLOAT32x4_ELEMENTS(FLOAT32x4_ELEMENTS, FixedFloat32x4Array)
389 PRINT_FLOAT64x2_ELEMENTS(FLOAT64x2_ELEMENTS, FixedFloat64x2Array)
390 PRINT_INT32x4_ELEMENTS(INT32x4_ELEMENTS, FixedInt32x4Array)
392 #undef PRINT_ELEMENTS
394 case DICTIONARY_ELEMENTS:
395 elements()->Print(os);
397 case SLOPPY_ARGUMENTS_ELEMENTS: {
398 FixedArray* p = FixedArray::cast(elements());
399 os << " parameter map:";
400 for (int i = 2; i < p->length(); i++) {
401 os << " " << (i - 2) << ":" << Brief(p->get(i));
403 os << "\n context: " << Brief(p->get(0))
404 << "\n arguments: " << Brief(p->get(1)) << "\n";
411 void JSObject::PrintTransitions(OStream& os) { // NOLINT
412 if (!map()->HasTransitionArray()) return;
413 TransitionArray* transitions = map()->transitions();
414 for (int i = 0; i < transitions->number_of_transitions(); i++) {
415 Name* key = transitions->GetKey(i);
419 if (key == GetHeap()->frozen_symbol()) {
420 os << " (transition to frozen)\n";
421 } else if (key == GetHeap()->elements_transition_symbol()) {
422 os << " (transition to "
423 << ElementsKindToString(transitions->GetTarget(i)->elements_kind())
425 } else if (key == GetHeap()->observed_symbol()) {
426 os << " (transition to Object.observe)\n";
428 switch (transitions->GetTargetDetails(i).type()) {
430 os << " (transition to field)\n";
434 os << " (transition to constant)\n";
437 os << " (transition to callback)\n";
439 // Values below are never in the target descriptor array.
449 void JSObject::JSObjectPrint(OStream& os) { // NOLINT
450 HeapObject::PrintHeader(os, "JSObject");
451 // Don't call GetElementsKind, its validation code can cause the printer to
452 // fail when debugging.
453 PrototypeIterator iter(GetIsolate(), this);
454 os << " - map = " << reinterpret_cast<void*>(map()) << " ["
455 << ElementsKindToString(this->map()->elements_kind())
456 << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent())
459 PrintTransitions(os);
465 void JSModule::JSModulePrint(OStream& os) { // NOLINT
466 HeapObject::PrintHeader(os, "JSModule");
467 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"
469 context()->Print(os);
470 os << " - scope_info = " << Brief(scope_info())
471 << ElementsKindToString(this->map()->elements_kind()) << " {\n";
478 static const char* TypeToString(InstanceType type) {
480 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
481 INSTANCE_TYPE_LIST(TYPE_TO_STRING)
482 #undef TYPE_TO_STRING
485 return "UNKNOWN"; // Keep the compiler happy.
489 void Symbol::SymbolPrint(OStream& os) { // NOLINT
490 HeapObject::PrintHeader(os, "Symbol");
491 os << " - hash: " << Hash();
492 os << "\n - name: " << Brief(name());
493 os << "\n - private: " << is_private();
494 os << "\n - own: " << is_own();
499 void Map::MapPrint(OStream& os) { // NOLINT
500 HeapObject::PrintHeader(os, "Map");
501 os << " - type: " << TypeToString(instance_type()) << "\n";
502 os << " - instance size: " << instance_size() << "\n";
503 os << " - inobject properties: " << inobject_properties() << "\n";
504 os << " - elements kind: " << ElementsKindToString(elements_kind());
505 os << "\n - pre-allocated property fields: "
506 << pre_allocated_property_fields() << "\n";
507 os << " - unused property fields: " << unused_property_fields() << "\n";
508 if (is_hidden_prototype()) os << " - hidden_prototype\n";
509 if (has_named_interceptor()) os << " - named_interceptor\n";
510 if (has_indexed_interceptor()) os << " - indexed_interceptor\n";
511 if (is_undetectable()) os << " - undetectable\n";
512 if (has_instance_call_handler()) os << " - instance_call_handler\n";
513 if (is_access_check_needed()) os << " - access_check_needed\n";
516 } else if (!is_extensible()) {
519 os << " - back pointer: " << Brief(GetBackPointer());
520 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
521 << "#" << NumberOfOwnDescriptors() << ": "
522 << Brief(instance_descriptors());
523 if (HasTransitionArray()) {
524 os << "\n - transitions: " << Brief(transitions());
526 os << "\n - prototype: " << Brief(prototype());
527 os << "\n - constructor: " << Brief(constructor());
528 os << "\n - code cache: " << Brief(code_cache());
529 os << "\n - dependent code: " << Brief(dependent_code());
534 void CodeCache::CodeCachePrint(OStream& os) { // NOLINT
535 HeapObject::PrintHeader(os, "CodeCache");
536 os << "\n - default_cache: " << Brief(default_cache());
537 os << "\n - normal_type_cache: " << Brief(normal_type_cache());
541 void PolymorphicCodeCache::PolymorphicCodeCachePrint(OStream& os) { // NOLINT
542 HeapObject::PrintHeader(os, "PolymorphicCodeCache");
543 os << "\n - cache: " << Brief(cache());
547 void TypeFeedbackInfo::TypeFeedbackInfoPrint(OStream& os) { // NOLINT
548 HeapObject::PrintHeader(os, "TypeFeedbackInfo");
549 os << " - ic_total_count: " << ic_total_count()
550 << ", ic_with_type_info_count: " << ic_with_type_info_count()
551 << ", ic_generic_count: " << ic_generic_count() << "\n";
555 void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(OStream& os) { // NOLINT
556 HeapObject::PrintHeader(os, "AliasedArgumentsEntry");
557 os << "\n - aliased_context_slot: " << aliased_context_slot();
561 void FixedArray::FixedArrayPrint(OStream& os) { // NOLINT
562 HeapObject::PrintHeader(os, "FixedArray");
563 os << " - length: " << length();
564 for (int i = 0; i < length(); i++) {
565 os << "\n [" << i << "]: " << Brief(get(i));
571 void FixedDoubleArray::FixedDoubleArrayPrint(OStream& os) { // NOLINT
572 HeapObject::PrintHeader(os, "FixedDoubleArray");
573 os << " - length: " << length();
574 for (int i = 0; i < length(); i++) {
575 os << "\n [" << i << "]: ";
576 if (is_the_hole(i)) {
586 void ConstantPoolArray::ConstantPoolArrayPrint(OStream& os) { // NOLINT
587 HeapObject::PrintHeader(os, "ConstantPoolArray");
588 os << " - length: " << length();
589 for (int i = 0; i <= last_index(INT32, SMALL_SECTION); i++) {
590 if (i < last_index(INT64, SMALL_SECTION)) {
591 os << "\n [" << i << "]: double: " << get_int64_entry_as_double(i);
592 } else if (i <= last_index(CODE_PTR, SMALL_SECTION)) {
593 os << "\n [" << i << "]: code target pointer: "
594 << reinterpret_cast<void*>(get_code_ptr_entry(i));
595 } else if (i <= last_index(HEAP_PTR, SMALL_SECTION)) {
596 os << "\n [" << i << "]: heap pointer: "
597 << reinterpret_cast<void*>(get_heap_ptr_entry(i));
598 } else if (i <= last_index(INT32, SMALL_SECTION)) {
599 os << "\n [" << i << "]: int32: " << get_int32_entry(i);
602 if (is_extended_layout()) {
603 os << "\n Extended section:";
604 for (int i = first_extended_section_index();
605 i <= last_index(INT32, EXTENDED_SECTION); i++) {
606 if (i < last_index(INT64, EXTENDED_SECTION)) {
607 os << "\n [" << i << "]: double: " << get_int64_entry_as_double(i);
608 } else if (i <= last_index(CODE_PTR, EXTENDED_SECTION)) {
609 os << "\n [" << i << "]: code target pointer: "
610 << reinterpret_cast<void*>(get_code_ptr_entry(i));
611 } else if (i <= last_index(HEAP_PTR, EXTENDED_SECTION)) {
612 os << "\n [" << i << "]: heap pointer: "
613 << reinterpret_cast<void*>(get_heap_ptr_entry(i));
614 } else if (i <= last_index(INT32, EXTENDED_SECTION)) {
615 os << "\n [" << i << "]: int32: " << get_int32_entry(i);
623 void JSValue::JSValuePrint(OStream& os) { // NOLINT
624 HeapObject::PrintHeader(os, "ValueObject");
629 void JSMessageObject::JSMessageObjectPrint(OStream& os) { // NOLINT
630 HeapObject::PrintHeader(os, "JSMessageObject");
631 os << " - type: " << Brief(type());
632 os << "\n - arguments: " << Brief(arguments());
633 os << "\n - start_position: " << start_position();
634 os << "\n - end_position: " << end_position();
635 os << "\n - script: " << Brief(script());
636 os << "\n - stack_frames: " << Brief(stack_frames());
641 void String::StringPrint(OStream& os) { // NOLINT
642 if (StringShape(this).IsInternalized()) {
644 } else if (StringShape(this).IsCons()) {
650 const char truncated_epilogue[] = "...<truncated>";
652 if (!FLAG_use_verbose_printer) {
654 len = 100 - sizeof(truncated_epilogue);
657 for (int i = 0; i < len; i++) {
658 os << AsUC16(Get(i));
660 if (len != length()) {
661 os << truncated_epilogue;
664 if (!StringShape(this).IsInternalized()) os << "\"";
668 void Name::NamePrint(OStream& os) { // NOLINT
670 String::cast(this)->StringPrint(os);
676 // This method is only meant to be called from gdb for debugging purposes.
677 // Since the string can also be in two-byte encoding, non-Latin1 characters
678 // will be ignored in the output.
679 char* String::ToAsciiArray() {
680 // Static so that subsequent calls frees previously allocated space.
681 // This also means that previous results will be overwritten.
682 static char* buffer = NULL;
683 if (buffer != NULL) free(buffer);
684 buffer = new char[length()+1];
685 WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
686 buffer[length()] = 0;
691 static const char* const weekdays[] = {
692 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
696 void JSDate::JSDatePrint(OStream& os) { // NOLINT
697 HeapObject::PrintHeader(os, "JSDate");
698 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
701 if (!year()->IsSmi()) {
702 os << " - time = NaN\n";
704 // TODO(svenpanne) Add some basic formatting to our streams.
705 Vector<char> buf = Vector<char>::New(100);
707 buf, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
708 weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
709 year()->IsSmi() ? Smi::cast(year())->value() : -1,
710 month()->IsSmi() ? Smi::cast(month())->value() : -1,
711 day()->IsSmi() ? Smi::cast(day())->value() : -1,
712 hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
713 min()->IsSmi() ? Smi::cast(min())->value() : -1,
714 sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
720 void JSProxy::JSProxyPrint(OStream& os) { // NOLINT
721 HeapObject::PrintHeader(os, "JSProxy");
722 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
723 os << " - handler = ";
724 handler()->Print(os);
725 os << "\n - hash = ";
731 void JSFunctionProxy::JSFunctionProxyPrint(OStream& os) { // NOLINT
732 HeapObject::PrintHeader(os, "JSFunctionProxy");
733 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
734 os << " - handler = ";
735 handler()->Print(os);
736 os << "\n - call_trap = ";
737 call_trap()->Print(os);
738 os << "\n - construct_trap = ";
739 construct_trap()->Print(os);
744 void JSSet::JSSetPrint(OStream& os) { // NOLINT
745 HeapObject::PrintHeader(os, "JSSet");
746 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
747 os << " - table = " << Brief(table());
752 void JSMap::JSMapPrint(OStream& os) { // NOLINT
753 HeapObject::PrintHeader(os, "JSMap");
754 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
755 os << " - table = " << Brief(table());
760 template <class Derived, class TableType>
761 void OrderedHashTableIterator<
762 Derived, TableType>::OrderedHashTableIteratorPrint(OStream& os) { // NOLINT
763 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
764 os << " - table = " << Brief(table());
765 os << "\n - index = " << Brief(index());
766 os << "\n - kind = " << Brief(kind());
771 template void OrderedHashTableIterator<
773 OrderedHashSet>::OrderedHashTableIteratorPrint(OStream& os); // NOLINT
776 template void OrderedHashTableIterator<
778 OrderedHashMap>::OrderedHashTableIteratorPrint(OStream& os); // NOLINT
781 void JSSetIterator::JSSetIteratorPrint(OStream& os) { // NOLINT
782 HeapObject::PrintHeader(os, "JSSetIterator");
783 OrderedHashTableIteratorPrint(os);
787 void JSMapIterator::JSMapIteratorPrint(OStream& os) { // NOLINT
788 HeapObject::PrintHeader(os, "JSMapIterator");
789 OrderedHashTableIteratorPrint(os);
793 void JSWeakMap::JSWeakMapPrint(OStream& os) { // NOLINT
794 HeapObject::PrintHeader(os, "JSWeakMap");
795 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
796 os << " - table = " << Brief(table());
801 void JSWeakSet::JSWeakSetPrint(OStream& os) { // NOLINT
802 HeapObject::PrintHeader(os, "JSWeakSet");
803 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
804 os << " - table = " << Brief(table());
809 void JSArrayBuffer::JSArrayBufferPrint(OStream& os) { // NOLINT
810 HeapObject::PrintHeader(os, "JSArrayBuffer");
811 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
812 os << " - backing_store = " << backing_store() << "\n";
813 os << " - byte_length = " << Brief(byte_length());
818 void JSTypedArray::JSTypedArrayPrint(OStream& os) { // NOLINT
819 HeapObject::PrintHeader(os, "JSTypedArray");
820 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
821 os << " - buffer = " << Brief(buffer());
822 os << "\n - byte_offset = " << Brief(byte_offset());
823 os << "\n - byte_length = " << Brief(byte_length());
824 os << "\n - length = " << Brief(length());
830 void JSDataView::JSDataViewPrint(OStream& os) { // NOLINT
831 HeapObject::PrintHeader(os, "JSDataView");
832 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
833 os << " - buffer =" << Brief(buffer());
834 os << "\n - byte_offset = " << Brief(byte_offset());
835 os << "\n - byte_length = " << Brief(byte_length());
840 void JSFunction::JSFunctionPrint(OStream& os) { // NOLINT
841 HeapObject::PrintHeader(os, "Function");
842 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
843 os << " - initial_map = ";
844 if (has_initial_map()) os << Brief(initial_map());
845 os << "\n - shared_info = " << Brief(shared());
846 os << "\n - name = " << Brief(shared()->name());
847 os << "\n - context = " << Brief(context());
848 if (shared()->bound()) {
849 os << "\n - bindings = " << Brief(function_bindings());
851 os << "\n - literals = " << Brief(literals());
853 os << "\n - code = " << Brief(code());
861 void SharedFunctionInfo::SharedFunctionInfoPrint(OStream& os) { // NOLINT
862 HeapObject::PrintHeader(os, "SharedFunctionInfo");
863 os << " - name: " << Brief(name());
864 os << "\n - expected_nof_properties: " << expected_nof_properties();
865 os << "\n - ast_node_count: " << ast_node_count();
866 os << "\n - instance class name = ";
867 instance_class_name()->Print(os);
868 os << "\n - code = " << Brief(code());
869 if (HasSourceCode()) {
870 os << "\n - source code = ";
871 String* source = String::cast(Script::cast(script())->source());
872 int start = start_position();
873 int length = end_position() - start;
874 SmartArrayPointer<char> source_string =
875 source->ToCString(DISALLOW_NULLS,
876 FAST_STRING_TRAVERSAL,
877 start, length, NULL);
878 os << source_string.get();
880 // Script files are often large, hard to read.
881 // os << "\n - script =";
882 // script()->Print(os);
883 os << "\n - function token position = " << function_token_position();
884 os << "\n - start position = " << start_position();
885 os << "\n - end position = " << end_position();
886 os << "\n - is expression = " << is_expression();
887 os << "\n - debug info = " << Brief(debug_info());
888 os << "\n - length = " << length();
889 os << "\n - optimized_code_map = " << Brief(optimized_code_map());
890 os << "\n - feedback_vector = ";
891 feedback_vector()->FixedArrayPrint(os);
896 void JSGlobalProxy::JSGlobalProxyPrint(OStream& os) { // NOLINT
897 os << "global_proxy ";
899 os << "native context : " << Brief(native_context());
904 void JSGlobalObject::JSGlobalObjectPrint(OStream& os) { // NOLINT
907 os << "native context : " << Brief(native_context());
912 void JSBuiltinsObject::JSBuiltinsObjectPrint(OStream& os) { // NOLINT
918 void Cell::CellPrint(OStream& os) { // NOLINT
919 HeapObject::PrintHeader(os, "Cell");
923 void PropertyCell::PropertyCellPrint(OStream& os) { // NOLINT
924 HeapObject::PrintHeader(os, "PropertyCell");
928 void Code::CodePrint(OStream& os) { // NOLINT
929 HeapObject::PrintHeader(os, "Code");
930 #ifdef ENABLE_DISASSEMBLER
931 if (FLAG_use_verbose_printer) {
932 Disassemble(NULL, os);
938 void Foreign::ForeignPrint(OStream& os) { // NOLINT
939 os << "foreign address : " << foreign_address();
943 void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(
944 OStream& os) { // NOLINT
945 HeapObject::PrintHeader(os, "ExecutableAccessorInfo");
946 os << "\n - name: " << Brief(name());
947 os << "\n - flag: " << Brief(flag());
948 os << "\n - getter: " << Brief(getter());
949 os << "\n - setter: " << Brief(setter());
950 os << "\n - data: " << Brief(data());
955 void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(OStream& os) { // NOLINT
956 HeapObject::PrintHeader(os, "DeclaredAccessorInfo");
957 os << "\n - name: " << Brief(name());
958 os << "\n - flag: " << Brief(flag());
959 os << "\n - descriptor: " << Brief(descriptor());
964 void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(
965 OStream& os) { // NOLINT
966 HeapObject::PrintHeader(os, "DeclaredAccessorDescriptor");
967 os << "\n - internal field: " << Brief(serialized_data());
972 void Box::BoxPrint(OStream& os) { // NOLINT
973 HeapObject::PrintHeader(os, "Box");
974 os << "\n - value: " << Brief(value());
979 void AccessorPair::AccessorPairPrint(OStream& os) { // NOLINT
980 HeapObject::PrintHeader(os, "AccessorPair");
981 os << "\n - getter: " << Brief(getter());
982 os << "\n - setter: " << Brief(setter());
987 void AccessCheckInfo::AccessCheckInfoPrint(OStream& os) { // NOLINT
988 HeapObject::PrintHeader(os, "AccessCheckInfo");
989 os << "\n - named_callback: " << Brief(named_callback());
990 os << "\n - indexed_callback: " << Brief(indexed_callback());
991 os << "\n - data: " << Brief(data());
996 void InterceptorInfo::InterceptorInfoPrint(OStream& os) { // NOLINT
997 HeapObject::PrintHeader(os, "InterceptorInfo");
998 os << "\n - getter: " << Brief(getter());
999 os << "\n - setter: " << Brief(setter());
1000 os << "\n - query: " << Brief(query());
1001 os << "\n - deleter: " << Brief(deleter());
1002 os << "\n - enumerator: " << Brief(enumerator());
1003 os << "\n - data: " << Brief(data());
1008 void CallHandlerInfo::CallHandlerInfoPrint(OStream& os) { // NOLINT
1009 HeapObject::PrintHeader(os, "CallHandlerInfo");
1010 os << "\n - callback: " << Brief(callback());
1011 os << "\n - data: " << Brief(data());
1016 void FunctionTemplateInfo::FunctionTemplateInfoPrint(OStream& os) { // NOLINT
1017 HeapObject::PrintHeader(os, "FunctionTemplateInfo");
1018 os << "\n - class name: " << Brief(class_name());
1019 os << "\n - tag: " << Brief(tag());
1020 os << "\n - property_list: " << Brief(property_list());
1021 os << "\n - serial_number: " << Brief(serial_number());
1022 os << "\n - call_code: " << Brief(call_code());
1023 os << "\n - property_accessors: " << Brief(property_accessors());
1024 os << "\n - prototype_template: " << Brief(prototype_template());
1025 os << "\n - parent_template: " << Brief(parent_template());
1026 os << "\n - named_property_handler: " << Brief(named_property_handler());
1027 os << "\n - indexed_property_handler: " << Brief(indexed_property_handler());
1028 os << "\n - instance_template: " << Brief(instance_template());
1029 os << "\n - signature: " << Brief(signature());
1030 os << "\n - access_check_info: " << Brief(access_check_info());
1031 os << "\n - hidden_prototype: " << (hidden_prototype() ? "true" : "false");
1032 os << "\n - undetectable: " << (undetectable() ? "true" : "false");
1033 os << "\n - need_access_check: " << (needs_access_check() ? "true" : "false");
1038 void ObjectTemplateInfo::ObjectTemplateInfoPrint(OStream& os) { // NOLINT
1039 HeapObject::PrintHeader(os, "ObjectTemplateInfo");
1040 os << " - tag: " << Brief(tag());
1041 os << "\n - property_list: " << Brief(property_list());
1042 os << "\n - property_accessors: " << Brief(property_accessors());
1043 os << "\n - constructor: " << Brief(constructor());
1044 os << "\n - internal_field_count: " << Brief(internal_field_count());
1049 void SignatureInfo::SignatureInfoPrint(OStream& os) { // NOLINT
1050 HeapObject::PrintHeader(os, "SignatureInfo");
1051 os << "\n - receiver: " << Brief(receiver());
1052 os << "\n - args: " << Brief(args());
1057 void TypeSwitchInfo::TypeSwitchInfoPrint(OStream& os) { // NOLINT
1058 HeapObject::PrintHeader(os, "TypeSwitchInfo");
1059 os << "\n - types: " << Brief(types());
1064 void AllocationSite::AllocationSitePrint(OStream& os) { // NOLINT
1065 HeapObject::PrintHeader(os, "AllocationSite");
1066 os << " - weak_next: " << Brief(weak_next());
1067 os << "\n - dependent code: " << Brief(dependent_code());
1068 os << "\n - nested site: " << Brief(nested_site());
1069 os << "\n - memento found count: "
1070 << Brief(Smi::FromInt(memento_found_count()));
1071 os << "\n - memento create count: "
1072 << Brief(Smi::FromInt(memento_create_count()));
1073 os << "\n - pretenure decision: "
1074 << Brief(Smi::FromInt(pretenure_decision()));
1075 os << "\n - transition_info: ";
1076 if (transition_info()->IsSmi()) {
1077 ElementsKind kind = GetElementsKind();
1078 os << "Array allocation with ElementsKind " << ElementsKindToString(kind);
1079 } else if (transition_info()->IsJSArray()) {
1080 os << "Array literal " << Brief(transition_info());
1082 os << "unknown transition_info" << Brief(transition_info());
1088 void AllocationMemento::AllocationMementoPrint(OStream& os) { // NOLINT
1089 HeapObject::PrintHeader(os, "AllocationMemento");
1090 os << " - allocation site: ";
1092 GetAllocationSite()->Print(os);
1094 os << "<invalid>\n";
1099 void Script::ScriptPrint(OStream& os) { // NOLINT
1100 HeapObject::PrintHeader(os, "Script");
1101 os << "\n - source: " << Brief(source());
1102 os << "\n - name: " << Brief(name());
1103 os << "\n - line_offset: " << Brief(line_offset());
1104 os << "\n - column_offset: " << Brief(column_offset());
1105 os << "\n - type: " << Brief(type());
1106 os << "\n - id: " << Brief(id());
1107 os << "\n - context data: " << Brief(context_data());
1108 os << "\n - wrapper: " << Brief(wrapper());
1109 os << "\n - compilation type: " << compilation_type();
1110 os << "\n - line ends: " << Brief(line_ends());
1111 os << "\n - eval from shared: " << Brief(eval_from_shared());
1112 os << "\n - eval from instructions offset: "
1113 << Brief(eval_from_instructions_offset());
1118 void DebugInfo::DebugInfoPrint(OStream& os) { // NOLINT
1119 HeapObject::PrintHeader(os, "DebugInfo");
1120 os << "\n - shared: " << Brief(shared());
1121 os << "\n - original_code: " << Brief(original_code());
1122 os << "\n - code: " << Brief(code());
1123 os << "\n - break_points: ";
1124 break_points()->Print(os);
1128 void BreakPointInfo::BreakPointInfoPrint(OStream& os) { // NOLINT
1129 HeapObject::PrintHeader(os, "BreakPointInfo");
1130 os << "\n - code_position: " << code_position()->value();
1131 os << "\n - source_position: " << source_position()->value();
1132 os << "\n - statement_position: " << statement_position()->value();
1133 os << "\n - break_point_objects: " << Brief(break_point_objects());
1138 void DescriptorArray::PrintDescriptors(OStream& os) { // NOLINT
1139 os << "Descriptor array " << number_of_descriptors() << "\n";
1140 for (int i = 0; i < number_of_descriptors(); i++) {
1143 os << " " << i << ": " << desc;
1149 void TransitionArray::PrintTransitions(OStream& os) { // NOLINT
1150 os << "Transition array %d\n", number_of_transitions();
1151 for (int i = 0; i < number_of_transitions(); i++) {
1152 os << " " << i << ": ";
1153 GetKey(i)->NamePrint(os);
1155 switch (GetTargetDetails(i).type()) {
1157 os << " (transition to field)\n";
1161 os << " (transition to constant)\n";
1164 os << " (transition to callback)\n";
1166 // Values below are never in the target descriptor array.
1176 #endif // OBJECT_PRINT
1179 } } // namespace v8::internal