1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "disassembler.h"
33 #include "objects-visiting.h"
40 void MaybeObject::Print() {
45 void MaybeObject::Print(FILE* out) {
46 Object* this_as_object;
47 if (ToObject(&this_as_object)) {
48 if (this_as_object->IsSmi()) {
49 Smi::cast(this_as_object)->SmiPrint(out);
51 HeapObject::cast(this_as_object)->HeapObjectPrint(out);
54 Failure::cast(this)->FailurePrint(out);
60 void MaybeObject::PrintLn() {
65 void MaybeObject::PrintLn(FILE* out) {
71 void HeapObject::PrintHeader(FILE* out, const char* id) {
72 PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id);
76 void HeapObject::HeapObjectPrint(FILE* out) {
77 InstanceType instance_type = map()->instance_type();
79 HandleScope scope(GetIsolate());
80 if (instance_type < FIRST_NONSTRING_TYPE) {
81 String::cast(this)->StringPrint(out);
85 switch (instance_type) {
87 Symbol::cast(this)->SymbolPrint(out);
90 Map::cast(this)->MapPrint(out);
92 case HEAP_NUMBER_TYPE:
93 HeapNumber::cast(this)->HeapNumberPrint(out);
96 Float32x4::cast(this)->Float32x4Print(out);
99 Int32x4::cast(this)->Int32x4Print(out);
101 case FIXED_DOUBLE_ARRAY_TYPE:
102 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out);
104 case CONSTANT_POOL_ARRAY_TYPE:
105 ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(out);
107 case FIXED_ARRAY_TYPE:
108 FixedArray::cast(this)->FixedArrayPrint(out);
110 case BYTE_ARRAY_TYPE:
111 ByteArray::cast(this)->ByteArrayPrint(out);
113 case FREE_SPACE_TYPE:
114 FreeSpace::cast(this)->FreeSpacePrint(out);
117 #define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \
118 case EXTERNAL_##TYPE##_ARRAY_TYPE: \
119 External##Type##Array::cast(this)->External##Type##ArrayPrint(out); \
122 TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
123 #undef PRINT_EXTERNAL_ARRAY
125 #define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
126 case Fixed##Type##Array::kInstanceType: \
127 Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(out); \
130 TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
131 #undef PRINT_FIXED_TYPED_ARRAY
134 PrintF(out, "filler");
136 case JS_OBJECT_TYPE: // fall through
137 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
139 case JS_GENERATOR_OBJECT_TYPE:
141 JSObject::cast(this)->JSObjectPrint(out);
144 Oddball::cast(this)->to_string()->Print(out);
147 JSModule::cast(this)->JSModulePrint(out);
149 case JS_FUNCTION_TYPE:
150 JSFunction::cast(this)->JSFunctionPrint(out);
152 case JS_GLOBAL_PROXY_TYPE:
153 JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out);
155 case JS_GLOBAL_OBJECT_TYPE:
156 JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
158 case JS_BUILTINS_OBJECT_TYPE:
159 JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
162 PrintF(out, "Value wrapper around:");
163 JSValue::cast(this)->value()->Print(out);
166 JSDate::cast(this)->JSDatePrint(out);
169 Code::cast(this)->CodePrint(out);
172 JSProxy::cast(this)->JSProxyPrint(out);
174 case JS_FUNCTION_PROXY_TYPE:
175 JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out);
178 JSSet::cast(this)->JSSetPrint(out);
181 JSMap::cast(this)->JSMapPrint(out);
183 case JS_WEAK_MAP_TYPE:
184 JSWeakMap::cast(this)->JSWeakMapPrint(out);
186 case JS_WEAK_SET_TYPE:
187 JSWeakSet::cast(this)->JSWeakSetPrint(out);
190 Foreign::cast(this)->ForeignPrint(out);
192 case SHARED_FUNCTION_INFO_TYPE:
193 SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out);
195 case JS_MESSAGE_OBJECT_TYPE:
196 JSMessageObject::cast(this)->JSMessageObjectPrint(out);
199 Cell::cast(this)->CellPrint(out);
201 case PROPERTY_CELL_TYPE:
202 PropertyCell::cast(this)->PropertyCellPrint(out);
204 case JS_ARRAY_BUFFER_TYPE:
205 JSArrayBuffer::cast(this)->JSArrayBufferPrint(out);
207 case JS_TYPED_ARRAY_TYPE:
208 JSTypedArray::cast(this)->JSTypedArrayPrint(out);
210 case JS_DATA_VIEW_TYPE:
211 JSDataView::cast(this)->JSDataViewPrint(out);
213 #define MAKE_STRUCT_CASE(NAME, Name, name) \
215 Name::cast(this)->Name##Print(out); \
217 STRUCT_LIST(MAKE_STRUCT_CASE)
218 #undef MAKE_STRUCT_CASE
221 PrintF(out, "UNKNOWN TYPE %d", map()->instance_type());
228 void ByteArray::ByteArrayPrint(FILE* out) {
229 PrintF(out, "byte array, data starts at %p", GetDataStartAddress());
233 void FreeSpace::FreeSpacePrint(FILE* out) {
234 PrintF(out, "free space, size %d", Size());
238 #define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size) \
239 void External##Type##Array::External##Type##ArrayPrint(FILE* out) { \
240 PrintF(out, "external " #type " array"); \
243 TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
245 #undef EXTERNAL_ARRAY_PRINTER
248 template <class Traits>
249 void FixedTypedArray<Traits>::FixedTypedArrayPrint(FILE* out) {
250 PrintF(out, "fixed %s", Traits::Designator());
254 void JSObject::PrintProperties(FILE* out) {
255 if (HasFastProperties()) {
256 DescriptorArray* descs = map()->instance_descriptors();
257 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
259 descs->GetKey(i)->NamePrint(out);
261 switch (descs->GetType(i)) {
263 int index = descs->GetFieldIndex(i);
264 RawFastPropertyAt(index)->ShortPrint(out);
265 PrintF(out, " (field at offset %d)\n", index);
269 descs->GetConstant(i)->ShortPrint(out);
270 PrintF(out, " (constant)\n");
273 descs->GetCallbacksObject(i)->ShortPrint(out);
274 PrintF(out, " (callback)\n");
276 case NORMAL: // only in slow mode
277 case HANDLER: // only in lookup results, not in descriptors
278 case INTERCEPTOR: // only in lookup results, not in descriptors
279 // There are no transitions in the descriptor array.
287 property_dictionary()->Print(out);
293 static void DoPrintElements(FILE *out, Object* object) {
294 T* p = T::cast(object);
295 for (int i = 0; i < p->length(); i++) {
296 PrintF(out, " %d: %d\n", i, p->get_scalar(i));
302 static void DoPrintDoubleElements(FILE* out, Object* object) {
303 T* p = T::cast(object);
304 for (int i = 0; i < p->length(); i++) {
305 PrintF(out, " %d: %f\n", i, p->get_scalar(i));
311 static void DoPrintFloat32x4Elements(FILE* out, Object* object) {
312 T* p = T::cast(object);
313 for (int i = 0; i < p->length(); i++) {
314 float32x4_value_t value = p->get_scalar(i);
315 PrintF(out, " %d: (%f, %f, %f, %f)\n",
316 i, value.storage[0], value.storage[1],
317 value.storage[2], value.storage[3]);
323 static void DoPrintInt32x4Elements(FILE* out, Object* object) {
324 T* p = T::cast(object);
325 for (int i = 0; i < p->length(); i++) {
326 int32x4_value_t value = p->get_scalar(i);
327 PrintF(out, " %d: (%d, %d, %d, %d)\n",
328 i, value.storage[0], value.storage[1],
329 value.storage[2], value.storage[3]);
334 void JSObject::PrintElements(FILE* out) {
335 // Don't call GetElementsKind, its validation code can cause the printer to
336 // fail when debugging.
337 switch (map()->elements_kind()) {
338 case FAST_HOLEY_SMI_ELEMENTS:
339 case FAST_SMI_ELEMENTS:
340 case FAST_HOLEY_ELEMENTS:
341 case FAST_ELEMENTS: {
342 // Print in array notation for non-sparse arrays.
343 FixedArray* p = FixedArray::cast(elements());
344 for (int i = 0; i < p->length(); i++) {
345 PrintF(out, " %d: ", i);
346 p->get(i)->ShortPrint(out);
351 case FAST_HOLEY_DOUBLE_ELEMENTS:
352 case FAST_DOUBLE_ELEMENTS: {
353 // Print in array notation for non-sparse arrays.
354 if (elements()->length() > 0) {
355 FixedDoubleArray* p = FixedDoubleArray::cast(elements());
356 for (int i = 0; i < p->length(); i++) {
357 if (p->is_the_hole(i)) {
358 PrintF(out, " %d: <the hole>", i);
360 PrintF(out, " %d: %g", i, p->get_scalar(i));
369 #define PRINT_ELEMENTS(Kind, Type) \
371 DoPrintElements<Type>(out, elements()); \
375 #define PRINT_DOUBLE_ELEMENTS(Kind, Type) \
377 DoPrintDoubleElements<Type>(out, elements()); \
381 #define PRINT_FLOAT32x4_ELEMENTS(Kind, Type) \
383 DoPrintFloat32x4Elements<Type>(out, elements()); \
387 #define PRINT_INT32x4_ELEMENTS(Kind, Type) \
389 DoPrintInt32x4Elements<Type>(out, elements()); \
393 PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray)
394 PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array)
395 PRINT_ELEMENTS(EXTERNAL_UINT8_ELEMENTS,
397 PRINT_ELEMENTS(EXTERNAL_INT16_ELEMENTS, ExternalInt16Array)
398 PRINT_ELEMENTS(EXTERNAL_UINT16_ELEMENTS,
400 PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array)
401 PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS,
403 PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
404 PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
405 PRINT_FLOAT32x4_ELEMENTS(EXTERNAL_FLOAT32x4_ELEMENTS,
406 ExternalFloat32x4Array)
407 PRINT_INT32x4_ELEMENTS(EXTERNAL_INT32x4_ELEMENTS, ExternalInt32x4Array)
410 PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
411 PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
412 PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
413 PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
414 PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
415 PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
416 PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
417 PRINT_DOUBLE_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
418 PRINT_DOUBLE_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
419 PRINT_FLOAT32x4_ELEMENTS(FLOAT32x4_ELEMENTS, FixedFloat32x4Array)
420 PRINT_INT32x4_ELEMENTS(INT32x4_ELEMENTS, FixedInt32x4Array)
422 #undef PRINT_DOUBLE_ELEMENTS
423 #undef PRINT_ELEMENTS
425 case DICTIONARY_ELEMENTS:
426 elements()->Print(out);
428 case NON_STRICT_ARGUMENTS_ELEMENTS: {
429 FixedArray* p = FixedArray::cast(elements());
430 PrintF(out, " parameter map:");
431 for (int i = 2; i < p->length(); i++) {
432 PrintF(out, " %d:", i - 2);
433 p->get(i)->ShortPrint(out);
435 PrintF(out, "\n context: ");
436 p->get(0)->ShortPrint(out);
437 PrintF(out, "\n arguments: ");
438 p->get(1)->ShortPrint(out);
446 void JSObject::PrintTransitions(FILE* out) {
447 if (!map()->HasTransitionArray()) return;
448 TransitionArray* transitions = map()->transitions();
449 for (int i = 0; i < transitions->number_of_transitions(); i++) {
451 transitions->GetKey(i)->NamePrint(out);
453 switch (transitions->GetTargetDetails(i).type()) {
455 PrintF(out, " (transition to field)\n");
459 PrintF(out, " (transition to constant)\n");
462 PrintF(out, " (transition to callback)\n");
464 // Values below are never in the target descriptor array.
477 void JSObject::JSObjectPrint(FILE* out) {
478 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this));
479 PrintF(out, " - map = %p [", reinterpret_cast<void*>(map()));
480 // Don't call GetElementsKind, its validation code can cause the printer to
481 // fail when debugging.
482 PrintElementsKind(out, this->map()->elements_kind());
484 "]\n - prototype = %p\n",
485 reinterpret_cast<void*>(GetPrototype()));
487 PrintProperties(out);
488 PrintTransitions(out);
494 void JSModule::JSModulePrint(FILE* out) {
495 HeapObject::PrintHeader(out, "JSModule");
496 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
497 PrintF(out, " - context = ");
498 context()->Print(out);
499 PrintF(out, " - scope_info = ");
500 scope_info()->ShortPrint(out);
501 PrintElementsKind(out, this->map()->elements_kind());
503 PrintProperties(out);
509 static const char* TypeToString(InstanceType type) {
511 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
512 INSTANCE_TYPE_LIST(TYPE_TO_STRING)
513 #undef TYPE_TO_STRING
516 return "UNKNOWN"; // Keep the compiler happy.
520 void Symbol::SymbolPrint(FILE* out) {
521 HeapObject::PrintHeader(out, "Symbol");
522 PrintF(out, " - hash: %d\n", Hash());
523 PrintF(out, " - name: ");
524 name()->ShortPrint();
525 PrintF(out, " - private: %d\n", is_private());
530 void Map::MapPrint(FILE* out) {
531 HeapObject::PrintHeader(out, "Map");
532 PrintF(out, " - type: %s\n", TypeToString(instance_type()));
533 PrintF(out, " - instance size: %d\n", instance_size());
534 PrintF(out, " - inobject properties: %d\n", inobject_properties());
535 PrintF(out, " - elements kind: ");
536 PrintElementsKind(out, elements_kind());
537 PrintF(out, "\n - pre-allocated property fields: %d\n",
538 pre_allocated_property_fields());
539 PrintF(out, " - unused property fields: %d\n", unused_property_fields());
540 if (is_hidden_prototype()) {
541 PrintF(out, " - hidden_prototype\n");
543 if (has_named_interceptor()) {
544 PrintF(out, " - named_interceptor\n");
546 if (has_indexed_interceptor()) {
547 PrintF(out, " - indexed_interceptor\n");
549 if (is_undetectable()) {
550 PrintF(out, " - undetectable\n");
552 if (has_instance_call_handler()) {
553 PrintF(out, " - instance_call_handler\n");
555 if (is_access_check_needed()) {
556 PrintF(out, " - access_check_needed\n");
559 PrintF(out, " - frozen\n");
560 } else if (!is_extensible()) {
561 PrintF(out, " - sealed\n");
563 PrintF(out, " - back pointer: ");
564 GetBackPointer()->ShortPrint(out);
565 PrintF(out, "\n - instance descriptors %s#%i: ",
566 owns_descriptors() ? "(own) " : "",
567 NumberOfOwnDescriptors());
568 instance_descriptors()->ShortPrint(out);
569 if (HasTransitionArray()) {
570 PrintF(out, "\n - transitions: ");
571 transitions()->ShortPrint(out);
573 PrintF(out, "\n - prototype: ");
574 prototype()->ShortPrint(out);
575 PrintF(out, "\n - constructor: ");
576 constructor()->ShortPrint(out);
577 PrintF(out, "\n - code cache: ");
578 code_cache()->ShortPrint(out);
579 PrintF(out, "\n - dependent code: ");
580 dependent_code()->ShortPrint(out);
585 void CodeCache::CodeCachePrint(FILE* out) {
586 HeapObject::PrintHeader(out, "CodeCache");
587 PrintF(out, "\n - default_cache: ");
588 default_cache()->ShortPrint(out);
589 PrintF(out, "\n - normal_type_cache: ");
590 normal_type_cache()->ShortPrint(out);
594 void PolymorphicCodeCache::PolymorphicCodeCachePrint(FILE* out) {
595 HeapObject::PrintHeader(out, "PolymorphicCodeCache");
596 PrintF(out, "\n - cache: ");
597 cache()->ShortPrint(out);
601 void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) {
602 HeapObject::PrintHeader(out, "TypeFeedbackInfo");
603 PrintF(out, " - ic_total_count: %d, ic_with_type_info_count: %d\n",
604 ic_total_count(), ic_with_type_info_count());
605 PrintF(out, " - type_feedback_cells: ");
606 type_feedback_cells()->FixedArrayPrint(out);
610 void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) {
611 HeapObject::PrintHeader(out, "AliasedArgumentsEntry");
612 PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot());
616 void FixedArray::FixedArrayPrint(FILE* out) {
617 HeapObject::PrintHeader(out, "FixedArray");
618 PrintF(out, " - length: %d", length());
619 for (int i = 0; i < length(); i++) {
620 PrintF(out, "\n [%d]: ", i);
621 get(i)->ShortPrint(out);
627 void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) {
628 HeapObject::PrintHeader(out, "FixedDoubleArray");
629 PrintF(out, " - length: %d", length());
630 for (int i = 0; i < length(); i++) {
631 if (is_the_hole(i)) {
632 PrintF(out, "\n [%d]: <the hole>", i);
634 PrintF(out, "\n [%d]: %g", i, get_scalar(i));
641 void ConstantPoolArray::ConstantPoolArrayPrint(FILE* out) {
642 HeapObject::PrintHeader(out, "ConstantPoolArray");
643 PrintF(out, " - length: %d", length());
644 for (int i = 0; i < length(); i++) {
645 if (i < first_ptr_index()) {
646 PrintF(out, "\n [%d]: double: %g", i, get_int64_entry_as_double(i));
647 } else if (i < first_int32_index()) {
648 PrintF(out, "\n [%d]: pointer: %p", i,
649 reinterpret_cast<void*>(get_ptr_entry(i)));
651 PrintF(out, "\n [%d]: int32: %d", i, get_int32_entry(i));
658 void JSValue::JSValuePrint(FILE* out) {
659 HeapObject::PrintHeader(out, "ValueObject");
664 void JSMessageObject::JSMessageObjectPrint(FILE* out) {
665 HeapObject::PrintHeader(out, "JSMessageObject");
666 PrintF(out, " - type: ");
667 type()->ShortPrint(out);
668 PrintF(out, "\n - arguments: ");
669 arguments()->ShortPrint(out);
670 PrintF(out, "\n - start_position: %d", start_position());
671 PrintF(out, "\n - end_position: %d", end_position());
672 PrintF(out, "\n - script: ");
673 script()->ShortPrint(out);
674 PrintF(out, "\n - stack_trace: ");
675 stack_trace()->ShortPrint(out);
676 PrintF(out, "\n - stack_frames: ");
677 stack_frames()->ShortPrint(out);
682 void String::StringPrint(FILE* out) {
683 if (StringShape(this).IsInternalized()) {
685 } else if (StringShape(this).IsCons()) {
691 const char truncated_epilogue[] = "...<truncated>";
693 if (!FLAG_use_verbose_printer) {
695 len = 100 - sizeof(truncated_epilogue);
698 for (int i = 0; i < len; i++) {
699 PrintF(out, "%c", Get(i));
701 if (len != length()) {
702 PrintF(out, "%s", truncated_epilogue);
705 if (!StringShape(this).IsInternalized()) PrintF(out, "\"");
709 void Name::NamePrint(FILE* out) {
711 String::cast(this)->StringPrint(out);
717 // This method is only meant to be called from gdb for debugging purposes.
718 // Since the string can also be in two-byte encoding, non-ASCII characters
719 // will be ignored in the output.
720 char* String::ToAsciiArray() {
721 // Static so that subsequent calls frees previously allocated space.
722 // This also means that previous results will be overwritten.
723 static char* buffer = NULL;
724 if (buffer != NULL) free(buffer);
725 buffer = new char[length()+1];
726 WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
727 buffer[length()] = 0;
732 static const char* const weekdays[] = {
733 "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
737 void JSDate::JSDatePrint(FILE* out) {
738 HeapObject::PrintHeader(out, "JSDate");
739 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
740 PrintF(out, " - value = ");
742 if (!year()->IsSmi()) {
743 PrintF(out, " - time = NaN\n");
745 PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
746 weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
747 year()->IsSmi() ? Smi::cast(year())->value() : -1,
748 month()->IsSmi() ? Smi::cast(month())->value() : -1,
749 day()->IsSmi() ? Smi::cast(day())->value() : -1,
750 hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
751 min()->IsSmi() ? Smi::cast(min())->value() : -1,
752 sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
757 void JSProxy::JSProxyPrint(FILE* out) {
758 HeapObject::PrintHeader(out, "JSProxy");
759 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
760 PrintF(out, " - handler = ");
761 handler()->Print(out);
762 PrintF(out, " - hash = ");
768 void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) {
769 HeapObject::PrintHeader(out, "JSFunctionProxy");
770 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
771 PrintF(out, " - handler = ");
772 handler()->Print(out);
773 PrintF(out, " - call_trap = ");
774 call_trap()->Print(out);
775 PrintF(out, " - construct_trap = ");
776 construct_trap()->Print(out);
781 void JSSet::JSSetPrint(FILE* out) {
782 HeapObject::PrintHeader(out, "JSSet");
783 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
784 PrintF(out, " - table = ");
785 table()->ShortPrint(out);
790 void JSMap::JSMapPrint(FILE* out) {
791 HeapObject::PrintHeader(out, "JSMap");
792 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
793 PrintF(out, " - table = ");
794 table()->ShortPrint(out);
799 void JSWeakMap::JSWeakMapPrint(FILE* out) {
800 HeapObject::PrintHeader(out, "JSWeakMap");
801 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
802 PrintF(out, " - table = ");
803 table()->ShortPrint(out);
808 void JSWeakSet::JSWeakSetPrint(FILE* out) {
809 HeapObject::PrintHeader(out, "JSWeakSet");
810 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
811 PrintF(out, " - table = ");
812 table()->ShortPrint(out);
817 void JSArrayBuffer::JSArrayBufferPrint(FILE* out) {
818 HeapObject::PrintHeader(out, "JSArrayBuffer");
819 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
820 PrintF(out, " - backing_store = %p\n", backing_store());
821 PrintF(out, " - byte_length = ");
822 byte_length()->ShortPrint(out);
827 void JSTypedArray::JSTypedArrayPrint(FILE* out) {
828 HeapObject::PrintHeader(out, "JSTypedArray");
829 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
830 PrintF(out, " - buffer =");
831 buffer()->ShortPrint(out);
832 PrintF(out, "\n - byte_offset = ");
833 byte_offset()->ShortPrint(out);
834 PrintF(out, "\n - byte_length = ");
835 byte_length()->ShortPrint(out);
836 PrintF(out, "\n - length = ");
837 length()->ShortPrint(out);
843 void JSDataView::JSDataViewPrint(FILE* out) {
844 HeapObject::PrintHeader(out, "JSDataView");
845 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
846 PrintF(out, " - buffer =");
847 buffer()->ShortPrint(out);
848 PrintF(out, "\n - byte_offset = ");
849 byte_offset()->ShortPrint(out);
850 PrintF(out, "\n - byte_length = ");
851 byte_length()->ShortPrint(out);
856 void JSFunction::JSFunctionPrint(FILE* out) {
857 HeapObject::PrintHeader(out, "Function");
858 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
859 PrintF(out, " - initial_map = ");
860 if (has_initial_map()) {
861 initial_map()->ShortPrint(out);
863 PrintF(out, "\n - shared_info = ");
864 shared()->ShortPrint(out);
865 PrintF(out, "\n - name = ");
866 shared()->name()->Print(out);
867 PrintF(out, "\n - context = ");
868 context()->ShortPrint(out);
869 if (shared()->bound()) {
870 PrintF(out, "\n - bindings = ");
871 function_bindings()->ShortPrint(out);
873 PrintF(out, "\n - literals = ");
874 literals()->ShortPrint(out);
876 PrintF(out, "\n - code = ");
877 code()->ShortPrint(out);
880 PrintProperties(out);
887 void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
888 HeapObject::PrintHeader(out, "SharedFunctionInfo");
889 PrintF(out, " - name: ");
890 name()->ShortPrint(out);
891 PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties());
892 PrintF(out, "\n - instance class name = ");
893 instance_class_name()->Print(out);
894 PrintF(out, "\n - code = ");
895 code()->ShortPrint(out);
896 if (HasSourceCode()) {
897 PrintF(out, "\n - source code = ");
898 String* source = String::cast(Script::cast(script())->source());
899 int start = start_position();
900 int length = end_position() - start;
901 SmartArrayPointer<char> source_string =
902 source->ToCString(DISALLOW_NULLS,
903 FAST_STRING_TRAVERSAL,
904 start, length, NULL);
905 PrintF(out, "%s", source_string.get());
907 // Script files are often large, hard to read.
908 // PrintF(out, "\n - script =");
909 // script()->Print(out);
910 PrintF(out, "\n - function token position = %d", function_token_position());
911 PrintF(out, "\n - start position = %d", start_position());
912 PrintF(out, "\n - end position = %d", end_position());
913 PrintF(out, "\n - is expression = %d", is_expression());
914 PrintF(out, "\n - debug info = ");
915 debug_info()->ShortPrint(out);
916 PrintF(out, "\n - length = %d", length());
917 PrintF(out, "\n - optimized_code_map = ");
918 optimized_code_map()->ShortPrint(out);
923 void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) {
924 PrintF(out, "global_proxy ");
926 PrintF(out, "native context : ");
927 native_context()->ShortPrint(out);
932 void JSGlobalObject::JSGlobalObjectPrint(FILE* out) {
933 PrintF(out, "global ");
935 PrintF(out, "native context : ");
936 native_context()->ShortPrint(out);
941 void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) {
942 PrintF(out, "builtins ");
947 void Cell::CellPrint(FILE* out) {
948 HeapObject::PrintHeader(out, "Cell");
952 void PropertyCell::PropertyCellPrint(FILE* out) {
953 HeapObject::PrintHeader(out, "PropertyCell");
957 void Code::CodePrint(FILE* out) {
958 HeapObject::PrintHeader(out, "Code");
959 #ifdef ENABLE_DISASSEMBLER
960 if (FLAG_use_verbose_printer) {
961 Disassemble(NULL, out);
967 void Foreign::ForeignPrint(FILE* out) {
968 PrintF(out, "foreign address : %p", foreign_address());
972 void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(FILE* out) {
973 HeapObject::PrintHeader(out, "ExecutableAccessorInfo");
974 PrintF(out, "\n - name: ");
975 name()->ShortPrint(out);
976 PrintF(out, "\n - flag: ");
977 flag()->ShortPrint(out);
978 PrintF(out, "\n - getter: ");
979 getter()->ShortPrint(out);
980 PrintF(out, "\n - setter: ");
981 setter()->ShortPrint(out);
982 PrintF(out, "\n - data: ");
983 data()->ShortPrint(out);
987 void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(FILE* out) {
988 HeapObject::PrintHeader(out, "DeclaredAccessorInfo");
989 PrintF(out, "\n - name: ");
990 name()->ShortPrint(out);
991 PrintF(out, "\n - flag: ");
992 flag()->ShortPrint(out);
993 PrintF(out, "\n - descriptor: ");
994 descriptor()->ShortPrint(out);
998 void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(FILE* out) {
999 HeapObject::PrintHeader(out, "DeclaredAccessorDescriptor");
1000 PrintF(out, "\n - internal field: ");
1001 serialized_data()->ShortPrint(out);
1005 void Box::BoxPrint(FILE* out) {
1006 HeapObject::PrintHeader(out, "Box");
1007 PrintF(out, "\n - value: ");
1008 value()->ShortPrint(out);
1012 void AccessorPair::AccessorPairPrint(FILE* out) {
1013 HeapObject::PrintHeader(out, "AccessorPair");
1014 PrintF(out, "\n - getter: ");
1015 getter()->ShortPrint(out);
1016 PrintF(out, "\n - setter: ");
1017 setter()->ShortPrint(out);
1018 PrintF(out, "\n - flag: ");
1019 access_flags()->ShortPrint(out);
1023 void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) {
1024 HeapObject::PrintHeader(out, "AccessCheckInfo");
1025 PrintF(out, "\n - named_callback: ");
1026 named_callback()->ShortPrint(out);
1027 PrintF(out, "\n - indexed_callback: ");
1028 indexed_callback()->ShortPrint(out);
1029 PrintF(out, "\n - data: ");
1030 data()->ShortPrint(out);
1034 void InterceptorInfo::InterceptorInfoPrint(FILE* out) {
1035 HeapObject::PrintHeader(out, "InterceptorInfo");
1036 PrintF(out, "\n - getter: ");
1037 getter()->ShortPrint(out);
1038 PrintF(out, "\n - setter: ");
1039 setter()->ShortPrint(out);
1040 PrintF(out, "\n - query: ");
1041 query()->ShortPrint(out);
1042 PrintF(out, "\n - deleter: ");
1043 deleter()->ShortPrint(out);
1044 PrintF(out, "\n - enumerator: ");
1045 enumerator()->ShortPrint(out);
1046 PrintF(out, "\n - data: ");
1047 data()->ShortPrint(out);
1051 void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) {
1052 HeapObject::PrintHeader(out, "CallHandlerInfo");
1053 PrintF(out, "\n - callback: ");
1054 callback()->ShortPrint(out);
1055 PrintF(out, "\n - data: ");
1056 data()->ShortPrint(out);
1057 PrintF(out, "\n - call_stub_cache: ");
1061 void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) {
1062 HeapObject::PrintHeader(out, "FunctionTemplateInfo");
1063 PrintF(out, "\n - class name: ");
1064 class_name()->ShortPrint(out);
1065 PrintF(out, "\n - tag: ");
1066 tag()->ShortPrint(out);
1067 PrintF(out, "\n - property_list: ");
1068 property_list()->ShortPrint(out);
1069 PrintF(out, "\n - serial_number: ");
1070 serial_number()->ShortPrint(out);
1071 PrintF(out, "\n - call_code: ");
1072 call_code()->ShortPrint(out);
1073 PrintF(out, "\n - property_accessors: ");
1074 property_accessors()->ShortPrint(out);
1075 PrintF(out, "\n - prototype_template: ");
1076 prototype_template()->ShortPrint(out);
1077 PrintF(out, "\n - parent_template: ");
1078 parent_template()->ShortPrint(out);
1079 PrintF(out, "\n - named_property_handler: ");
1080 named_property_handler()->ShortPrint(out);
1081 PrintF(out, "\n - indexed_property_handler: ");
1082 indexed_property_handler()->ShortPrint(out);
1083 PrintF(out, "\n - instance_template: ");
1084 instance_template()->ShortPrint(out);
1085 PrintF(out, "\n - signature: ");
1086 signature()->ShortPrint(out);
1087 PrintF(out, "\n - access_check_info: ");
1088 access_check_info()->ShortPrint(out);
1089 PrintF(out, "\n - hidden_prototype: %s",
1090 hidden_prototype() ? "true" : "false");
1091 PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false");
1092 PrintF(out, "\n - need_access_check: %s",
1093 needs_access_check() ? "true" : "false");
1097 void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) {
1098 HeapObject::PrintHeader(out, "ObjectTemplateInfo");
1099 PrintF(out, " - tag: ");
1100 tag()->ShortPrint(out);
1101 PrintF(out, "\n - property_list: ");
1102 property_list()->ShortPrint(out);
1103 PrintF(out, "\n - property_accessors: ");
1104 property_accessors()->ShortPrint(out);
1105 PrintF(out, "\n - constructor: ");
1106 constructor()->ShortPrint(out);
1107 PrintF(out, "\n - internal_field_count: ");
1108 internal_field_count()->ShortPrint(out);
1113 void SignatureInfo::SignatureInfoPrint(FILE* out) {
1114 HeapObject::PrintHeader(out, "SignatureInfo");
1115 PrintF(out, "\n - receiver: ");
1116 receiver()->ShortPrint(out);
1117 PrintF(out, "\n - args: ");
1118 args()->ShortPrint(out);
1122 void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) {
1123 HeapObject::PrintHeader(out, "TypeSwitchInfo");
1124 PrintF(out, "\n - types: ");
1125 types()->ShortPrint(out);
1129 void AllocationSite::AllocationSitePrint(FILE* out) {
1130 HeapObject::PrintHeader(out, "AllocationSite");
1131 PrintF(out, " - weak_next: ");
1132 weak_next()->ShortPrint(out);
1133 PrintF(out, "\n - dependent code: ");
1134 dependent_code()->ShortPrint(out);
1135 PrintF(out, "\n - nested site: ");
1136 nested_site()->ShortPrint(out);
1137 PrintF(out, "\n - memento found count: ");
1138 Smi::FromInt(memento_found_count())->ShortPrint(out);
1139 PrintF(out, "\n - memento create count: ");
1140 Smi::FromInt(memento_create_count())->ShortPrint(out);
1141 PrintF(out, "\n - pretenure decision: ");
1142 Smi::FromInt(pretenure_decision())->ShortPrint(out);
1143 PrintF(out, "\n - transition_info: ");
1144 if (transition_info()->IsSmi()) {
1145 ElementsKind kind = GetElementsKind();
1146 PrintF(out, "Array allocation with ElementsKind ");
1147 PrintElementsKind(out, kind);
1150 } else if (transition_info()->IsJSArray()) {
1151 PrintF(out, "Array literal ");
1152 transition_info()->ShortPrint(out);
1157 PrintF(out, "unknown transition_info");
1158 transition_info()->ShortPrint(out);
1163 void AllocationMemento::AllocationMementoPrint(FILE* out) {
1164 HeapObject::PrintHeader(out, "AllocationMemento");
1165 PrintF(out, " - allocation site: ");
1167 GetAllocationSite()->Print();
1169 PrintF(out, "<invalid>\n");
1174 void Script::ScriptPrint(FILE* out) {
1175 HeapObject::PrintHeader(out, "Script");
1176 PrintF(out, "\n - source: ");
1177 source()->ShortPrint(out);
1178 PrintF(out, "\n - name: ");
1179 name()->ShortPrint(out);
1180 PrintF(out, "\n - line_offset: ");
1181 line_offset()->ShortPrint(out);
1182 PrintF(out, "\n - column_offset: ");
1183 column_offset()->ShortPrint(out);
1184 PrintF(out, "\n - type: ");
1185 type()->ShortPrint(out);
1186 PrintF(out, "\n - id: ");
1187 id()->ShortPrint(out);
1188 PrintF(out, "\n - data: ");
1189 data()->ShortPrint(out);
1190 PrintF(out, "\n - context data: ");
1191 context_data()->ShortPrint(out);
1192 PrintF(out, "\n - wrapper: ");
1193 wrapper()->ShortPrint(out);
1194 PrintF(out, "\n - compilation type: %d", compilation_type());
1195 PrintF(out, "\n - line ends: ");
1196 line_ends()->ShortPrint(out);
1197 PrintF(out, "\n - eval from shared: ");
1198 eval_from_shared()->ShortPrint(out);
1199 PrintF(out, "\n - eval from instructions offset: ");
1200 eval_from_instructions_offset()->ShortPrint(out);
1205 #ifdef ENABLE_DEBUGGER_SUPPORT
1206 void DebugInfo::DebugInfoPrint(FILE* out) {
1207 HeapObject::PrintHeader(out, "DebugInfo");
1208 PrintF(out, "\n - shared: ");
1209 shared()->ShortPrint(out);
1210 PrintF(out, "\n - original_code: ");
1211 original_code()->ShortPrint(out);
1212 PrintF(out, "\n - code: ");
1213 code()->ShortPrint(out);
1214 PrintF(out, "\n - break_points: ");
1215 break_points()->Print(out);
1219 void BreakPointInfo::BreakPointInfoPrint(FILE* out) {
1220 HeapObject::PrintHeader(out, "BreakPointInfo");
1221 PrintF(out, "\n - code_position: %d", code_position()->value());
1222 PrintF(out, "\n - source_position: %d", source_position()->value());
1223 PrintF(out, "\n - statement_position: %d", statement_position()->value());
1224 PrintF(out, "\n - break_point_objects: ");
1225 break_point_objects()->ShortPrint(out);
1227 #endif // ENABLE_DEBUGGER_SUPPORT
1230 void DescriptorArray::PrintDescriptors(FILE* out) {
1231 PrintF(out, "Descriptor array %d\n", number_of_descriptors());
1232 for (int i = 0; i < number_of_descriptors(); i++) {
1233 PrintF(out, " %d: ", i);
1242 void TransitionArray::PrintTransitions(FILE* out) {
1243 PrintF(out, "Transition array %d\n", number_of_transitions());
1244 for (int i = 0; i < number_of_transitions(); i++) {
1245 PrintF(out, " %d: ", i);
1246 GetKey(i)->NamePrint(out);
1248 switch (GetTargetDetails(i).type()) {
1250 PrintF(out, " (transition to field)\n");
1254 PrintF(out, " (transition to constant)\n");
1257 PrintF(out, " (transition to callback)\n");
1259 // Values below are never in the target descriptor array.
1273 #endif // OBJECT_PRINT
1276 } } // namespace v8::internal