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