LCOV - code coverage report
Current view: top level - src - objects-printer.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 85 134 63.4 %
Date: 2019-01-20 Functions: 7 15 46.7 %

          Line data    Source code
       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/objects.h"
       6             : 
       7             : #include <iomanip>
       8             : #include <memory>
       9             : 
      10             : #include "src/bootstrapper.h"
      11             : #include "src/disasm.h"
      12             : #include "src/disassembler.h"
      13             : #include "src/interpreter/bytecodes.h"
      14             : #include "src/objects-inl.h"
      15             : #include "src/objects/arguments-inl.h"
      16             : #include "src/objects/cell-inl.h"
      17             : #include "src/objects/data-handler-inl.h"
      18             : #include "src/objects/debug-objects-inl.h"
      19             : #include "src/objects/embedder-data-array-inl.h"
      20             : #include "src/objects/embedder-data-slot-inl.h"
      21             : #include "src/objects/feedback-cell-inl.h"
      22             : #include "src/objects/foreign-inl.h"
      23             : #include "src/objects/free-space-inl.h"
      24             : #include "src/objects/hash-table-inl.h"
      25             : #include "src/objects/heap-number-inl.h"
      26             : #include "src/objects/js-array-buffer-inl.h"
      27             : #include "src/objects/js-array-inl.h"
      28             : #include "src/snapshot/embedded-data.h"
      29             : #ifdef V8_INTL_SUPPORT
      30             : #include "src/objects/js-break-iterator-inl.h"
      31             : #include "src/objects/js-collator-inl.h"
      32             : #endif  // V8_INTL_SUPPORT
      33             : #include "src/objects/js-collection-inl.h"
      34             : #ifdef V8_INTL_SUPPORT
      35             : #include "src/objects/js-date-time-format-inl.h"
      36             : #endif  // V8_INTL_SUPPORT
      37             : #include "src/objects/js-generator-inl.h"
      38             : #ifdef V8_INTL_SUPPORT
      39             : #include "src/objects/js-list-format-inl.h"
      40             : #include "src/objects/js-locale-inl.h"
      41             : #include "src/objects/js-number-format-inl.h"
      42             : #include "src/objects/js-plural-rules-inl.h"
      43             : #endif  // V8_INTL_SUPPORT
      44             : #include "src/objects/js-regexp-inl.h"
      45             : #include "src/objects/js-regexp-string-iterator-inl.h"
      46             : #ifdef V8_INTL_SUPPORT
      47             : #include "src/objects/js-relative-time-format-inl.h"
      48             : #include "src/objects/js-segment-iterator-inl.h"
      49             : #include "src/objects/js-segmenter-inl.h"
      50             : #endif  // V8_INTL_SUPPORT
      51             : #include "src/objects/js-weak-refs-inl.h"
      52             : #include "src/objects/literal-objects-inl.h"
      53             : #include "src/objects/microtask-inl.h"
      54             : #include "src/objects/module-inl.h"
      55             : #include "src/objects/oddball-inl.h"
      56             : #include "src/objects/promise-inl.h"
      57             : #include "src/objects/stack-frame-info-inl.h"
      58             : #include "src/objects/struct-inl.h"
      59             : #include "src/ostreams.h"
      60             : #include "src/regexp/jsregexp.h"
      61             : #include "src/transitions-inl.h"
      62             : #include "src/wasm/wasm-code-manager.h"
      63             : #include "src/wasm/wasm-engine.h"
      64             : #include "src/wasm/wasm-objects-inl.h"
      65             : 
      66             : namespace v8 {
      67             : namespace internal {
      68             : 
      69             : #ifdef OBJECT_PRINT
      70             : 
      71             : void Object::Print() const {
      72             :   StdoutStream os;
      73             :   this->Print(os);
      74             :   os << std::flush;
      75             : }
      76             : 
      77             : void Object::Print(std::ostream& os) const {  // NOLINT
      78             :   if (IsSmi()) {
      79             :     os << "Smi: " << std::hex << "0x" << Smi::ToInt(*this);
      80             :     os << std::dec << " (" << Smi::ToInt(*this) << ")\n";
      81             :   } else {
      82             :     HeapObject::cast(*this)->HeapObjectPrint(os);
      83             :   }
      84             : }
      85             : 
      86             : void HeapObject::PrintHeader(std::ostream& os, const char* id) {  // NOLINT
      87             :   os << reinterpret_cast<void*>(ptr()) << ": [";
      88             :   if (id != nullptr) {
      89             :     os << id;
      90             :   } else {
      91             :     os << map()->instance_type();
      92             :   }
      93             :   os << "]";
      94             :   MemoryChunk* chunk = MemoryChunk::FromAddress(ptr());
      95             :   if (chunk->owner()->identity() == OLD_SPACE) os << " in OldSpace";
      96             :   if (!IsMap()) os << "\n - map: " << Brief(map());
      97             : }
      98             : 
      99             : void HeapObject::HeapObjectPrint(std::ostream& os) {  // NOLINT
     100             :   InstanceType instance_type = map()->instance_type();
     101             : 
     102             :   if (instance_type < FIRST_NONSTRING_TYPE) {
     103             :     String::cast(*this)->StringPrint(os);
     104             :     os << "\n";
     105             :     return;
     106             :   }
     107             : 
     108             :   switch (instance_type) {
     109             :     case SYMBOL_TYPE:
     110             :       Symbol::cast(*this)->SymbolPrint(os);
     111             :       break;
     112             :     case MAP_TYPE:
     113             :       Map::cast(*this)->MapPrint(os);
     114             :       break;
     115             :     case HEAP_NUMBER_TYPE:
     116             :       HeapNumber::cast(*this)->HeapNumberPrint(os);
     117             :       os << "\n";
     118             :       break;
     119             :     case MUTABLE_HEAP_NUMBER_TYPE:
     120             :       os << "<mutable ";
     121             :       MutableHeapNumber::cast(*this)->MutableHeapNumberPrint(os);
     122             :       os << ">\n";
     123             :       break;
     124             :     case BIGINT_TYPE:
     125             :       BigInt::cast(*this)->BigIntPrint(os);
     126             :       os << "\n";
     127             :       break;
     128             :     case EMBEDDER_DATA_ARRAY_TYPE:
     129             :       EmbedderDataArray::cast(*this)->EmbedderDataArrayPrint(os);
     130             :       break;
     131             :     case FIXED_DOUBLE_ARRAY_TYPE:
     132             :       FixedDoubleArray::cast(*this)->FixedDoubleArrayPrint(os);
     133             :       break;
     134             :     case FIXED_ARRAY_TYPE:
     135             :       FixedArray::cast(*this)->FixedArrayPrint(os);
     136             :       break;
     137             :     case AWAIT_CONTEXT_TYPE:
     138             :     case BLOCK_CONTEXT_TYPE:
     139             :     case CATCH_CONTEXT_TYPE:
     140             :     case DEBUG_EVALUATE_CONTEXT_TYPE:
     141             :     case EVAL_CONTEXT_TYPE:
     142             :     case FUNCTION_CONTEXT_TYPE:
     143             :     case MODULE_CONTEXT_TYPE:
     144             :     case SCRIPT_CONTEXT_TYPE:
     145             :     case WITH_CONTEXT_TYPE:
     146             :     case SCRIPT_CONTEXT_TABLE_TYPE:
     147             :       Context::cast(*this)->ContextPrint(os);
     148             :       break;
     149             :     case NATIVE_CONTEXT_TYPE:
     150             :       NativeContext::cast(*this)->NativeContextPrint(os);
     151             :       break;
     152             :     case HASH_TABLE_TYPE:
     153             :     case ORDERED_HASH_MAP_TYPE:
     154             :     case ORDERED_HASH_SET_TYPE:
     155             :     case ORDERED_NAME_DICTIONARY_TYPE:
     156             :     case NAME_DICTIONARY_TYPE:
     157             :     case GLOBAL_DICTIONARY_TYPE:
     158             :     case SIMPLE_NUMBER_DICTIONARY_TYPE:
     159             :       FixedArray::cast(*this)->FixedArrayPrint(os);
     160             :       break;
     161             :     case STRING_TABLE_TYPE:
     162             :       ObjectHashTable::cast(*this)->ObjectHashTablePrint(os);
     163             :       break;
     164             :     case NUMBER_DICTIONARY_TYPE:
     165             :       NumberDictionary::cast(*this)->NumberDictionaryPrint(os);
     166             :       break;
     167             :     case EPHEMERON_HASH_TABLE_TYPE:
     168             :       EphemeronHashTable::cast(*this)->EphemeronHashTablePrint(os);
     169             :       break;
     170             :     case OBJECT_BOILERPLATE_DESCRIPTION_TYPE:
     171             :       ObjectBoilerplateDescription::cast(*this)
     172             :           ->ObjectBoilerplateDescriptionPrint(os);
     173             :       break;
     174             :     case PROPERTY_ARRAY_TYPE:
     175             :       PropertyArray::cast(*this)->PropertyArrayPrint(os);
     176             :       break;
     177             :     case BYTE_ARRAY_TYPE:
     178             :       ByteArray::cast(*this)->ByteArrayPrint(os);
     179             :       break;
     180             :     case BYTECODE_ARRAY_TYPE:
     181             :       BytecodeArray::cast(*this)->BytecodeArrayPrint(os);
     182             :       break;
     183             :     case DESCRIPTOR_ARRAY_TYPE:
     184             :       DescriptorArray::cast(*this)->DescriptorArrayPrint(os);
     185             :       break;
     186             :     case TRANSITION_ARRAY_TYPE:
     187             :       TransitionArray::cast(*this)->TransitionArrayPrint(os);
     188             :       break;
     189             :     case FEEDBACK_CELL_TYPE:
     190             :       FeedbackCell::cast(*this)->FeedbackCellPrint(os);
     191             :       break;
     192             :     case FEEDBACK_VECTOR_TYPE:
     193             :       FeedbackVector::cast(*this)->FeedbackVectorPrint(os);
     194             :       break;
     195             :     case FREE_SPACE_TYPE:
     196             :       FreeSpace::cast(*this)->FreeSpacePrint(os);
     197             :       break;
     198             : 
     199             : #define PRINT_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype)       \
     200             :   case Fixed##Type##Array::kInstanceType:                      \
     201             :     Fixed##Type##Array::cast(*this)->FixedTypedArrayPrint(os); \
     202             :     break;
     203             : 
     204             :       TYPED_ARRAYS(PRINT_FIXED_TYPED_ARRAY)
     205             : #undef PRINT_FIXED_TYPED_ARRAY
     206             : 
     207             :     case FILLER_TYPE:
     208             :       os << "filler";
     209             :       break;
     210             :     case JS_OBJECT_TYPE:  // fall through
     211             :     case JS_API_OBJECT_TYPE:
     212             :     case JS_SPECIAL_API_OBJECT_TYPE:
     213             :     case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
     214             :     case JS_ASYNC_FUNCTION_OBJECT_TYPE:
     215             :     case JS_ASYNC_GENERATOR_OBJECT_TYPE:
     216             :     case JS_ARGUMENTS_TYPE:
     217             :     case JS_ERROR_TYPE:
     218             :     // TODO(titzer): debug printing for more wasm objects
     219             :     case WASM_EXCEPTION_TYPE:
     220             :     case WASM_GLOBAL_TYPE:
     221             :     case WASM_MEMORY_TYPE:
     222             :     case WASM_TABLE_TYPE:
     223             :       JSObject::cast(*this)->JSObjectPrint(os);
     224             :       break;
     225             :     case WASM_MODULE_TYPE:
     226             :       WasmModuleObject::cast(*this)->WasmModuleObjectPrint(os);
     227             :       break;
     228             :     case WASM_INSTANCE_TYPE:
     229             :       WasmInstanceObject::cast(*this)->WasmInstanceObjectPrint(os);
     230             :       break;
     231             :     case JS_GENERATOR_OBJECT_TYPE:
     232             :       JSGeneratorObject::cast(*this)->JSGeneratorObjectPrint(os);
     233             :       break;
     234             :     case JS_PROMISE_TYPE:
     235             :       JSPromise::cast(*this)->JSPromisePrint(os);
     236             :       break;
     237             :     case JS_ARRAY_TYPE:
     238             :       JSArray::cast(*this)->JSArrayPrint(os);
     239             :       break;
     240             :     case JS_REGEXP_TYPE:
     241             :       JSRegExp::cast(*this)->JSRegExpPrint(os);
     242             :       break;
     243             :     case JS_REGEXP_STRING_ITERATOR_TYPE:
     244             :       JSRegExpStringIterator::cast(*this)->JSRegExpStringIteratorPrint(os);
     245             :       break;
     246             :     case ODDBALL_TYPE:
     247             :       Oddball::cast(*this)->to_string()->Print(os);
     248             :       break;
     249             :     case JS_BOUND_FUNCTION_TYPE:
     250             :       JSBoundFunction::cast(*this)->JSBoundFunctionPrint(os);
     251             :       break;
     252             :     case JS_FUNCTION_TYPE:
     253             :       JSFunction::cast(*this)->JSFunctionPrint(os);
     254             :       break;
     255             :     case JS_GLOBAL_PROXY_TYPE:
     256             :       JSGlobalProxy::cast(*this)->JSGlobalProxyPrint(os);
     257             :       break;
     258             :     case JS_GLOBAL_OBJECT_TYPE:
     259             :       JSGlobalObject::cast(*this)->JSGlobalObjectPrint(os);
     260             :       break;
     261             :     case JS_VALUE_TYPE:
     262             :       JSValue::cast(*this)->JSValuePrint(os);
     263             :       break;
     264             :     case JS_DATE_TYPE:
     265             :       JSDate::cast(*this)->JSDatePrint(os);
     266             :       break;
     267             :     case CODE_TYPE:
     268             :       Code::cast(*this)->CodePrint(os);
     269             :       break;
     270             :     case CODE_DATA_CONTAINER_TYPE:
     271             :       CodeDataContainer::cast(*this)->CodeDataContainerPrint(os);
     272             :       break;
     273             :     case JS_PROXY_TYPE:
     274             :       JSProxy::cast(*this)->JSProxyPrint(os);
     275             :       break;
     276             :     case JS_SET_TYPE:
     277             :       JSSet::cast(*this)->JSSetPrint(os);
     278             :       break;
     279             :     case JS_MAP_TYPE:
     280             :       JSMap::cast(*this)->JSMapPrint(os);
     281             :       break;
     282             :     case JS_SET_KEY_VALUE_ITERATOR_TYPE:
     283             :     case JS_SET_VALUE_ITERATOR_TYPE:
     284             :       JSSetIterator::cast(*this)->JSSetIteratorPrint(os);
     285             :       break;
     286             :     case JS_MAP_KEY_ITERATOR_TYPE:
     287             :     case JS_MAP_KEY_VALUE_ITERATOR_TYPE:
     288             :     case JS_MAP_VALUE_ITERATOR_TYPE:
     289             :       JSMapIterator::cast(*this)->JSMapIteratorPrint(os);
     290             :       break;
     291             :     case JS_WEAK_CELL_TYPE:
     292             :       JSWeakCell::cast(*this)->JSWeakCellPrint(os);
     293             :       break;
     294             :     case JS_WEAK_REF_TYPE:
     295             :       JSWeakRef::cast(*this)->JSWeakRefPrint(os);
     296             :       break;
     297             :     case JS_WEAK_FACTORY_TYPE:
     298             :       JSWeakFactory::cast(*this)->JSWeakFactoryPrint(os);
     299             :       break;
     300             :     case JS_WEAK_FACTORY_CLEANUP_ITERATOR_TYPE:
     301             :       JSWeakFactoryCleanupIterator::cast(*this)
     302             :           ->JSWeakFactoryCleanupIteratorPrint(os);
     303             :       break;
     304             :     case JS_WEAK_MAP_TYPE:
     305             :       JSWeakMap::cast(*this)->JSWeakMapPrint(os);
     306             :       break;
     307             :     case JS_WEAK_SET_TYPE:
     308             :       JSWeakSet::cast(*this)->JSWeakSetPrint(os);
     309             :       break;
     310             :     case JS_MODULE_NAMESPACE_TYPE:
     311             :       JSModuleNamespace::cast(*this)->JSModuleNamespacePrint(os);
     312             :       break;
     313             :     case FOREIGN_TYPE:
     314             :       Foreign::cast(*this)->ForeignPrint(os);
     315             :       break;
     316             :     case CALL_HANDLER_INFO_TYPE:
     317             :       CallHandlerInfo::cast(*this)->CallHandlerInfoPrint(os);
     318             :       break;
     319             :     case PREPARSE_DATA_TYPE:
     320             :       PreparseData::cast(*this)->PreparseDataPrint(os);
     321             :       break;
     322             :     case UNCOMPILED_DATA_WITHOUT_PREPARSE_DATA_TYPE:
     323             :       UncompiledDataWithoutPreparseData::cast(*this)
     324             :           ->UncompiledDataWithoutPreparseDataPrint(os);
     325             :       break;
     326             :     case UNCOMPILED_DATA_WITH_PREPARSE_DATA_TYPE:
     327             :       UncompiledDataWithPreparseData::cast(*this)
     328             :           ->UncompiledDataWithPreparseDataPrint(os);
     329             :       break;
     330             :     case SHARED_FUNCTION_INFO_TYPE:
     331             :       SharedFunctionInfo::cast(*this)->SharedFunctionInfoPrint(os);
     332             :       break;
     333             :     case JS_MESSAGE_OBJECT_TYPE:
     334             :       JSMessageObject::cast(*this)->JSMessageObjectPrint(os);
     335             :       break;
     336             :     case CELL_TYPE:
     337             :       Cell::cast(*this)->CellPrint(os);
     338             :       break;
     339             :     case PROPERTY_CELL_TYPE:
     340             :       PropertyCell::cast(*this)->PropertyCellPrint(os);
     341             :       break;
     342             :     case JS_ARRAY_BUFFER_TYPE:
     343             :       JSArrayBuffer::cast(*this)->JSArrayBufferPrint(os);
     344             :       break;
     345             :     case JS_ARRAY_ITERATOR_TYPE:
     346             :       JSArrayIterator::cast(*this)->JSArrayIteratorPrint(os);
     347             :       break;
     348             :     case JS_TYPED_ARRAY_TYPE:
     349             :       JSTypedArray::cast(*this)->JSTypedArrayPrint(os);
     350             :       break;
     351             :     case JS_DATA_VIEW_TYPE:
     352             :       JSDataView::cast(*this)->JSDataViewPrint(os);
     353             :       break;
     354             : #ifdef V8_INTL_SUPPORT
     355             :     case JS_INTL_V8_BREAK_ITERATOR_TYPE:
     356             :       JSV8BreakIterator::cast(*this)->JSV8BreakIteratorPrint(os);
     357             :       break;
     358             :     case JS_INTL_COLLATOR_TYPE:
     359             :       JSCollator::cast(*this)->JSCollatorPrint(os);
     360             :       break;
     361             :     case JS_INTL_DATE_TIME_FORMAT_TYPE:
     362             :       JSDateTimeFormat::cast(*this)->JSDateTimeFormatPrint(os);
     363             :       break;
     364             :     case JS_INTL_LIST_FORMAT_TYPE:
     365             :       JSListFormat::cast(*this)->JSListFormatPrint(os);
     366             :       break;
     367             :     case JS_INTL_LOCALE_TYPE:
     368             :       JSLocale::cast(*this)->JSLocalePrint(os);
     369             :       break;
     370             :     case JS_INTL_NUMBER_FORMAT_TYPE:
     371             :       JSNumberFormat::cast(*this)->JSNumberFormatPrint(os);
     372             :       break;
     373             :     case JS_INTL_PLURAL_RULES_TYPE:
     374             :       JSPluralRules::cast(*this)->JSPluralRulesPrint(os);
     375             :       break;
     376             :     case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
     377             :       JSRelativeTimeFormat::cast(*this)->JSRelativeTimeFormatPrint(os);
     378             :       break;
     379             :     case JS_INTL_SEGMENT_ITERATOR_TYPE:
     380             :       JSSegmentIterator::cast(*this)->JSSegmentIteratorPrint(os);
     381             :       break;
     382             :     case JS_INTL_SEGMENTER_TYPE:
     383             :       JSSegmenter::cast(*this)->JSSegmenterPrint(os);
     384             :       break;
     385             : #endif  // V8_INTL_SUPPORT
     386             : #define MAKE_STRUCT_CASE(TYPE, Name, name) \
     387             :   case TYPE:                               \
     388             :     Name::cast(*this)->Name##Print(os);    \
     389             :     break;
     390             :       STRUCT_LIST(MAKE_STRUCT_CASE)
     391             : #undef MAKE_STRUCT_CASE
     392             : 
     393             :     case ALLOCATION_SITE_TYPE:
     394             :       AllocationSite::cast(*this)->AllocationSitePrint(os);
     395             :       break;
     396             :     case LOAD_HANDLER_TYPE:
     397             :       LoadHandler::cast(*this)->LoadHandlerPrint(os);
     398             :       break;
     399             :     case STORE_HANDLER_TYPE:
     400             :       StoreHandler::cast(*this)->StoreHandlerPrint(os);
     401             :       break;
     402             :     case SCOPE_INFO_TYPE:
     403             :       ScopeInfo::cast(*this)->ScopeInfoPrint(os);
     404             :       break;
     405             :     case FEEDBACK_METADATA_TYPE:
     406             :       FeedbackMetadata::cast(*this)->FeedbackMetadataPrint(os);
     407             :       break;
     408             :     case WEAK_FIXED_ARRAY_TYPE:
     409             :       WeakFixedArray::cast(*this)->WeakFixedArrayPrint(os);
     410             :       break;
     411             :     case WEAK_ARRAY_LIST_TYPE:
     412             :       WeakArrayList::cast(*this)->WeakArrayListPrint(os);
     413             :       break;
     414             :     case INTERNALIZED_STRING_TYPE:
     415             :     case EXTERNAL_INTERNALIZED_STRING_TYPE:
     416             :     case ONE_BYTE_INTERNALIZED_STRING_TYPE:
     417             :     case EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
     418             :     case EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
     419             :     case UNCACHED_EXTERNAL_INTERNALIZED_STRING_TYPE:
     420             :     case UNCACHED_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE:
     421             :     case UNCACHED_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE:
     422             :     case STRING_TYPE:
     423             :     case CONS_STRING_TYPE:
     424             :     case EXTERNAL_STRING_TYPE:
     425             :     case SLICED_STRING_TYPE:
     426             :     case THIN_STRING_TYPE:
     427             :     case ONE_BYTE_STRING_TYPE:
     428             :     case CONS_ONE_BYTE_STRING_TYPE:
     429             :     case EXTERNAL_ONE_BYTE_STRING_TYPE:
     430             :     case SLICED_ONE_BYTE_STRING_TYPE:
     431             :     case THIN_ONE_BYTE_STRING_TYPE:
     432             :     case EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
     433             :     case UNCACHED_EXTERNAL_STRING_TYPE:
     434             :     case UNCACHED_EXTERNAL_ONE_BYTE_STRING_TYPE:
     435             :     case UNCACHED_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE:
     436             :     case SMALL_ORDERED_HASH_MAP_TYPE:
     437             :     case SMALL_ORDERED_HASH_SET_TYPE:
     438             :     case SMALL_ORDERED_NAME_DICTIONARY_TYPE:
     439             :     case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE:
     440             :     case JS_STRING_ITERATOR_TYPE:
     441             :       // TODO(all): Handle these types too.
     442             :       os << "UNKNOWN TYPE " << map()->instance_type();
     443             :       UNREACHABLE();
     444             :       break;
     445             :   }
     446             : }
     447             : 
     448             : void ByteArray::ByteArrayPrint(std::ostream& os) {  // NOLINT
     449             :   PrintHeader(os, "ByteArray");
     450             :   os << "\n - length: " << length()
     451             :      << "\n - data-start: " << static_cast<void*>(GetDataStartAddress())
     452             :      << "\n";
     453             : }
     454             : 
     455             : void BytecodeArray::BytecodeArrayPrint(std::ostream& os) {  // NOLINT
     456             :   PrintHeader(os, "BytecodeArray");
     457             :   Disassemble(os);
     458             : }
     459             : 
     460             : 
     461             : void FreeSpace::FreeSpacePrint(std::ostream& os) {  // NOLINT
     462             :   os << "free space, size " << Size();
     463             : }
     464             : 
     465             : 
     466             : template <class Traits>
     467             : void FixedTypedArray<Traits>::FixedTypedArrayPrint(
     468             :     std::ostream& os) {  // NOLINT
     469             :   os << "fixed " << Traits::Designator();
     470             : }
     471             : 
     472             : bool JSObject::PrintProperties(std::ostream& os) {  // NOLINT
     473             :   if (HasFastProperties()) {
     474             :     DescriptorArray descs = map()->instance_descriptors();
     475             :     int nof_inobject_properties = map()->GetInObjectProperties();
     476             :     int i = 0;
     477             :     for (; i < map()->NumberOfOwnDescriptors(); i++) {
     478             :       os << "\n    ";
     479             :       descs->GetKey(i)->NamePrint(os);
     480             :       os << ": ";
     481             :       PropertyDetails details = descs->GetDetails(i);
     482             :       switch (details.location()) {
     483             :         case kField: {
     484             :           FieldIndex field_index = FieldIndex::ForDescriptor(map(), i);
     485             :           if (IsUnboxedDoubleField(field_index)) {
     486             :             os << "<unboxed double> " << RawFastDoublePropertyAt(field_index);
     487             :           } else {
     488             :             os << Brief(RawFastPropertyAt(field_index));
     489             :           }
     490             :           break;
     491             :         }
     492             :         case kDescriptor:
     493             :           os << Brief(descs->GetStrongValue(i));
     494             :           break;
     495             :       }
     496             :       os << " ";
     497             :       details.PrintAsFastTo(os, PropertyDetails::kForProperties);
     498             :       if (details.location() != kField) continue;
     499             :       int field_index = details.field_index();
     500             :       if (nof_inobject_properties <= field_index) {
     501             :         field_index -= nof_inobject_properties;
     502             :         os << " properties[" << field_index << "]";
     503             :       }
     504             :     }
     505             :     return i > 0;
     506             :   } else if (IsJSGlobalObject()) {
     507             :     JSGlobalObject::cast(*this)->global_dictionary()->Print(os);
     508             :   } else {
     509             :     property_dictionary()->Print(os);
     510             :   }
     511             :   return true;
     512             : }
     513             : 
     514             : namespace {
     515             : 
     516             : template <class T>
     517             : bool IsTheHoleAt(T array, int index) {
     518             :   return false;
     519             : }
     520             : 
     521             : template <>
     522             : bool IsTheHoleAt(FixedDoubleArray array, int index) {
     523             :   return array->is_the_hole(index);
     524             : }
     525             : 
     526             : template <class T>
     527             : double GetScalarElement(T array, int index) {
     528             :   if (IsTheHoleAt(array, index)) {
     529             :     return std::numeric_limits<double>::quiet_NaN();
     530             :   }
     531             :   return array->get_scalar(index);
     532             : }
     533             : 
     534             : template <class T>
     535             : void DoPrintElements(std::ostream& os, Object object) {  // NOLINT
     536             :   const bool print_the_hole = std::is_same<T, FixedDoubleArray>::value;
     537             :   T array = T::cast(object);
     538             :   if (array->length() == 0) return;
     539             :   int previous_index = 0;
     540             :   double previous_value = GetScalarElement(array, 0);
     541             :   double value = 0.0;
     542             :   int i;
     543             :   for (i = 1; i <= array->length(); i++) {
     544             :     if (i < array->length()) value = GetScalarElement(array, i);
     545             :     bool values_are_nan = std::isnan(previous_value) && std::isnan(value);
     546             :     if (i != array->length() && (previous_value == value || values_are_nan) &&
     547             :         IsTheHoleAt(array, i - 1) == IsTheHoleAt(array, i)) {
     548             :       continue;
     549             :     }
     550             :     os << "\n";
     551             :     std::stringstream ss;
     552             :     ss << previous_index;
     553             :     if (previous_index != i - 1) {
     554             :       ss << '-' << (i - 1);
     555             :     }
     556             :     os << std::setw(12) << ss.str() << ": ";
     557             :     if (print_the_hole && IsTheHoleAt(array, i - 1)) {
     558             :       os << "<the_hole>";
     559             :     } else {
     560             :       os << previous_value;
     561             :     }
     562             :     previous_index = i;
     563             :     previous_value = value;
     564             :   }
     565             : }
     566             : 
     567             : template <typename T>
     568             : void PrintFixedArrayElements(std::ostream& os, T array) {
     569             :   // Print in array notation for non-sparse arrays.
     570             :   Object previous_value = array->length() > 0 ? array->get(0) : Object();
     571             :   Object value;
     572             :   int previous_index = 0;
     573             :   int i;
     574             :   for (i = 1; i <= array->length(); i++) {
     575             :     if (i < array->length()) value = array->get(i);
     576             :     if (previous_value == value && i != array->length()) {
     577             :       continue;
     578             :     }
     579             :     os << "\n";
     580             :     std::stringstream ss;
     581             :     ss << previous_index;
     582             :     if (previous_index != i - 1) {
     583             :       ss << '-' << (i - 1);
     584             :     }
     585             :     os << std::setw(12) << ss.str() << ": " << Brief(previous_value);
     586             :     previous_index = i;
     587             :     previous_value = value;
     588             :   }
     589             : }
     590             : 
     591             : void PrintDictionaryElements(std::ostream& os, FixedArrayBase elements) {
     592             :   // Print some internal fields
     593             :   NumberDictionary dict = NumberDictionary::cast(elements);
     594             :   if (dict->requires_slow_elements()) {
     595             :     os << "\n   - requires_slow_elements";
     596             :   } else {
     597             :     os << "\n   - max_number_key: " << dict->max_number_key();
     598             :   }
     599             :   dict->Print(os);
     600             : }
     601             : 
     602             : void PrintSloppyArgumentElements(std::ostream& os, ElementsKind kind,
     603             :                                  SloppyArgumentsElements elements) {
     604             :   FixedArray arguments_store = elements->arguments();
     605             :   os << "\n    0: context: " << Brief(elements->context())
     606             :      << "\n    1: arguments_store: " << Brief(arguments_store)
     607             :      << "\n    parameter to context slot map:";
     608             :   for (uint32_t i = 0; i < elements->parameter_map_length(); i++) {
     609             :     uint32_t raw_index = i + SloppyArgumentsElements::kParameterMapStart;
     610             :     Object mapped_entry = elements->get_mapped_entry(i);
     611             :     os << "\n    " << raw_index << ": param(" << i
     612             :        << "): " << Brief(mapped_entry);
     613             :     if (mapped_entry->IsTheHole()) {
     614             :       os << " in the arguments_store[" << i << "]";
     615             :     } else {
     616             :       os << " in the context";
     617             :     }
     618             :   }
     619             :   if (arguments_store->length() == 0) return;
     620             :   os << "\n }"
     621             :      << "\n - arguments_store: " << Brief(arguments_store) << " "
     622             :      << ElementsKindToString(arguments_store->map()->elements_kind()) << " {";
     623             :   if (kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS) {
     624             :     PrintFixedArrayElements(os, arguments_store);
     625             :   } else {
     626             :     DCHECK_EQ(kind, SLOW_SLOPPY_ARGUMENTS_ELEMENTS);
     627             :     PrintDictionaryElements(os, arguments_store);
     628             :   }
     629             : }
     630             : 
     631             : void PrintEmbedderData(std::ostream& os, EmbedderDataSlot slot) {
     632             :   DisallowHeapAllocation no_gc;
     633             :   Object value = slot.load_tagged();
     634             :   os << Brief(value);
     635             :   void* raw_pointer;
     636             :   if (slot.ToAlignedPointer(&raw_pointer)) {
     637             :     os << ", aligned pointer: " << raw_pointer;
     638             :   }
     639             : }
     640             : 
     641             : }  // namespace
     642             : 
     643             : void JSObject::PrintElements(std::ostream& os) {  // NOLINT
     644             :   // Don't call GetElementsKind, its validation code can cause the printer to
     645             :   // fail when debugging.
     646             :   os << " - elements: " << Brief(elements()) << " {";
     647             :   if (elements()->length() == 0) {
     648             :     os << " }\n";
     649             :     return;
     650             :   }
     651             :   switch (map()->elements_kind()) {
     652             :     case HOLEY_SMI_ELEMENTS:
     653             :     case PACKED_SMI_ELEMENTS:
     654             :     case HOLEY_ELEMENTS:
     655             :     case PACKED_ELEMENTS:
     656             :     case FAST_STRING_WRAPPER_ELEMENTS: {
     657             :       PrintFixedArrayElements(os, FixedArray::cast(elements()));
     658             :       break;
     659             :     }
     660             :     case HOLEY_DOUBLE_ELEMENTS:
     661             :     case PACKED_DOUBLE_ELEMENTS: {
     662             :       DoPrintElements<FixedDoubleArray>(os, elements());
     663             :       break;
     664             :     }
     665             : 
     666             : #define PRINT_ELEMENTS(Type, type, TYPE, elementType)    \
     667             :   case TYPE##_ELEMENTS: {                                \
     668             :     DoPrintElements<Fixed##Type##Array>(os, elements()); \
     669             :     break;                                               \
     670             :   }
     671             :       TYPED_ARRAYS(PRINT_ELEMENTS)
     672             : #undef PRINT_ELEMENTS
     673             : 
     674             :     case DICTIONARY_ELEMENTS:
     675             :     case SLOW_STRING_WRAPPER_ELEMENTS:
     676             :       PrintDictionaryElements(os, elements());
     677             :       break;
     678             :     case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
     679             :     case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
     680             :       PrintSloppyArgumentElements(os, map()->elements_kind(),
     681             :                                   SloppyArgumentsElements::cast(elements()));
     682             :       break;
     683             :     case NO_ELEMENTS:
     684             :       break;
     685             :   }
     686             :   os << "\n }\n";
     687             : }
     688             : 
     689             : static void JSObjectPrintHeader(std::ostream& os, JSObject obj,
     690             :                                 const char* id) {  // NOLINT
     691             :   Isolate* isolate = obj->GetIsolate();
     692             :   obj->PrintHeader(os, id);
     693             :   // Don't call GetElementsKind, its validation code can cause the printer to
     694             :   // fail when debugging.
     695             :   os << " [";
     696             :   if (obj->HasFastProperties()) {
     697             :     os << "FastProperties";
     698             :   } else {
     699             :     os << "DictionaryProperties";
     700             :   }
     701             :   PrototypeIterator iter(isolate, obj);
     702             :   os << "]\n - prototype: " << Brief(iter.GetCurrent());
     703             :   os << "\n - elements: " << Brief(obj->elements()) << " ["
     704             :      << ElementsKindToString(obj->map()->elements_kind());
     705             :   if (obj->elements()->IsCowArray()) os << " (COW)";
     706             :   os << "]";
     707             :   Object hash = obj->GetHash();
     708             :   if (hash->IsSmi()) {
     709             :     os << "\n - hash: " << Brief(hash);
     710             :   }
     711             :   if (obj->GetEmbedderFieldCount() > 0) {
     712             :     os << "\n - embedder fields: " << obj->GetEmbedderFieldCount();
     713             :   }
     714             : }
     715             : 
     716             : static void JSObjectPrintBody(std::ostream& os,
     717             :                               JSObject obj,  // NOLINT
     718             :                               bool print_elements = true) {
     719             :   os << "\n - properties: ";
     720             :   Object properties_or_hash = obj->raw_properties_or_hash();
     721             :   if (!properties_or_hash->IsSmi()) {
     722             :     os << Brief(properties_or_hash);
     723             :   }
     724             :   os << " {";
     725             :   if (obj->PrintProperties(os)) os << "\n ";
     726             :   os << "}\n";
     727             :   if (print_elements && obj->elements()->length() > 0) {
     728             :     obj->PrintElements(os);
     729             :   }
     730             :   int embedder_fields = obj->GetEmbedderFieldCount();
     731             :   if (embedder_fields > 0) {
     732             :     os << " - embedder fields = {";
     733             :     for (int i = 0; i < embedder_fields; i++) {
     734             :       os << "\n    ";
     735             :       PrintEmbedderData(os, EmbedderDataSlot(obj, i));
     736             :     }
     737             :     os << "\n }\n";
     738             :   }
     739             : }
     740             : 
     741             : void JSObject::JSObjectPrint(std::ostream& os) {  // NOLINT
     742             :   JSObjectPrintHeader(os, *this, nullptr);
     743             :   JSObjectPrintBody(os, *this);
     744             : }
     745             : 
     746             : void JSGeneratorObject::JSGeneratorObjectPrint(std::ostream& os) {  // NOLINT
     747             :   JSObjectPrintHeader(os, *this, "JSGeneratorObject");
     748             :   os << "\n - function: " << Brief(function());
     749             :   os << "\n - context: " << Brief(context());
     750             :   os << "\n - receiver: " << Brief(receiver());
     751             :   if (is_executing() || is_closed()) {
     752             :     os << "\n - input: " << Brief(input_or_debug_pos());
     753             :   } else {
     754             :     DCHECK(is_suspended());
     755             :     os << "\n - debug pos: " << Brief(input_or_debug_pos());
     756             :   }
     757             :   const char* mode = "(invalid)";
     758             :   switch (resume_mode()) {
     759             :     case kNext:
     760             :       mode = ".next()";
     761             :       break;
     762             :     case kReturn:
     763             :       mode = ".return()";
     764             :       break;
     765             :     case kThrow:
     766             :       mode = ".throw()";
     767             :       break;
     768             :   }
     769             :   os << "\n - resume mode: " << mode;
     770             :   os << "\n - continuation: " << continuation();
     771             :   if (is_closed()) os << " (closed)";
     772             :   if (is_executing()) os << " (executing)";
     773             :   if (is_suspended()) os << " (suspended)";
     774             :   if (is_suspended()) {
     775             :     DisallowHeapAllocation no_gc;
     776             :     SharedFunctionInfo fun_info = function()->shared();
     777             :     if (fun_info->HasSourceCode()) {
     778             :       Script script = Script::cast(fun_info->script());
     779             :       int lin = script->GetLineNumber(source_position()) + 1;
     780             :       int col = script->GetColumnNumber(source_position()) + 1;
     781             :       String script_name = script->name()->IsString()
     782             :                                ? String::cast(script->name())
     783             :                                : GetReadOnlyRoots().empty_string();
     784             :       os << "\n - source position: " << source_position();
     785             :       os << " (";
     786             :       script_name->PrintUC16(os);
     787             :       os << ", lin " << lin;
     788             :       os << ", col " << col;
     789             :       os << ")";
     790             :     }
     791             :   }
     792             :   os << "\n - register file: " << Brief(parameters_and_registers());
     793             :   JSObjectPrintBody(os, *this);
     794             : }
     795             : 
     796             : void JSArray::JSArrayPrint(std::ostream& os) {  // NOLINT
     797             :   JSObjectPrintHeader(os, *this, "JSArray");
     798             :   os << "\n - length: " << Brief(this->length());
     799             :   JSObjectPrintBody(os, *this);
     800             : }
     801             : 
     802             : void JSPromise::JSPromisePrint(std::ostream& os) {  // NOLINT
     803             :   JSObjectPrintHeader(os, *this, "JSPromise");
     804             :   os << "\n - status: " << JSPromise::Status(status());
     805             :   if (status() == Promise::kPending) {
     806             :     os << "\n - reactions: " << Brief(reactions());
     807             :   } else {
     808             :     os << "\n - result: " << Brief(result());
     809             :   }
     810             :   os << "\n - has_handler: " << has_handler();
     811             :   JSObjectPrintBody(os, *this);
     812             : }
     813             : 
     814             : void JSRegExp::JSRegExpPrint(std::ostream& os) {  // NOLINT
     815             :   JSObjectPrintHeader(os, *this, "JSRegExp");
     816             :   os << "\n - data: " << Brief(data());
     817             :   os << "\n - source: " << Brief(source());
     818             :   JSObjectPrintBody(os, *this);
     819             : }
     820             : 
     821             : void JSRegExpStringIterator::JSRegExpStringIteratorPrint(
     822             :     std::ostream& os) {  // NOLINT
     823             :   JSObjectPrintHeader(os, *this, "JSRegExpStringIterator");
     824             :   os << "\n - regex: " << Brief(iterating_regexp());
     825             :   os << "\n - string: " << Brief(iterating_string());
     826             :   os << "\n - done: " << done();
     827             :   os << "\n - global: " << global();
     828             :   os << "\n - unicode: " << unicode();
     829             :   JSObjectPrintBody(os, *this);
     830             : }
     831             : 
     832             : void Symbol::SymbolPrint(std::ostream& os) {  // NOLINT
     833             :   PrintHeader(os, "Symbol");
     834             :   os << "\n - hash: " << Hash();
     835             :   os << "\n - name: " << Brief(name());
     836             :   if (name()->IsUndefined()) {
     837             :     os << " (" << PrivateSymbolToName() << ")";
     838             :   }
     839             :   os << "\n - private: " << is_private();
     840             : }
     841             : 
     842             : 
     843             : void DescriptorArray::DescriptorArrayPrint(std::ostream& os) {
     844             :   PrintHeader(os, "DescriptorArray");
     845             :   os << "\n - enum_cache: ";
     846             :   if (enum_cache()->keys()->length() == 0) {
     847             :     os << "empty";
     848             :   } else {
     849             :     os << enum_cache()->keys()->length();
     850             :     os << "\n   - keys: " << Brief(enum_cache()->keys());
     851             :     os << "\n   - indices: " << Brief(enum_cache()->indices());
     852             :   }
     853             :   os << "\n - nof slack descriptors: " << number_of_slack_descriptors();
     854             :   os << "\n - nof descriptors: " << number_of_descriptors();
     855             :   int16_t raw_marked = raw_number_of_marked_descriptors();
     856             :   os << "\n - raw marked descriptors: mc epoch "
     857             :      << NumberOfMarkedDescriptors::Epoch::decode(raw_marked) << ", marked "
     858             :      << NumberOfMarkedDescriptors::Marked::decode(raw_marked);
     859             :   PrintDescriptors(os);
     860             : }
     861             : 
     862             : void AliasedArgumentsEntry::AliasedArgumentsEntryPrint(
     863             :     std::ostream& os) {  // NOLINT
     864             :   PrintHeader(os, "AliasedArgumentsEntry");
     865             :   os << "\n - aliased_context_slot: " << aliased_context_slot();
     866             : }
     867             : 
     868             : namespace {
     869             : void PrintFixedArrayWithHeader(std::ostream& os, FixedArray array,
     870             :                                const char* type) {
     871             :   array->PrintHeader(os, type);
     872             :   os << "\n - length: " << array->length();
     873             :   PrintFixedArrayElements(os, array);
     874             :   os << "\n";
     875             : }
     876             : 
     877             : template <typename T>
     878             : void PrintHashTableWithHeader(std::ostream& os, T table, const char* type) {
     879             :   table->PrintHeader(os, type);
     880             :   os << "\n - length: " << table->length();
     881             :   os << "\n - elements: " << table->NumberOfElements();
     882             :   os << "\n - deleted: " << table->NumberOfDeletedElements();
     883             :   os << "\n - capacity: " << table->Capacity();
     884             : 
     885             :   os << "\n - elements: {";
     886             :   for (int i = 0; i < table->Capacity(); i++) {
     887             :     os << '\n'
     888             :        << std::setw(12) << i << ": " << Brief(table->KeyAt(i)) << " -> "
     889             :        << Brief(table->ValueAt(i));
     890             :   }
     891             :   os << "\n }\n";
     892             : }
     893             : 
     894             : template <typename T>
     895             : void PrintWeakArrayElements(std::ostream& os, T* array) {
     896             :   // Print in array notation for non-sparse arrays.
     897             :   MaybeObject previous_value =
     898             :       array->length() > 0 ? array->Get(0) : MaybeObject(kNullAddress);
     899             :   MaybeObject value;
     900             :   int previous_index = 0;
     901             :   int i;
     902             :   for (i = 1; i <= array->length(); i++) {
     903             :     if (i < array->length()) value = array->Get(i);
     904             :     if (previous_value == value && i != array->length()) {
     905             :       continue;
     906             :     }
     907             :     os << "\n";
     908             :     std::stringstream ss;
     909             :     ss << previous_index;
     910             :     if (previous_index != i - 1) {
     911             :       ss << '-' << (i - 1);
     912             :     }
     913             :     os << std::setw(12) << ss.str() << ": " << Brief(previous_value);
     914             :     previous_index = i;
     915             :     previous_value = value;
     916             :   }
     917             : }
     918             : 
     919             : }  // namespace
     920             : 
     921             : void EmbedderDataArray::EmbedderDataArrayPrint(std::ostream& os) {
     922             :   PrintHeader(os, "EmbedderDataArray");
     923             :   os << "\n - length: " << length();
     924             :   EmbedderDataSlot start(*this, 0);
     925             :   EmbedderDataSlot end(*this, length());
     926             :   for (EmbedderDataSlot slot = start; slot < end; ++slot) {
     927             :     os << "\n    ";
     928             :     PrintEmbedderData(os, slot);
     929             :   }
     930             :   os << "\n";
     931             : }
     932             : 
     933             : void FixedArray::FixedArrayPrint(std::ostream& os) {
     934             :   PrintFixedArrayWithHeader(os, *this, "FixedArray");
     935             : }
     936             : 
     937             : namespace {
     938             : void PrintContextWithHeader(std::ostream& os, Context context,
     939             :                             const char* type) {
     940             :   context->PrintHeader(os, type);
     941             :   os << "\n - length: " << context->length();
     942             :   os << "\n - scope_info: " << Brief(context->scope_info());
     943             :   os << "\n - previous: " << Brief(context->previous());
     944             :   os << "\n - extension_object: " << Brief(context->extension_object());
     945             :   os << "\n - native_context: " << Brief(context->native_context());
     946             :   PrintFixedArrayElements(os, context);
     947             :   os << "\n";
     948             : }
     949             : }  // namespace
     950             : 
     951             : void Context::ContextPrint(std::ostream& os) {
     952             :   PrintContextWithHeader(os, *this, "Context");
     953             : }
     954             : 
     955             : void NativeContext::NativeContextPrint(std::ostream& os) {
     956             :   PrintContextWithHeader(os, *this, "NativeContext");
     957             :   os << " - microtask_queue: " << microtask_queue() << "\n";
     958             : }
     959             : 
     960             : void ObjectHashTable::ObjectHashTablePrint(std::ostream& os) {
     961             :   PrintHashTableWithHeader(os, *this, "ObjectHashTable");
     962             : }
     963             : 
     964             : void NumberDictionary::NumberDictionaryPrint(std::ostream& os) {
     965             :   PrintHashTableWithHeader(os, *this, "NumberDictionary");
     966             : }
     967             : 
     968             : void EphemeronHashTable::EphemeronHashTablePrint(std::ostream& os) {
     969             :   PrintHashTableWithHeader(os, *this, "EphemeronHashTable");
     970             : }
     971             : 
     972             : void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionPrint(
     973             :     std::ostream& os) {
     974             :   PrintFixedArrayWithHeader(os, *this, "ObjectBoilerplateDescription");
     975             : }
     976             : 
     977             : void PropertyArray::PropertyArrayPrint(std::ostream& os) {  // NOLINT
     978             :   PrintHeader(os, "PropertyArray");
     979             :   os << "\n - length: " << length();
     980             :   os << "\n - hash: " << Hash();
     981             :   PrintFixedArrayElements(os, *this);
     982             :   os << "\n";
     983             : }
     984             : 
     985             : void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) {  // NOLINT
     986             :   PrintHeader(os, "FixedDoubleArray");
     987             :   os << "\n - length: " << length();
     988             :   DoPrintElements<FixedDoubleArray>(os, *this);
     989             :   os << "\n";
     990             : }
     991             : 
     992             : void WeakFixedArray::WeakFixedArrayPrint(std::ostream& os) {
     993             :   PrintHeader(os, "WeakFixedArray");
     994             :   os << "\n - length: " << length() << "\n";
     995             :   PrintWeakArrayElements(os, this);
     996             :   os << "\n";
     997             : }
     998             : 
     999             : void WeakArrayList::WeakArrayListPrint(std::ostream& os) {
    1000             :   PrintHeader(os, "WeakArrayList");
    1001             :   os << "\n - capacity: " << capacity();
    1002             :   os << "\n - length: " << length() << "\n";
    1003             :   PrintWeakArrayElements(os, this);
    1004             :   os << "\n";
    1005             : }
    1006             : 
    1007             : void TransitionArray::TransitionArrayPrint(std::ostream& os) {  // NOLINT
    1008             :   PrintHeader(os, "TransitionArray");
    1009             :   PrintInternal(os);
    1010             : }
    1011             : 
    1012             : void FeedbackCell::FeedbackCellPrint(std::ostream& os) {  // NOLINT
    1013             :   PrintHeader(os, "FeedbackCell");
    1014             :   ReadOnlyRoots roots = GetReadOnlyRoots();
    1015             :   if (map() == roots.no_closures_cell_map()) {
    1016             :     os << "\n - no closures";
    1017             :   } else if (map() == roots.one_closure_cell_map()) {
    1018             :     os << "\n - one closure";
    1019             :   } else if (map() == roots.many_closures_cell_map()) {
    1020             :     os << "\n - many closures";
    1021             :   } else {
    1022             :     os << "\n - Invalid FeedbackCell map";
    1023             :   }
    1024             :   os << " - value: " << Brief(value());
    1025             :   os << "\n";
    1026             : }
    1027             : 
    1028             : void FeedbackVectorSpec::Print() {
    1029             :   StdoutStream os;
    1030             : 
    1031             :   FeedbackVectorSpecPrint(os);
    1032             : 
    1033             :   os << std::flush;
    1034             : }
    1035             : 
    1036             : void FeedbackVectorSpec::FeedbackVectorSpecPrint(std::ostream& os) {  // NOLINT
    1037             :   int slot_count = slots();
    1038             :   os << " - slot_count: " << slot_count;
    1039             :   if (slot_count == 0) {
    1040             :     os << " (empty)\n";
    1041             :     return;
    1042             :   }
    1043             : 
    1044             :   for (int slot = 0; slot < slot_count;) {
    1045             :     FeedbackSlotKind kind = GetKind(FeedbackSlot(slot));
    1046             :     int entry_size = FeedbackMetadata::GetSlotSize(kind);
    1047             :     DCHECK_LT(0, entry_size);
    1048             :     os << "\n Slot #" << slot << " " << kind;
    1049             :     slot += entry_size;
    1050             :   }
    1051             :   os << "\n";
    1052             : }
    1053             : 
    1054             : void FeedbackMetadata::FeedbackMetadataPrint(std::ostream& os) {
    1055             :   PrintHeader(os, "FeedbackMetadata");
    1056             :   os << "\n - slot_count: " << slot_count();
    1057             : 
    1058             :   FeedbackMetadataIterator iter(*this);
    1059             :   while (iter.HasNext()) {
    1060             :     FeedbackSlot slot = iter.Next();
    1061             :     FeedbackSlotKind kind = iter.kind();
    1062             :     os << "\n Slot " << slot << " " << kind;
    1063             :   }
    1064             :   os << "\n";
    1065             : }
    1066             : 
    1067             : void FeedbackVector::FeedbackVectorPrint(std::ostream& os) {  // NOLINT
    1068             :   PrintHeader(os, "FeedbackVector");
    1069             :   os << "\n - length: " << length();
    1070             :   if (length() == 0) {
    1071             :     os << " (empty)\n";
    1072             :     return;
    1073             :   }
    1074             : 
    1075             :   os << "\n - shared function info: " << Brief(shared_function_info());
    1076             :   os << "\n - optimized code/marker: ";
    1077             :   if (has_optimized_code()) {
    1078             :     os << Brief(optimized_code());
    1079             :   } else {
    1080             :     os << optimization_marker();
    1081             :   }
    1082             :   os << "\n - invocation count: " << invocation_count();
    1083             :   os << "\n - profiler ticks: " << profiler_ticks();
    1084             : 
    1085             :   FeedbackMetadataIterator iter(metadata());
    1086             :   while (iter.HasNext()) {
    1087             :     FeedbackSlot slot = iter.Next();
    1088             :     FeedbackSlotKind kind = iter.kind();
    1089             : 
    1090             :     os << "\n - slot " << slot << " " << kind << " ";
    1091             :     FeedbackSlotPrint(os, slot);
    1092             : 
    1093             :     int entry_size = iter.entry_size();
    1094             :     if (entry_size > 0) os << " {";
    1095             :     for (int i = 0; i < entry_size; i++) {
    1096             :       int index = GetIndex(slot) + i;
    1097             :       os << "\n     [" << index << "]: " << Brief(get(index));
    1098             :     }
    1099             :     if (entry_size > 0) os << "\n  }";
    1100             :   }
    1101             :   os << "\n";
    1102             : }
    1103             : 
    1104             : void FeedbackVector::FeedbackSlotPrint(std::ostream& os,
    1105             :                                        FeedbackSlot slot) {  // NOLINT
    1106             :   FeedbackNexus nexus(*this, slot);
    1107             :   nexus.Print(os);
    1108             : }
    1109             : 
    1110             : void FeedbackNexus::Print(std::ostream& os) {  // NOLINT
    1111             :   switch (kind()) {
    1112             :     case FeedbackSlotKind::kCall:
    1113             :     case FeedbackSlotKind::kLoadProperty:
    1114             :     case FeedbackSlotKind::kLoadKeyed:
    1115             :     case FeedbackSlotKind::kLoadGlobalInsideTypeof:
    1116             :     case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
    1117             :     case FeedbackSlotKind::kStoreNamedSloppy:
    1118             :     case FeedbackSlotKind::kStoreNamedStrict:
    1119             :     case FeedbackSlotKind::kStoreOwnNamed:
    1120             :     case FeedbackSlotKind::kStoreGlobalSloppy:
    1121             :     case FeedbackSlotKind::kStoreGlobalStrict:
    1122             :     case FeedbackSlotKind::kStoreKeyedSloppy:
    1123             :     case FeedbackSlotKind::kInstanceOf:
    1124             :     case FeedbackSlotKind::kStoreDataPropertyInLiteral:
    1125             :     case FeedbackSlotKind::kStoreKeyedStrict:
    1126             :     case FeedbackSlotKind::kStoreInArrayLiteral:
    1127             :     case FeedbackSlotKind::kCloneObject: {
    1128             :       os << InlineCacheState2String(StateFromFeedback());
    1129             :       break;
    1130             :     }
    1131             :     case FeedbackSlotKind::kBinaryOp: {
    1132             :       os << "BinaryOp:" << GetBinaryOperationFeedback();
    1133             :       break;
    1134             :     }
    1135             :     case FeedbackSlotKind::kCompareOp: {
    1136             :       os << "CompareOp:" << GetCompareOperationFeedback();
    1137             :       break;
    1138             :     }
    1139             :     case FeedbackSlotKind::kForIn: {
    1140             :       os << "ForIn:" << GetForInFeedback();
    1141             :       break;
    1142             :     }
    1143             :     case FeedbackSlotKind::kCreateClosure:
    1144             :     case FeedbackSlotKind::kLiteral:
    1145             :     case FeedbackSlotKind::kTypeProfile:
    1146             :       break;
    1147             :     case FeedbackSlotKind::kInvalid:
    1148             :     case FeedbackSlotKind::kKindsNumber:
    1149             :       UNREACHABLE();
    1150             :       break;
    1151             :   }
    1152             : }
    1153             : 
    1154             : void JSValue::JSValuePrint(std::ostream& os) {  // NOLINT
    1155             :   JSObjectPrintHeader(os, *this, "JSValue");
    1156             :   os << "\n - value: " << Brief(value());
    1157             :   JSObjectPrintBody(os, *this);
    1158             : }
    1159             : 
    1160             : void JSMessageObject::JSMessageObjectPrint(std::ostream& os) {  // NOLINT
    1161             :   JSObjectPrintHeader(os, *this, "JSMessageObject");
    1162             :   os << "\n - type: " << static_cast<int>(type());
    1163             :   os << "\n - arguments: " << Brief(argument());
    1164             :   os << "\n - start_position: " << start_position();
    1165             :   os << "\n - end_position: " << end_position();
    1166             :   os << "\n - script: " << Brief(script());
    1167             :   os << "\n - stack_frames: " << Brief(stack_frames());
    1168             :   JSObjectPrintBody(os, *this);
    1169             : }
    1170             : 
    1171             : 
    1172             : void String::StringPrint(std::ostream& os) {  // NOLINT
    1173             :   if (!HasOnlyOneByteChars()) {
    1174             :     os << "u";
    1175             :   }
    1176             :   if (StringShape(*this).IsInternalized()) {
    1177             :     os << "#";
    1178             :   } else if (StringShape(*this).IsCons()) {
    1179             :     os << "c\"";
    1180             :   } else if (StringShape(*this).IsThin()) {
    1181             :     os << ">\"";
    1182             :   } else {
    1183             :     os << "\"";
    1184             :   }
    1185             : 
    1186             :   const char truncated_epilogue[] = "...<truncated>";
    1187             :   int len = length();
    1188             :   if (!FLAG_use_verbose_printer) {
    1189             :     if (len > 100) {
    1190             :       len = 100 - sizeof(truncated_epilogue);
    1191             :     }
    1192             :   }
    1193             :   for (int i = 0; i < len; i++) {
    1194             :     os << AsUC16(Get(i));
    1195             :   }
    1196             :   if (len != length()) {
    1197             :     os << truncated_epilogue;
    1198             :   }
    1199             : 
    1200             :   if (!StringShape(*this).IsInternalized()) os << "\"";
    1201             : }
    1202             : 
    1203             : 
    1204             : void Name::NamePrint(std::ostream& os) {  // NOLINT
    1205             :   if (IsString()) {
    1206             :     String::cast(*this)->StringPrint(os);
    1207             :   } else {
    1208             :     os << Brief(*this);
    1209             :   }
    1210             : }
    1211             : 
    1212             : 
    1213             : static const char* const weekdays[] = {
    1214             :   "???", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
    1215             : };
    1216             : 
    1217             : void JSDate::JSDatePrint(std::ostream& os) {  // NOLINT
    1218             :   JSObjectPrintHeader(os, *this, "JSDate");
    1219             :   os << "\n - value: " << Brief(value());
    1220             :   if (!year()->IsSmi()) {
    1221             :     os << "\n - time = NaN\n";
    1222             :   } else {
    1223             :     // TODO(svenpanne) Add some basic formatting to our streams.
    1224             :     ScopedVector<char> buf(100);
    1225             :     SNPrintF(buf, "\n - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
    1226             :              weekdays[weekday()->IsSmi() ? Smi::ToInt(weekday()) + 1 : 0],
    1227             :              year()->IsSmi() ? Smi::ToInt(year()) : -1,
    1228             :              month()->IsSmi() ? Smi::ToInt(month()) : -1,
    1229             :              day()->IsSmi() ? Smi::ToInt(day()) : -1,
    1230             :              hour()->IsSmi() ? Smi::ToInt(hour()) : -1,
    1231             :              min()->IsSmi() ? Smi::ToInt(min()) : -1,
    1232             :              sec()->IsSmi() ? Smi::ToInt(sec()) : -1);
    1233             :     os << buf.start();
    1234             :   }
    1235             :   JSObjectPrintBody(os, *this);
    1236             : }
    1237             : 
    1238             : 
    1239             : void JSProxy::JSProxyPrint(std::ostream& os) {  // NOLINT
    1240             :   PrintHeader(os, "JSProxy");
    1241             :   os << "\n - target: ";
    1242             :   target()->ShortPrint(os);
    1243             :   os << "\n - handler: ";
    1244             :   handler()->ShortPrint(os);
    1245             :   os << "\n";
    1246             : }
    1247             : 
    1248             : void JSSet::JSSetPrint(std::ostream& os) {  // NOLINT
    1249             :   JSObjectPrintHeader(os, *this, "JSSet");
    1250             :   os << " - table: " << Brief(table());
    1251             :   JSObjectPrintBody(os, *this);
    1252             : }
    1253             : 
    1254             : void JSMap::JSMapPrint(std::ostream& os) {  // NOLINT
    1255             :   JSObjectPrintHeader(os, *this, "JSMap");
    1256             :   os << " - table: " << Brief(table());
    1257             :   JSObjectPrintBody(os, *this);
    1258             : }
    1259             : 
    1260             : void JSCollectionIterator::JSCollectionIteratorPrint(
    1261             :     std::ostream& os, const char* name) {  // NOLINT
    1262             :   JSObjectPrintHeader(os, *this, name);
    1263             :   os << "\n - table: " << Brief(table());
    1264             :   os << "\n - index: " << Brief(index());
    1265             :   JSObjectPrintBody(os, *this);
    1266             : }
    1267             : 
    1268             : void JSSetIterator::JSSetIteratorPrint(std::ostream& os) {  // NOLINT
    1269             :   JSCollectionIteratorPrint(os, "JSSetIterator");
    1270             : }
    1271             : 
    1272             : void JSMapIterator::JSMapIteratorPrint(std::ostream& os) {  // NOLINT
    1273             :   JSCollectionIteratorPrint(os, "JSMapIterator");
    1274             : }
    1275             : 
    1276             : void JSWeakCell::JSWeakCellPrint(std::ostream& os) {
    1277             :   JSObjectPrintHeader(os, *this, "JSWeakCell");
    1278             :   os << "\n - factory: " << Brief(factory());
    1279             :   os << "\n - target: " << Brief(target());
    1280             :   os << "\n - holdings: " << Brief(holdings());
    1281             :   os << "\n - prev: " << Brief(prev());
    1282             :   os << "\n - next: " << Brief(next());
    1283             :   JSObjectPrintBody(os, *this);
    1284             : }
    1285             : 
    1286             : void JSWeakRef::JSWeakRefPrint(std::ostream& os) {
    1287             :   JSObjectPrintHeader(os, *this, "JSWeakRef");
    1288             :   os << "\n - target: " << Brief(target());
    1289             :   JSObjectPrintBody(os, *this);
    1290             : }
    1291             : 
    1292             : void JSWeakFactory::JSWeakFactoryPrint(std::ostream& os) {
    1293             :   JSObjectPrintHeader(os, *this, "JSWeakFactory");
    1294             :   os << "\n - native_context: " << Brief(native_context());
    1295             :   os << "\n - cleanup: " << Brief(cleanup());
    1296             :   os << "\n - active_cells: " << Brief(active_cells());
    1297             :   os << "\n - cleared_cells: " << Brief(cleared_cells());
    1298             :   JSObjectPrintBody(os, *this);
    1299             : }
    1300             : 
    1301             : void JSWeakFactoryCleanupIterator::JSWeakFactoryCleanupIteratorPrint(
    1302             :     std::ostream& os) {
    1303             :   JSObjectPrintHeader(os, *this, "JSWeakFactoryCleanupIterator");
    1304             :   os << "\n - factory: " << Brief(factory());
    1305             :   JSObjectPrintBody(os, *this);
    1306             : }
    1307             : 
    1308             : void WeakFactoryCleanupJobTask::WeakFactoryCleanupJobTaskPrint(
    1309             :     std::ostream& os) {
    1310             :   PrintHeader(os, "WeakFactoryCleanupJobTask");
    1311             :   os << "\n - factory: " << Brief(factory());
    1312             : }
    1313             : 
    1314             : void JSWeakMap::JSWeakMapPrint(std::ostream& os) {  // NOLINT
    1315             :   JSObjectPrintHeader(os, *this, "JSWeakMap");
    1316             :   os << "\n - table: " << Brief(table());
    1317             :   JSObjectPrintBody(os, *this);
    1318             : }
    1319             : 
    1320             : void JSWeakSet::JSWeakSetPrint(std::ostream& os) {  // NOLINT
    1321             :   JSObjectPrintHeader(os, *this, "JSWeakSet");
    1322             :   os << "\n - table: " << Brief(table());
    1323             :   JSObjectPrintBody(os, *this);
    1324             : }
    1325             : 
    1326             : void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) {  // NOLINT
    1327             :   JSObjectPrintHeader(os, *this, "JSArrayBuffer");
    1328             :   os << "\n - backing_store: " << backing_store();
    1329             :   os << "\n - byte_length: " << byte_length();
    1330             :   if (is_external()) os << "\n - external";
    1331             :   if (is_detachable()) os << "\n - detachable";
    1332             :   if (was_detached()) os << "\n - detached";
    1333             :   if (is_shared()) os << "\n - shared";
    1334             :   if (is_wasm_memory()) os << "\n - is_wasm_memory";
    1335             :   if (is_growable()) os << "\n - growable";
    1336             :   JSObjectPrintBody(os, *this, !was_detached());
    1337             : }
    1338             : 
    1339             : void JSTypedArray::JSTypedArrayPrint(std::ostream& os) {  // NOLINT
    1340             :   JSObjectPrintHeader(os, *this, "JSTypedArray");
    1341             :   os << "\n - buffer: " << Brief(buffer());
    1342             :   os << "\n - byte_offset: " << byte_offset();
    1343             :   os << "\n - byte_length: " << byte_length();
    1344             :   os << "\n - length: " << Brief(length());
    1345             :   if (WasDetached()) os << "\n - detached";
    1346             :   JSObjectPrintBody(os, *this, !WasDetached());
    1347             : }
    1348             : 
    1349             : void JSArrayIterator::JSArrayIteratorPrint(std::ostream& os) {  // NOLING
    1350             :   JSObjectPrintHeader(os, *this, "JSArrayIterator");
    1351             :   os << "\n - iterated_object: " << Brief(iterated_object());
    1352             :   os << "\n - next_index: " << Brief(next_index());
    1353             :   os << "\n - kind: " << kind();
    1354             :   JSObjectPrintBody(os, *this);
    1355             : }
    1356             : 
    1357             : void JSDataView::JSDataViewPrint(std::ostream& os) {  // NOLINT
    1358             :   JSObjectPrintHeader(os, *this, "JSDataView");
    1359             :   os << "\n - buffer =" << Brief(buffer());
    1360             :   os << "\n - byte_offset: " << byte_offset();
    1361             :   os << "\n - byte_length: " << byte_length();
    1362             :   if (WasDetached()) os << "\n - detached";
    1363             :   JSObjectPrintBody(os, *this, !WasDetached());
    1364             : }
    1365             : 
    1366             : void JSBoundFunction::JSBoundFunctionPrint(std::ostream& os) {  // NOLINT
    1367             :   JSObjectPrintHeader(os, *this, "JSBoundFunction");
    1368             :   os << "\n - bound_target_function: " << Brief(bound_target_function());
    1369             :   os << "\n - bound_this: " << Brief(bound_this());
    1370             :   os << "\n - bound_arguments: " << Brief(bound_arguments());
    1371             :   JSObjectPrintBody(os, *this);
    1372             : }
    1373             : 
    1374             : void JSFunction::JSFunctionPrint(std::ostream& os) {  // NOLINT
    1375             :   Isolate* isolate = GetIsolate();
    1376             :   JSObjectPrintHeader(os, *this, "Function");
    1377             :   os << "\n - function prototype: ";
    1378             :   if (has_prototype_slot()) {
    1379             :     if (has_prototype()) {
    1380             :       os << Brief(prototype());
    1381             :       if (map()->has_non_instance_prototype()) {
    1382             :         os << " (non-instance prototype)";
    1383             :       }
    1384             :     }
    1385             :     os << "\n - initial_map: ";
    1386             :     if (has_initial_map()) os << Brief(initial_map());
    1387             :   } else {
    1388             :     os << "<no-prototype-slot>";
    1389             :   }
    1390             :   os << "\n - shared_info: " << Brief(shared());
    1391             :   os << "\n - name: " << Brief(shared()->Name());
    1392             : 
    1393             :   // Print Builtin name for builtin functions
    1394             :   int builtin_index = code()->builtin_index();
    1395             :   if (Builtins::IsBuiltinId(builtin_index) && !IsInterpreted()) {
    1396             :     os << "\n - builtin: " << isolate->builtins()->name(builtin_index);
    1397             :   }
    1398             : 
    1399             :   os << "\n - formal_parameter_count: "
    1400             :      << shared()->internal_formal_parameter_count();
    1401             :   os << "\n - kind: " << shared()->kind();
    1402             :   os << "\n - context: " << Brief(context());
    1403             :   os << "\n - code: " << Brief(code());
    1404             :   if (IsInterpreted()) {
    1405             :     os << "\n - interpreted";
    1406             :     if (shared()->HasBytecodeArray()) {
    1407             :       os << "\n - bytecode: " << shared()->GetBytecodeArray();
    1408             :     }
    1409             :   }
    1410             :   if (WasmExportedFunction::IsWasmExportedFunction(*this)) {
    1411             :     WasmExportedFunction function = WasmExportedFunction::cast(*this);
    1412             :     os << "\n - WASM instance "
    1413             :        << reinterpret_cast<void*>(function->instance()->ptr());
    1414             :     os << "\n - WASM function index " << function->function_index();
    1415             :   }
    1416             :   shared()->PrintSourceCode(os);
    1417             :   JSObjectPrintBody(os, *this);
    1418             :   os << "\n - feedback vector: ";
    1419             :   if (!shared()->HasFeedbackMetadata()) {
    1420             :     os << "feedback metadata is not available in SFI\n";
    1421             :   } else if (has_feedback_vector()) {
    1422             :     feedback_vector()->FeedbackVectorPrint(os);
    1423             :   } else {
    1424             :     os << "not available\n";
    1425             :   }
    1426             : }
    1427             : 
    1428             : void SharedFunctionInfo::PrintSourceCode(std::ostream& os) {
    1429             :   if (HasSourceCode()) {
    1430             :     os << "\n - source code: ";
    1431             :     String source = String::cast(Script::cast(script())->source());
    1432             :     int start = StartPosition();
    1433             :     int length = EndPosition() - start;
    1434             :     std::unique_ptr<char[]> source_string = source->ToCString(
    1435             :         DISALLOW_NULLS, FAST_STRING_TRAVERSAL, start, length, nullptr);
    1436             :     os << source_string.get();
    1437             :   }
    1438             : }
    1439             : 
    1440             : void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) {  // NOLINT
    1441             :   PrintHeader(os, "SharedFunctionInfo");
    1442             :   os << "\n - name: ";
    1443             :   if (HasSharedName()) {
    1444             :     os << Brief(Name());
    1445             :   } else {
    1446             :     os << "<no-shared-name>";
    1447             :   }
    1448             :   if (HasInferredName()) {
    1449             :     os << "\n - inferred name: " << Brief(inferred_name());
    1450             :   }
    1451             :   os << "\n - kind: " << kind();
    1452             :   if (needs_home_object()) {
    1453             :     os << "\n - needs_home_object";
    1454             :   }
    1455             :   os << "\n - function_map_index: " << function_map_index();
    1456             :   os << "\n - formal_parameter_count: " << internal_formal_parameter_count();
    1457             :   os << "\n - expected_nof_properties: " << expected_nof_properties();
    1458             :   os << "\n - language_mode: " << language_mode();
    1459             :   os << "\n - data: " << Brief(function_data());
    1460             :   os << "\n - code (from data): " << Brief(GetCode());
    1461             :   PrintSourceCode(os);
    1462             :   // Script files are often large, hard to read.
    1463             :   // os << "\n - script =";
    1464             :   // script()->Print(os);
    1465             :   if (is_named_expression()) {
    1466             :     os << "\n - named expression";
    1467             :   } else if (is_anonymous_expression()) {
    1468             :     os << "\n - anonymous expression";
    1469             :   } else if (is_declaration()) {
    1470             :     os << "\n - declaration";
    1471             :   }
    1472             :   os << "\n - function token position: " << function_token_position();
    1473             :   os << "\n - start position: " << StartPosition();
    1474             :   os << "\n - end position: " << EndPosition();
    1475             :   if (HasDebugInfo()) {
    1476             :     os << "\n - debug info: " << Brief(GetDebugInfo());
    1477             :   } else {
    1478             :     os << "\n - no debug info";
    1479             :   }
    1480             :   os << "\n - scope info: " << Brief(scope_info());
    1481             :   if (HasOuterScopeInfo()) {
    1482             :     os << "\n - outer scope info: " << Brief(GetOuterScopeInfo());
    1483             :   }
    1484             :   os << "\n - length: " << length();
    1485             :   os << "\n - feedback_metadata: ";
    1486             :   if (HasFeedbackMetadata()) {
    1487             :     feedback_metadata()->FeedbackMetadataPrint(os);
    1488             :   } else {
    1489             :     os << "<none>";
    1490             :   }
    1491             :   os << "\n";
    1492             : }
    1493             : 
    1494             : void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) {  // NOLINT
    1495             :   JSObjectPrintHeader(os, *this, "JSGlobalProxy");
    1496             :   if (!GetIsolate()->bootstrapper()->IsActive()) {
    1497             :     os << "\n - native context: " << Brief(native_context());
    1498             :   }
    1499             :   JSObjectPrintBody(os, *this);
    1500             : }
    1501             : 
    1502             : void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) {  // NOLINT
    1503             :   JSObjectPrintHeader(os, *this, "JSGlobalObject");
    1504             :   if (!GetIsolate()->bootstrapper()->IsActive()) {
    1505             :     os << "\n - native context: " << Brief(native_context());
    1506             :   }
    1507             :   os << "\n - global proxy: " << Brief(global_proxy());
    1508             :   JSObjectPrintBody(os, *this);
    1509             : }
    1510             : 
    1511             : void Cell::CellPrint(std::ostream& os) {  // NOLINT
    1512             :   PrintHeader(os, "Cell");
    1513             :   os << "\n - value: " << Brief(value());
    1514             :   os << "\n";
    1515             : }
    1516             : 
    1517             : void PropertyCell::PropertyCellPrint(std::ostream& os) {  // NOLINT
    1518             :   PrintHeader(os, "PropertyCell");
    1519             :   os << "\n - name: ";
    1520             :   name()->NamePrint(os);
    1521             :   os << "\n - value: " << Brief(value());
    1522             :   os << "\n - details: ";
    1523             :   property_details().PrintAsSlowTo(os);
    1524             :   PropertyCellType cell_type = property_details().cell_type();
    1525             :   os << "\n - cell_type: ";
    1526             :   if (value()->IsTheHole()) {
    1527             :     switch (cell_type) {
    1528             :       case PropertyCellType::kUninitialized:
    1529             :         os << "Uninitialized";
    1530             :         break;
    1531             :       case PropertyCellType::kInvalidated:
    1532             :         os << "Invalidated";
    1533             :         break;
    1534             :       default:
    1535             :         os << "??? " << static_cast<int>(cell_type);
    1536             :         break;
    1537             :     }
    1538             :   } else {
    1539             :     switch (cell_type) {
    1540             :       case PropertyCellType::kUndefined:
    1541             :         os << "Undefined";
    1542             :         break;
    1543             :       case PropertyCellType::kConstant:
    1544             :         os << "Constant";
    1545             :         break;
    1546             :       case PropertyCellType::kConstantType:
    1547             :         os << "ConstantType"
    1548             :            << " (";
    1549             :         switch (GetConstantType()) {
    1550             :           case PropertyCellConstantType::kSmi:
    1551             :             os << "Smi";
    1552             :             break;
    1553             :           case PropertyCellConstantType::kStableMap:
    1554             :             os << "StableMap";
    1555             :             break;
    1556             :         }
    1557             :         os << ")";
    1558             :         break;
    1559             :       case PropertyCellType::kMutable:
    1560             :         os << "Mutable";
    1561             :         break;
    1562             :     }
    1563             :   }
    1564             :   os << "\n";
    1565             : }
    1566             : 
    1567             : void Code::CodePrint(std::ostream& os) {  // NOLINT
    1568             :   PrintHeader(os, "Code");
    1569             :   os << "\n";
    1570             : #ifdef ENABLE_DISASSEMBLER
    1571             :   if (FLAG_use_verbose_printer) {
    1572             :     Disassemble(nullptr, os);
    1573             :   }
    1574             : #endif
    1575             : }
    1576             : 
    1577             : void CodeDataContainer::CodeDataContainerPrint(std::ostream& os) {  // NOLINT
    1578             :   PrintHeader(os, "CodeDataContainer");
    1579             :   os << "\n - kind_specific_flags: " << kind_specific_flags();
    1580             :   os << "\n";
    1581             : }
    1582             : 
    1583             : void Foreign::ForeignPrint(std::ostream& os) {  // NOLINT
    1584             :   os << "foreign address : " << reinterpret_cast<void*>(foreign_address());
    1585             :   os << "\n";
    1586             : }
    1587             : 
    1588             : 
    1589             : void AccessorInfo::AccessorInfoPrint(std::ostream& os) {  // NOLINT
    1590             :   PrintHeader(os, "AccessorInfo");
    1591             :   os << "\n - name: " << Brief(name());
    1592             :   os << "\n - flags: " << flags();
    1593             :   os << "\n - getter: " << Brief(getter());
    1594             :   os << "\n - setter: " << Brief(setter());
    1595             :   os << "\n - js_getter: " << Brief(js_getter());
    1596             :   os << "\n - data: " << Brief(data());
    1597             :   os << "\n";
    1598             : }
    1599             : 
    1600             : void CallbackTask::CallbackTaskPrint(std::ostream& os) {  // NOLINT
    1601             :   PrintHeader(os, "CallbackTask");
    1602             :   os << "\n - callback: " << Brief(callback());
    1603             :   os << "\n - data: " << Brief(data());
    1604             :   os << "\n";
    1605             : }
    1606             : 
    1607             : void CallableTask::CallableTaskPrint(std::ostream& os) {  // NOLINT
    1608             :   PrintHeader(os, "CallableTask");
    1609             :   os << "\n - context: " << Brief(context());
    1610             :   os << "\n - callable: " << Brief(callable());
    1611             :   os << "\n";
    1612             : }
    1613             : 
    1614             : void PromiseFulfillReactionJobTask::PromiseFulfillReactionJobTaskPrint(
    1615             :     std::ostream& os) {  // NOLINT
    1616             :   PrintHeader(os, "PromiseFulfillReactionJobTask");
    1617             :   os << "\n - argument: " << Brief(argument());
    1618             :   os << "\n - context: " << Brief(context());
    1619             :   os << "\n - handler: " << Brief(handler());
    1620             :   os << "\n - promise_or_capability: " << Brief(promise_or_capability());
    1621             :   os << "\n";
    1622             : }
    1623             : 
    1624             : void PromiseRejectReactionJobTask::PromiseRejectReactionJobTaskPrint(
    1625             :     std::ostream& os) {  // NOLINT
    1626             :   PrintHeader(os, "PromiseRejectReactionJobTask");
    1627             :   os << "\n - argument: " << Brief(argument());
    1628             :   os << "\n - context: " << Brief(context());
    1629             :   os << "\n - handler: " << Brief(handler());
    1630             :   os << "\n - promise_or_capability: " << Brief(promise_or_capability());
    1631             :   os << "\n";
    1632             : }
    1633             : 
    1634             : void PromiseResolveThenableJobTask::PromiseResolveThenableJobTaskPrint(
    1635             :     std::ostream& os) {  // NOLINT
    1636             :   PrintHeader(os, "PromiseResolveThenableJobTask");
    1637             :   os << "\n - context: " << Brief(context());
    1638             :   os << "\n - promise_to_resolve: " << Brief(promise_to_resolve());
    1639             :   os << "\n - then: " << Brief(then());
    1640             :   os << "\n - thenable: " << Brief(thenable());
    1641             :   os << "\n";
    1642             : }
    1643             : 
    1644             : void PromiseCapability::PromiseCapabilityPrint(std::ostream& os) {  // NOLINT
    1645             :   PrintHeader(os, "PromiseCapability");
    1646             :   os << "\n - promise: " << Brief(promise());
    1647             :   os << "\n - resolve: " << Brief(resolve());
    1648             :   os << "\n - reject: " << Brief(reject());
    1649             :   os << "\n";
    1650             : }
    1651             : 
    1652             : void PromiseReaction::PromiseReactionPrint(std::ostream& os) {  // NOLINT
    1653             :   PrintHeader(os, "PromiseReaction");
    1654             :   os << "\n - next: " << Brief(next());
    1655             :   os << "\n - reject_handler: " << Brief(reject_handler());
    1656             :   os << "\n - fulfill_handler: " << Brief(fulfill_handler());
    1657             :   os << "\n - promise_or_capability: " << Brief(promise_or_capability());
    1658             :   os << "\n";
    1659             : }
    1660             : 
    1661             : void AsyncGeneratorRequest::AsyncGeneratorRequestPrint(
    1662             :     std::ostream& os) {  // NOLINT
    1663             :   PrintHeader(os, "AsyncGeneratorRequest");
    1664             :   const char* mode = "Invalid!";
    1665             :   switch (resume_mode()) {
    1666             :     case JSGeneratorObject::kNext:
    1667             :       mode = ".next()";
    1668             :       break;
    1669             :     case JSGeneratorObject::kReturn:
    1670             :       mode = ".return()";
    1671             :       break;
    1672             :     case JSGeneratorObject::kThrow:
    1673             :       mode = ".throw()";
    1674             :       break;
    1675             :   }
    1676             :   os << "\n - resume mode: " << mode;
    1677             :   os << "\n - value: " << Brief(value());
    1678             :   os << "\n - next: " << Brief(next());
    1679             :   os << "\n";
    1680             : }
    1681             : 
    1682             : void ModuleInfoEntry::ModuleInfoEntryPrint(std::ostream& os) {  // NOLINT
    1683             :   PrintHeader(os, "ModuleInfoEntry");
    1684             :   os << "\n - export_name: " << Brief(export_name());
    1685             :   os << "\n - local_name: " << Brief(local_name());
    1686             :   os << "\n - import_name: " << Brief(import_name());
    1687             :   os << "\n - module_request: " << module_request();
    1688             :   os << "\n - cell_index: " << cell_index();
    1689             :   os << "\n - beg_pos: " << beg_pos();
    1690             :   os << "\n - end_pos: " << end_pos();
    1691             :   os << "\n";
    1692             : }
    1693             : 
    1694             : void Module::ModulePrint(std::ostream& os) {  // NOLINT
    1695             :   PrintHeader(os, "Module");
    1696             :   os << "\n - origin: " << Brief(script()->GetNameOrSourceURL());
    1697             :   os << "\n - code: " << Brief(code());
    1698             :   os << "\n - exports: " << Brief(exports());
    1699             :   os << "\n - requested_modules: " << Brief(requested_modules());
    1700             :   os << "\n - script: " << Brief(script());
    1701             :   os << "\n - import_meta: " << Brief(import_meta());
    1702             :   os << "\n - status: " << status();
    1703             :   os << "\n - exception: " << Brief(exception());
    1704             :   os << "\n";
    1705             : }
    1706             : 
    1707             : void JSModuleNamespace::JSModuleNamespacePrint(std::ostream& os) {  // NOLINT
    1708             :   JSObjectPrintHeader(os, *this, "JSModuleNamespace");
    1709             :   os << "\n - module: " << Brief(module());
    1710             :   JSObjectPrintBody(os, *this);
    1711             : }
    1712             : 
    1713             : void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) {  // NOLINT
    1714             :   PrintHeader(os, "PrototypeInfo");
    1715             :   os << "\n - module namespace: " << Brief(module_namespace());
    1716             :   os << "\n - prototype users: " << Brief(prototype_users());
    1717             :   os << "\n - registry slot: " << registry_slot();
    1718             :   os << "\n - object create map: " << Brief(object_create_map());
    1719             :   os << "\n - should_be_fast_map: " << should_be_fast_map();
    1720             :   os << "\n";
    1721             : }
    1722             : 
    1723             : void Tuple2::Tuple2Print(std::ostream& os) {  // NOLINT
    1724             :   PrintHeader(os, "Tuple2");
    1725             :   os << "\n - value1: " << Brief(value1());
    1726             :   os << "\n - value2: " << Brief(value2());
    1727             :   os << "\n";
    1728             : }
    1729             : 
    1730             : void Tuple3::Tuple3Print(std::ostream& os) {  // NOLINT
    1731             :   PrintHeader(os, "Tuple3");
    1732             :   os << "\n - value1: " << Brief(value1());
    1733             :   os << "\n - value2: " << Brief(value2());
    1734             :   os << "\n - value3: " << Brief(value3());
    1735             :   os << "\n";
    1736             : }
    1737             : 
    1738             : void ArrayBoilerplateDescription::ArrayBoilerplateDescriptionPrint(
    1739             :     std::ostream& os) {  // NOLINT
    1740             :   PrintHeader(os, "ArrayBoilerplateDescription");
    1741             :   os << "\n - elements kind: " << elements_kind();
    1742             :   os << "\n - constant elements: " << Brief(constant_elements());
    1743             :   os << "\n";
    1744             : }
    1745             : 
    1746             : void AsmWasmData::AsmWasmDataPrint(std::ostream& os) {  // NOLINT
    1747             :   PrintHeader(os, "AsmWasmData");
    1748             :   os << "\n - native module: " << Brief(managed_native_module());
    1749             :   os << "\n - export_wrappers: " << Brief(export_wrappers());
    1750             :   os << "\n - offset table: " << Brief(asm_js_offset_table());
    1751             :   os << "\n - uses bitset: " << uses_bitset()->value();
    1752             :   os << "\n";
    1753             : }
    1754             : 
    1755             : void WasmDebugInfo::WasmDebugInfoPrint(std::ostream& os) {  // NOLINT
    1756             :   PrintHeader(os, "WasmDebugInfo");
    1757             :   os << "\n - wasm_instance: " << Brief(wasm_instance());
    1758             :   os << "\n";
    1759             : }
    1760             : 
    1761             : void WasmExceptionTag::WasmExceptionTagPrint(std::ostream& os) {  // NOLINT
    1762             :   PrintHeader(os, "WasmExceptionTag");
    1763             :   os << "\n - index: " << index();
    1764             :   os << "\n";
    1765             : }
    1766             : 
    1767             : void WasmInstanceObject::WasmInstanceObjectPrint(std::ostream& os) {  // NOLINT
    1768             :   PrintHeader(os, "WasmInstanceObject");
    1769             :   os << "\n - module_object: " << Brief(module_object());
    1770             :   os << "\n - exports_object: " << Brief(exports_object());
    1771             :   os << "\n - native_context: " << Brief(native_context());
    1772             :   if (has_memory_object()) {
    1773             :     os << "\n - memory_object: " << Brief(memory_object());
    1774             :   }
    1775             :   if (has_untagged_globals_buffer()) {
    1776             :     os << "\n - untagged_globals_buffer: " << Brief(untagged_globals_buffer());
    1777             :   }
    1778             :   if (has_tagged_globals_buffer()) {
    1779             :     os << "\n - tagged_globals_buffer: " << Brief(tagged_globals_buffer());
    1780             :   }
    1781             :   if (has_imported_mutable_globals_buffers()) {
    1782             :     os << "\n - imported_mutable_globals_buffers: "
    1783             :        << Brief(imported_mutable_globals_buffers());
    1784             :   }
    1785             :   if (has_debug_info()) {
    1786             :     os << "\n - debug_info: " << Brief(debug_info());
    1787             :   }
    1788             :   if (has_table_object()) {
    1789             :     os << "\n - table_object: " << Brief(table_object());
    1790             :   }
    1791             :   os << "\n - imported_function_refs: " << Brief(imported_function_refs());
    1792             :   if (has_indirect_function_table_refs()) {
    1793             :     os << "\n - indirect_function_table_refs: "
    1794             :        << Brief(indirect_function_table_refs());
    1795             :   }
    1796             :   if (has_managed_native_allocations()) {
    1797             :     os << "\n - managed_native_allocations: "
    1798             :        << Brief(managed_native_allocations());
    1799             :   }
    1800             :   os << "\n - memory_start: " << static_cast<void*>(memory_start());
    1801             :   os << "\n - memory_size: " << memory_size();
    1802             :   os << "\n - memory_mask: " << AsHex(memory_mask());
    1803             :   os << "\n - imported_function_targets: "
    1804             :      << static_cast<void*>(imported_function_targets());
    1805             :   os << "\n - globals_start: " << static_cast<void*>(globals_start());
    1806             :   os << "\n - imported_mutable_globals: "
    1807             :      << static_cast<void*>(imported_mutable_globals());
    1808             :   os << "\n - indirect_function_table_size: " << indirect_function_table_size();
    1809             :   os << "\n - indirect_function_table_sig_ids: "
    1810             :      << static_cast<void*>(indirect_function_table_sig_ids());
    1811             :   os << "\n - indirect_function_table_targets: "
    1812             :      << static_cast<void*>(indirect_function_table_targets());
    1813             :   os << "\n";
    1814             : }
    1815             : 
    1816             : void WasmExportedFunctionData::WasmExportedFunctionDataPrint(
    1817             :     std::ostream& os) {  // NOLINT
    1818             :   PrintHeader(os, "WasmExportedFunctionData");
    1819             :   os << "\n - wrapper_code: " << Brief(wrapper_code());
    1820             :   os << "\n - instance: " << Brief(instance());
    1821             :   os << "\n - function_index: " << function_index();
    1822             :   os << "\n";
    1823             : }
    1824             : 
    1825             : void WasmModuleObject::WasmModuleObjectPrint(std::ostream& os) {  // NOLINT
    1826             :   PrintHeader(os, "WasmModuleObject");
    1827             :   os << "\n - module: " << module();
    1828             :   os << "\n - native module: " << native_module();
    1829             :   os << "\n - export wrappers: " << Brief(export_wrappers());
    1830             :   os << "\n - script: " << Brief(script());
    1831             :   if (has_asm_js_offset_table()) {
    1832             :     os << "\n - asm_js_offset_table: " << Brief(asm_js_offset_table());
    1833             :   }
    1834             :   if (has_breakpoint_infos()) {
    1835             :     os << "\n - breakpoint_infos: " << Brief(breakpoint_infos());
    1836             :   }
    1837             :   os << "\n";
    1838             : }
    1839             : 
    1840             : void LoadHandler::LoadHandlerPrint(std::ostream& os) {  // NOLINT
    1841             :   PrintHeader(os, "LoadHandler");
    1842             :   // TODO(ishell): implement printing based on handler kind
    1843             :   os << "\n - handler: " << Brief(smi_handler());
    1844             :   os << "\n - validity_cell: " << Brief(validity_cell());
    1845             :   int data_count = data_field_count();
    1846             :   if (data_count >= 1) {
    1847             :     os << "\n - data1: " << Brief(data1());
    1848             :   }
    1849             :   if (data_count >= 2) {
    1850             :     os << "\n - data2: " << Brief(data2());
    1851             :   }
    1852             :   if (data_count >= 3) {
    1853             :     os << "\n - data3: " << Brief(data3());
    1854             :   }
    1855             :   os << "\n";
    1856             : }
    1857             : 
    1858             : void StoreHandler::StoreHandlerPrint(std::ostream& os) {  // NOLINT
    1859             :   PrintHeader(os, "StoreHandler");
    1860             :   // TODO(ishell): implement printing based on handler kind
    1861             :   os << "\n - handler: " << Brief(smi_handler());
    1862             :   os << "\n - validity_cell: " << Brief(validity_cell());
    1863             :   int data_count = data_field_count();
    1864             :   if (data_count >= 1) {
    1865             :     os << "\n - data1: " << Brief(data1());
    1866             :   }
    1867             :   if (data_count >= 2) {
    1868             :     os << "\n - data2: " << Brief(data2());
    1869             :   }
    1870             :   if (data_count >= 3) {
    1871             :     os << "\n - data3: " << Brief(data3());
    1872             :   }
    1873             :   os << "\n";
    1874             : }
    1875             : 
    1876             : void AccessorPair::AccessorPairPrint(std::ostream& os) {  // NOLINT
    1877             :   PrintHeader(os, "AccessorPair");
    1878             :   os << "\n - getter: " << Brief(getter());
    1879             :   os << "\n - setter: " << Brief(setter());
    1880             :   os << "\n";
    1881             : }
    1882             : 
    1883             : 
    1884             : void AccessCheckInfo::AccessCheckInfoPrint(std::ostream& os) {  // NOLINT
    1885             :   PrintHeader(os, "AccessCheckInfo");
    1886             :   os << "\n - callback: " << Brief(callback());
    1887             :   os << "\n - named_interceptor: " << Brief(named_interceptor());
    1888             :   os << "\n - indexed_interceptor: " << Brief(indexed_interceptor());
    1889             :   os << "\n - data: " << Brief(data());
    1890             :   os << "\n";
    1891             : }
    1892             : 
    1893             : void CallHandlerInfo::CallHandlerInfoPrint(std::ostream& os) {  // NOLINT
    1894             :   PrintHeader(os, "CallHandlerInfo");
    1895             :   os << "\n - callback: " << Brief(callback());
    1896             :   os << "\n - js_callback: " << Brief(js_callback());
    1897             :   os << "\n - data: " << Brief(data());
    1898             :   os << "\n - side_effect_free: "
    1899             :      << (IsSideEffectFreeCallHandlerInfo() ? "true" : "false");
    1900             :   os << "\n";
    1901             : }
    1902             : 
    1903             : void InterceptorInfo::InterceptorInfoPrint(std::ostream& os) {  // NOLINT
    1904             :   PrintHeader(os, "InterceptorInfo");
    1905             :   os << "\n - getter: " << Brief(getter());
    1906             :   os << "\n - setter: " << Brief(setter());
    1907             :   os << "\n - query: " << Brief(query());
    1908             :   os << "\n - deleter: " << Brief(deleter());
    1909             :   os << "\n - enumerator: " << Brief(enumerator());
    1910             :   os << "\n - data: " << Brief(data());
    1911             :   os << "\n";
    1912             : }
    1913             : 
    1914             : 
    1915             : void FunctionTemplateInfo::FunctionTemplateInfoPrint(
    1916             :     std::ostream& os) {  // NOLINT
    1917             :   PrintHeader(os, "FunctionTemplateInfo");
    1918             :   os << "\n - class name: " << Brief(class_name());
    1919             :   os << "\n - tag: " << Brief(tag());
    1920             :   os << "\n - serial_number: " << Brief(serial_number());
    1921             :   os << "\n - property_list: " << Brief(property_list());
    1922             :   os << "\n - call_code: " << Brief(call_code());
    1923             :   os << "\n - property_accessors: " << Brief(property_accessors());
    1924             :   os << "\n - signature: " << Brief(signature());
    1925             :   os << "\n - cached_property_name: " << Brief(cached_property_name());
    1926             :   os << "\n - hidden_prototype: " << (hidden_prototype() ? "true" : "false");
    1927             :   os << "\n - undetectable: " << (undetectable() ? "true" : "false");
    1928             :   os << "\n - need_access_check: " << (needs_access_check() ? "true" : "false");
    1929             :   os << "\n - instantiated: " << (instantiated() ? "true" : "false");
    1930             :   os << "\n - rare_data: " << Brief(rare_data());
    1931             :   os << "\n";
    1932             : }
    1933             : 
    1934             : void FunctionTemplateRareData::FunctionTemplateRareDataPrint(
    1935             :     std::ostream& os) {  // NOLINT
    1936             :   PrintHeader(os, "FunctionTemplateRareData");
    1937             :   os << "\n - prototype_template: " << Brief(prototype_template());
    1938             :   os << "\n - prototype_provider_template: "
    1939             :      << Brief(prototype_provider_template());
    1940             :   os << "\n - parent_template: " << Brief(parent_template());
    1941             :   os << "\n - named_property_handler: " << Brief(named_property_handler());
    1942             :   os << "\n - indexed_property_handler: " << Brief(indexed_property_handler());
    1943             :   os << "\n - instance_template: " << Brief(instance_template());
    1944             :   os << "\n - instance_call_handler: " << Brief(instance_call_handler());
    1945             :   os << "\n - access_check_info: " << Brief(access_check_info());
    1946             :   os << "\n";
    1947             : }
    1948             : 
    1949             : void ObjectTemplateInfo::ObjectTemplateInfoPrint(std::ostream& os) {  // NOLINT
    1950             :   PrintHeader(os, "ObjectTemplateInfo");
    1951             :   os << "\n - tag: " << Brief(tag());
    1952             :   os << "\n - serial_number: " << Brief(serial_number());
    1953             :   os << "\n - property_list: " << Brief(property_list());
    1954             :   os << "\n - property_accessors: " << Brief(property_accessors());
    1955             :   os << "\n - constructor: " << Brief(constructor());
    1956             :   os << "\n - embedder_field_count: " << embedder_field_count();
    1957             :   os << "\n - immutable_proto: " << (immutable_proto() ? "true" : "false");
    1958             :   os << "\n";
    1959             : }
    1960             : 
    1961             : 
    1962             : void AllocationSite::AllocationSitePrint(std::ostream& os) {  // NOLINT
    1963             :   PrintHeader(os, "AllocationSite");
    1964             :   if (this->HasWeakNext()) os << "\n - weak_next: " << Brief(weak_next());
    1965             :   os << "\n - dependent code: " << Brief(dependent_code());
    1966             :   os << "\n - nested site: " << Brief(nested_site());
    1967             :   os << "\n - memento found count: "
    1968             :      << Brief(Smi::FromInt(memento_found_count()));
    1969             :   os << "\n - memento create count: "
    1970             :      << Brief(Smi::FromInt(memento_create_count()));
    1971             :   os << "\n - pretenure decision: "
    1972             :      << Brief(Smi::FromInt(pretenure_decision()));
    1973             :   os << "\n - transition_info: ";
    1974             :   if (!PointsToLiteral()) {
    1975             :     ElementsKind kind = GetElementsKind();
    1976             :     os << "Array allocation with ElementsKind " << ElementsKindToString(kind);
    1977             :   } else if (boilerplate()->IsJSArray()) {
    1978             :     os << "Array literal with boilerplate " << Brief(boilerplate());
    1979             :   } else {
    1980             :     os << "Object literal with boilerplate " << Brief(boilerplate());
    1981             :   }
    1982             :   os << "\n";
    1983             : }
    1984             : 
    1985             : 
    1986             : void AllocationMemento::AllocationMementoPrint(std::ostream& os) {  // NOLINT
    1987             :   PrintHeader(os, "AllocationMemento");
    1988             :   os << "\n - allocation site: ";
    1989             :   if (IsValid()) {
    1990             :     GetAllocationSite()->AllocationSitePrint(os);
    1991             :   } else {
    1992             :     os << "<invalid>\n";
    1993             :   }
    1994             : }
    1995             : 
    1996             : 
    1997             : void Script::ScriptPrint(std::ostream& os) {  // NOLINT
    1998             :   PrintHeader(os, "Script");
    1999             :   os << "\n - source: " << Brief(source());
    2000             :   os << "\n - name: " << Brief(name());
    2001             :   os << "\n - line_offset: " << line_offset();
    2002             :   os << "\n - column_offset: " << column_offset();
    2003             :   os << "\n - type: " << type();
    2004             :   os << "\n - id: " << id();
    2005             :   os << "\n - context data: " << Brief(context_data());
    2006             :   os << "\n - compilation type: " << compilation_type();
    2007             :   os << "\n - line ends: " << Brief(line_ends());
    2008             :   if (has_eval_from_shared()) {
    2009             :     os << "\n - eval from shared: " << Brief(eval_from_shared());
    2010             :   }
    2011             :   if (is_wrapped()) {
    2012             :     os << "\n - wrapped arguments: " << Brief(wrapped_arguments());
    2013             :   }
    2014             :   os << "\n - eval from position: " << eval_from_position();
    2015             :   os << "\n - shared function infos: " << Brief(shared_function_infos());
    2016             :   os << "\n";
    2017             : }
    2018             : 
    2019             : #ifdef V8_INTL_SUPPORT
    2020             : void JSV8BreakIterator::JSV8BreakIteratorPrint(std::ostream& os) {  // NOLINT
    2021             :   JSObjectPrintHeader(os, *this, "JSV8BreakIterator");
    2022             :   os << "\n - locale: " << Brief(locale());
    2023             :   os << "\n - type: " << TypeAsString();
    2024             :   os << "\n - break iterator: " << Brief(break_iterator());
    2025             :   os << "\n - unicode string: " << Brief(unicode_string());
    2026             :   os << "\n - bound adopt text: " << Brief(bound_adopt_text());
    2027             :   os << "\n - bound first: " << Brief(bound_first());
    2028             :   os << "\n - bound next: " << Brief(bound_next());
    2029             :   os << "\n - bound current: " << Brief(bound_current());
    2030             :   os << "\n - bound break type: " << Brief(bound_break_type());
    2031             :   os << "\n";
    2032             : }
    2033             : 
    2034             : void JSCollator::JSCollatorPrint(std::ostream& os) {  // NOLINT
    2035             :   JSObjectPrintHeader(os, *this, "JSCollator");
    2036             :   os << "\n - icu collator: " << Brief(icu_collator());
    2037             :   os << "\n - bound compare: " << Brief(bound_compare());
    2038             :   JSObjectPrintBody(os, *this);
    2039             : }
    2040             : 
    2041             : void JSDateTimeFormat::JSDateTimeFormatPrint(std::ostream& os) {  // NOLINT
    2042             :   JSObjectPrintHeader(os, *this, "JSDateTimeFormat");
    2043             :   os << "\n - icu locale: " << Brief(icu_locale());
    2044             :   os << "\n - icu simple date format: " << Brief(icu_simple_date_format());
    2045             :   os << "\n - bound format: " << Brief(bound_format());
    2046             :   os << "\n - hour cycle: " << HourCycleAsString();
    2047             :   JSObjectPrintBody(os, *this);
    2048             : }
    2049             : 
    2050             : void JSListFormat::JSListFormatPrint(std::ostream& os) {  // NOLINT
    2051             :   JSObjectPrintHeader(os, *this, "JSListFormat");
    2052             :   os << "\n - locale: " << Brief(locale());
    2053             :   os << "\n - style: " << StyleAsString();
    2054             :   os << "\n - type: " << TypeAsString();
    2055             :   os << "\n - icu formatter: " << Brief(icu_formatter());
    2056             :   JSObjectPrintBody(os, *this);
    2057             : }
    2058             : 
    2059             : void JSLocale::JSLocalePrint(std::ostream& os) {  // NOLINT
    2060             :   JSObjectPrintHeader(os, *this, "JSLocale");
    2061             :   os << "\n - icu locale: " << Brief(icu_locale());
    2062             :   JSObjectPrintBody(os, *this);
    2063             : }
    2064             : 
    2065             : void JSNumberFormat::JSNumberFormatPrint(std::ostream& os) {  // NOLINT
    2066             :   JSObjectPrintHeader(os, *this, "JSNumberFormat");
    2067             :   os << "\n - locale: " << Brief(locale());
    2068             :   os << "\n - icu_number_format: " << Brief(icu_number_format());
    2069             :   os << "\n - bound_format: " << Brief(bound_format());
    2070             :   os << "\n - style: " << StyleAsString();
    2071             :   os << "\n - currency_display: " << CurrencyDisplayAsString();
    2072             :   JSObjectPrintBody(os, *this);
    2073             : }
    2074             : 
    2075             : void JSPluralRules::JSPluralRulesPrint(std::ostream& os) {  // NOLINT
    2076             :   JSObjectPrintHeader(os, *this, "JSPluralRules");
    2077             :   os << "\n - locale: " << Brief(locale());
    2078             :   os << "\n - type: " << TypeAsString();
    2079             :   os << "\n - icu plural rules: " << Brief(icu_plural_rules());
    2080             :   os << "\n - icu decimal format: " << Brief(icu_decimal_format());
    2081             :   JSObjectPrintBody(os, *this);
    2082             : }
    2083             : 
    2084             : void JSRelativeTimeFormat::JSRelativeTimeFormatPrint(
    2085             :     std::ostream& os) {  // NOLINT
    2086             :   JSObjectPrintHeader(os, *this, "JSRelativeTimeFormat");
    2087             :   os << "\n - locale: " << Brief(locale());
    2088             :   os << "\n - style: " << StyleAsString();
    2089             :   os << "\n - numeric: " << NumericAsString();
    2090             :   os << "\n - icu formatter: " << Brief(icu_formatter());
    2091             :   os << "\n";
    2092             : }
    2093             : 
    2094             : void JSSegmentIterator::JSSegmentIteratorPrint(std::ostream& os) {  // NOLINT
    2095             :   JSObjectPrintHeader(os, *this, "JSSegmentIterator");
    2096             :   os << "\n - icu break iterator: " << Brief(icu_break_iterator());
    2097             :   os << "\n - unicode string: " << Brief(unicode_string());
    2098             :   os << "\n - granularity: " << GranularityAsString();
    2099             :   os << "\n";
    2100             : }
    2101             : 
    2102             : void JSSegmenter::JSSegmenterPrint(std::ostream& os) {  // NOLINT
    2103             :   JSObjectPrintHeader(os, *this, "JSSegmenter");
    2104             :   os << "\n - locale: " << Brief(locale());
    2105             :   os << "\n - granularity: " << GranularityAsString();
    2106             :   os << "\n - lineBreakStyle: " << LineBreakStyleAsString();
    2107             :   os << "\n - icu break iterator: " << Brief(icu_break_iterator());
    2108             :   JSObjectPrintBody(os, *this);
    2109             : }
    2110             : #endif  // V8_INTL_SUPPORT
    2111             : 
    2112             : namespace {
    2113             : void PrintScopeInfoList(ScopeInfo scope_info, std::ostream& os,
    2114             :                         const char* list_name, int nof_internal_slots,
    2115             :                         int start, int length) {
    2116             :   if (length <= 0) return;
    2117             :   int end = start + length;
    2118             :   os << "\n - " << list_name;
    2119             :   if (nof_internal_slots > 0) {
    2120             :     os << " " << start << "-" << end << " [internal slots]";
    2121             :   }
    2122             :   os << " {\n";
    2123             :   for (int i = nof_internal_slots; start < end; ++i, ++start) {
    2124             :     os << "    - " << i << ": ";
    2125             :     String::cast(scope_info->get(start))->ShortPrint(os);
    2126             :     os << "\n";
    2127             :   }
    2128             :   os << "  }";
    2129             : }
    2130             : }  // namespace
    2131             : 
    2132             : void ScopeInfo::ScopeInfoPrint(std::ostream& os) {  // NOLINT
    2133             :   PrintHeader(os, "ScopeInfo");
    2134             :   if (length() == 0) {
    2135             :     os << "\n - length = 0\n";
    2136             :     return;
    2137             :   }
    2138             :   int flags = Flags();
    2139             : 
    2140             :   os << "\n - parameters: " << ParameterCount();
    2141             :   os << "\n - context locals : " << ContextLocalCount();
    2142             : 
    2143             :   os << "\n - scope type: " << scope_type();
    2144             :   if (CallsSloppyEval()) os << "\n - sloppy eval";
    2145             :   os << "\n - language mode: " << language_mode();
    2146             :   if (is_declaration_scope()) os << "\n - declaration scope";
    2147             :   if (HasReceiver()) {
    2148             :     os << "\n - receiver: " << ReceiverVariableField::decode(flags);
    2149             :   }
    2150             :   if (HasNewTarget()) os << "\n - needs new target";
    2151             :   if (HasFunctionName()) {
    2152             :     os << "\n - function name(" << FunctionVariableField::decode(flags)
    2153             :        << "): ";
    2154             :     FunctionName()->ShortPrint(os);
    2155             :   }
    2156             :   if (IsAsmModule()) os << "\n - asm module";
    2157             :   if (HasSimpleParameters()) os << "\n - simple parameters";
    2158             :   os << "\n - function kind: " << function_kind();
    2159             :   if (HasOuterScopeInfo()) {
    2160             :     os << "\n - outer scope info: " << Brief(OuterScopeInfo());
    2161             :   }
    2162             :   if (HasFunctionName()) {
    2163             :     os << "\n - function name: " << Brief(FunctionName());
    2164             :   }
    2165             :   if (HasInferredFunctionName()) {
    2166             :     os << "\n - inferred function name: " << Brief(InferredFunctionName());
    2167             :   }
    2168             : 
    2169             :   if (HasPositionInfo()) {
    2170             :     os << "\n - start position: " << StartPosition();
    2171             :     os << "\n - end position: " << EndPosition();
    2172             :   }
    2173             :   os << "\n - length: " << length();
    2174             :   if (length() > 0) {
    2175             :     PrintScopeInfoList(*this, os, "context slots", Context::MIN_CONTEXT_SLOTS,
    2176             :                        ContextLocalNamesIndex(), ContextLocalCount());
    2177             :     // TODO(neis): Print module stuff if present.
    2178             :   }
    2179             :   os << "\n";
    2180             : }
    2181             : 
    2182             : void DebugInfo::DebugInfoPrint(std::ostream& os) {  // NOLINT
    2183             :   PrintHeader(os, "DebugInfo");
    2184             :   os << "\n - flags: " << flags();
    2185             :   os << "\n - debugger_hints: " << debugger_hints();
    2186             :   os << "\n - shared: " << Brief(shared());
    2187             :   os << "\n - script: " << Brief(script());
    2188             :   os << "\n - original bytecode array: " << Brief(original_bytecode_array());
    2189             :   os << "\n - debug bytecode array: " << Brief(debug_bytecode_array());
    2190             :   os << "\n - break_points: ";
    2191             :   break_points()->FixedArrayPrint(os);
    2192             :   os << "\n - coverage_info: " << Brief(coverage_info());
    2193             : }
    2194             : 
    2195             : 
    2196             : void StackFrameInfo::StackFrameInfoPrint(std::ostream& os) {  // NOLINT
    2197             :   PrintHeader(os, "StackFrame");
    2198             :   os << "\n - line_number: " << line_number();
    2199             :   os << "\n - column_number: " << column_number();
    2200             :   os << "\n - script_id: " << script_id();
    2201             :   os << "\n - script_name: " << Brief(script_name());
    2202             :   os << "\n - script_name_or_source_url: "
    2203             :      << Brief(script_name_or_source_url());
    2204             :   os << "\n - function_name: " << Brief(function_name());
    2205             :   os << "\n - is_eval: " << (is_eval() ? "true" : "false");
    2206             :   os << "\n - is_constructor: " << (is_constructor() ? "true" : "false");
    2207             :   os << "\n";
    2208             : }
    2209             : 
    2210             : static void PrintBitMask(std::ostream& os, uint32_t value) {  // NOLINT
    2211             :   for (int i = 0; i < 32; i++) {
    2212             :     if ((i & 7) == 0) os << " ";
    2213             :     os << (((value & 1) == 0) ? "_" : "x");
    2214             :     value >>= 1;
    2215             :   }
    2216             : }
    2217             : 
    2218             : void LayoutDescriptor::Print() {
    2219             :   StdoutStream os;
    2220             :   this->Print(os);
    2221             :   os << std::flush;
    2222             : }
    2223             : 
    2224             : void LayoutDescriptor::ShortPrint(std::ostream& os) {
    2225             :   if (IsSmi()) {
    2226             :     // Print tagged value for easy use with "jld" gdb macro.
    2227             :     os << reinterpret_cast<void*>(ptr());
    2228             :   } else {
    2229             :     os << Brief(*this);
    2230             :   }
    2231             : }
    2232             : 
    2233             : void LayoutDescriptor::Print(std::ostream& os) {  // NOLINT
    2234             :   os << "Layout descriptor: ";
    2235             :   if (IsFastPointerLayout()) {
    2236             :     os << "<all tagged>";
    2237             :   } else if (IsSmi()) {
    2238             :     os << "fast";
    2239             :     PrintBitMask(os, static_cast<uint32_t>(Smi::ToInt(*this)));
    2240             :   } else if (IsOddball() && IsUninitialized()) {
    2241             :     os << "<uninitialized>";
    2242             :   } else {
    2243             :     os << "slow";
    2244             :     int num_words = number_of_layout_words();
    2245             :     for (int i = 0; i < num_words; i++) {
    2246             :       if (i > 0) os << " |";
    2247             :       PrintBitMask(os, get_layout_word(i));
    2248             :     }
    2249             :   }
    2250             :   os << "\n";
    2251             : }
    2252             : 
    2253             : void PreparseData::PreparseDataPrint(std::ostream& os) {  // NOLINT
    2254             :   PrintHeader(os, "PreparseData");
    2255             :   os << "\n - data_length: " << data_length();
    2256             :   os << "\n - children_length: " << children_length();
    2257             :   for (int i = 0; i < children_length(); ++i) {
    2258             :     os << "\n - [" << i << "]: " << Brief(get_child(i));
    2259             :   }
    2260             :   os << "\n";
    2261             : }
    2262             : 
    2263             : void UncompiledDataWithoutPreparseData::UncompiledDataWithoutPreparseDataPrint(
    2264             :     std::ostream& os) {  // NOLINT
    2265             :   PrintHeader(os, "UncompiledDataWithoutPreparseData");
    2266             :   os << "\n - start position: " << start_position();
    2267             :   os << "\n - end position: " << end_position();
    2268             :   os << "\n";
    2269             : }
    2270             : 
    2271             : void UncompiledDataWithPreparseData::UncompiledDataWithPreparseDataPrint(
    2272             :     std::ostream& os) {  // NOLINT
    2273             :   PrintHeader(os, "UncompiledDataWithPreparseData");
    2274             :   os << "\n - start position: " << start_position();
    2275             :   os << "\n - end position: " << end_position();
    2276             :   os << "\n - preparse_data: " << Brief(preparse_data());
    2277             :   os << "\n";
    2278             : }
    2279             : 
    2280             : void InterpreterData::InterpreterDataPrint(std::ostream& os) {  // NOLINT
    2281             :   PrintHeader(os, "InterpreterData");
    2282             :   os << "\n - bytecode_array: " << Brief(bytecode_array());
    2283             :   os << "\n - interpreter_trampoline: " << Brief(interpreter_trampoline());
    2284             :   os << "\n";
    2285             : }
    2286             : 
    2287             : void MaybeObject::Print() {
    2288             :   StdoutStream os;
    2289             :   this->Print(os);
    2290             :   os << std::flush;
    2291             : }
    2292             : 
    2293             : void MaybeObject::Print(std::ostream& os) {
    2294             :   Smi smi;
    2295             :   HeapObject heap_object;
    2296             :   if (ToSmi(&smi)) {
    2297             :     smi->SmiPrint(os);
    2298             :   } else if (IsCleared()) {
    2299             :     os << "[cleared]";
    2300             :   } else if (GetHeapObjectIfWeak(&heap_object)) {
    2301             :     os << "[weak] ";
    2302             :     heap_object->HeapObjectPrint(os);
    2303             :   } else if (GetHeapObjectIfStrong(&heap_object)) {
    2304             :     heap_object->HeapObjectPrint(os);
    2305             :   } else {
    2306             :     UNREACHABLE();
    2307             :   }
    2308             : }
    2309             : 
    2310             : #endif  // OBJECT_PRINT
    2311             : 
    2312         212 : void HeapNumber::HeapNumberPrint(std::ostream& os) { os << value(); }
    2313             : 
    2314           0 : void MutableHeapNumber::MutableHeapNumberPrint(std::ostream& os) {
    2315             :   os << value();
    2316           0 : }
    2317             : 
    2318             : // TODO(cbruni): remove once the new maptracer is in place.
    2319           0 : void Name::NameShortPrint() {
    2320           0 :   if (this->IsString()) {
    2321           0 :     PrintF("%s", String::cast(*this)->ToCString().get());
    2322             :   } else {
    2323             :     DCHECK(this->IsSymbol());
    2324           0 :     Symbol s = Symbol::cast(*this);
    2325           0 :     if (s->name()->IsUndefined()) {
    2326           0 :       PrintF("#<%s>", s->PrivateSymbolToName());
    2327             :     } else {
    2328           0 :       PrintF("<%s>", String::cast(s->name())->ToCString().get());
    2329             :     }
    2330             :   }
    2331           0 : }
    2332             : 
    2333             : // TODO(cbruni): remove once the new maptracer is in place.
    2334           0 : int Name::NameShortPrint(Vector<char> str) {
    2335           0 :   if (this->IsString()) {
    2336           0 :     return SNPrintF(str, "%s", String::cast(*this)->ToCString().get());
    2337             :   } else {
    2338             :     DCHECK(this->IsSymbol());
    2339           0 :     Symbol s = Symbol::cast(*this);
    2340           0 :     if (s->name()->IsUndefined()) {
    2341           0 :       return SNPrintF(str, "#<%s>", s->PrivateSymbolToName());
    2342             :     } else {
    2343           0 :       return SNPrintF(str, "<%s>", String::cast(s->name())->ToCString().get());
    2344             :     }
    2345             :   }
    2346             : }
    2347             : 
    2348       15867 : void Map::PrintMapDetails(std::ostream& os) {
    2349             :   DisallowHeapAllocation no_gc;
    2350       15867 :   this->MapPrint(os);
    2351       15867 :   instance_descriptors()->PrintDescriptors(os);
    2352       15867 : }
    2353             : 
    2354       15867 : void Map::MapPrint(std::ostream& os) {  // NOLINT
    2355             : #ifdef OBJECT_PRINT
    2356             :   PrintHeader(os, "Map");
    2357             : #else
    2358       15867 :   os << "Map=" << reinterpret_cast<void*>(ptr());
    2359             : #endif
    2360       15867 :   os << "\n - type: " << instance_type();
    2361       15867 :   os << "\n - instance size: ";
    2362       15867 :   if (instance_size() == kVariableSizeSentinel) {
    2363        1020 :     os << "variable";
    2364             :   } else {
    2365       14847 :     os << instance_size();
    2366             :   }
    2367       15867 :   if (IsJSObjectMap()) {
    2368       13208 :     os << "\n - inobject properties: " << GetInObjectProperties();
    2369             :   }
    2370       15867 :   os << "\n - elements kind: " << ElementsKindToString(elements_kind());
    2371       15867 :   os << "\n - unused property fields: " << UnusedPropertyFields();
    2372       15867 :   os << "\n - enum length: ";
    2373       15867 :   if (EnumLength() == kInvalidEnumCacheSentinel) {
    2374       15867 :     os << "invalid";
    2375             :   } else {
    2376           0 :     os << EnumLength();
    2377             :   }
    2378       15867 :   if (is_deprecated()) os << "\n - deprecated_map";
    2379       15867 :   if (is_stable()) os << "\n - stable_map";
    2380       15867 :   if (is_migration_target()) os << "\n - migration_target";
    2381       15867 :   if (is_dictionary_map()) os << "\n - dictionary_map";
    2382       15867 :   if (has_hidden_prototype()) os << "\n - has_hidden_prototype";
    2383       15867 :   if (has_named_interceptor()) os << "\n - named_interceptor";
    2384       15867 :   if (has_indexed_interceptor()) os << "\n - indexed_interceptor";
    2385       15867 :   if (may_have_interesting_symbols()) os << "\n - may_have_interesting_symbols";
    2386       15867 :   if (is_undetectable()) os << "\n - undetectable";
    2387       15867 :   if (is_callable()) os << "\n - callable";
    2388       15867 :   if (is_constructor()) os << "\n - constructor";
    2389       15867 :   if (has_prototype_slot()) {
    2390        2184 :     os << "\n - has_prototype_slot";
    2391        2184 :     if (has_non_instance_prototype()) os << " (non-instance prototype)";
    2392             :   }
    2393       15867 :   if (is_access_check_needed()) os << "\n - access_check_needed";
    2394       15867 :   if (!is_extensible()) os << "\n - non-extensible";
    2395       15867 :   if (is_prototype_map()) {
    2396        4240 :     os << "\n - prototype_map";
    2397        4240 :     os << "\n - prototype info: " << Brief(prototype_info());
    2398             :   } else {
    2399       11627 :     os << "\n - back pointer: " << Brief(GetBackPointer());
    2400             :   }
    2401       15867 :   os << "\n - prototype_validity cell: " << Brief(prototype_validity_cell());
    2402       15867 :   os << "\n - instance descriptors " << (owns_descriptors() ? "(own) " : "")
    2403       15867 :      << "#" << NumberOfOwnDescriptors() << ": "
    2404       31734 :      << Brief(instance_descriptors());
    2405             :   if (FLAG_unbox_double_fields) {
    2406       15867 :     os << "\n - layout descriptor: ";
    2407       15867 :     layout_descriptor()->ShortPrint(os);
    2408             :   }
    2409             : 
    2410             :   Isolate* isolate;
    2411             :   // Read-only maps can't have transitions, which is fortunate because we need
    2412             :   // the isolate to iterate over the transitions.
    2413       15867 :   if (Isolate::FromWritableHeapObject(*this, &isolate)) {
    2414             :     DisallowHeapAllocation no_gc;
    2415       13283 :     TransitionsAccessor transitions(isolate, *this, &no_gc);
    2416       13283 :     int nof_transitions = transitions.NumberOfTransitions();
    2417       13283 :     if (nof_transitions > 0) {
    2418         125 :       os << "\n - transitions #" << nof_transitions << ": ";
    2419         125 :       HeapObject heap_object;
    2420         125 :       Smi smi;
    2421         125 :       if (raw_transitions()->ToSmi(&smi)) {
    2422           0 :         os << Brief(smi);
    2423         125 :       } else if (raw_transitions()->GetHeapObject(&heap_object)) {
    2424         125 :         os << Brief(heap_object);
    2425             :       }
    2426             : #ifdef OBJECT_PRINT
    2427             :       transitions.PrintTransitions(os);
    2428             : #endif  // OBJECT_PRINT
    2429             :     }
    2430             :   }
    2431       15867 :   os << "\n - prototype: " << Brief(prototype());
    2432       15867 :   os << "\n - constructor: " << Brief(GetConstructor());
    2433       15867 :   os << "\n - dependent code: " << Brief(dependent_code());
    2434       15867 :   os << "\n - construction counter: " << construction_counter();
    2435       15867 :   os << "\n";
    2436       15867 : }
    2437             : 
    2438       15867 : void DescriptorArray::PrintDescriptors(std::ostream& os) {
    2439      118718 :   for (int i = 0; i < number_of_descriptors(); i++) {
    2440       43492 :     Name key = GetKey(i);
    2441       43492 :     os << "\n  [" << i << "]: ";
    2442             : #ifdef OBJECT_PRINT
    2443             :     key->NamePrint(os);
    2444             : #else
    2445       43492 :     key->ShortPrint(os);
    2446             : #endif
    2447       43492 :     os << " ";
    2448       43492 :     PrintDescriptorDetails(os, i, PropertyDetails::kPrintFull);
    2449             :   }
    2450       15867 :   os << "\n";
    2451       15867 : }
    2452             : 
    2453       43492 : void DescriptorArray::PrintDescriptorDetails(std::ostream& os, int descriptor,
    2454             :                                              PropertyDetails::PrintMode mode) {
    2455       43492 :   PropertyDetails details = GetDetails(descriptor);
    2456       43492 :   details.PrintAsFastTo(os, mode);
    2457       43492 :   os << " @ ";
    2458       43492 :   switch (details.location()) {
    2459             :     case kField: {
    2460       10744 :       FieldType field_type = GetFieldType(descriptor);
    2461       10744 :       field_type->PrintTo(os);
    2462             :       break;
    2463             :     }
    2464             :     case kDescriptor:
    2465       32748 :       Object value = GetStrongValue(descriptor);
    2466       32748 :       os << Brief(value);
    2467       32748 :       if (value->IsAccessorPair()) {
    2468        1975 :         AccessorPair pair = AccessorPair::cast(value);
    2469        3950 :         os << "(get: " << Brief(pair->getter())
    2470        5925 :            << ", set: " << Brief(pair->setter()) << ")";
    2471             :       }
    2472             :       break;
    2473             :   }
    2474       43492 : }
    2475             : 
    2476             : #if defined(DEBUG) || defined(OBJECT_PRINT)
    2477             : // This method is only meant to be called from gdb for debugging purposes.
    2478             : // Since the string can also be in two-byte encoding, non-Latin1 characters
    2479             : // will be ignored in the output.
    2480             : char* String::ToAsciiArray() {
    2481             :   // Static so that subsequent calls frees previously allocated space.
    2482             :   // This also means that previous results will be overwritten.
    2483             :   static char* buffer = nullptr;
    2484             :   if (buffer != nullptr) delete[] buffer;
    2485             :   buffer = new char[length() + 1];
    2486             :   WriteToFlat(*this, reinterpret_cast<uint8_t*>(buffer), 0, length());
    2487             :   buffer[length()] = 0;
    2488             :   return buffer;
    2489             : }
    2490             : 
    2491             : // static
    2492             : void TransitionsAccessor::PrintOneTransition(std::ostream& os, Name key,
    2493             :                                              Map target) {
    2494             :   os << "\n     ";
    2495             : #ifdef OBJECT_PRINT
    2496             :   key->NamePrint(os);
    2497             : #else
    2498             :   key->ShortPrint(os);
    2499             : #endif
    2500             :   os << ": ";
    2501             :   ReadOnlyRoots roots = key->GetReadOnlyRoots();
    2502             :   if (key == roots.nonextensible_symbol()) {
    2503             :     os << "(transition to non-extensible)";
    2504             :   } else if (key == roots.sealed_symbol()) {
    2505             :     os << "(transition to sealed)";
    2506             :   } else if (key == roots.frozen_symbol()) {
    2507             :     os << "(transition to frozen)";
    2508             :   } else if (key == roots.elements_transition_symbol()) {
    2509             :     os << "(transition to " << ElementsKindToString(target->elements_kind())
    2510             :        << ")";
    2511             :   } else if (key == roots.strict_function_transition_symbol()) {
    2512             :     os << " (transition to strict function)";
    2513             :   } else {
    2514             :     DCHECK(!IsSpecialTransition(roots, key));
    2515             :     os << "(transition to ";
    2516             :     int descriptor = target->LastAdded();
    2517             :     DescriptorArray descriptors = target->instance_descriptors();
    2518             :     descriptors->PrintDescriptorDetails(os, descriptor,
    2519             :                                         PropertyDetails::kForTransitions);
    2520             :     os << ")";
    2521             :   }
    2522             :   os << " -> " << Brief(target);
    2523             : }
    2524             : 
    2525             : void TransitionArray::PrintInternal(std::ostream& os) {
    2526             :   int num_transitions = number_of_transitions();
    2527             :   os << "Transition array #" << num_transitions << ":";
    2528             :   for (int i = 0; i < num_transitions; i++) {
    2529             :     Name key = GetKey(i);
    2530             :     Map target = GetTarget(i);
    2531             :     TransitionsAccessor::PrintOneTransition(os, key, target);
    2532             :   }
    2533             :   os << "\n" << std::flush;
    2534             : }
    2535             : 
    2536             : void TransitionsAccessor::PrintTransitions(std::ostream& os) {  // NOLINT
    2537             :   switch (encoding()) {
    2538             :     case kPrototypeInfo:
    2539             :     case kUninitialized:
    2540             :     case kMigrationTarget:
    2541             :       return;
    2542             :     case kWeakRef: {
    2543             :       Map target = Map::cast(raw_transitions_->GetHeapObjectAssumeWeak());
    2544             :       Name key = GetSimpleTransitionKey(target);
    2545             :       PrintOneTransition(os, key, target);
    2546             :       break;
    2547             :     }
    2548             :     case kFullTransitionArray:
    2549             :       return transitions()->PrintInternal(os);
    2550             :   }
    2551             : }
    2552             : 
    2553             : void TransitionsAccessor::PrintTransitionTree() {
    2554             :   StdoutStream os;
    2555             :   os << "map= " << Brief(map_);
    2556             :   DisallowHeapAllocation no_gc;
    2557             :   PrintTransitionTree(os, 0, &no_gc);
    2558             :   os << "\n" << std::flush;
    2559             : }
    2560             : 
    2561             : void TransitionsAccessor::PrintTransitionTree(std::ostream& os, int level,
    2562             :                                               DisallowHeapAllocation* no_gc) {
    2563             :   ReadOnlyRoots roots = ReadOnlyRoots(isolate_);
    2564             :   int num_transitions = NumberOfTransitions();
    2565             :   if (num_transitions == 0) return;
    2566             :   for (int i = 0; i < num_transitions; i++) {
    2567             :     Name key = GetKey(i);
    2568             :     Map target = GetTarget(i);
    2569             :     os << std::endl
    2570             :        << "  " << level << "/" << i << ":" << std::setw(level * 2 + 2) << " ";
    2571             :     std::stringstream ss;
    2572             :     ss << Brief(target);
    2573             :     os << std::left << std::setw(50) << ss.str() << ": ";
    2574             : 
    2575             :     if (key == roots.nonextensible_symbol()) {
    2576             :       os << "to non-extensible";
    2577             :     } else if (key == roots.sealed_symbol()) {
    2578             :       os << "to sealed ";
    2579             :     } else if (key == roots.frozen_symbol()) {
    2580             :       os << "to frozen";
    2581             :     } else if (key == roots.elements_transition_symbol()) {
    2582             :       os << "to " << ElementsKindToString(target->elements_kind());
    2583             :     } else if (key == roots.strict_function_transition_symbol()) {
    2584             :       os << "to strict function";
    2585             :     } else {
    2586             : #ifdef OBJECT_PRINT
    2587             :       key->NamePrint(os);
    2588             : #else
    2589             :       key->ShortPrint(os);
    2590             : #endif
    2591             :       os << " ";
    2592             :       DCHECK(!IsSpecialTransition(ReadOnlyRoots(isolate_), key));
    2593             :       os << "to ";
    2594             :       int descriptor = target->LastAdded();
    2595             :       DescriptorArray descriptors = target->instance_descriptors();
    2596             :       descriptors->PrintDescriptorDetails(os, descriptor,
    2597             :                                           PropertyDetails::kForTransitions);
    2598             :     }
    2599             :     TransitionsAccessor transitions(isolate_, target, no_gc);
    2600             :     transitions.PrintTransitionTree(os, level + 1, no_gc);
    2601             :   }
    2602             : }
    2603             : 
    2604             : void JSObject::PrintTransitions(std::ostream& os) {  // NOLINT
    2605             :   DisallowHeapAllocation no_gc;
    2606             :   TransitionsAccessor ta(GetIsolate(), map(), &no_gc);
    2607             :   if (ta.NumberOfTransitions() == 0) return;
    2608             :   os << "\n - transitions";
    2609             :   ta.PrintTransitions(os);
    2610             : }
    2611             : 
    2612             : #endif  // defined(DEBUG) || defined(OBJECT_PRINT)
    2613             : }  // namespace internal
    2614             : }  // namespace v8
    2615             : 
    2616             : //
    2617             : // The following functions are used by our gdb macros.
    2618             : //
    2619           0 : V8_EXPORT_PRIVATE extern void _v8_internal_Print_Object(void* object) {
    2620           0 :   i::Object(reinterpret_cast<i::Address>(object))->Print();
    2621           0 : }
    2622             : 
    2623           0 : V8_EXPORT_PRIVATE extern void _v8_internal_Print_Code(void* object) {
    2624           0 :   i::Address address = reinterpret_cast<i::Address>(object);
    2625             :   i::Isolate* isolate = i::Isolate::Current();
    2626             : 
    2627             :   i::wasm::WasmCode* wasm_code =
    2628           0 :       isolate->wasm_engine()->code_manager()->LookupCode(address);
    2629           0 :   if (wasm_code) {
    2630           0 :     i::StdoutStream os;
    2631           0 :     wasm_code->Disassemble(nullptr, os, address);
    2632           0 :     return;
    2633             :   }
    2634             : 
    2635           0 :   if (!isolate->heap()->InSpaceSlow(address, i::CODE_SPACE) &&
    2636           0 :       !isolate->heap()->InSpaceSlow(address, i::LO_SPACE) &&
    2637           0 :       !i::InstructionStream::PcIsOffHeap(isolate, address)) {
    2638             :     i::PrintF(
    2639             :         "%p is not within the current isolate's large object, code or embedded "
    2640             :         "spaces\n",
    2641           0 :         object);
    2642           0 :     return;
    2643             :   }
    2644             : 
    2645           0 :   i::Code code = isolate->FindCodeObject(address);
    2646           0 :   if (!code->IsCode()) {
    2647           0 :     i::PrintF("No code object found containing %p\n", object);
    2648           0 :     return;
    2649             :   }
    2650             : #ifdef ENABLE_DISASSEMBLER
    2651             :   i::StdoutStream os;
    2652             :   code->Disassemble(nullptr, os, address);
    2653             : #else   // ENABLE_DISASSEMBLER
    2654             :   code->Print();
    2655             : #endif  // ENABLE_DISASSEMBLER
    2656             : }
    2657             : 
    2658           0 : V8_EXPORT_PRIVATE extern void _v8_internal_Print_LayoutDescriptor(
    2659             :     void* object) {
    2660           0 :   i::Object o(reinterpret_cast<i::Address>(object));
    2661           0 :   if (!o->IsLayoutDescriptor()) {
    2662             :     printf("Please provide a layout descriptor\n");
    2663             :   } else {
    2664           0 :     i::LayoutDescriptor::cast(o)->Print();
    2665             :   }
    2666           0 : }
    2667             : 
    2668           0 : V8_EXPORT_PRIVATE extern void _v8_internal_Print_StackTrace() {
    2669             :   i::Isolate* isolate = i::Isolate::Current();
    2670           0 :   isolate->PrintStack(stdout);
    2671           0 : }
    2672             : 
    2673           0 : V8_EXPORT_PRIVATE extern void _v8_internal_Print_TransitionTree(void* object) {
    2674           0 :   i::Object o(reinterpret_cast<i::Address>(object));
    2675           0 :   if (!o->IsMap()) {
    2676             :     printf("Please provide a valid Map\n");
    2677             :   } else {
    2678             : #if defined(DEBUG) || defined(OBJECT_PRINT)
    2679             :     i::DisallowHeapAllocation no_gc;
    2680             :     i::Map map = i::Map::unchecked_cast(o);
    2681             :     i::TransitionsAccessor transitions(i::Isolate::Current(), map, &no_gc);
    2682             :     transitions.PrintTransitionTree();
    2683             : #endif
    2684             :   }
    2685      183867 : }

Generated by: LCOV version 1.10