objects-printer.cc 36.5 KB
Newer Older
1
// Copyright 2012 the V8 project authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
//     * Neither the name of Google Inc. nor the names of its
//       contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "v8.h"

#include "disassembler.h"
#include "disasm.h"
#include "jsregexp.h"
#include "objects-visiting.h"

namespace v8 {
namespace internal {

#ifdef OBJECT_PRINT

40 41 42 43 44
void MaybeObject::Print() {
  Print(stdout);
}


45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
void MaybeObject::Print(FILE* out) {
  Object* this_as_object;
  if (ToObject(&this_as_object)) {
    if (this_as_object->IsSmi()) {
      Smi::cast(this_as_object)->SmiPrint(out);
    } else {
      HeapObject::cast(this_as_object)->HeapObjectPrint(out);
    }
  } else {
    Failure::cast(this)->FailurePrint(out);
  }
  Flush(out);
}


60 61 62 63 64
void MaybeObject::PrintLn() {
  PrintLn(stdout);
}


65 66 67 68 69 70 71 72 73 74 75 76 77 78
void MaybeObject::PrintLn(FILE* out) {
  Print(out);
  PrintF(out, "\n");
}


void HeapObject::PrintHeader(FILE* out, const char* id) {
  PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id);
}


void HeapObject::HeapObjectPrint(FILE* out) {
  InstanceType instance_type = map()->instance_type();

79
  HandleScope scope(GetIsolate());
80 81 82 83 84 85
  if (instance_type < FIRST_NONSTRING_TYPE) {
    String::cast(this)->StringPrint(out);
    return;
  }

  switch (instance_type) {
86 87 88
    case SYMBOL_TYPE:
      Symbol::cast(this)->SymbolPrint(out);
      break;
89 90 91 92 93 94
    case MAP_TYPE:
      Map::cast(this)->MapPrint(out);
      break;
    case HEAP_NUMBER_TYPE:
      HeapNumber::cast(this)->HeapNumberPrint(out);
      break;
95 96 97
    case FIXED_DOUBLE_ARRAY_TYPE:
      FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out);
      break;
98 99 100
    case CONSTANT_POOL_ARRAY_TYPE:
      ConstantPoolArray::cast(this)->ConstantPoolArrayPrint(out);
      break;
101 102 103 104 105 106
    case FIXED_ARRAY_TYPE:
      FixedArray::cast(this)->FixedArrayPrint(out);
      break;
    case BYTE_ARRAY_TYPE:
      ByteArray::cast(this)->ByteArrayPrint(out);
      break;
107 108 109
    case FREE_SPACE_TYPE:
      FreeSpace::cast(this)->FreeSpacePrint(out);
      break;
110 111 112 113

#define PRINT_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size)                    \
    case EXTERNAL_##TYPE##_ARRAY_TYPE:                                         \
      External##Type##Array::cast(this)->External##Type##ArrayPrint(out);      \
114
      break;
115 116 117 118 119

     TYPED_ARRAYS(PRINT_EXTERNAL_ARRAY)
#undef PRINT_EXTERNAL_ARRAY

#define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size)                 \
120 121 122 123
    case Fixed##Type##Array::kInstanceType:                                    \
      Fixed##Type##Array::cast(this)->FixedTypedArrayPrint(out);               \
      break;

124 125
    TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
#undef PRINT_FIXED_TYPED_ARRAY
126

127 128 129 130 131 132
    case FILLER_TYPE:
      PrintF(out, "filler");
      break;
    case JS_OBJECT_TYPE:  // fall through
    case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
    case JS_ARRAY_TYPE:
133
    case JS_GENERATOR_OBJECT_TYPE:
134 135 136 137 138 139
    case JS_REGEXP_TYPE:
      JSObject::cast(this)->JSObjectPrint(out);
      break;
    case ODDBALL_TYPE:
      Oddball::cast(this)->to_string()->Print(out);
      break;
140 141 142
    case JS_MODULE_TYPE:
      JSModule::cast(this)->JSModulePrint(out);
      break;
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
    case JS_FUNCTION_TYPE:
      JSFunction::cast(this)->JSFunctionPrint(out);
      break;
    case JS_GLOBAL_PROXY_TYPE:
      JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out);
      break;
    case JS_GLOBAL_OBJECT_TYPE:
      JSGlobalObject::cast(this)->JSGlobalObjectPrint(out);
      break;
    case JS_BUILTINS_OBJECT_TYPE:
      JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out);
      break;
    case JS_VALUE_TYPE:
      PrintF(out, "Value wrapper around:");
      JSValue::cast(this)->value()->Print(out);
      break;
159
    case JS_DATE_TYPE:
160
      JSDate::cast(this)->JSDatePrint(out);
161
      break;
162 163 164
    case CODE_TYPE:
      Code::cast(this)->CodePrint(out);
      break;
165 166 167
    case JS_PROXY_TYPE:
      JSProxy::cast(this)->JSProxyPrint(out);
      break;
168 169 170
    case JS_FUNCTION_PROXY_TYPE:
      JSFunctionProxy::cast(this)->JSFunctionProxyPrint(out);
      break;
171 172 173 174 175 176
    case JS_SET_TYPE:
      JSSet::cast(this)->JSSetPrint(out);
      break;
    case JS_MAP_TYPE:
      JSMap::cast(this)->JSMapPrint(out);
      break;
177 178 179
    case JS_WEAK_MAP_TYPE:
      JSWeakMap::cast(this)->JSWeakMapPrint(out);
      break;
180 181 182
    case JS_WEAK_SET_TYPE:
      JSWeakSet::cast(this)->JSWeakSetPrint(out);
      break;
