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