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