183 184
    case FOREIGN_TYPE:
      Foreign::cast(this)->ForeignPrint(out);
185 186 187 188
      break;
    case SHARED_FUNCTION_INFO_TYPE:
      SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out);
      break;
189 190 191
    case JS_MESSAGE_OBJECT_TYPE:
      JSMessageObject::cast(this)->JSMessageObjectPrint(out);
      break;
192 193 194 195
    case CELL_TYPE:
      Cell::cast(this)->CellPrint(out);
      break;
    case PROPERTY_CELL_TYPE:
196
      PropertyCell::cast(this)->PropertyCellPrint(out);
197
      break;
198 199
    case JS_ARRAY_BUFFER_TYPE:
      JSArrayBuffer::cast(this)->JSArrayBufferPrint(out);
200
      break;
201 202
    case JS_TYPED_ARRAY_TYPE:
      JSTypedArray::cast(this)->JSTypedArrayPrint(out);
203
      break;
204 205 206
    case JS_DATA_VIEW_TYPE:
      JSDataView::cast(this)->JSDataViewPrint(out);
      break;
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
#define MAKE_STRUCT_CASE(NAME, Name, name) \
  case NAME##_TYPE:                        \
    Name::cast(this)->Name##Print(out);    \
    break;
  STRUCT_LIST(MAKE_STRUCT_CASE)
#undef MAKE_STRUCT_CASE

    default:
      PrintF(out, "UNKNOWN TYPE %d", map()->instance_type());
      UNREACHABLE();
      break;
  }
}


void ByteArray::ByteArrayPrint(FILE* out) {
  PrintF(out, "byte array, data starts at %p", GetDataStartAddress());
}


227 228 229 230 231
void FreeSpace::FreeSpacePrint(FILE* out) {
  PrintF(out, "free space, size %d", Size());
}


232 233 234 235
#define EXTERNAL_ARRAY_PRINTER(Type, type, TYPE, ctype, size)                 \
  void External##Type##Array::External##Type##ArrayPrint(FILE* out) {         \
    PrintF(out, "external " #type " array");                                  \
  }
236

237
TYPED_ARRAYS(EXTERNAL_ARRAY_PRINTER)
238

239
#undef EXTERNAL_ARRAY_PRINTER
240

241

242 243 244 245 246
template <class Traits>
void FixedTypedArray<Traits>::FixedTypedArrayPrint(FILE* out) {
  PrintF(out, "fixed %s", Traits::Designator());
}

247

248 249 250
void JSObject::PrintProperties(FILE* out) {
  if (HasFastProperties()) {
    DescriptorArray* descs = map()->instance_descriptors();
251
    for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) {
252
      PrintF(out, "   ");
253
      descs->GetKey(i)->NamePrint(out);
254 255 256 257
      PrintF(out, ": ");
      switch (descs->GetType(i)) {
        case FIELD: {
          int index = descs->GetFieldIndex(i);
258
          RawFastPropertyAt(index)->ShortPrint(out);
259 260 261
          PrintF(out, " (field at offset %d)\n", index);
          break;
        }
262 263 264
        case CONSTANT:
          descs->GetConstant(i)->ShortPrint(out);
          PrintF(out, " (constant)\n");
265 266 267 268 269
          break;
        case CALLBACKS:
          descs->GetCallbacksObject(i)->ShortPrint(out);
          PrintF(out, " (callback)\n");
          break;
270 271 272
        case NORMAL:  // only in slow mode
        case HANDLER:  // only in lookup results, not in descriptors
        case INTERCEPTOR:  // only in lookup results, not in descriptors
273 274
        // There are no transitions in the descriptor array.
        case TRANSITION:
275
        case NONEXISTENT:
276 277 278 279 280 281 282 283 284 285
          UNREACHABLE();
          break;
      }
    }
  } else {
    property_dictionary()->Print(out);
  }
}


286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
template<class T>
static void DoPrintElements(FILE *out, Object* object) {
  T* p = T::cast(object);
  for (int i = 0; i < p->length(); i++) {
    PrintF(out, "   %d: %d\n", i, p->get_scalar(i));
  }
}


template<class T>
static void DoPrintDoubleElements(FILE* out, Object* object) {
  T* p = T::cast(object);
  for (int i = 0; i < p->length(); i++) {
    PrintF(out, "   %d: %f\n", i, p->get_scalar(i));
  }
}


