Upstream version 8.37.186.0
[platform/framework/web/crosswalk.git] / src / v8 / src / objects-printer.cc
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.
4
5 #include "src/v8.h"
6
7 #include "src/disassembler.h"
8 #include "src/disasm.h"
9 #include "src/jsregexp.h"
10 #include "src/objects-visiting.h"
11
12 namespace v8 {
13 namespace internal {
14
15 #ifdef OBJECT_PRINT
16
17 void Object::Print() {
18   Print(stdout);
19 }
20
21
22 void Object::Print(FILE* out) {
23   if (IsSmi()) {
24     Smi::cast(this)->SmiPrint(out);
25   } else {
26     HeapObject::cast(this)->HeapObjectPrint(out);
27   }
28   Flush(out);
29 }
30
31
32 void Object::PrintLn() {
33   PrintLn(stdout);
34 }
35
36
37 void Object::PrintLn(FILE* out) {
38   Print(out);
39   PrintF(out, "\n");
40 }
41
42
43 void HeapObject::PrintHeader(FILE* out, const char* id) {
44   PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id);
45 }
46
47
48 void HeapObject::HeapObjectPrint(FILE* out) {
49   InstanceType instance_type = map()->instance_type();
50
51   HandleScope scope(GetIsolate());
52   if (instance_type < FIRST_NONSTRING_TYPE) {
53     String::cast(this)->StringPrint(out);
54     return;
55   }
56
57   switch (instance_type) {
58     case SYMBOL_TYPE:
59       Symbol::cast(this)->SymbolPrint(out);
60       break;
61     case MAP_TYPE:
62       Map::cast(this)->MapPrint(out);
63       break;
64     case HEAP_NUMBER_TYPE:
65       HeapNumber::cast(this)->HeapNumberPrint(out);
66       break;
67     case FLOAT32x4_TYPE:
68       Float32x4::cast(this)->Float32x4Print(out);
69       break;
70     case FLOAT64x2_TYPE:
71       Float64x2::cast(this)->Float64x2Print(out);
72       break;
73     case INT32x4_TYPE:
74       Int32x4::cast(this)->Int32x4Print(out);
75       break;
76     case FIXED_DOUBLE_ARRAY_TYPE:
77       FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out);
78       break;
79     case CONSTANT_POOL_ARRAY_TYPE:
80       ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(out);
81       break;
82     case FIXED_ARRAY_TYPE:
83       FixedArray::cast(this)->FixedArrayPrint(out);
84       break;
85     case BYTE_ARRAY_TYPE:
86       ByteArray::cast(this)->ByteArrayPrint(out);
87       break;
88     case FREE_SPACE_TYPE:
89       FreeSpace::cast(this)->FreeSpacePrint(out);
90       break;
91
92 #define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size)                    \
93     case EXTERNAL_##TYPE##_ARRAY_TYPE:                                         \
94       External##Type##Array::cast(this)->External##Type##ArrayPrint(out);      \
95       break;
96
97      TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
98 #undef PRINT_EXTERNAL_ARRAY
99
100 #define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size)                 \
101     case Fixed##Type##Array::kInstanceType:                                    \
102       Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(out);               \
103       break;
104
105     TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
106 #undef PRINT_FIXED_TYPED_ARRAY
107
108     case FILLER_TYPE:
109       PrintF(out, "filler");
110       break;
111     case JS_OBJECT_TYPE:  // fall through
112     case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
113     case JS_ARRAY_TYPE:
114     case JS_GENERATOR_OBJECT_TYPE:
115     case JS_REGEXP_TYPE:
116       JSObject::cast(this)->JSObjectPrint(out);
117       break;
118     case ODDBALL_TYPE:
119       Oddball::cast(this)->to_string()->Print(out);
120       break;
121     case JS_MODULE_TYPE:
122       JSModule::cast(this)->JSModulePrint(out);
123       break;
124     case JS_FUNCTION_TYPE:
125       JSFunction::cast(this)->JSFunctionPrint(out);
126       break;
127     case JS_GLOBAL_PROXY_TYPE:
128       JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out);
129       break;
130     case JS_GLOBAL_OBJECT_TYPE:
131       JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
132       break;
133     case JS_BUILTINS_OBJECT_TYPE:
134       JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
135       break;
136     case JS_VALUE_TYPE:
137       PrintF(out, "Value wrapper around:");
138       JSValue::cast(this)->value()->Print(out);
139       break;
140     case JS_DATE_TYPE:
141       JSDate::cast(this)->JSDatePrint(out);
142       break;
143     case CODE_TYPE:
144       Code::cast(this)->CodePrint(out);
145       break;
146     case JS_PROXY_TYPE:
147       JSProxy::cast(this)->JSProxyPrint(out);
148       break;
149     case JS_FUNCTION_PROXY_TYPE:
150       JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out);
151       break;
152     case JS_SET_TYPE:
153       JSSet::cast(this)->JSSetPrint(out);
154       break;
155     case JS_MAP_TYPE:
156       JSMap::cast(this)->JSMapPrint(out);
157       break;
158     case JS_SET_ITERATOR_TYPE:
159       JSSetIterator::cast(this)->JSSetIteratorPrint(out);
160       break;
161     case JS_MAP_ITERATOR_TYPE:
162       JSMapIterator::cast(this)->JSMapIteratorPrint(out);
163       break;
164     case JS_WEAK_MAP_TYPE:
165       JSWeakMap::cast(this)->JSWeakMapPrint(out);
166       break;
167     case JS_WEAK_SET_TYPE:
168       JSWeakSet::cast(this)->JSWeakSetPrint(out);
169       break;
170     case FOREIGN_TYPE:
171       Foreign::cast(this)->ForeignPrint(out);
172       break;
173     case SHARED_FUNCTION_INFO_TYPE:
174       SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out);
175       break;
176     case JS_MESSAGE_OBJECT_TYPE:
177       JSMessageObject::cast(this)->JSMessageObjectPrint(out);
178       break;
179     case CELL_TYPE:
180       Cell::cast(this)->CellPrint(out);
181       break;
182     case PROPERTY_CELL_TYPE:
183       PropertyCell::cast(this)->PropertyCellPrint(out);
184       break;
185     case JS_ARRAY_BUFFER_TYPE:
186       JSArrayBuffer::cast(this)->JSArrayBufferPrint(out);
187       break;
188     case JS_TYPED_ARRAY_TYPE:
189       JSTypedArray::cast(this)->JSTypedArrayPrint(out);
190       break;
191     case JS_DATA_VIEW_TYPE:
192       JSDataView::cast(this)->JSDataViewPrint(out);
193       break;
194 #define MAKE_STRUCT_CASE(NAME, Name, name) \
195   case NAME##_TYPE:                        \
196     Name::cast(this)->Name##Print(out);    \
197     break;
198   STRUCT_LIST(MAKE_STRUCT_CASE)
199 #undef MAKE_STRUCT_CASE
200
201     default:
202       PrintF(out, "UNKNOWN TYPE %d", map()->instance_type());
203       UNREACHABLE();
204       break;
205   }
206 }
207
208
209 void ByteArray::ByteArrayPrint(FILE* out) {
210   PrintF(out, "byte array, data starts at %p", GetDataStartAddress());
211 }
212
213
214 void FreeSpace::FreeSpacePrint(FILE* out) {
215   PrintF(out, "free space, size %d", Size());
216 }
217
218
219 #define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size)                 \
220   void External##Type##Array::External##Type##ArrayPrint(FILE* out) {         \
221     PrintF(out, "external " #type " array");                                  \
222   }
223
224 TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
225
226 #undef EXTERNAL_ARRAY_PRINTER
227
228
229 template <class Traits>
230 void FixedTypedArray<Traits>::FixedTypedArrayPrint(FILE* out) {
231   PrintF(out, "fixed %s", Traits::Designator());
232 }
233
234
235 void JSObject::PrintProperties(FILE* out) {
236   if (HasFastProperties()) {
237     DescriptorArray* descs = map()->instance_descriptors();
238     for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
239       PrintF(out, "   ");
240       descs->GetKey(i)->NamePrint(out);
241       PrintF(out, ": ");
242       switch (descs->GetType(i)) {
243         case FIELD: {
244           FieldIndex index = FieldIndex::ForDescriptor(map(), i);
245           RawFastPropertyAt(index)->ShortPrint(out);
246           PrintF(out, " (field at offset %d)\n", index.property_index());
247           break;
248         }
249         case CONSTANT:
250           descs->GetConstant(i)->ShortPrint(out);
251           PrintF(out, " (constant)\n");
252           break;
253         case CALLBACKS:
254           descs->GetCallbacksObject(i)->ShortPrint(out);
255           PrintF(out, " (callback)\n");
256           break;
257         case NORMAL:  // only in slow mode
258         case HANDLER:  // only in lookup results, not in descriptors
259         case INTERCEPTOR:  // only in lookup results, not in descriptors
260         // There are no transitions in the descriptor array.
261         case NONEXISTENT:
262           UNREACHABLE();
263           break;
264       }
265     }
266   } else {
267     property_dictionary()->Print(out);
268   }
269 }
270
271
272 template<class T>
273 static void DoPrintElements(FILE *out, Object* object) {
274   T* p = T::cast(object);
275   for (int i = 0; i < p->length(); i++) {
276     PrintF(out, "   %d: %d\n", i, p->get_scalar(i));
277   }
278 }
279
280
281 template<class T>
282 static void DoPrintDoubleElements(FILE* out, Object* object) {
283   T* p = T::cast(object);
284   for (int i = 0; i < p->length(); i++) {
285     PrintF(out, "   %d: %f\n", i, p->get_scalar(i));
286   }
287 }
288
289
290 template<class T>
291 static void DoPrintFloat32x4Elements(FILE* out, Object* object) {
292   T* p = T::cast(object);
293   for (int i = 0; i < p->length(); i++) {
294     float32x4_value_t value =  p->get_scalar(i);
295     PrintF(out, "   %d: (%f, %f, %f, %f)\n",
296            i, value.storage[0], value.storage[1],
297            value.storage[2], value.storage[3]);
298   }
299 }
300
301
302 template<class T>
303 static void DoPrintFloat64x2Elements(FILE* out, Object* object) {
304   T* p = T::cast(object);
305   for (int i = 0; i < p->length(); i++) {
306     float64x2_value_t value =  p->get_scalar(i);
307     PrintF(out, "   %d: (%f, %f)\n", i, value.storage[0], value.storage[1]);
308   }
309 }
310
311
312 template<class T>
313 static void DoPrintInt32x4Elements(FILE* out, Object* object) {
314   T* p = T::cast(object);
315   for (int i = 0; i < p->length(); i++) {
316     int32x4_value_t value =  p->get_scalar(i);
317     PrintF(out, "   %d: (%d, %d, %d, %d)\n",
318            i, value.storage[0], value.storage[1],
319            value.storage[2], value.storage[3]);
320   }
321 }
322
323
324 void JSObject::PrintElements(FILE* out) {
325   // Don't call GetElementsKind, its validation code can cause the printer to
326   // fail when debugging.
327   switch (map()->elements_kind()) {
328     case FAST_HOLEY_SMI_ELEMENTS:
329     case FAST_SMI_ELEMENTS:
330     case FAST_HOLEY_ELEMENTS:
331     case FAST_ELEMENTS: {
332       // Print in array notation for non-sparse arrays.
333       FixedArray* p = FixedArray::cast(elements());
334       for (int i = 0; i < p->length(); i++) {
335         PrintF(out, "   %d: ", i);
336         p->get(i)->ShortPrint(out);
337         PrintF(out, "\n");
338       }
339       break;
340     }
341     case FAST_HOLEY_DOUBLE_ELEMENTS:
342     case FAST_DOUBLE_ELEMENTS: {
343       // Print in array notation for non-sparse arrays.
344       if (elements()->length() > 0) {
345         FixedDoubleArray* p = FixedDoubleArray::cast(elements());
346         for (int i = 0; i < p->length(); i++) {
347           if (p->is_the_hole(i)) {
348             PrintF(out, "   %d: <the hole>", i);
349           } else {
350             PrintF(out, "   %d: %g", i, p->get_scalar(i));
351           }
352           PrintF(out, "\n");
353         }
354       }
355       break;
356     }
357
358
359 #define PRINT_ELEMENTS(Kind, Type)                                          \
360     case Kind: {                                                            \
361       DoPrintElements<Type>(out, elements());                               \
362       break;                                                                \
363     }
364
365 #define PRINT_DOUBLE_ELEMENTS(Kind, Type)                                   \
366     case Kind: {                                                            \
367       DoPrintDoubleElements<Type>(out, elements());                         \
368       break;                                                                \
369     }
370
371 #define PRINT_FLOAT32x4_ELEMENTS(Kind, Type)                                \
372     case Kind: {                                                            \
373       DoPrintFloat32x4Elements<Type>(out, elements());                      \
374       break;                                                                \
375     }
376
377 #define PRINT_FLOAT64x2_ELEMENTS(Kind, Type)                                \
378     case Kind: {                                                            \
379       DoPrintFloat64x2Elements<Type>(out, elements());                      \
380       break;                                                                \
381     }
382
383 #define PRINT_INT32x4_ELEMENTS(Kind, Type)                                  \
384     case Kind: {                                                            \
385       DoPrintInt32x4Elements<Type>(out, elements());                        \
386       break;                                                                \
387     }
388
389     PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray)
390     PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array)
391     PRINT_ELEMENTS(EXTERNAL_UINT8_ELEMENTS,
392         ExternalUint8Array)
393     PRINT_ELEMENTS(EXTERNAL_INT16_ELEMENTS, ExternalInt16Array)
394     PRINT_ELEMENTS(EXTERNAL_UINT16_ELEMENTS,
395         ExternalUint16Array)
396     PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array)
397     PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS,
398         ExternalUint32Array)
399     PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
400     PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
401     PRINT_FLOAT32x4_ELEMENTS(EXTERNAL_FLOAT32x4_ELEMENTS,
402         ExternalFloat32x4Array)
403     PRINT_FLOAT64x2_ELEMENTS(EXTERNAL_FLOAT64x2_ELEMENTS,
404         ExternalFloat64x2Array)
405     PRINT_INT32x4_ELEMENTS(EXTERNAL_INT32x4_ELEMENTS, ExternalInt32x4Array)
406
407
408     PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
409     PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
410     PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
411     PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
412     PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
413     PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
414     PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
415     PRINT_DOUBLE_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
416     PRINT_DOUBLE_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)
417     PRINT_FLOAT32x4_ELEMENTS(FLOAT32x4_ELEMENTS, FixedFloat32x4Array)
418     PRINT_FLOAT64x2_ELEMENTS(FLOAT64x2_ELEMENTS, FixedFloat64x2Array)
419     PRINT_INT32x4_ELEMENTS(INT32x4_ELEMENTS, FixedInt32x4Array)
420
421 #undef PRINT_DOUBLE_ELEMENTS
422 #undef PRINT_ELEMENTS
423
424     case DICTIONARY_ELEMENTS:
425       elements()->Print(out);
426       break;
427     case SLOPPY_ARGUMENTS_ELEMENTS: {
428       FixedArray* p = FixedArray::cast(elements());
429       PrintF(out, "   parameter map:");
430       for (int i = 2; i < p->length(); i++) {
431         PrintF(out, " %d:", i - 2);
432         p->get(i)->ShortPrint(out);
433       }
434       PrintF(out, "\n   context: ");
435       p->get(0)->ShortPrint(out);
436       PrintF(out, "\n   arguments: ");
437       p->get(1)->ShortPrint(out);
438       PrintF(out, "\n");
439       break;
440     }
441   }
442 }
443
444
445 void JSObject::PrintTransitions(FILE* out) {
446   if (!map()->HasTransitionArray()) return;
447   TransitionArray* transitions = map()->transitions();
448   for (int i = 0; i < transitions->number_of_transitions(); i++) {
449     Name* key = transitions->GetKey(i);
450     PrintF(out, "   ");
451     key->NamePrint(out);
452     PrintF(out, ": ");
453     if (key == GetHeap()->frozen_symbol()) {
454       PrintF(out, " (transition to frozen)\n");
455     } else if (key == GetHeap()->elements_transition_symbol()) {
456       PrintF(out, " (transition to ");
457       PrintElementsKind(out, transitions->GetTarget(i)->elements_kind());
458       PrintF(out, ")\n");
459     } else if (key == GetHeap()->observed_symbol()) {
460       PrintF(out, " (transition to Object.observe)\n");
461     } else {
462       switch (transitions->GetTargetDetails(i).type()) {
463         case FIELD: {
464           PrintF(out, " (transition to field)\n");
465           break;
466         }
467         case CONSTANT:
468           PrintF(out, " (transition to constant)\n");
469           break;
470         case CALLBACKS:
471           PrintF(out, " (transition to callback)\n");
472           break;
473         // Values below are never in the target descriptor array.
474         case NORMAL:
475         case HANDLER:
476         case INTERCEPTOR:
477         case NONEXISTENT:
478           UNREACHABLE();
479           break;
480       }
481     }
482   }
483 }
484
485
486 void JSObject::JSObjectPrint(FILE* out) {
487   PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this));
488   PrintF(out, " - map = %p [", reinterpret_cast<void*>(map()));
489   // Don't call GetElementsKind, its validation code can cause the printer to
490   // fail when debugging.
491   PrintElementsKind(out, this->map()->elements_kind());
492   PrintF(out,
493          "]\n - prototype = %p\n",
494          reinterpret_cast<void*>(GetPrototype()));
495   PrintF(out, " {\n");
496   PrintProperties(out);
497   PrintTransitions(out);
498   PrintElements(out);
499   PrintF(out, " }\n");
500 }
501
502
503 void JSModule::JSModulePrint(FILE* out) {
504   HeapObject::PrintHeader(out, "JSModule");
505   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
506   PrintF(out, " - context = ");
507   context()->Print(out);
508   PrintF(out, " - scope_info = ");
509   scope_info()->ShortPrint(out);
510   PrintElementsKind(out, this->map()->elements_kind());
511   PrintF(out, " {\n");
512   PrintProperties(out);
513   PrintElements(out);
514   PrintF(out, " }\n");
515 }
516
517
518 static const char* TypeToString(InstanceType type) {
519   switch (type) {
520 #define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
521   INSTANCE_TYPE_LIST(TYPE_TO_STRING)
522 #undef TYPE_TO_STRING
523   }
524   UNREACHABLE();
525   return "UNKNOWN";  // Keep the compiler happy.
526 }
527
528
529 void Symbol::SymbolPrint(FILE* out) {
530   HeapObject::PrintHeader(out, "Symbol");
531   PrintF(out, " - hash: %d\n", Hash());
532   PrintF(out, " - name: ");
533   name()->ShortPrint();
534   PrintF(out, " - private: %d\n", is_private());
535   PrintF(out, "\n");
536 }
537
538
539 void Map::MapPrint(FILE* out) {
540   HeapObject::PrintHeader(out, "Map");
541   PrintF(out, " - type: %s\n", TypeToString(instance_type()));
542   PrintF(out, " - instance size: %d\n", instance_size());
543   PrintF(out, " - inobject properties: %d\n", inobject_properties());
544   PrintF(out, " - elements kind: ");
545   PrintElementsKind(out, elements_kind());
546   PrintF(out, "\n - pre-allocated property fields: %d\n",
547       pre_allocated_property_fields());
548   PrintF(out, " - unused property fields: %d\n", unused_property_fields());
549   if (is_hidden_prototype()) {
550     PrintF(out, " - hidden_prototype\n");
551   }
552   if (has_named_interceptor()) {
553     PrintF(out, " - named_interceptor\n");
554   }
555   if (has_indexed_interceptor()) {
556     PrintF(out, " - indexed_interceptor\n");
557   }
558   if (is_undetectable()) {
559     PrintF(out, " - undetectable\n");
560   }
561   if (has_instance_call_handler()) {
562     PrintF(out, " - instance_call_handler\n");
563   }
564   if (is_access_check_needed()) {
565     PrintF(out, " - access_check_needed\n");
566   }
567   if (is_frozen()) {
568     PrintF(out, " - frozen\n");
569   } else if (!is_extensible()) {
570     PrintF(out, " - sealed\n");
571   }
572   PrintF(out, " - back pointer: ");
573   GetBackPointer()->ShortPrint(out);
574   PrintF(out, "\n - instance descriptors %s#%i: ",
575          owns_descriptors() ? "(own) " : "",
576          NumberOfOwnDescriptors());
577   instance_descriptors()->ShortPrint(out);
578   if (HasTransitionArray()) {
579     PrintF(out, "\n - transitions: ");
580     transitions()->ShortPrint(out);
581   }
582   PrintF(out, "\n - prototype: ");
583   prototype()->ShortPrint(out);
584   PrintF(out, "\n - constructor: ");
585   constructor()->ShortPrint(out);
586   PrintF(out, "\n - code cache: ");
587   code_cache()->ShortPrint(out);
588   PrintF(out, "\n - dependent code: ");
589   dependent_code()->ShortPrint(out);
590   PrintF(out, "\n");
591 }
592
593
594 void CodeCache::CodeCachePrint(FILE* out) {
595   HeapObject::PrintHeader(out, "CodeCache");
596   PrintF(out, "\n - default_cache: ");
597   default_cache()->ShortPrint(out);
598   PrintF(out, "\n - normal_type_cache: ");
599   normal_type_cache()->ShortPrint(out);
600 }
601
602
603 void PolymorphicCodeCache::PolymorphicCodeCachePrint(FILE* out) {
604   HeapObject::PrintHeader(out, "PolymorphicCodeCache");
605   PrintF(out, "\n - cache: ");
606   cache()->ShortPrint(out);
607 }
608
609
610 void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) {
611   HeapObject::PrintHeader(out, "TypeFeedbackInfo");
612   PrintF(out, " - ic_total_count: %d, ic_with_type_info_count: %d\n",
613          ic_total_count(), ic_with_type_info_count());
614 }
615
616
617 void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) {
618   HeapObject::PrintHeader(out, "AliasedArgumentsEntry");
619   PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot());
620 }
621
622
623 void FixedArray::FixedArrayPrint(FILE* out) {
624   HeapObject::PrintHeader(out, "FixedArray");
625   PrintF(out, " - length: %d", length());
626   for (int i = 0; i < length(); i++) {
627     PrintF(out, "\n  [%d]: ", i);
628     get(i)->ShortPrint(out);
629   }
630   PrintF(out, "\n");
631 }
632
633
634 void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) {
635   HeapObject::PrintHeader(out, "FixedDoubleArray");
636   PrintF(out, " - length: %d", length());
637   for (int i = 0; i < length(); i++) {
638     if (is_the_hole(i)) {
639       PrintF(out, "\n  [%d]: <the hole>", i);
640     } else {
641       PrintF(out, "\n  [%d]: %g", i, get_scalar(i));
642     }
643   }
644   PrintF(out, "\n");
645 }
646
647
648 void ConstantPoolArray::ConstantPoolArrayPrint(FILE* out) {
649   HeapObject::PrintHeader(out, "ConstantPoolArray");
650   PrintF(out, " - length: %d", length());
651   for (int i = 0; i <= last_index(INT32, SMALL_SECTION); i++) {
652     if (i < last_index(INT64, SMALL_SECTION)) {
653       PrintF(out, "\n  [%d]: double: %g", i, get_int64_entry_as_double(i));
654     } else if (i <= last_index(CODE_PTR, SMALL_SECTION)) {
655       PrintF(out, "\n  [%d]: code target pointer: %p", i,
656              reinterpret_cast<void*>(get_code_ptr_entry(i)));
657     } else if (i <= last_index(HEAP_PTR, SMALL_SECTION)) {
658       PrintF(out, "\n  [%d]: heap pointer: %p", i,
659              reinterpret_cast<void*>(get_heap_ptr_entry(i)));
660     } else if (i <= last_index(INT32, SMALL_SECTION)) {
661       PrintF(out, "\n  [%d]: int32: %d", i, get_int32_entry(i));
662     }
663   }
664   if (is_extended_layout()) {
665     PrintF(out, "\n  Extended section:");
666     for (int i = first_extended_section_index();
667          i <= last_index(INT32, EXTENDED_SECTION); i++) {
668     if (i < last_index(INT64, EXTENDED_SECTION)) {
669       PrintF(out, "\n  [%d]: double: %g", i, get_int64_entry_as_double(i));
670     } else if (i <= last_index(CODE_PTR, EXTENDED_SECTION)) {
671       PrintF(out, "\n  [%d]: code target pointer: %p", i,
672              reinterpret_cast<void*>(get_code_ptr_entry(i)));
673     } else if (i <= last_index(HEAP_PTR, EXTENDED_SECTION)) {
674       PrintF(out, "\n  [%d]: heap pointer: %p", i,
675              reinterpret_cast<void*>(get_heap_ptr_entry(i)));
676     } else if (i <= last_index(INT32, EXTENDED_SECTION)) {
677       PrintF(out, "\n  [%d]: int32: %d", i, get_int32_entry(i));
678     }
679   }
680   }
681   PrintF(out, "\n");
682 }
683
684
685 void JSValue::JSValuePrint(FILE* out) {
686   HeapObject::PrintHeader(out, "ValueObject");
687   value()->Print(out);
688 }
689
690
691 void JSMessageObject::JSMessageObjectPrint(FILE* out) {
692   HeapObject::PrintHeader(out, "JSMessageObject");
693   PrintF(out, " - type: ");
694   type()->ShortPrint(out);
695   PrintF(out, "\n - arguments: ");
696   arguments()->ShortPrint(out);
697   PrintF(out, "\n - start_position: %d", start_position());
698   PrintF(out, "\n - end_position: %d", end_position());
699   PrintF(out, "\n - script: ");
700   script()->ShortPrint(out);
701   PrintF(out, "\n - stack_frames: ");
702   stack_frames()->ShortPrint(out);
703   PrintF(out, "\n");
704 }
705
706
707 void String::StringPrint(FILE* out) {
708   if (StringShape(this).IsInternalized()) {
709     PrintF(out, "#");
710   } else if (StringShape(this).IsCons()) {
711     PrintF(out, "c\"");
712   } else {
713     PrintF(out, "\"");
714   }
715
716   const char truncated_epilogue[] = "...<truncated>";
717   int len = length();
718   if (!FLAG_use_verbose_printer) {
719     if (len > 100) {
720       len = 100 - sizeof(truncated_epilogue);
721     }
722   }
723   for (int i = 0; i < len; i++) {
724     PrintF(out, "%c", Get(i));
725   }
726   if (len != length()) {
727     PrintF(out, "%s", truncated_epilogue);
728   }
729
730   if (!StringShape(this).IsInternalized()) PrintF(out, "\"");
731 }
732
733
734 void Name::NamePrint(FILE* out) {
735   if (IsString())
736     String::cast(this)->StringPrint(out);
737   else
738     ShortPrint();
739 }
740
741
742 // This method is only meant to be called from gdb for debugging purposes.
743 // Since the string can also be in two-byte encoding, non-ASCII characters
744 // will be ignored in the output.
745 char* String::ToAsciiArray() {
746   // Static so that subsequent calls frees previously allocated space.
747   // This also means that previous results will be overwritten.
748   static char* buffer = NULL;
749   if (buffer != NULL) free(buffer);
750   buffer = new char[length()+1];
751   WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
752   buffer[length()] = 0;
753   return buffer;
754 }
755
756
757 static const char* const weekdays[] = {
758   "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
759 };
760
761
762 void JSDate::JSDatePrint(FILE* out) {
763   HeapObject::PrintHeader(out, "JSDate");
764   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
765   PrintF(out, " - value = ");
766   value()->Print(out);
767   if (!year()->IsSmi()) {
768     PrintF(out, " - time = NaN\n");
769   } else {
770     PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
771            weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
772            year()->IsSmi() ? Smi::cast(year())->value() : -1,
773            month()->IsSmi() ? Smi::cast(month())->value() : -1,
774            day()->IsSmi() ? Smi::cast(day())->value() : -1,
775            hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
776            min()->IsSmi() ? Smi::cast(min())->value() : -1,
777            sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
778   }
779 }
780
781
782 void JSProxy::JSProxyPrint(FILE* out) {
783   HeapObject::PrintHeader(out, "JSProxy");
784   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
785   PrintF(out, " - handler = ");
786   handler()->Print(out);
787   PrintF(out, "\n - hash = ");
788   hash()->Print(out);
789   PrintF(out, "\n");
790 }
791
792
793 void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) {
794   HeapObject::PrintHeader(out, "JSFunctionProxy");
795   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
796   PrintF(out, " - handler = ");
797   handler()->Print(out);
798   PrintF(out, "\n - call_trap = ");
799   call_trap()->Print(out);
800   PrintF(out, "\n - construct_trap = ");
801   construct_trap()->Print(out);
802   PrintF(out, "\n");
803 }
804
805
806 void JSSet::JSSetPrint(FILE* out) {
807   HeapObject::PrintHeader(out, "JSSet");
808   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
809   PrintF(out, " - table = ");
810   table()->ShortPrint(out);
811   PrintF(out, "\n");
812 }
813
814
815 void JSMap::JSMapPrint(FILE* out) {
816   HeapObject::PrintHeader(out, "JSMap");
817   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
818   PrintF(out, " - table = ");
819   table()->ShortPrint(out);
820   PrintF(out, "\n");
821 }
822
823
824 template<class Derived, class TableType>
825 void OrderedHashTableIterator<Derived, TableType>::
826     OrderedHashTableIteratorPrint(FILE* out) {
827   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
828   PrintF(out, " - table = ");
829   table()->ShortPrint(out);
830   PrintF(out, "\n - index = ");
831   index()->ShortPrint(out);
832   PrintF(out, "\n - kind = ");
833   kind()->ShortPrint(out);
834   PrintF(out, "\n");
835 }
836
837
838 template void
839 OrderedHashTableIterator<JSSetIterator,
840     OrderedHashSet>::OrderedHashTableIteratorPrint(FILE* out);
841
842
843 template void
844 OrderedHashTableIterator<JSMapIterator,
845     OrderedHashMap>::OrderedHashTableIteratorPrint(FILE* out);
846
847
848 void JSSetIterator::JSSetIteratorPrint(FILE* out) {
849   HeapObject::PrintHeader(out, "JSSetIterator");
850   OrderedHashTableIteratorPrint(out);
851 }
852
853
854 void JSMapIterator::JSMapIteratorPrint(FILE* out) {
855   HeapObject::PrintHeader(out, "JSMapIterator");
856   OrderedHashTableIteratorPrint(out);
857 }
858
859
860 void JSWeakMap::JSWeakMapPrint(FILE* out) {
861   HeapObject::PrintHeader(out, "JSWeakMap");
862   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
863   PrintF(out, " - table = ");
864   table()->ShortPrint(out);
865   PrintF(out, "\n");
866 }
867
868
869 void JSWeakSet::JSWeakSetPrint(FILE* out) {
870   HeapObject::PrintHeader(out, "JSWeakSet");
871   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
872   PrintF(out, " - table = ");
873   table()->ShortPrint(out);
874   PrintF(out, "\n");
875 }
876
877
878 void JSArrayBuffer::JSArrayBufferPrint(FILE* out) {
879   HeapObject::PrintHeader(out, "JSArrayBuffer");
880   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
881   PrintF(out, " - backing_store = %p\n", backing_store());
882   PrintF(out, " - byte_length = ");
883   byte_length()->ShortPrint(out);
884   PrintF(out, "\n");
885 }
886
887
888 void JSTypedArray::JSTypedArrayPrint(FILE* out) {
889   HeapObject::PrintHeader(out, "JSTypedArray");
890   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
891   PrintF(out, " - buffer =");
892   buffer()->ShortPrint(out);
893   PrintF(out, "\n - byte_offset = ");
894   byte_offset()->ShortPrint(out);
895   PrintF(out, "\n - byte_length = ");
896   byte_length()->ShortPrint(out);
897   PrintF(out, "\n - length = ");
898   length()->ShortPrint(out);
899   PrintF(out, "\n");
900   PrintElements(out);
901 }
902
903
904 void JSDataView::JSDataViewPrint(FILE* out) {
905   HeapObject::PrintHeader(out, "JSDataView");
906   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
907   PrintF(out, " - buffer =");
908   buffer()->ShortPrint(out);
909   PrintF(out, "\n - byte_offset = ");
910   byte_offset()->ShortPrint(out);
911   PrintF(out, "\n - byte_length = ");
912   byte_length()->ShortPrint(out);
913   PrintF(out, "\n");
914 }
915
916
917 void JSFunction::JSFunctionPrint(FILE* out) {
918   HeapObject::PrintHeader(out, "Function");
919   PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
920   PrintF(out, " - initial_map = ");
921   if (has_initial_map()) {
922     initial_map()->ShortPrint(out);
923   }
924   PrintF(out, "\n - shared_info = ");
925   shared()->ShortPrint(out);
926   PrintF(out, "\n   - name = ");
927   shared()->name()->Print(out);
928   PrintF(out, "\n - context = ");
929   context()->ShortPrint(out);
930   if (shared()->bound()) {
931     PrintF(out, "\n - bindings = ");
932     function_bindings()->ShortPrint(out);
933   } else {
934     PrintF(out, "\n - literals = ");
935     literals()->ShortPrint(out);
936   }
937   PrintF(out, "\n - code = ");
938   code()->ShortPrint(out);
939   PrintF(out, "\n");
940
941   PrintProperties(out);
942   PrintElements(out);
943
944   PrintF(out, "\n");
945 }
946
947
948 void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
949   HeapObject::PrintHeader(out, "SharedFunctionInfo");
950   PrintF(out, " - name: ");
951   name()->ShortPrint(out);
952   PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties());
953   PrintF(out, "\n - ast_node_count: %d", ast_node_count());
954   PrintF(out, "\n - instance class name = ");
955   instance_class_name()->Print(out);
956   PrintF(out, "\n - code = ");
957   code()->ShortPrint(out);
958   if (HasSourceCode()) {
959     PrintF(out, "\n - source code = ");
960     String* source = String::cast(Script::cast(script())->source());
961     int start = start_position();
962     int length = end_position() - start;
963     SmartArrayPointer<char> source_string =
964         source->ToCString(DISALLOW_NULLS,
965                           FAST_STRING_TRAVERSAL,
966                           start, length, NULL);
967     PrintF(out, "%s", source_string.get());
968   }
969   // Script files are often large, hard to read.
970   // PrintF(out, "\n - script =");
971   // script()->Print(out);
972   PrintF(out, "\n - function token position = %d", function_token_position());
973   PrintF(out, "\n - start position = %d", start_position());
974   PrintF(out, "\n - end position = %d", end_position());
975   PrintF(out, "\n - is expression = %d", is_expression());
976   PrintF(out, "\n - debug info = ");
977   debug_info()->ShortPrint(out);
978   PrintF(out, "\n - length = %d", length());
979   PrintF(out, "\n - optimized_code_map = ");
980   optimized_code_map()->ShortPrint(out);
981   PrintF(out, "\n - feedback_vector = ");
982   feedback_vector()->FixedArrayPrint(out);
983   PrintF(out, "\n");
984 }
985
986
987 void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) {
988   PrintF(out, "global_proxy ");
989   JSObjectPrint(out);
990   PrintF(out, "native context : ");
991   native_context()->ShortPrint(out);
992   PrintF(out, "\n");
993 }
994
995
996 void JSGlobalObject::JSGlobalObjectPrint(FILE* out) {
997   PrintF(out, "global ");
998   JSObjectPrint(out);
999   PrintF(out, "native context : ");
1000   native_context()->ShortPrint(out);
1001   PrintF(out, "\n");
1002 }
1003
1004
1005 void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) {
1006   PrintF(out, "builtins ");
1007   JSObjectPrint(out);
1008 }
1009
1010
1011 void Cell::CellPrint(FILE* out) {
1012   HeapObject::PrintHeader(out, "Cell");
1013 }
1014
1015
1016 void PropertyCell::PropertyCellPrint(FILE* out) {
1017   HeapObject::PrintHeader(out, "PropertyCell");
1018 }
1019
1020
1021 void Code::CodePrint(FILE* out) {
1022   HeapObject::PrintHeader(out, "Code");
1023 #ifdef ENABLE_DISASSEMBLER
1024   if (FLAG_use_verbose_printer) {
1025     Disassemble(NULL, out);
1026   }
1027 #endif
1028 }
1029
1030
1031 void Foreign::ForeignPrint(FILE* out) {
1032   PrintF(out, "foreign address : %p", foreign_address());
1033 }
1034
1035
1036 void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(FILE* out) {
1037   HeapObject::PrintHeader(out, "ExecutableAccessorInfo");
1038   PrintF(out, "\n - name: ");
1039   name()->ShortPrint(out);
1040   PrintF(out, "\n - flag: ");
1041   flag()->ShortPrint(out);
1042   PrintF(out, "\n - getter: ");
1043   getter()->ShortPrint(out);
1044   PrintF(out, "\n - setter: ");
1045   setter()->ShortPrint(out);
1046   PrintF(out, "\n - data: ");
1047   data()->ShortPrint(out);
1048 }
1049
1050
1051 void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(FILE* out) {
1052   HeapObject::PrintHeader(out, "DeclaredAccessorInfo");
1053   PrintF(out, "\n - name: ");
1054   name()->ShortPrint(out);
1055   PrintF(out, "\n - flag: ");
1056   flag()->ShortPrint(out);
1057   PrintF(out, "\n - descriptor: ");
1058   descriptor()->ShortPrint(out);
1059 }
1060
1061
1062 void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(FILE* out) {
1063   HeapObject::PrintHeader(out, "DeclaredAccessorDescriptor");
1064   PrintF(out, "\n - internal field: ");
1065   serialized_data()->ShortPrint(out);
1066 }
1067
1068
1069 void Box::BoxPrint(FILE* out) {
1070   HeapObject::PrintHeader(out, "Box");
1071   PrintF(out, "\n - value: ");
1072   value()->ShortPrint(out);
1073 }
1074
1075
1076 void AccessorPair::AccessorPairPrint(FILE* out) {
1077   HeapObject::PrintHeader(out, "AccessorPair");
1078   PrintF(out, "\n - getter: ");
1079   getter()->ShortPrint(out);
1080   PrintF(out, "\n - setter: ");
1081   setter()->ShortPrint(out);
1082   PrintF(out, "\n - flag: ");
1083   access_flags()->ShortPrint(out);
1084 }
1085
1086
1087 void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) {
1088   HeapObject::PrintHeader(out, "AccessCheckInfo");
1089   PrintF(out, "\n - named_callback: ");
1090   named_callback()->ShortPrint(out);
1091   PrintF(out, "\n - indexed_callback: ");
1092   indexed_callback()->ShortPrint(out);
1093   PrintF(out, "\n - data: ");
1094   data()->ShortPrint(out);
1095 }
1096
1097
1098 void InterceptorInfo::InterceptorInfoPrint(FILE* out) {
1099   HeapObject::PrintHeader(out, "InterceptorInfo");
1100   PrintF(out, "\n - getter: ");
1101   getter()->ShortPrint(out);
1102   PrintF(out, "\n - setter: ");
1103   setter()->ShortPrint(out);
1104   PrintF(out, "\n - query: ");
1105   query()->ShortPrint(out);
1106   PrintF(out, "\n - deleter: ");
1107   deleter()->ShortPrint(out);
1108   PrintF(out, "\n - enumerator: ");
1109   enumerator()->ShortPrint(out);
1110   PrintF(out, "\n - data: ");
1111   data()->ShortPrint(out);
1112 }
1113
1114
1115 void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) {
1116   HeapObject::PrintHeader(out, "CallHandlerInfo");
1117   PrintF(out, "\n - callback: ");
1118   callback()->ShortPrint(out);
1119   PrintF(out, "\n - data: ");
1120   data()->ShortPrint(out);
1121   PrintF(out, "\n - call_stub_cache: ");
1122 }
1123
1124
1125 void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) {
1126   HeapObject::PrintHeader(out, "FunctionTemplateInfo");
1127   PrintF(out, "\n - class name: ");
1128   class_name()->ShortPrint(out);
1129   PrintF(out, "\n - tag: ");
1130   tag()->ShortPrint(out);
1131   PrintF(out, "\n - property_list: ");
1132   property_list()->ShortPrint(out);
1133   PrintF(out, "\n - serial_number: ");
1134   serial_number()->ShortPrint(out);
1135   PrintF(out, "\n - call_code: ");
1136   call_code()->ShortPrint(out);
1137   PrintF(out, "\n - property_accessors: ");
1138   property_accessors()->ShortPrint(out);
1139   PrintF(out, "\n - prototype_template: ");
1140   prototype_template()->ShortPrint(out);
1141   PrintF(out, "\n - parent_template: ");
1142   parent_template()->ShortPrint(out);
1143   PrintF(out, "\n - named_property_handler: ");
1144   named_property_handler()->ShortPrint(out);
1145   PrintF(out, "\n - indexed_property_handler: ");
1146   indexed_property_handler()->ShortPrint(out);
1147   PrintF(out, "\n - instance_template: ");
1148   instance_template()->ShortPrint(out);
1149   PrintF(out, "\n - signature: ");
1150   signature()->ShortPrint(out);
1151   PrintF(out, "\n - access_check_info: ");
1152   access_check_info()->ShortPrint(out);
1153   PrintF(out, "\n - hidden_prototype: %s",
1154          hidden_prototype() ? "true" : "false");
1155   PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false");
1156   PrintF(out, "\n - need_access_check: %s",
1157          needs_access_check() ? "true" : "false");
1158 }
1159
1160
1161 void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) {
1162   HeapObject::PrintHeader(out, "ObjectTemplateInfo");
1163   PrintF(out, " - tag: ");
1164   tag()->ShortPrint(out);
1165   PrintF(out, "\n - property_list: ");
1166   property_list()->ShortPrint(out);
1167   PrintF(out, "\n - property_accessors: ");
1168   property_accessors()->ShortPrint(out);
1169   PrintF(out, "\n - constructor: ");
1170   constructor()->ShortPrint(out);
1171   PrintF(out, "\n - internal_field_count: ");
1172   internal_field_count()->ShortPrint(out);
1173   PrintF(out, "\n");
1174 }
1175
1176
1177 void SignatureInfo::SignatureInfoPrint(FILE* out) {
1178   HeapObject::PrintHeader(out, "SignatureInfo");
1179   PrintF(out, "\n - receiver: ");
1180   receiver()->ShortPrint(out);
1181   PrintF(out, "\n - args: ");
1182   args()->ShortPrint(out);
1183 }
1184
1185
1186 void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) {
1187   HeapObject::PrintHeader(out, "TypeSwitchInfo");
1188   PrintF(out, "\n - types: ");
1189   types()->ShortPrint(out);
1190 }
1191
1192
1193 void AllocationSite::AllocationSitePrint(FILE* out) {
1194   HeapObject::PrintHeader(out, "AllocationSite");
1195   PrintF(out, " - weak_next: ");
1196   weak_next()->ShortPrint(out);
1197   PrintF(out, "\n - dependent code: ");
1198   dependent_code()->ShortPrint(out);
1199   PrintF(out, "\n - nested site: ");
1200   nested_site()->ShortPrint(out);
1201   PrintF(out, "\n - memento found count: ");
1202   Smi::FromInt(memento_found_count())->ShortPrint(out);
1203   PrintF(out, "\n - memento create count: ");
1204   Smi::FromInt(memento_create_count())->ShortPrint(out);
1205   PrintF(out, "\n - pretenure decision: ");
1206   Smi::FromInt(pretenure_decision())->ShortPrint(out);
1207   PrintF(out, "\n - transition_info: ");
1208   if (transition_info()->IsSmi()) {
1209     ElementsKind kind = GetElementsKind();
1210     PrintF(out, "Array allocation with ElementsKind ");
1211     PrintElementsKind(out, kind);
1212     PrintF(out, "\n");
1213     return;
1214   } else if (transition_info()->IsJSArray()) {
1215     PrintF(out, "Array literal ");
1216     transition_info()->ShortPrint(out);
1217     PrintF(out, "\n");
1218     return;
1219   }
1220
1221   PrintF(out, "unknown transition_info");
1222   transition_info()->ShortPrint(out);
1223   PrintF(out, "\n");
1224 }
1225
1226
1227 void AllocationMemento::AllocationMementoPrint(FILE* out) {
1228   HeapObject::PrintHeader(out, "AllocationMemento");
1229   PrintF(out, " - allocation site: ");
1230   if (IsValid()) {
1231     GetAllocationSite()->Print();
1232   } else {
1233     PrintF(out, "<invalid>\n");
1234   }
1235 }
1236
1237
1238 void Script::ScriptPrint(FILE* out) {
1239   HeapObject::PrintHeader(out, "Script");
1240   PrintF(out, "\n - source: ");
1241   source()->ShortPrint(out);
1242   PrintF(out, "\n - name: ");
1243   name()->ShortPrint(out);
1244   PrintF(out, "\n - line_offset: ");
1245   line_offset()->ShortPrint(out);
1246   PrintF(out, "\n - column_offset: ");
1247   column_offset()->ShortPrint(out);
1248   PrintF(out, "\n - type: ");
1249   type()->ShortPrint(out);
1250   PrintF(out, "\n - id: ");
1251   id()->ShortPrint(out);
1252   PrintF(out, "\n - context data: ");
1253   context_data()->ShortPrint(out);
1254   PrintF(out, "\n - wrapper: ");
1255   wrapper()->ShortPrint(out);
1256   PrintF(out, "\n - compilation type: %d", compilation_type());
1257   PrintF(out, "\n - line ends: ");
1258   line_ends()->ShortPrint(out);
1259   PrintF(out, "\n - eval from shared: ");
1260   eval_from_shared()->ShortPrint(out);
1261   PrintF(out, "\n - eval from instructions offset: ");
1262   eval_from_instructions_offset()->ShortPrint(out);
1263   PrintF(out, "\n");
1264 }
1265
1266
1267 void DebugInfo::DebugInfoPrint(FILE* out) {
1268   HeapObject::PrintHeader(out, "DebugInfo");
1269   PrintF(out, "\n - shared: ");
1270   shared()->ShortPrint(out);
1271   PrintF(out, "\n - original_code: ");
1272   original_code()->ShortPrint(out);
1273   PrintF(out, "\n - code: ");
1274   code()->ShortPrint(out);
1275   PrintF(out, "\n - break_points: ");
1276   break_points()->Print(out);
1277 }
1278
1279
1280 void BreakPointInfo::BreakPointInfoPrint(FILE* out) {
1281   HeapObject::PrintHeader(out, "BreakPointInfo");
1282   PrintF(out, "\n - code_position: %d", code_position()->value());
1283   PrintF(out, "\n - source_position: %d", source_position()->value());
1284   PrintF(out, "\n - statement_position: %d", statement_position()->value());
1285   PrintF(out, "\n - break_point_objects: ");
1286   break_point_objects()->ShortPrint(out);
1287 }
1288
1289
1290 void DescriptorArray::PrintDescriptors(FILE* out) {
1291   PrintF(out, "Descriptor array  %d\n", number_of_descriptors());
1292   for (int i = 0; i < number_of_descriptors(); i++) {
1293     PrintF(out, " %d: ", i);
1294     Descriptor desc;
1295     Get(i, &desc);
1296     desc.Print(out);
1297   }
1298   PrintF(out, "\n");
1299 }
1300
1301
1302 void TransitionArray::PrintTransitions(FILE* out) {
1303   PrintF(out, "Transition array  %d\n", number_of_transitions());
1304   for (int i = 0; i < number_of_transitions(); i++) {
1305     PrintF(out, " %d: ", i);
1306     GetKey(i)->NamePrint(out);
1307     PrintF(out, ": ");
1308     switch (GetTargetDetails(i).type()) {
1309       case FIELD: {
1310         PrintF(out, " (transition to field)\n");
1311         break;
1312       }
1313       case CONSTANT:
1314         PrintF(out, " (transition to constant)\n");
1315         break;
1316       case CALLBACKS:
1317         PrintF(out, " (transition to callback)\n");
1318         break;
1319       // Values below are never in the target descriptor array.
1320       case NORMAL:
1321       case HANDLER:
1322       case INTERCEPTOR:
1323       case NONEXISTENT:
1324         UNREACHABLE();
1325         break;
1326     }
1327   }
1328   PrintF(out, "\n");
1329 }
1330
1331
1332 #endif  // OBJECT_PRINT
1333
1334
1335 } }  // namespace v8::internal