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