304
void JSObject::PrintElements(FILE* out) {
305 306 307
  // Don't call GetElementsKind, its validation code can cause the printer to
  // fail when debugging.
  switch (map()->elements_kind()) {
308 309 310
    case FAST_HOLEY_SMI_ELEMENTS:
    case FAST_SMI_ELEMENTS:
    case FAST_HOLEY_ELEMENTS:
311 312 313 314 315 316 317 318 319 320
    case FAST_ELEMENTS: {
      // Print in array notation for non-sparse arrays.
      FixedArray* p = FixedArray::cast(elements());
      for (int i = 0; i < p->length(); i++) {
        PrintF(out, "   %d: ", i);
        p->get(i)->ShortPrint(out);
        PrintF(out, "\n");
      }
      break;
    }
321
    case FAST_HOLEY_DOUBLE_ELEMENTS:
322 323
    case FAST_DOUBLE_ELEMENTS: {
      // Print in array notation for non-sparse arrays.
324 325 326 327 328 329 330 331 332
      if (elements()->length() > 0) {
        FixedDoubleArray* p = FixedDoubleArray::cast(elements());
        for (int i = 0; i < p->length(); i++) {
          if (p->is_the_hole(i)) {
            PrintF(out, "   %d: <the hole>", i);
          } else {
            PrintF(out, "   %d: %g", i, p->get_scalar(i));
          }
          PrintF(out, "\n");
333 334 335 336
        }
      }
      break;
    }
337 338 339 340 341 342


#define PRINT_ELEMENTS(Kind, Type)                                          \
    case Kind: {                                                            \
      DoPrintElements<Type>(out, elements());                               \
      break;                                                                \
343
    }
344 345 346 347 348

#define PRINT_DOUBLE_ELEMENTS(Kind, Type)                                   \
    case Kind: {                                                            \
      DoPrintDoubleElements<Type>(out, elements());                         \
      break;                                                                \
349
    }
350

351 352 353 354 355 356 357 358 359 360 361 362
    PRINT_ELEMENTS(EXTERNAL_UINT8_CLAMPED_ELEMENTS, ExternalUint8ClampedArray)
    PRINT_ELEMENTS(EXTERNAL_INT8_ELEMENTS, ExternalInt8Array)
    PRINT_ELEMENTS(EXTERNAL_UINT8_ELEMENTS,
        ExternalUint8Array)
    PRINT_ELEMENTS(EXTERNAL_INT16_ELEMENTS, ExternalInt16Array)
    PRINT_ELEMENTS(EXTERNAL_UINT16_ELEMENTS,
        ExternalUint16Array)
    PRINT_ELEMENTS(EXTERNAL_INT32_ELEMENTS, ExternalInt32Array)
    PRINT_ELEMENTS(EXTERNAL_UINT32_ELEMENTS,
        ExternalUint32Array)
    PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT32_ELEMENTS, ExternalFloat32Array)
    PRINT_DOUBLE_ELEMENTS(EXTERNAL_FLOAT64_ELEMENTS, ExternalFloat64Array)
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377


    PRINT_ELEMENTS(UINT8_ELEMENTS, FixedUint8Array)
    PRINT_ELEMENTS(UINT8_CLAMPED_ELEMENTS, FixedUint8ClampedArray)
    PRINT_ELEMENTS(INT8_ELEMENTS, FixedInt8Array)
    PRINT_ELEMENTS(UINT16_ELEMENTS, FixedUint16Array)
    PRINT_ELEMENTS(INT16_ELEMENTS, FixedInt16Array)
    PRINT_ELEMENTS(UINT32_ELEMENTS, FixedUint32Array)
    PRINT_ELEMENTS(INT32_ELEMENTS, FixedInt32Array)
    PRINT_DOUBLE_ELEMENTS(FLOAT32_ELEMENTS, FixedFloat32Array)
    PRINT_DOUBLE_ELEMENTS(FLOAT64_ELEMENTS, FixedFloat64Array)

#undef PRINT_DOUBLE_ELEMENTS
#undef PRINT_ELEMENTS

378 379 380
    case DICTIONARY_ELEMENTS:
      elements()->Print(out);
      break;
381
    case SLOPPY_ARGUMENTS_ELEMENTS: {
382
      FixedArray* p = FixedArray::cast(elements());
383
      PrintF(out, "   parameter map:");
384
      for (int i = 2; i < p->length(); i++) {
385
        PrintF(out, " %d:", i - 2);
386 387
        p->get(i)->ShortPrint(out);
      }
388 389 390 391 392
      PrintF(out, "\n   context: ");
      p->get(0)->ShortPrint(out);
      PrintF(out, "\n   arguments: ");
      p->get(1)->ShortPrint(out);
      PrintF(out, "\n");
393 394
      break;
    }
395 396 397 398
  }
}


399 400 401 402
void JSObject::PrintTransitions(FILE* out) {
  if (!map()->HasTransitionArray()) return;
  TransitionArray* transitions = map()->transitions();
  for (int i = 0; i < transitions->number_of_transitions(); i++) {
403
    Name* key = transitions->GetKey(i);
404
    PrintF(out, "   ");
405
    key->NamePrint(out);
406
    PrintF(out, ": ");
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
    if (key == GetHeap()->frozen_symbol()) {
      PrintF(out, " (transition to frozen)\n");
    } else if (key == GetHeap()->elements_transition_symbol()) {
      PrintF(out, " (transition to ");
      PrintElementsKind(out, transitions->GetTarget(i)->elements_kind());
      PrintF(out, ")\n");
    } else if (key == GetHeap()->observed_symbol()) {
      PrintF(out, " (transition to Object.observe)\n");
    } else {
      switch (transitions->GetTargetDetails(i).type()) {
        case FIELD: {
          PrintF(out, " (transition to field)\n");
          break;
        }
        case CONSTANT:
          PrintF(out, " (transition to constant)\n");
          break;
        case CALLBACKS:
          PrintF(out, " (transition to callback)\n");
          break;
        // Values below are never in the target descriptor array.
        case NORMAL:
        case HANDLER:
        case INTERCEPTOR:
        case TRANSITION:
        case NONEXISTENT:
          UNREACHABLE();
          break;
435 436 437 438 439 440
      }
    }
  }
}


441 442
void JSObject::JSObjectPrint(FILE* out) {
  PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this));
443 444 445 446 447 448 449
  PrintF(out, " - map = %p [", reinterpret_cast<void*>(map()));
  // Don't call GetElementsKind, its validation code can cause the printer to
  // fail when debugging.
  PrintElementsKind(out, this->map()->elements_kind());
  PrintF(out,
         "]\n - prototype = %p\n",
         reinterpret_cast<void*>(GetPrototype()));
450 451
  PrintF(out, " {\n");
  PrintProperties(out);
