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(std::ostream& os) { // NOLINT
27 Smi::cast(this)->SmiPrint(os);
29 HeapObject::cast(this)->HeapObjectPrint(os);
34 void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT
35 os << "" << reinterpret_cast<void*>(this) << ": [" << id << "]\n";
39 void HeapObject::HeapObjectPrint(std::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);
63 case FIXED_DOUBLE_ARRAY_TYPE:
64 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
66 case CONSTANT_POOL_ARRAY_TYPE:
67 ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(os);
69 case FIXED_ARRAY_TYPE:
70 FixedArray::cast(this)->FixedArrayPrint(os);
73 ByteArray::cast(this)->ByteArrayPrint(os);
76 FreeSpace::cast(this)->FreeSpacePrint(os);
79 #define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
80 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
81 External##Type##Array::cast(this)->External##Type##ArrayPrint(os); \
84 TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
85 #undef PRINT_EXTERNAL_ARRAY
87 #define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
88 case Fixed##Type##Array::kInstanceType: \
89 Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(os); \
92 TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
93 #undef PRINT_FIXED_TYPED_ARRAY
98 case JS_OBJECT_TYPE: // fall through
99 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
101 case JS_GENERATOR_OBJECT_TYPE:
103 JSObject::cast(this)->JSObjectPrint(os);
106 Oddball::cast(this)->to_string()->Print(os);
109 JSModule::cast(this)->JSModulePrint(os);
111 case JS_FUNCTION_TYPE:
112 JSFunction::cast(this)->JSFunctionPrint(os);
114 case JS_GLOBAL_PROXY_TYPE:
115 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(os);
117 case JS_GLOBAL_OBJECT_TYPE:
118 JSGlobalObject::cast(this)->JSGlobalObjectPrint(os);
120 case JS_BUILTINS_OBJECT_TYPE:
121 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(os);
124 os << "Value wrapper around:";
125 JSValue::cast(this)->value()->Print(os);
128 JSDate::cast(this)->JSDatePrint(os);
131 Code::cast(this)->CodePrint(os);
134 JSProxy::cast(this)->JSProxyPrint(os);
136 case JS_FUNCTION_PROXY_TYPE:
137 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(os);
140 JSSet::cast(this)->JSSetPrint(os);
143 JSMap::cast(this)->JSMapPrint(os);
145 case JS_SET_ITERATOR_TYPE:
146 JSSetIterator::cast(this)->JSSetIteratorPrint(os);
148 case JS_MAP_ITERATOR_TYPE:
149 JSMapIterator::cast(this)->JSMapIteratorPrint(os);
151 case JS_WEAK_MAP_TYPE:
152 JSWeakMap::cast(this)->JSWeakMapPrint(os);
154 case JS_WEAK_SET_TYPE:
155 JSWeakSet::cast(this)->JSWeakSetPrint(os);
158 Foreign::cast(this)->ForeignPrint(os);
160 case SHARED_FUNCTION_INFO_TYPE:
161 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(os);
163 case JS_MESSAGE_OBJECT_TYPE:
164 JSMessageObject::cast(this)->JSMessageObjectPrint(os);
167 Cell::cast(this)->CellPrint(os);
169 case PROPERTY_CELL_TYPE:
170 PropertyCell::cast(this)->PropertyCellPrint(os);
173 WeakCell::cast(this)->WeakCellPrint(os);
175 case JS_ARRAY_BUFFER_TYPE:
176 JSArrayBuffer::cast(this)->JSArrayBufferPrint(os);
178 case JS_TYPED_ARRAY_TYPE:
179 JSTypedArray::cast(this)->JSTypedArrayPrint(os);
181 case JS_DATA_VIEW_TYPE:
182 JSDataView::cast(this)->JSDataViewPrint(os);
184 #define MAKE_STRUCT_CASE(NAME, Name, name) \
186 Name::cast(this)->Name##Print(os); \
188 STRUCT_LIST(MAKE_STRUCT_CASE)
189 #undef MAKE_STRUCT_CASE
192 os << "UNKNOWN TYPE " << map()->instance_type();
199 void ByteArray::ByteArrayPrint(std::ostream& os) { // NOLINT
200 os << "byte array, data starts at " << GetDataStartAddress();
204 void FreeSpace::FreeSpacePrint(std::ostream& os) { // NOLINT
205 os << "free space, size " << Size();
209 #define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
210 void External##Type##Array::External##Type##ArrayPrint(std::ostream& os) { \
211 os << "external " #type " array"; \
214 TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
216 #undef EXTERNAL_ARRAY_PRINTER
219 template <class Traits>
220 void FixedTypedArray<Traits>::FixedTypedArrayPrint(
221 std::ostream& os) { // NOLINT
222 os << "fixed " << Traits::Designator();
226 void JSObject::PrintProperties(std::ostream& os) { // NOLINT
227 if (HasFastProperties()) {
228 DescriptorArray* descs = map()->instance_descriptors();
229 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
231 descs->GetKey(i)->NamePrint(os);
233 switch (descs->GetType(i)) {
235 FieldIndex index = FieldIndex::ForDescriptor(map(), i);
236 os << Brief(RawFastPropertyAt(index)) << " (field at offset "
237 << index.property_index() << ")\n";
241 os << Brief(descs->GetConstant(i)) << " (constant)\n";
244 os << Brief(descs->GetCallbacksObject(i)) << " (callback)\n";
246 case NORMAL: // only in slow mode
252 property_dictionary()->Print(os);
258 static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT
259 T* p = T::cast(object);
260 for (int i = 0; i < p->length(); i++) {
261 os << " " << i << ": " << p->get_scalar(i) << "\n";
266 void JSObject::PrintElements(std::ostream& os) { // NOLINT
267 // Don't call GetElementsKind, its validation code can cause the printer to
268 // fail when debugging.
269 switch (map()->elements_kind()) {
270 case FAST_HOLEY_SMI_ELEMENTS:
271 case FAST_SMI_ELEMENTS:
272 case FAST_HOLEY_ELEMENTS:
273 case FAST_ELEMENTS: {
274 // Print in array notation for non-sparse arrays.
275 FixedArray* p = FixedArray::cast(elements());
276 for (int i = 0; i < p->length(); i++) {
277 os << " " << i << ": " << Brief(p->get(i)) << "\n";
281 case FAST_HOLEY_DOUBLE_ELEMENTS:
282 case FAST_DOUBLE_ELEMENTS: {
283 // Print in array notation for non-sparse arrays.
284 if (elements()->length() > 0) {
285 FixedDoubleArray* p = FixedDoubleArray::cast(elements());
286 for (int i = 0; i < p->length(); i++) {
287 os << " " << i << ": ";
288 if (p->is_the_hole(i)) {
291 os << p->get_scalar(i);
300 #define PRINT_ELEMENTS(Kind, Type) \
302 DoPrintElements<Type>(os, elements()); \
306 PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray)
307 PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array)
308 PRINT_ELEMENTS(EXTERNAL_UINT8_ELEMENTS,
310 PRINT_ELEMENTS(EXTERNAL_INT16_ELEMENTS, ExternalInt16Array)
311 PRINT_ELEMENTS(EXTERNAL_UINT16_ELEMENTS,
313 PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array)
314 PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS,
316 PRINT_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
317 PRINT_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
319 PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
320 PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
321 PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
322 PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
323 PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
324 PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
325 PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
326 PRINT_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
327 PRINT_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
329 #undef PRINT_ELEMENTS
331 case DICTIONARY_ELEMENTS:
332 elements()->Print(os);
334 case SLOPPY_ARGUMENTS_ELEMENTS: {
335 FixedArray* p = FixedArray::cast(elements());
336 os << " parameter map:";
337 for (int i = 2; i < p->length(); i++) {
338 os << " " << (i - 2) << ":" << Brief(p->get(i));
340 os << "\n context: " << Brief(p->get(0))
341 << "\n arguments: " << Brief(p->get(1)) << "\n";
348 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT
349 if (!map()->HasTransitionArray()) return;
350 map()->transitions()->PrintTransitions(os, false);
354 void JSObject::JSObjectPrint(std::ostream& os) { // NOLINT
355 HeapObject::PrintHeader(os, "JSObject");
356 // Don't call GetElementsKind, its validation code can cause the printer to
357 // fail when debugging.
358 PrototypeIterator iter(GetIsolate(), this);
359 os << " - map = " << reinterpret_cast<void*>(map()) << " ["
360 << ElementsKindToString(this->map()->elements_kind())
361 << "]\n - prototype = " << reinterpret_cast<void*>(iter.GetCurrent())
364 PrintTransitions(os);
370 void JSModule::JSModulePrint(std::ostream& os) { // NOLINT
371 HeapObject::PrintHeader(os, "JSModule");
372 os << " - map = " << reinterpret_cast<void*>(map()) << "\n"
374 context()->Print(os);
375 os << " - scope_info = " << Brief(scope_info())
376 << ElementsKindToString(this->map()->elements_kind()) << " {\n";
383 static const char* TypeToString(InstanceType type) {
385 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
386 INSTANCE_TYPE_LIST(TYPE_TO_STRING)
387 #undef TYPE_TO_STRING
390 return "UNKNOWN"; // Keep the compiler happy.
394 void Symbol::SymbolPrint(std::ostream& os) { // NOLINT
395 HeapObject::PrintHeader(os, "Symbol");
396 os << " - hash: " << Hash();
397 os << "\n - name: " << Brief(name());
398 if (name()->IsUndefined()) {
399 os << " (" << PrivateSymbolToName() << ")";
401 os << "\n - private: " << is_private();
402 os << "\n - own: " << is_own();
407 void Map::MapPrint(std::ostream& os) { // NOLINT
408 HeapObject::PrintHeader(os, "Map");
409 os << " - type: " << TypeToString(instance_type()) << "\n";
410 os << " - instance size: " << instance_size() << "\n";
411 os << " - inobject properties: " << inobject_properties() << "\n";
412 os << " - elements kind: " << ElementsKindToString(elements_kind());
413 os << "\n - pre-allocated property fields: "
414 << pre_allocated_property_fields() << "\n";
415 os << " - unused property fields: " << unused_property_fields() << "\n";
416 if (is_dictionary_map()) os << " - dictionary_map\n";
417 if (is_prototype_map()) os << " - prototype_map\n";
418 if (is_hidden_prototype()) os << " - hidden_prototype\n";
419 if (has_named_interceptor()) os << " - named_interceptor\n";
420 if (has_indexed_interceptor()) os << " - indexed_interceptor\n";
421 if (is_undetectable()) os << " - undetectable\n";
422 if (has_instance_call_handler()) os << " - instance_call_handler\n";
423 if (is_access_check_needed()) os << " - access_check_needed\n";
426 } else if (!is_extensible()) {
429 os << " - back pointer: " << Brief(GetBackPointer());
430 os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
431 << "#" << NumberOfOwnDescriptors() << ": "
432 << Brief(instance_descriptors());
433 if (HasTransitionArray()) {
434 os << "\n - transitions: " << Brief(transitions());
436 os << "\n - prototype: " << Brief(prototype());
437 os << "\n - constructor: " << Brief(constructor());
438 os << "\n - code cache: " << Brief(code_cache());
439 os << "\n - dependent code: " << Brief(dependent_code());
444 void CodeCache::CodeCachePrint(std::ostream& os) { // NOLINT
445 HeapObject::PrintHeader(os, "CodeCache");
446 os << "\n - default_cache: " << Brief(default_cache());
447 os << "\n - normal_type_cache: " << Brief(normal_type_cache());
451 void PolymorphicCodeCache::PolymorphicCodeCachePrint(
452 std::ostream& os) { // NOLINT
453 HeapObject::PrintHeader(os, "PolymorphicCodeCache");
454 os << "\n - cache: " << Brief(cache());
458 void TypeFeedbackInfo::TypeFeedbackInfoPrint(std::ostream& os) { // NOLINT
459 HeapObject::PrintHeader(os, "TypeFeedbackInfo");
460 os << " - ic_total_count: " << ic_total_count()
461 << ", ic_with_type_info_count: " << ic_with_type_info_count()
462 << ", ic_generic_count: " << ic_generic_count() << "\n";
466 void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(
467 std::ostream& os) { // NOLINT
468 HeapObject::PrintHeader(os, "AliasedArgumentsEntry");
469 os << "\n - aliased_context_slot: " << aliased_context_slot();
473 void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
474 HeapObject::PrintHeader(os, "FixedArray");
475 os << " - length: " << length();
476 for (int i = 0; i < length(); i++) {
477 os << "\n [" << i << "]: " << Brief(get(i));
483 void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { // NOLINT
484 HeapObject::PrintHeader(os, "FixedDoubleArray");
485 os << " - length: " << length();
486 for (int i = 0; i < length(); i++) {
487 os << "\n [" << i << "]: ";
488 if (is_the_hole(i)) {
498 void ConstantPoolArray::ConstantPoolArrayPrint(std::ostream& os) { // NOLINT
499 HeapObject::PrintHeader(os, "ConstantPoolArray");
500 os << " - length: " << length();
501 for (int i = 0; i <= last_index(INT32, SMALL_SECTION); i++) {
502 if (i < last_index(INT64, SMALL_SECTION)) {
503 os << "\n [" << i << "]: double: " << get_int64_entry_as_double(i);
504 } else if (i <= last_index(CODE_PTR, SMALL_SECTION)) {
505 os << "\n [" << i << "]: code target pointer: "
506 << reinterpret_cast<void*>(get_code_ptr_entry(i));
507 } else if (i <= last_index(HEAP_PTR, SMALL_SECTION)) {
508 os << "\n [" << i << "]: heap pointer: "
509 << reinterpret_cast<void*>(get_heap_ptr_entry(i));
510 } else if (i <= last_index(INT32, SMALL_SECTION)) {
511 os << "\n [" << i << "]: int32: " << get_int32_entry(i);
514 if (is_extended_layout()) {
515 os << "\n Extended section:";
516 for (int i = first_extended_section_index();
517 i <= last_index(INT32, EXTENDED_SECTION); i++) {
518 if (i < last_index(INT64, EXTENDED_SECTION)) {
519 os << "\n [" << i << "]: double: " << get_int64_entry_as_double(i);
520 } else if (i <= last_index(CODE_PTR, EXTENDED_SECTION)) {
521 os << "\n [" << i << "]: code target pointer: "
522 << reinterpret_cast<void*>(get_code_ptr_entry(i));
523 } else if (i <= last_index(HEAP_PTR, EXTENDED_SECTION)) {
524 os << "\n [" << i << "]: heap pointer: "
525 << reinterpret_cast<void*>(get_heap_ptr_entry(i));
526 } else if (i <= last_index(INT32, EXTENDED_SECTION)) {
527 os << "\n [" << i << "]: int32: " << get_int32_entry(i);
535 void JSValue::JSValuePrint(std::ostream& os) { // NOLINT
536 HeapObject::PrintHeader(os, "ValueObject");
541 void JSMessageObject::JSMessageObjectPrint(std::ostream& os) { // NOLINT
542 HeapObject::PrintHeader(os, "JSMessageObject");
543 os << " - type: " << Brief(type());
544 os << "\n - arguments: " << Brief(arguments());
545 os << "\n - start_position: " << start_position();
546 os << "\n - end_position: " << end_position();
547 os << "\n - script: " << Brief(script());
548 os << "\n - stack_frames: " << Brief(stack_frames());
553 void String::StringPrint(std::ostream& os) { // NOLINT
554 if (StringShape(this).IsInternalized()) {
556 } else if (StringShape(this).IsCons()) {
562 const char truncated_epilogue[] = "...<truncated>";
564 if (!FLAG_use_verbose_printer) {
566 len = 100 - sizeof(truncated_epilogue);
569 for (int i = 0; i < len; i++) {
570 os << AsUC16(Get(i));
572 if (len != length()) {
573 os << truncated_epilogue;
576 if (!StringShape(this).IsInternalized()) os << "\"";
580 void Name::NamePrint(std::ostream& os) { // NOLINT
582 String::cast(this)->StringPrint(os);
583 } else if (IsSymbol()) {
584 Symbol::cast(this)->name()->Print(os);
591 // This method is only meant to be called from gdb for debugging purposes.
592 // Since the string can also be in two-byte encoding, non-Latin1 characters
593 // will be ignored in the output.
594 char* String::ToAsciiArray() {
595 // Static so that subsequent calls frees previously allocated space.
596 // This also means that previous results will be overwritten.
597 static char* buffer = NULL;
598 if (buffer != NULL) delete[] buffer;
599 buffer = new char[length()+1];
600 WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
601 buffer[length()] = 0;
606 static const char* const weekdays[] = {
607 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
611 void JSDate::JSDatePrint(std::ostream& os) { // NOLINT
612 HeapObject::PrintHeader(os, "JSDate");
613 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
616 if (!year()->IsSmi()) {
617 os << " - time = NaN\n";
619 // TODO(svenpanne) Add some basic formatting to our streams.
620 Vector<char> buf = Vector<char>::New(100);
622 buf, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
623 weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
624 year()->IsSmi() ? Smi::cast(year())->value() : -1,
625 month()->IsSmi() ? Smi::cast(month())->value() : -1,
626 day()->IsSmi() ? Smi::cast(day())->value() : -1,
627 hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
628 min()->IsSmi() ? Smi::cast(min())->value() : -1,
629 sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
635 void JSProxy::JSProxyPrint(std::ostream& os) { // NOLINT
636 HeapObject::PrintHeader(os, "JSProxy");
637 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
638 os << " - handler = ";
639 handler()->Print(os);
640 os << "\n - hash = ";
646 void JSFunctionProxy::JSFunctionProxyPrint(std::ostream& os) { // NOLINT
647 HeapObject::PrintHeader(os, "JSFunctionProxy");
648 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
649 os << " - handler = ";
650 handler()->Print(os);
651 os << "\n - call_trap = ";
652 call_trap()->Print(os);
653 os << "\n - construct_trap = ";
654 construct_trap()->Print(os);
659 void JSSet::JSSetPrint(std::ostream& os) { // NOLINT
660 HeapObject::PrintHeader(os, "JSSet");
661 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
662 os << " - table = " << Brief(table());
667 void JSMap::JSMapPrint(std::ostream& os) { // NOLINT
668 HeapObject::PrintHeader(os, "JSMap");
669 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
670 os << " - table = " << Brief(table());
675 template <class Derived, class TableType>
677 OrderedHashTableIterator<Derived, TableType>::OrderedHashTableIteratorPrint(
678 std::ostream& os) { // NOLINT
679 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
680 os << " - table = " << Brief(table());
681 os << "\n - index = " << Brief(index());
682 os << "\n - kind = " << Brief(kind());
687 template void OrderedHashTableIterator<
689 OrderedHashSet>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
692 template void OrderedHashTableIterator<
694 OrderedHashMap>::OrderedHashTableIteratorPrint(std::ostream& os); // NOLINT
697 void JSSetIterator::JSSetIteratorPrint(std::ostream& os) { // NOLINT
698 HeapObject::PrintHeader(os, "JSSetIterator");
699 OrderedHashTableIteratorPrint(os);
703 void JSMapIterator::JSMapIteratorPrint(std::ostream& os) { // NOLINT
704 HeapObject::PrintHeader(os, "JSMapIterator");
705 OrderedHashTableIteratorPrint(os);
709 void JSWeakMap::JSWeakMapPrint(std::ostream& os) { // NOLINT
710 HeapObject::PrintHeader(os, "JSWeakMap");
711 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
712 os << " - table = " << Brief(table());
717 void JSWeakSet::JSWeakSetPrint(std::ostream& os) { // NOLINT
718 HeapObject::PrintHeader(os, "JSWeakSet");
719 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
720 os << " - table = " << Brief(table());
725 void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { // NOLINT
726 HeapObject::PrintHeader(os, "JSArrayBuffer");
727 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
728 os << " - backing_store = " << backing_store() << "\n";
729 os << " - byte_length = " << Brief(byte_length());
734 void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { // NOLINT
735 HeapObject::PrintHeader(os, "JSTypedArray");
736 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
737 os << " - buffer = " << Brief(buffer());
738 os << "\n - byte_offset = " << Brief(byte_offset());
739 os << "\n - byte_length = " << Brief(byte_length());
740 os << "\n - length = " << Brief(length());
746 void JSDataView::JSDataViewPrint(std::ostream& os) { // NOLINT
747 HeapObject::PrintHeader(os, "JSDataView");
748 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
749 os << " - buffer =" << Brief(buffer());
750 os << "\n - byte_offset = " << Brief(byte_offset());
751 os << "\n - byte_length = " << Brief(byte_length());
756 void JSFunction::JSFunctionPrint(std::ostream& os) { // NOLINT
757 HeapObject::PrintHeader(os, "Function");
758 os << " - map = " << reinterpret_cast<void*>(map()) << "\n";
759 os << " - initial_map = ";
760 if (has_initial_map()) os << Brief(initial_map());
761 os << "\n - shared_info = " << Brief(shared());
762 os << "\n - name = " << Brief(shared()->name());
763 os << "\n - context = " << Brief(context());
764 if (shared()->bound()) {
765 os << "\n - bindings = " << Brief(function_bindings());
767 os << "\n - literals = " << Brief(literals());
769 os << "\n - code = " << Brief(code());
777 void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT
778 HeapObject::PrintHeader(os, "SharedFunctionInfo");
779 os << " - name: " << Brief(name());
780 os << "\n - expected_nof_properties: " << expected_nof_properties();
781 os << "\n - ast_node_count: " << ast_node_count();
782 os << "\n - instance class name = ";
783 instance_class_name()->Print(os);
784 os << "\n - code = " << Brief(code());
785 if (HasSourceCode()) {
786 os << "\n - source code = ";
787 String* source = String::cast(Script::cast(script())->source());
788 int start = start_position();
789 int length = end_position() - start;
790 SmartArrayPointer<char> source_string =
791 source->ToCString(DISALLOW_NULLS,
792 FAST_STRING_TRAVERSAL,
793 start, length, NULL);
794 os << source_string.get();
796 // Script files are often large, hard to read.
797 // os << "\n - script =";
798 // script()->Print(os);
799 os << "\n - function token position = " << function_token_position();
800 os << "\n - start position = " << start_position();
801 os << "\n - end position = " << end_position();
802 os << "\n - is expression = " << is_expression();
803 os << "\n - debug info = " << Brief(debug_info());
804 os << "\n - length = " << length();
805 os << "\n - optimized_code_map = " << Brief(optimized_code_map());
806 os << "\n - feedback_vector = ";
807 feedback_vector()->FixedArrayPrint(os);
812 void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) { // NOLINT
813 os << "global_proxy ";
815 os << "native context : " << Brief(native_context());
820 void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) { // NOLINT
823 os << "native context : " << Brief(native_context());
828 void JSBuiltinsObject::JSBuiltinsObjectPrint(std::ostream& os) { // NOLINT
834 void Cell::CellPrint(std::ostream& os) { // NOLINT
835 HeapObject::PrintHeader(os, "Cell");
839 void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT
840 HeapObject::PrintHeader(os, "PropertyCell");
844 void WeakCell::WeakCellPrint(std::ostream& os) { // NOLINT
845 HeapObject::PrintHeader(os, "WeakCell");
849 void Code::CodePrint(std::ostream& os) { // NOLINT
850 HeapObject::PrintHeader(os, "Code");
851 #ifdef ENABLE_DISASSEMBLER
852 if (FLAG_use_verbose_printer) {
853 Disassemble(NULL, os);
859 void Foreign::ForeignPrint(std::ostream& os) { // NOLINT
860 os << "foreign address : " << foreign_address();
864 void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(
865 std::ostream& os) { // NOLINT
866 HeapObject::PrintHeader(os, "ExecutableAccessorInfo");
867 os << "\n - name: " << Brief(name());
868 os << "\n - flag: " << Brief(flag());
869 os << "\n - getter: " << Brief(getter());
870 os << "\n - setter: " << Brief(setter());
871 os << "\n - data: " << Brief(data());
876 void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(
877 std::ostream& os) { // NOLINT
878 HeapObject::PrintHeader(os, "DeclaredAccessorInfo");
879 os << "\n - name: " << Brief(name());
880 os << "\n - flag: " << Brief(flag());
881 os << "\n - descriptor: " << Brief(descriptor());
886 void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(
887 std::ostream& os) { // NOLINT
888 HeapObject::PrintHeader(os, "DeclaredAccessorDescriptor");
889 os << "\n - internal field: " << Brief(serialized_data());
894 void Box::BoxPrint(std::ostream& os) { // NOLINT
895 HeapObject::PrintHeader(os, "Box");
896 os << "\n - value: " << Brief(value());
901 void AccessorPair::AccessorPairPrint(std::ostream& os) { // NOLINT
902 HeapObject::PrintHeader(os, "AccessorPair");
903 os << "\n - getter: " << Brief(getter());
904 os << "\n - setter: " << Brief(setter());
909 void AccessCheckInfo::AccessCheckInfoPrint(std::ostream& os) { // NOLINT
910 HeapObject::PrintHeader(os, "AccessCheckInfo");
911 os << "\n - named_callback: " << Brief(named_callback());
912 os << "\n - indexed_callback: " << Brief(indexed_callback());
913 os << "\n - data: " << Brief(data());
918 void InterceptorInfo::InterceptorInfoPrint(std::ostream& os) { // NOLINT
919 HeapObject::PrintHeader(os, "InterceptorInfo");
920 os << "\n - getter: " << Brief(getter());
921 os << "\n - setter: " << Brief(setter());
922 os << "\n - query: " << Brief(query());
923 os << "\n - deleter: " << Brief(deleter());
924 os << "\n - enumerator: " << Brief(enumerator());
925 os << "\n - data: " << Brief(data());
930 void CallHandlerInfo::CallHandlerInfoPrint(std::ostream& os) { // NOLINT
931 HeapObject::PrintHeader(os, "CallHandlerInfo");
932 os << "\n - callback: " << Brief(callback());
933 os << "\n - data: " << Brief(data());
938 void FunctionTemplateInfo::FunctionTemplateInfoPrint(
939 std::ostream& os) { // NOLINT
940 HeapObject::PrintHeader(os, "FunctionTemplateInfo");
941 os << "\n - class name: " << Brief(class_name());
942 os << "\n - tag: " << Brief(tag());
943 os << "\n - property_list: " << Brief(property_list());
944 os << "\n - serial_number: " << Brief(serial_number());
945 os << "\n - call_code: " << Brief(call_code());
946 os << "\n - property_accessors: " << Brief(property_accessors());
947 os << "\n - prototype_template: " << Brief(prototype_template());
948 os << "\n - parent_template: " << Brief(parent_template());
949 os << "\n - named_property_handler: " << Brief(named_property_handler());
950 os << "\n - indexed_property_handler: " << Brief(indexed_property_handler());
951 os << "\n - instance_template: " << Brief(instance_template());
952 os << "\n - signature: " << Brief(signature());
953 os << "\n - access_check_info: " << Brief(access_check_info());
954 os << "\n - hidden_prototype: " << (hidden_prototype() ? "true" : "false");
955 os << "\n - undetectable: " << (undetectable() ? "true" : "false");
956 os << "\n - need_access_check: " << (needs_access_check() ? "true" : "false");
961 void ObjectTemplateInfo::ObjectTemplateInfoPrint(std::ostream& os) { // NOLINT
962 HeapObject::PrintHeader(os, "ObjectTemplateInfo");
963 os << " - tag: " << Brief(tag());
964 os << "\n - property_list: " << Brief(property_list());
965 os << "\n - property_accessors: " << Brief(property_accessors());
966 os << "\n - constructor: " << Brief(constructor());
967 os << "\n - internal_field_count: " << Brief(internal_field_count());
972 void SignatureInfo::SignatureInfoPrint(std::ostream& os) { // NOLINT
973 HeapObject::PrintHeader(os, "SignatureInfo");
974 os << "\n - receiver: " << Brief(receiver());
975 os << "\n - args: " << Brief(args());
980 void TypeSwitchInfo::TypeSwitchInfoPrint(std::ostream& os) { // NOLINT
981 HeapObject::PrintHeader(os, "TypeSwitchInfo");
982 os << "\n - types: " << Brief(types());
987 void AllocationSite::AllocationSitePrint(std::ostream& os) { // NOLINT
988 HeapObject::PrintHeader(os, "AllocationSite");
989 os << " - weak_next: " << Brief(weak_next());
990 os << "\n - dependent code: " << Brief(dependent_code());
991 os << "\n - nested site: " << Brief(nested_site());
992 os << "\n - memento found count: "
993 << Brief(Smi::FromInt(memento_found_count()));
994 os << "\n - memento create count: "
995 << Brief(Smi::FromInt(memento_create_count()));
996 os << "\n - pretenure decision: "
997 << Brief(Smi::FromInt(pretenure_decision()));
998 os << "\n - transition_info: ";
999 if (transition_info()->IsSmi()) {
1000 ElementsKind kind = GetElementsKind();
1001 os << "Array allocation with ElementsKind " << ElementsKindToString(kind);
1002 } else if (transition_info()->IsJSArray()) {
1003 os << "Array literal " << Brief(transition_info());
1005 os << "unknown transition_info" << Brief(transition_info());
1011 void AllocationMemento::AllocationMementoPrint(std::ostream& os) { // NOLINT
1012 HeapObject::PrintHeader(os, "AllocationMemento");
1013 os << " - allocation site: ";
1015 GetAllocationSite()->Print(os);
1017 os << "<invalid>\n";
1022 void Script::ScriptPrint(std::ostream& os) { // NOLINT
1023 HeapObject::PrintHeader(os, "Script");
1024 os << "\n - source: " << Brief(source());
1025 os << "\n - name: " << Brief(name());
1026 os << "\n - line_offset: " << Brief(line_offset());
1027 os << "\n - column_offset: " << Brief(column_offset());
1028 os << "\n - type: " << Brief(type());
1029 os << "\n - id: " << Brief(id());
1030 os << "\n - context data: " << Brief(context_data());
1031 os << "\n - wrapper: " << Brief(wrapper());
1032 os << "\n - compilation type: " << compilation_type();
1033 os << "\n - line ends: " << Brief(line_ends());
1034 os << "\n - eval from shared: " << Brief(eval_from_shared());
1035 os << "\n - eval from instructions offset: "
1036 << Brief(eval_from_instructions_offset());
1041 void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
1042 HeapObject::PrintHeader(os, "DebugInfo");
1043 os << "\n - shared: " << Brief(shared());
1044 os << "\n - original_code: " << Brief(original_code());
1045 os << "\n - code: " << Brief(code());
1046 os << "\n - break_points: ";
1047 break_points()->Print(os);
1051 void BreakPointInfo::BreakPointInfoPrint(std::ostream& os) { // NOLINT
1052 HeapObject::PrintHeader(os, "BreakPointInfo");
1053 os << "\n - code_position: " << code_position()->value();
1054 os << "\n - source_position: " << source_position()->value();
1055 os << "\n - statement_position: " << statement_position()->value();
1056 os << "\n - break_point_objects: " << Brief(break_point_objects());
1061 void DescriptorArray::Print() {
1062 OFStream os(stdout);
1063 this->PrintDescriptors(os);
1068 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT
1069 os << "Descriptor array " << number_of_descriptors() << "\n";
1070 for (int i = 0; i < number_of_descriptors(); i++) {
1073 os << " " << i << ": " << desc << "\n";
1079 void TransitionArray::Print() {
1080 OFStream os(stdout);
1081 this->PrintTransitions(os);
1086 void TransitionArray::PrintTransitions(std::ostream& os,
1087 bool print_header) { // NOLINT
1089 os << "Transition array " << number_of_transitions() << "\n";
1091 for (int i = 0; i < number_of_transitions(); i++) {
1092 Name* key = GetKey(i);
1096 if (key == GetHeap()->frozen_symbol()) {
1097 os << " (transition to frozen)";
1098 } else if (key == GetHeap()->elements_transition_symbol()) {
1099 os << " (transition to "
1100 << ElementsKindToString(GetTarget(i)->elements_kind()) << ")";
1101 } else if (key == GetHeap()->observed_symbol()) {
1102 os << " (transition to Object.observe)";
1104 PropertyDetails details = GetTargetDetails(i);
1105 switch (details.type()) {
1107 os << " (transition to field)";
1111 os << " (transition to constant " << Brief(GetTargetValue(i)) << ")";
1114 os << " (transition to callback " << Brief(GetTargetValue(i)) << ")";
1116 // Values below are never in the target descriptor array.
1121 os << ", attrs: " << details.attributes();
1123 os << " -> " << Brief(GetTarget(i)) << "\n";
1128 #endif // OBJECT_PRINT
1131 } } // namespace v8::internal