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