452
  PrintTransitions(out);
453 454 455 456 457
  PrintElements(out);
  PrintF(out, " }\n");
}


458 459
void JSModule::JSModulePrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSModule");
460
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
461 462
  PrintF(out, " - context = ");
  context()->Print(out);
463 464
  PrintF(out, " - scope_info = ");
  scope_info()->ShortPrint(out);
465 466 467 468 469 470 471 472
  PrintElementsKind(out, this->map()->elements_kind());
  PrintF(out, " {\n");
  PrintProperties(out);
  PrintElements(out);
  PrintF(out, " }\n");
}


473 474
static const char* TypeToString(InstanceType type) {
  switch (type) {
475 476 477
#define TYPE_TO_STRING(TYPE) case TYPE: return #TYPE;
  INSTANCE_TYPE_LIST(TYPE_TO_STRING)
#undef TYPE_TO_STRING
478
  }
479 480
  UNREACHABLE();
  return "UNKNOWN";  // Keep the compiler happy.
481 482 483
}


484 485 486
void Symbol::SymbolPrint(FILE* out) {
  HeapObject::PrintHeader(out, "Symbol");
  PrintF(out, " - hash: %d\n", Hash());
487 488
  PrintF(out, " - name: ");
  name()->ShortPrint();
489
  PrintF(out, " - private: %d\n", is_private());
490
  PrintF(out, "\n");
491 492 493
}


494 495 496 497 498
void Map::MapPrint(FILE* out) {
  HeapObject::PrintHeader(out, "Map");
  PrintF(out, " - type: %s\n", TypeToString(instance_type()));
  PrintF(out, " - instance size: %d\n", instance_size());
  PrintF(out, " - inobject properties: %d\n", inobject_properties());
499 500 501
  PrintF(out, " - elements kind: ");
  PrintElementsKind(out, elements_kind());
  PrintF(out, "\n - pre-allocated property fields: %d\n",
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
      pre_allocated_property_fields());
  PrintF(out, " - unused property fields: %d\n", unused_property_fields());
  if (is_hidden_prototype()) {
    PrintF(out, " - hidden_prototype\n");
  }
  if (has_named_interceptor()) {
    PrintF(out, " - named_interceptor\n");
  }
  if (has_indexed_interceptor()) {
    PrintF(out, " - indexed_interceptor\n");
  }
  if (is_undetectable()) {
    PrintF(out, " - undetectable\n");
  }
  if (has_instance_call_handler()) {
    PrintF(out, " - instance_call_handler\n");
  }
  if (is_access_check_needed()) {
    PrintF(out, " - access_check_needed\n");
  }
522 523 524 525 526
  if (is_frozen()) {
    PrintF(out, " - frozen\n");
  } else if (!is_extensible()) {
    PrintF(out, " - sealed\n");
  }
527 528
  PrintF(out, " - back pointer: ");
  GetBackPointer()->ShortPrint(out);
529 530
  PrintF(out, "\n - instance descriptors %s#%i: ",
         owns_descriptors() ? "(own) " : "",
531
         NumberOfOwnDescriptors());
532
  instance_descriptors()->ShortPrint(out);
533 534 535 536
  if (HasTransitionArray()) {
    PrintF(out, "\n - transitions: ");
    transitions()->ShortPrint(out);
  }
537 538 539 540
  PrintF(out, "\n - prototype: ");
  prototype()->ShortPrint(out);
  PrintF(out, "\n - constructor: ");
  constructor()->ShortPrint(out);
541 542
  PrintF(out, "\n - code cache: ");
  code_cache()->ShortPrint(out);
543 544
  PrintF(out, "\n - dependent code: ");
  dependent_code()->ShortPrint(out);
545 546 547 548 549 550 551 552 553 554
  PrintF(out, "\n");
}


void CodeCache::CodeCachePrint(FILE* out) {
  HeapObject::PrintHeader(out, "CodeCache");
  PrintF(out, "\n - default_cache: ");
  default_cache()->ShortPrint(out);
  PrintF(out, "\n - normal_type_cache: ");
  normal_type_cache()->ShortPrint(out);
555 556 557 558 559 560 561
}


void PolymorphicCodeCache::PolymorphicCodeCachePrint(FILE* out) {
  HeapObject::PrintHeader(out, "PolymorphicCodeCache");
  PrintF(out, "\n - cache: ");
  cache()->ShortPrint(out);
562 563 564
}


565 566
void TypeFeedbackInfo::TypeFeedbackInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "TypeFeedbackInfo");
567
  PrintF(out, " - ic_total_count: %d, ic_with_type_info_count: %d\n",
568
         ic_total_count(), ic_with_type_info_count());
569 570
  PrintF(out, " - feedback_vector: ");
  feedback_vector()->FixedArrayPrint(out);
571 572 573
}


574 575 576 577 578 579
void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(FILE* out) {
  HeapObject::PrintHeader(out, "AliasedArgumentsEntry");
  PrintF(out, "\n - aliased_context_slot: %d", aliased_context_slot());
}


580 581 582 583 584 585 586 587 588 589 590
void FixedArray::FixedArrayPrint(FILE* out) {
  HeapObject::PrintHeader(out, "FixedArray");
  PrintF(out, " - length: %d", length());
  for (int i = 0; i < length(); i++) {
    PrintF(out, "\n  [%d]: ", i);
    get(i)->ShortPrint(out);
  }
  PrintF(out, "\n");
}


