LCOV - code coverage report
Current view: top level - src - objects-printer.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 82 131 62.6 %
Date: 2019-04-19 Functions: 6 15 40.0 %

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

Generated by: LCOV version 1.10