#include <iomanip>
#include <memory>
#include <optional>
#include "src/api/api-arguments.h"
#include "src/common/globals.h"
#include "src/diagnostics/disasm.h"
#include "src/diagnostics/disassembler.h"
#include "src/execution/frames-inl.h"
#include "src/execution/isolate-utils-inl.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap-write-barrier-inl.h"
#include "src/heap/marking-inl.h"
#include "src/ic/handler-configuration-inl.h"
#include "src/init/bootstrapper.h"
#include "src/interpreter/bytecodes.h"
#include "src/objects/all-objects-inl.h"
#include "src/objects/code-kind.h"
#include "src/objects/instance-type.h"
#include "src/objects/js-objects.h"
#include "src/regexp/regexp.h"
#include "src/snapshot/embedded/embedded-data.h"
#include "src/strings/string-stream.h"
#include "src/utils/ostreams.h"
#include "third_party/fp16/src/include/fp16.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/debug/debug-wasm-objects-inl.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#endif
namespace v8::internal {
namespace {
constexpr char kUnavailableString[] = …;
}
#ifdef OBJECT_PRINT
void Print(Tagged<Object> obj) { … }
void Print(Tagged<Object> obj, std::ostream& os) { … }
namespace {
#define AS_PTR …
#define AS_OBJ …
void PrintFunctionCallbackInfo(Address* implicit_args, Address* js_args,
Address length, std::ostream& os) { … }
void PrintPropertyCallbackInfo(Address* args, std::ostream& os) { … }
#undef AS_PTR
#undef AS_OBJ
}
void PrintFunctionCallbackInfo(void* function_callback_info) { … }
void PrintPropertyCallbackInfo(void* property_callback_info) { … }
namespace {
void PrintHeapObjectHeaderWithoutMap(Tagged<HeapObject> object,
std::ostream& os, const char* id) { … }
template <typename T>
void PrintDictionaryContents(std::ostream& os, Tagged<T> dict) { … }
}
void HeapObjectLayout::PrintHeader(std::ostream& os, const char* id) { … }
void HeapObject::PrintHeader(std::ostream& os, const char* id) { … }
void HeapObject::HeapObjectPrint(std::ostream& os) { … }
void ByteArray::ByteArrayPrint(std::ostream& os) { … }
void TrustedByteArray::TrustedByteArrayPrint(std::ostream& os) { … }
void BytecodeArray::BytecodeArrayPrint(std::ostream& os) { … }
void BytecodeWrapper::BytecodeWrapperPrint(std::ostream& os) { … }
void FreeSpace::FreeSpacePrint(std::ostream& os) { … }
bool JSObject::PrintProperties(std::ostream& os) { … }
namespace {
template <class T>
bool IsTheHoleAt(Tagged<T> array, int index) { … }
template <>
bool IsTheHoleAt(Tagged<FixedDoubleArray> array, int index) { … }
template <class T>
double GetScalarElement(Tagged<T> array, int index) { … }
template <class T>
void DoPrintElements(std::ostream& os, Tagged<Object> object, int length) { … }
struct Fp16Printer { … };
template <typename ElementType>
void PrintTypedArrayElements(std::ostream& os, const ElementType* data_ptr,
size_t length, bool is_on_heap) { … }
template <typename T>
void PrintFixedArrayElements(std::ostream& os, Tagged<T> array, int capacity,
Tagged<Object> (*get)(Tagged<T>, int)) { … }
template <typename T>
void PrintFixedArrayElements(std::ostream& os, Tagged<T> array) { … }
void PrintDictionaryElements(std::ostream& os,
Tagged<FixedArrayBase> elements) { … }
void PrintSloppyArgumentElements(std::ostream& os, ElementsKind kind,
Tagged<SloppyArgumentsElements> elements) { … }
void PrintEmbedderData(Isolate* isolate, std::ostream& os,
EmbedderDataSlot slot) { … }
}
void JSObject::PrintElements(std::ostream& os) { … }
namespace {
void JSObjectPrintHeader(std::ostream& os, Tagged<JSObject> obj,
const char* id) { … }
void JSAPIObjectWithEmbedderSlotsPrintHeader(std::ostream& os,
Tagged<JSObject> obj,
const char* id = nullptr) { … }
void JSObjectPrintBody(std::ostream& os, Tagged<JSObject> obj,
bool print_elements = true) { … }
}
void JSObject::JSObjectPrint(std::ostream& os) { … }
void JSExternalObject::JSExternalObjectPrint(std::ostream& os) { … }
void JSGeneratorObject::JSGeneratorObjectPrint(std::ostream& os) { … }
void JSArray::JSArrayPrint(std::ostream& os) { … }
void JSPromise::JSPromisePrint(std::ostream& os) { … }
void JSRegExp::JSRegExpPrint(std::ostream& os) { … }
void RegExpData::RegExpDataPrint(std::ostream& os) { … }
void AtomRegExpData::AtomRegExpDataPrint(std::ostream& os) { … }
void IrRegExpData::IrRegExpDataPrint(std::ostream& os) { … }
void RegExpDataWrapper::RegExpDataWrapperPrint(std::ostream& os) { … }
void JSRegExpStringIterator::JSRegExpStringIteratorPrint(std::ostream& os) { … }
void Symbol::SymbolPrint(std::ostream& os) { … }
void DescriptorArray::DescriptorArrayPrint(std::ostream& os) { … }
namespace {
template <typename T>
void PrintFixedArrayWithHeader(std::ostream& os, Tagged<T> array,
const char* type) { … }
template <typename T>
void PrintWeakArrayElements(std::ostream& os, T* array) { … }
}
void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionPrint(
std::ostream& os) { … }
void ClassBoilerplate::ClassBoilerplatePrint(std::ostream& os) { … }
void RegExpBoilerplateDescription::RegExpBoilerplateDescriptionPrint(
std::ostream& os) { … }
void EmbedderDataArray::EmbedderDataArrayPrint(std::ostream& os) { … }
void FixedArray::FixedArrayPrint(std::ostream& os) { … }
void TrustedFixedArray::TrustedFixedArrayPrint(std::ostream& os) { … }
void ProtectedFixedArray::ProtectedFixedArrayPrint(std::ostream& os) { … }
void ArrayList::ArrayListPrint(std::ostream& os) { … }
void ScriptContextTable::ScriptContextTablePrint(std::ostream& os) { … }
void RegExpMatchInfo::RegExpMatchInfoPrint(std::ostream& os) { … }
void SloppyArgumentsElements::SloppyArgumentsElementsPrint(std::ostream& os) { … }
namespace {
const char* SideEffectType2String(SideEffectType type) { … }
}
void AccessorInfo::AccessorInfoPrint(std::ostream& os) { … }
void FunctionTemplateInfo::FunctionTemplateInfoPrint(std::ostream& os) { … }
namespace {
void PrintContextWithHeader(std::ostream& os, Tagged<Context> context,
const char* type) { … }
}
void Context::ContextPrint(std::ostream& os) { … }
void NativeContext::NativeContextPrint(std::ostream& os) { … }
namespace {
DataPrinter;
template <typename T>
void PrintTableContentsGeneric(std::ostream& os, T dict,
DataPrinter print_data_at) { … }
void PrintNameDictionaryFlags(std::ostream& os, Tagged<NameDictionary> dict) { … }
template <typename T>
void PrintDictionaryContentsFull(std::ostream& os, T dict) { … }
template <typename T>
void PrintHashMapContentsFull(std::ostream& os, T dict) { … }
template <typename T>
void PrintHashSetContentsFull(std::ostream& os, T dict) { … }
template <typename T>
void PrintOrderedHashTableHeaderAndBuckets(std::ostream& os, T table,
const char* type) { … }
template <typename T>
void PrintHashTableHeader(std::ostream& os, T table, const char* type) { … }
}
void ObjectHashTable::ObjectHashTablePrint(std::ostream& os) { … }
void NameToIndexHashTable::NameToIndexHashTablePrint(std::ostream& os) { … }
void RegisteredSymbolTable::RegisteredSymbolTablePrint(std::ostream& os) { … }
void NumberDictionary::NumberDictionaryPrint(std::ostream& os) { … }
void EphemeronHashTable::EphemeronHashTablePrint(std::ostream& os) { … }
void NameDictionary::NameDictionaryPrint(std::ostream& os) { … }
void GlobalDictionary::GlobalDictionaryPrint(std::ostream& os) { … }
void SmallOrderedHashSet::SmallOrderedHashSetPrint(std::ostream& os) { … }
void SmallOrderedHashMap::SmallOrderedHashMapPrint(std::ostream& os) { … }
void SmallOrderedNameDictionary::SmallOrderedNameDictionaryPrint(
std::ostream& os) { … }
void OrderedHashSet::OrderedHashSetPrint(std::ostream& os) { … }
void OrderedHashMap::OrderedHashMapPrint(std::ostream& os) { … }
void OrderedNameDictionary::OrderedNameDictionaryPrint(std::ostream& os) { … }
void print_hex_byte(std::ostream& os, int value) { … }
void SwissNameDictionary::SwissNameDictionaryPrint(std::ostream& os) { … }
void PropertyArray::PropertyArrayPrint(std::ostream& os) { … }
void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { … }
void WeakFixedArray::WeakFixedArrayPrint(std::ostream& os) { … }
void TrustedWeakFixedArray::TrustedWeakFixedArrayPrint(std::ostream& os) { … }
void WeakArrayList::WeakArrayListPrint(std::ostream& os) { … }
void TransitionArray::TransitionArrayPrint(std::ostream& os) { … }
void FeedbackCell::FeedbackCellPrint(std::ostream& os) { … }
void FeedbackVectorSpec::Print() { … }
void FeedbackVectorSpec::FeedbackVectorSpecPrint(std::ostream& os) { … }
void FeedbackMetadata::FeedbackMetadataPrint(std::ostream& os) { … }
void ClosureFeedbackCellArray::ClosureFeedbackCellArrayPrint(std::ostream& os) { … }
void FeedbackVector::FeedbackVectorPrint(std::ostream& os) { … }
void FeedbackVector::FeedbackSlotPrint(std::ostream& os, FeedbackSlot slot) { … }
void FeedbackNexus::Print(std::ostream& os) { … }
void Oddball::OddballPrint(std::ostream& os) { … }
void Hole::HolePrint(std::ostream& os) { … }
void JSAsyncFunctionObject::JSAsyncFunctionObjectPrint(std::ostream& os) { … }
void JSAsyncGeneratorObject::JSAsyncGeneratorObjectPrint(std::ostream& os) { … }
void JSArgumentsObject::JSArgumentsObjectPrint(std::ostream& os) { … }
void JSStringIterator::JSStringIteratorPrint(std::ostream& os) { … }
void JSAsyncFromSyncIterator::JSAsyncFromSyncIteratorPrint(std::ostream& os) { … }
void JSValidIteratorWrapper::JSValidIteratorWrapperPrint(std::ostream& os) { … }
void JSPrimitiveWrapper::JSPrimitiveWrapperPrint(std::ostream& os) { … }
void JSMessageObject::JSMessageObjectPrint(std::ostream& os) { … }
void String::StringPrint(std::ostream& os) { … }
void Name::NamePrint(std::ostream& os) { … }
static const char* const weekdays[] = …;
void JSDate::JSDatePrint(std::ostream& os) { … }
void JSSet::JSSetPrint(std::ostream& os) { … }
void JSMap::JSMapPrint(std::ostream& os) { … }
void JSCollectionIterator::JSCollectionIteratorPrint(std::ostream& os,
const char* name) { … }
void JSSetIterator::JSSetIteratorPrint(std::ostream& os) { … }
void JSMapIterator::JSMapIteratorPrint(std::ostream& os) { … }
void JSWeakRef::JSWeakRefPrint(std::ostream& os) { … }
void JSShadowRealm::JSShadowRealmPrint(std::ostream& os) { … }
void JSWrappedFunction::JSWrappedFunctionPrint(std::ostream& os) { … }
void JSFinalizationRegistry::JSFinalizationRegistryPrint(std::ostream& os) { … }
void JSSharedArray::JSSharedArrayPrint(std::ostream& os) { … }
void JSSharedStruct::JSSharedStructPrint(std::ostream& os) { … }
void JSAtomicsMutex::JSAtomicsMutexPrint(std::ostream& os) { … }
void JSAtomicsCondition::JSAtomicsConditionPrint(std::ostream& os) { … }
std::ostream& operator<<(std::ostream& os, DisposableStackState state) { … }
void JSDisposableStackBase::JSDisposableStackBasePrint(std::ostream& os) { … }
void JSAsyncDisposableStack::JSAsyncDisposableStackPrint(std::ostream& os) { … }
void JSIteratorHelper::JSIteratorHelperPrintHeader(std::ostream& os,
const char* helper_name) { … }
void JSIteratorMapHelper::JSIteratorMapHelperPrint(std::ostream& os) { … }
void JSIteratorFilterHelper::JSIteratorFilterHelperPrint(std::ostream& os) { … }
void JSIteratorTakeHelper::JSIteratorTakeHelperPrint(std::ostream& os) { … }
void JSIteratorDropHelper::JSIteratorDropHelperPrint(std::ostream& os) { … }
void JSIteratorFlatMapHelper::JSIteratorFlatMapHelperPrint(std::ostream& os) { … }
void JSWeakMap::JSWeakMapPrint(std::ostream& os) { … }
void JSWeakSet::JSWeakSetPrint(std::ostream& os) { … }
void JSArrayBuffer::JSArrayBufferPrint(std::ostream& os) { … }
void JSTypedArray::JSTypedArrayPrint(std::ostream& os) { … }
void JSArrayIterator::JSArrayIteratorPrint(std::ostream& os) { … }
void JSDataView::JSDataViewPrint(std::ostream& os) { … }
void JSRabGsabDataView::JSRabGsabDataViewPrint(std::ostream& os) { … }
void JSBoundFunction::JSBoundFunctionPrint(std::ostream& os) { … }
void JSFunction::JSFunctionPrint(std::ostream& os) { … }
void SharedFunctionInfo::PrintSourceCode(std::ostream& os) { … }
void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { … }
void SharedFunctionInfoWrapper::SharedFunctionInfoWrapperPrint(
std::ostream& os) { … }
void JSGlobalProxy::JSGlobalProxyPrint(std::ostream& os) { … }
void JSGlobalObject::JSGlobalObjectPrint(std::ostream& os) { … }
void PropertyCell::PropertyCellPrint(std::ostream& os) { … }
void ConstTrackingLetCell::ConstTrackingLetCellPrint(std::ostream& os) { … }
void InstructionStream::InstructionStreamPrint(std::ostream& os) { … }
void Code::CodePrint(std::ostream& os, const char* name, Address current_pc) { … }
void CodeWrapper::CodeWrapperPrint(std::ostream& os) { … }
void Foreign::ForeignPrint(std::ostream& os) { … }
void TrustedForeign::TrustedForeignPrint(std::ostream& os) { … }
void AsyncGeneratorRequest::AsyncGeneratorRequestPrint(std::ostream& os) { … }
static void PrintModuleFields(Tagged<Module> module, std::ostream& os) { … }
void Module::ModulePrint(std::ostream& os) { … }
void SourceTextModule::SourceTextModulePrint(std::ostream& os) { … }
void JSModuleNamespace::JSModuleNamespacePrint(std::ostream& os) { … }
void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) { … }
void ArrayBoilerplateDescription::ArrayBoilerplateDescriptionPrint(
std::ostream& os) { … }
#if V8_ENABLE_WEBASSEMBLY
void AsmWasmData::AsmWasmDataPrint(std::ostream& os) { … }
void WasmTypeInfo::WasmTypeInfoPrint(std::ostream& os) { … }
void WasmStruct::WasmStructPrint(std::ostream& os) { … }
void WasmArray::WasmArrayPrint(std::ostream& os) { … }
void WasmContinuationObject::WasmContinuationObjectPrint(std::ostream& os) { … }
void WasmSuspenderObject::WasmSuspenderObjectPrint(std::ostream& os) { … }
void WasmSuspendingObject::WasmSuspendingObjectPrint(std::ostream& os) { … }
void WasmInstanceObject::WasmInstanceObjectPrint(std::ostream& os) { … }
void WasmTrustedInstanceData::WasmTrustedInstanceDataPrint(std::ostream& os) { … }
void WasmDispatchTable::WasmDispatchTablePrint(std::ostream& os) { … }
void WasmFunctionData::WasmFunctionDataPrint(std::ostream& os) { … }
void WasmExportedFunctionData::WasmExportedFunctionDataPrint(std::ostream& os) { … }
void WasmJSFunctionData::WasmJSFunctionDataPrint(std::ostream& os) { … }
void WasmResumeData::WasmResumeDataPrint(std::ostream& os) { … }
void WasmImportData::WasmImportDataPrint(std::ostream& os) { … }
void WasmInternalFunction::WasmInternalFunctionPrint(std::ostream& os) { … }
void WasmFuncRef::WasmFuncRefPrint(std::ostream& os) { … }
void WasmCapiFunctionData::WasmCapiFunctionDataPrint(std::ostream& os) { … }
void WasmExceptionPackage::WasmExceptionPackagePrint(std::ostream& os) { … }
void WasmModuleObject::WasmModuleObjectPrint(std::ostream& os) { … }
void WasmGlobalObject::WasmGlobalObjectPrint(std::ostream& os) { … }
void WasmValueObject::WasmValueObjectPrint(std::ostream& os) { … }
#endif
void LoadHandler::LoadHandlerPrint(std::ostream& os) { … }
void StoreHandler::StoreHandlerPrint(std::ostream& os) { … }
void AllocationSite::AllocationSitePrint(std::ostream& os) { … }
void AllocationMemento::AllocationMementoPrint(std::ostream& os) { … }
void ScriptOrModule::ScriptOrModulePrint(std::ostream& os) { … }
void Script::ScriptPrint(std::ostream& os) { … }
void JSTemporalPlainDate::JSTemporalPlainDatePrint(std::ostream& os) { … }
void JSTemporalPlainTime::JSTemporalPlainTimePrint(std::ostream& os) { … }
void JSTemporalPlainDateTime::JSTemporalPlainDateTimePrint(std::ostream& os) { … }
void JSTemporalZonedDateTime::JSTemporalZonedDateTimePrint(std::ostream& os) { … }
void JSTemporalDuration::JSTemporalDurationPrint(std::ostream& os) { … }
void JSTemporalInstant::JSTemporalInstantPrint(std::ostream& os) { … }
void JSTemporalPlainYearMonth::JSTemporalPlainYearMonthPrint(std::ostream& os) { … }
void JSTemporalPlainMonthDay::JSTemporalPlainMonthDayPrint(std::ostream& os) { … }
void JSTemporalTimeZone::JSTemporalTimeZonePrint(std::ostream& os) { … }
void JSTemporalCalendar::JSTemporalCalendarPrint(std::ostream& os) { … }
void JSRawJson::JSRawJsonPrint(std::ostream& os) { … }
#ifdef V8_INTL_SUPPORT
void JSV8BreakIterator::JSV8BreakIteratorPrint(std::ostream& os) { … }
void JSCollator::JSCollatorPrint(std::ostream& os) { … }
void JSDateTimeFormat::JSDateTimeFormatPrint(std::ostream& os) { … }
void JSDisplayNames::JSDisplayNamesPrint(std::ostream& os) { … }
void JSDurationFormat::JSDurationFormatPrint(std::ostream& os) { … }
void JSListFormat::JSListFormatPrint(std::ostream& os) { … }
void JSLocale::JSLocalePrint(std::ostream& os) { … }
void JSNumberFormat::JSNumberFormatPrint(std::ostream& os) { … }
void JSPluralRules::JSPluralRulesPrint(std::ostream& os) { … }
void JSRelativeTimeFormat::JSRelativeTimeFormatPrint(std::ostream& os) { … }
void JSSegmentIterator::JSSegmentIteratorPrint(std::ostream& os) { … }
void JSSegmenter::JSSegmenterPrint(std::ostream& os) { … }
void JSSegments::JSSegmentsPrint(std::ostream& os) { … }
#endif
namespace {
void PrintScopeInfoList(Tagged<ScopeInfo> scope_info, std::ostream& os,
const char* list_name, int length) { … }
}
void ScopeInfo::ScopeInfoPrint(std::ostream& os) { … }
void PreparseData::PreparseDataPrint(std::ostream& os) { … }
void HeapNumber::HeapNumberPrint(std::ostream& os) { … }
#endif
void HeapObject::Print() { … }
void HeapObject::Print(Tagged<Object> obj) { … }
void HeapObject::Print(Tagged<Object> obj, std::ostream& os) { … }
void HeapObject::HeapObjectShortPrint(std::ostream& os) { … }
void HeapNumber::HeapNumberShortPrint(std::ostream& os) { … }
void Name::NameShortPrint() { … }
int Name::NameShortPrint(base::Vector<char> str) { … }
void Symbol::SymbolShortPrint(std::ostream& os) { … }
void Map::PrintMapDetails(std::ostream& os) { … }
void Map::MapPrint(std::ostream& os) { … }
void DescriptorArray::PrintDescriptors(std::ostream& os) { … }
void DescriptorArray::PrintDescriptorDetails(std::ostream& os,
InternalIndex descriptor,
PropertyDetails::PrintMode mode) { … }
#if defined(DEBUG) || defined(OBJECT_PRINT)
char* String::ToAsciiArray() { … }
void TransitionsAccessor::PrintOneTransition(std::ostream& os, Tagged<Name> key,
Tagged<Map> target) { … }
void TransitionArray::PrintInternal(std::ostream& os) { … }
void TransitionsAccessor::PrintTransitions(std::ostream& os) { … }
void TransitionsAccessor::PrintTransitionTree() { … }
void TransitionsAccessor::PrintTransitionTree(
std::ostream& os, int level, DisallowGarbageCollection* no_gc) { … }
void JSObject::PrintTransitions(std::ostream& os) { … }
#endif
}
namespace {
inline i::Tagged<i::Object> GetObjectFromRaw(void* object) { … }
}
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern i::Tagged<i::Object> _v8_internal_Get_Object(
void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_Object(void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern std::string _v8_internal_Print_Object_To_String(
void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_LoadHandler(void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_StoreHandler(void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_Code(void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_OnlyCode(void* object,
size_t range_limit) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_StackTrace() { … }
namespace _v8_internal_debugonly {
struct StackTraceDebugDetails { … };
}
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern std::vector<
_v8_internal_debugonly::StackTraceDebugDetails>
_v8_internal_Expand_StackTrace(i::Isolate* isolate) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_TransitionTree(
void* object, bool start_at_root = false) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE extern void _v8_internal_Print_Object_MarkBit(void* object) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE void _v8_internal_Print_FunctionCallbackInfo(
void* function_callback_info) { … }
V8_DONT_STRIP_SYMBOL
V8_EXPORT_PRIVATE void _v8_internal_Print_PropertyCallbackInfo(
void* property_callback_info) { … }