591 592 593 594
void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) {
  HeapObject::PrintHeader(out, "FixedDoubleArray");
  PrintF(out, " - length: %d", length());
  for (int i = 0; i < length(); i++) {
595 596 597 598 599
    if (is_the_hole(i)) {
      PrintF(out, "\n  [%d]: <the hole>", i);
    } else {
      PrintF(out, "\n  [%d]: %g", i, get_scalar(i));
    }
600 601 602 603 604
  }
  PrintF(out, "\n");
}


605 606 607 608
void ConstantPoolArray::ConstantPoolArrayPrint(FILE* out) {
  HeapObject::PrintHeader(out, "ConstantPoolArray");
  PrintF(out, " - length: %d", length());
  for (int i = 0; i < length(); i++) {
609
    if (i < first_code_ptr_index()) {
610
      PrintF(out, "\n  [%d]: double: %g", i, get_int64_entry_as_double(i));
611 612 613
    } else if (i < first_heap_ptr_index()) {
      PrintF(out, "\n  [%d]: code target pointer: %p", i,
             reinterpret_cast<void*>(get_code_ptr_entry(i)));
614
    } else if (i < first_int32_index()) {
615 616
      PrintF(out, "\n  [%d]: heap pointer: %p", i,
             reinterpret_cast<void*>(get_heap_ptr_entry(i)));
617 618 619 620 621 622 623 624
    } else {
      PrintF(out, "\n  [%d]: int32: %d", i, get_int32_entry(i));
    }
  }
  PrintF(out, "\n");
}


625 626 627 628 629 630
void JSValue::JSValuePrint(FILE* out) {
  HeapObject::PrintHeader(out, "ValueObject");
  value()->Print(out);
}


631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
void JSMessageObject::JSMessageObjectPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSMessageObject");
  PrintF(out, " - type: ");
  type()->ShortPrint(out);
  PrintF(out, "\n - arguments: ");
  arguments()->ShortPrint(out);
  PrintF(out, "\n - start_position: %d", start_position());
  PrintF(out, "\n - end_position: %d", end_position());
  PrintF(out, "\n - script: ");
  script()->ShortPrint(out);
  PrintF(out, "\n - stack_frames: ");
  stack_frames()->ShortPrint(out);
  PrintF(out, "\n");
}


647
void String::StringPrint(FILE* out) {
648
  if (StringShape(this).IsInternalized()) {
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
    PrintF(out, "#");
  } else if (StringShape(this).IsCons()) {
    PrintF(out, "c\"");
  } else {
    PrintF(out, "\"");
  }

  const char truncated_epilogue[] = "...<truncated>";
  int len = length();
  if (!FLAG_use_verbose_printer) {
    if (len > 100) {
      len = 100 - sizeof(truncated_epilogue);
    }
  }
  for (int i = 0; i < len; i++) {
    PrintF(out, "%c", Get(i));
  }
  if (len != length()) {
    PrintF(out, "%s", truncated_epilogue);
  }

670
  if (!StringShape(this).IsInternalized()) PrintF(out, "\"");
671 672 673
}


674 675 676 677 678 679 680 681
void Name::NamePrint(FILE* out) {
  if (IsString())
    String::cast(this)->StringPrint(out);
  else
    ShortPrint();
}


682
// This method is only meant to be called from gdb for debugging purposes.
683
// Since the string can also be in two-byte encoding, non-ASCII characters
684 685 686 687 688 689 690
// will be ignored in the output.
char* String::ToAsciiArray() {
  // Static so that subsequent calls frees previously allocated space.
  // This also means that previous results will be overwritten.
  static char* buffer = NULL;
  if (buffer != NULL) free(buffer);
  buffer = new char[length()+1];
691
  WriteToFlat(this, reinterpret_cast<uint8_t*>(buffer), 0, length());
692 693 694 695 696
  buffer[length()] = 0;
  return buffer;
}


697 698 699 700
static const char* const weekdays[] = {
  "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
};

701

702 703
void JSDate::JSDatePrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSDate");
704
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
705 706 707 708 709
  PrintF(out, " - value = ");
  value()->Print(out);
  if (!year()->IsSmi()) {
    PrintF(out, " - time = NaN\n");
  } else {
710 711 712 713 714 715 716 717
    PrintF(out, " - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
           weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
           year()->IsSmi() ? Smi::cast(year())->value() : -1,
           month()->IsSmi() ? Smi::cast(month())->value() : -1,
           day()->IsSmi() ? Smi::cast(day())->value() : -1,
           hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
           min()->IsSmi() ? Smi::cast(min())->value() : -1,
           sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
718 719 720 721
  }
}


722 723
void JSProxy::JSProxyPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSProxy");
724
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
725 726
  PrintF(out, " - handler = ");
  handler()->Print(out);
727 728
  PrintF(out, " - hash = ");
  hash()->Print(out);
729 730 731 732
  PrintF(out, "\n");
}


733 734
void JSFunctionProxy::JSFunctionProxyPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSFunctionProxy");
735
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
736 737 738 739 740 741 742 743 744 745
  PrintF(out, " - handler = ");
  handler()->Print(out);
  PrintF(out, " - call_trap = ");
  call_trap()->Print(out);
  PrintF(out, " - construct_trap = ");
  construct_trap()->Print(out);
  PrintF(out, "\n");
}


746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
void JSSet::JSSetPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSSet");
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
  PrintF(out, " - table = ");
  table()->ShortPrint(out);
  PrintF(out, "\n");
}


void JSMap::JSMapPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSMap");
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
  PrintF(out, " - table = ");
  table()->ShortPrint(out);
  PrintF(out, "\n");
}


764 765
void JSWeakMap::JSWeakMapPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSWeakMap");
766
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
767 768 769 770 771 772
  PrintF(out, " - table = ");
  table()->ShortPrint(out);
  PrintF(out, "\n");
}


773 774
void JSWeakSet::JSWeakSetPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSWeakSet");
775
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
776 777 778 779 780 781
  PrintF(out, " - table = ");
  table()->ShortPrint(out);
  PrintF(out, "\n");
}


782 783
void JSArrayBuffer::JSArrayBufferPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSArrayBuffer");
784 785
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
  PrintF(out, " - backing_store = %p\n", backing_store());
786 787 788 789 790 791
  PrintF(out, " - byte_length = ");
  byte_length()->ShortPrint(out);
  PrintF(out, "\n");
}


792 793
void JSTypedArray::JSTypedArrayPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSTypedArray");
794
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
795 796 797 798 799 800
  PrintF(out, " - buffer =");
  buffer()->ShortPrint(out);
  PrintF(out, "\n - byte_offset = ");
  byte_offset()->ShortPrint(out);
  PrintF(out, "\n - byte_length = ");
  byte_length()->ShortPrint(out);
801
  PrintF(out, "\n - length = ");
802
  length()->ShortPrint(out);
803
  PrintF(out, "\n");
804 805 806 807
  PrintElements(out);
}


808 809 810 811 812 813 814 815 816
void JSDataView::JSDataViewPrint(FILE* out) {
  HeapObject::PrintHeader(out, "JSDataView");
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
  PrintF(out, " - buffer =");
  buffer()->ShortPrint(out);
  PrintF(out, "\n - byte_offset = ");
  byte_offset()->ShortPrint(out);
  PrintF(out, "\n - byte_length = ");
  byte_length()->ShortPrint(out);
817
  PrintF(out, "\n");
818 819 820
}


821 822
void JSFunction::JSFunctionPrint(FILE* out) {
  HeapObject::PrintHeader(out, "Function");
823
  PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map()));
824 825 826 827 828 829 830 831 832
  PrintF(out, " - initial_map = ");
  if (has_initial_map()) {
    initial_map()->ShortPrint(out);
  }
  PrintF(out, "\n - shared_info = ");
  shared()->ShortPrint(out);
  PrintF(out, "\n   - name = ");
  shared()->name()->Print(out);
  PrintF(out, "\n - context = ");
833
  context()->ShortPrint(out);
834 835 836 837 838 839 840
  if (shared()->bound()) {
    PrintF(out, "\n - bindings = ");
    function_bindings()->ShortPrint(out);
  } else {
    PrintF(out, "\n - literals = ");
    literals()->ShortPrint(out);
  }
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
  PrintF(out, "\n - code = ");
  code()->ShortPrint(out);
  PrintF(out, "\n");

  PrintProperties(out);
  PrintElements(out);

  PrintF(out, "\n");
}


void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "SharedFunctionInfo");
  PrintF(out, " - name: ");
  name()->ShortPrint(out);
  PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties());
  PrintF(out, "\n - instance class name = ");
  instance_class_name()->Print(out);
  PrintF(out, "\n - code = ");
  code()->ShortPrint(out);
861 862
  if (HasSourceCode()) {
    PrintF(out, "\n - source code = ");
863 864 865 866 867 868 869
    String* source = String::cast(Script::cast(script())->source());
    int start = start_position();
    int length = end_position() - start;
    SmartArrayPointer<char> source_string =
        source->ToCString(DISALLOW_NULLS,
                          FAST_STRING_TRAVERSAL,
                          start, length, NULL);
870
    PrintF(out, "%s", source_string.get());
871
  }
872 873 874 875 876 877 878 879 880 881
  // Script files are often large, hard to read.
  // PrintF(out, "\n - script =");
  // script()->Print(out);
  PrintF(out, "\n - function token position = %d", function_token_position());
  PrintF(out, "\n - start position = %d", start_position());
  PrintF(out, "\n - end position = %d", end_position());
  PrintF(out, "\n - is expression = %d", is_expression());
  PrintF(out, "\n - debug info = ");
  debug_info()->ShortPrint(out);
  PrintF(out, "\n - length = %d", length());
882 883
  PrintF(out, "\n - optimized_code_map = ");
  optimized_code_map()->ShortPrint(out);
884 885 886 887 888
  PrintF(out, "\n");
}


void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) {
889
  PrintF(out, "global_proxy ");
890
  JSObjectPrint(out);
891 892
  PrintF(out, "native context : ");
  native_context()->ShortPrint(out);
893 894 895 896 897 898 899
  PrintF(out, "\n");
}


void JSGlobalObject::JSGlobalObjectPrint(FILE* out) {
  PrintF(out, "global ");
  JSObjectPrint(out);
900 901
  PrintF(out, "native context : ");
  native_context()->ShortPrint(out);
902 903 904 905 906 907 908 909 910 911
  PrintF(out, "\n");
}


void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) {
  PrintF(out, "builtins ");
  JSObjectPrint(out);
}


912 913 914 915 916
void Cell::CellPrint(FILE* out) {
  HeapObject::PrintHeader(out, "Cell");
}


917 918
void PropertyCell::PropertyCellPrint(FILE* out) {
  HeapObject::PrintHeader(out, "PropertyCell");
919 920 921 922 923 924 925 926 927 928 929 930 931
}


void Code::CodePrint(FILE* out) {
  HeapObject::PrintHeader(out, "Code");
#ifdef ENABLE_DISASSEMBLER
  if (FLAG_use_verbose_printer) {
    Disassemble(NULL, out);
  }
#endif
}


932
void Foreign::ForeignPrint(FILE* out) {
933
  PrintF(out, "foreign address : %p", foreign_address());
934 935 936
}


937 938 939 940 941 942
void ExecutableAccessorInfo::ExecutableAccessorInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "ExecutableAccessorInfo");
  PrintF(out, "\n - name: ");
  name()->ShortPrint(out);
  PrintF(out, "\n - flag: ");
  flag()->ShortPrint(out);
943 944 945 946 947 948
  PrintF(out, "\n - getter: ");
  getter()->ShortPrint(out);
  PrintF(out, "\n - setter: ");
  setter()->ShortPrint(out);
  PrintF(out, "\n - data: ");
  data()->ShortPrint(out);
949 950 951 952 953 954 955
}


void DeclaredAccessorInfo::DeclaredAccessorInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "DeclaredAccessorInfo");
  PrintF(out, "\n - name: ");
  name()->ShortPrint(out);
956 957
  PrintF(out, "\n - flag: ");
  flag()->ShortPrint(out);
958 959 960 961 962 963 964 965
  PrintF(out, "\n - descriptor: ");
  descriptor()->ShortPrint(out);
}


void DeclaredAccessorDescriptor::DeclaredAccessorDescriptorPrint(FILE* out) {
  HeapObject::PrintHeader(out, "DeclaredAccessorDescriptor");
  PrintF(out, "\n - internal field: ");
966
  serialized_data()->ShortPrint(out);
967 968 969
}


970 971 972 973 974 975 976
void Box::BoxPrint(FILE* out) {
  HeapObject::PrintHeader(out, "Box");
  PrintF(out, "\n - value: ");
  value()->ShortPrint(out);
}


977 978 979 980 981 982
void AccessorPair::AccessorPairPrint(FILE* out) {
  HeapObject::PrintHeader(out, "AccessorPair");
  PrintF(out, "\n - getter: ");
  getter()->ShortPrint(out);
  PrintF(out, "\n - setter: ");
  setter()->ShortPrint(out);
983 984
  PrintF(out, "\n - flag: ");
  access_flags()->ShortPrint(out);
985 986 987
}


988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063
void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "AccessCheckInfo");
  PrintF(out, "\n - named_callback: ");
  named_callback()->ShortPrint(out);
  PrintF(out, "\n - indexed_callback: ");
  indexed_callback()->ShortPrint(out);
  PrintF(out, "\n - data: ");
  data()->ShortPrint(out);
}


void InterceptorInfo::InterceptorInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "InterceptorInfo");
  PrintF(out, "\n - getter: ");
  getter()->ShortPrint(out);
  PrintF(out, "\n - setter: ");
  setter()->ShortPrint(out);
  PrintF(out, "\n - query: ");
  query()->ShortPrint(out);
  PrintF(out, "\n - deleter: ");
  deleter()->ShortPrint(out);
  PrintF(out, "\n - enumerator: ");
  enumerator()->ShortPrint(out);
  PrintF(out, "\n - data: ");
  data()->ShortPrint(out);
}


void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "CallHandlerInfo");
  PrintF(out, "\n - callback: ");
  callback()->ShortPrint(out);
  PrintF(out, "\n - data: ");
  data()->ShortPrint(out);
  PrintF(out, "\n - call_stub_cache: ");
}


void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "FunctionTemplateInfo");
  PrintF(out, "\n - class name: ");
  class_name()->ShortPrint(out);
  PrintF(out, "\n - tag: ");
  tag()->ShortPrint(out);
  PrintF(out, "\n - property_list: ");
  property_list()->ShortPrint(out);
  PrintF(out, "\n - serial_number: ");
  serial_number()->ShortPrint(out);
  PrintF(out, "\n - call_code: ");
  call_code()->ShortPrint(out);
  PrintF(out, "\n - property_accessors: ");
  property_accessors()->ShortPrint(out);
  PrintF(out, "\n - prototype_template: ");
  prototype_template()->ShortPrint(out);
  PrintF(out, "\n - parent_template: ");
  parent_template()->ShortPrint(out);
  PrintF(out, "\n - named_property_handler: ");
  named_property_handler()->ShortPrint(out);
  PrintF(out, "\n - indexed_property_handler: ");
  indexed_property_handler()->ShortPrint(out);
  PrintF(out, "\n - instance_template: ");
  instance_template()->ShortPrint(out);
  PrintF(out, "\n - signature: ");
  signature()->ShortPrint(out);
  PrintF(out, "\n - access_check_info: ");
  access_check_info()->ShortPrint(out);
  PrintF(out, "\n - hidden_prototype: %s",
         hidden_prototype() ? "true" : "false");
  PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false");
  PrintF(out, "\n - need_access_check: %s",
         needs_access_check() ? "true" : "false");
}


void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "ObjectTemplateInfo");
1064 1065 1066 1067
  PrintF(out, " - tag: ");
  tag()->ShortPrint(out);
  PrintF(out, "\n - property_list: ");
  property_list()->ShortPrint(out);
1068 1069
  PrintF(out, "\n - property_accessors: ");
  property_accessors()->ShortPrint(out);
1070 1071 1072 1073
  PrintF(out, "\n - constructor: ");
  constructor()->ShortPrint(out);
  PrintF(out, "\n - internal_field_count: ");
  internal_field_count()->ShortPrint(out);
1074
  PrintF(out, "\n");
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
}


void SignatureInfo::SignatureInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "SignatureInfo");
  PrintF(out, "\n - receiver: ");
  receiver()->ShortPrint(out);
  PrintF(out, "\n - args: ");
  args()->ShortPrint(out);
}


void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "TypeSwitchInfo");
  PrintF(out, "\n - types: ");
  types()->ShortPrint(out);
}


1094 1095
void AllocationSite::AllocationSitePrint(FILE* out) {
  HeapObject::PrintHeader(out, "AllocationSite");
1096 1097
  PrintF(out, " - weak_next: ");
  weak_next()->ShortPrint(out);
1098 1099
  PrintF(out, "\n - dependent code: ");
  dependent_code()->ShortPrint(out);
1100 1101
  PrintF(out, "\n - nested site: ");
  nested_site()->ShortPrint(out);
1102
  PrintF(out, "\n - memento found count: ");
1103
  Smi::FromInt(memento_found_count())->ShortPrint(out);
1104
  PrintF(out, "\n - memento create count: ");
1105
  Smi::FromInt(memento_create_count())->ShortPrint(out);
1106
  PrintF(out, "\n - pretenure decision: ");
1107
  Smi::FromInt(pretenure_decision())->ShortPrint(out);
1108
  PrintF(out, "\n - transition_info: ");
1109 1110 1111 1112 1113 1114
  if (transition_info()->IsSmi()) {
    ElementsKind kind = GetElementsKind();
    PrintF(out, "Array allocation with ElementsKind ");
    PrintElementsKind(out, kind);
    PrintF(out, "\n");
    return;
1115
  } else if (transition_info()->IsJSArray()) {
1116
    PrintF(out, "Array literal ");
1117
    transition_info()->ShortPrint(out);
1118 1119 1120 1121
    PrintF(out, "\n");
    return;
  }

1122 1123
  PrintF(out, "unknown transition_info");
  transition_info()->ShortPrint(out);
1124 1125 1126 1127
  PrintF(out, "\n");
}


1128 1129
void AllocationMemento::AllocationMementoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "AllocationMemento");
1130 1131 1132 1133 1134 1135 1136 1137 1138
  PrintF(out, " - allocation site: ");
  if (IsValid()) {
    GetAllocationSite()->Print();
  } else {
    PrintF(out, "<invalid>\n");
  }
}


1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
void Script::ScriptPrint(FILE* out) {
  HeapObject::PrintHeader(out, "Script");
  PrintF(out, "\n - source: ");
  source()->ShortPrint(out);
  PrintF(out, "\n - name: ");
  name()->ShortPrint(out);
  PrintF(out, "\n - line_offset: ");
  line_offset()->ShortPrint(out);
  PrintF(out, "\n - column_offset: ");
  column_offset()->ShortPrint(out);
  PrintF(out, "\n - type: ");
  type()->ShortPrint(out);
  PrintF(out, "\n - id: ");
  id()->ShortPrint(out);
  PrintF(out, "\n - context data: ");
  context_data()->ShortPrint(out);
  PrintF(out, "\n - wrapper: ");
  wrapper()->ShortPrint(out);
1157
  PrintF(out, "\n - compilation type: %d", compilation_type());
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204
  PrintF(out, "\n - line ends: ");
  line_ends()->ShortPrint(out);
  PrintF(out, "\n - eval from shared: ");
  eval_from_shared()->ShortPrint(out);
  PrintF(out, "\n - eval from instructions offset: ");
  eval_from_instructions_offset()->ShortPrint(out);
  PrintF(out, "\n");
}


#ifdef ENABLE_DEBUGGER_SUPPORT
void DebugInfo::DebugInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "DebugInfo");
  PrintF(out, "\n - shared: ");
  shared()->ShortPrint(out);
  PrintF(out, "\n - original_code: ");
  original_code()->ShortPrint(out);
  PrintF(out, "\n - code: ");
  code()->ShortPrint(out);
  PrintF(out, "\n - break_points: ");
  break_points()->Print(out);
}


void BreakPointInfo::BreakPointInfoPrint(FILE* out) {
  HeapObject::PrintHeader(out, "BreakPointInfo");
  PrintF(out, "\n - code_position: %d", code_position()->value());
  PrintF(out, "\n - source_position: %d", source_position()->value());
  PrintF(out, "\n - statement_position: %d", statement_position()->value());
  PrintF(out, "\n - break_point_objects: ");
  break_point_objects()->ShortPrint(out);
}
#endif  // ENABLE_DEBUGGER_SUPPORT


void DescriptorArray::PrintDescriptors(FILE* out) {
  PrintF(out, "Descriptor array  %d\n", number_of_descriptors());
  for (int i = 0; i < number_of_descriptors(); i++) {
    PrintF(out, " %d: ", i);
    Descriptor desc;
    Get(i, &desc);
    desc.Print(out);
  }
  PrintF(out, "\n");
}


1205 1206 1207 1208
void TransitionArray::PrintTransitions(FILE* out) {
  PrintF(out, "Transition array  %d\n", number_of_transitions());
  for (int i = 0; i < number_of_transitions(); i++) {
    PrintF(out, " %d: ", i);
1209
    GetKey(i)->NamePrint(out);
1210 1211 1212 1213 1214 1215
    PrintF(out, ": ");
    switch (GetTargetDetails(i).type()) {
      case FIELD: {
        PrintF(out, " (transition to field)\n");
        break;
      }
1216 1217
      case CONSTANT:
        PrintF(out, " (transition to constant)\n");
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235
        break;
      case CALLBACKS:
        PrintF(out, " (transition to callback)\n");
        break;
      // Values below are never in the target descriptor array.
      case NORMAL:
      case HANDLER:
      case INTERCEPTOR:
      case TRANSITION:
      case NONEXISTENT:
        UNREACHABLE();
        break;
    }
  }
  PrintF(out, "\n");
}


1236 1237 1238 1239
#endif  // OBJECT_PRINT


} }  // namespace v8::internal