5 #include "src/objects.h" 7 #include "src/assembler-inl.h" 8 #include "src/bootstrapper.h" 10 #include "src/disasm.h" 11 #include "src/disassembler.h" 12 #include "src/elements.h" 13 #include "src/field-type.h" 14 #include "src/layout-descriptor.h" 15 #include "src/macro-assembler.h" 16 #include "src/objects-inl.h" 17 #include "src/objects/arguments-inl.h" 18 #include "src/objects/bigint.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/hash-table-inl.h" 24 #include "src/objects/js-array-inl.h" 25 #ifdef V8_INTL_SUPPORT 26 #include "src/objects/js-break-iterator-inl.h" 27 #include "src/objects/js-collator-inl.h" 28 #endif // V8_INTL_SUPPORT 29 #include "src/objects/js-collection-inl.h" 30 #ifdef V8_INTL_SUPPORT 31 #include "src/objects/js-date-time-format-inl.h" 32 #endif // V8_INTL_SUPPORT 33 #include "src/objects/js-generator-inl.h" 34 #ifdef V8_INTL_SUPPORT 35 #include "src/objects/js-list-format-inl.h" 36 #include "src/objects/js-locale-inl.h" 37 #include "src/objects/js-number-format-inl.h" 38 #include "src/objects/js-plural-rules-inl.h" 39 #endif // V8_INTL_SUPPORT 40 #include "src/objects/js-regexp-inl.h" 41 #include "src/objects/js-regexp-string-iterator-inl.h" 42 #ifdef V8_INTL_SUPPORT 43 #include "src/objects/js-relative-time-format-inl.h" 44 #include "src/objects/js-segment-iterator-inl.h" 45 #include "src/objects/js-segmenter-inl.h" 46 #endif // V8_INTL_SUPPORT 47 #include "src/objects/js-weak-refs-inl.h" 48 #include "src/objects/literal-objects-inl.h" 49 #include "src/objects/maybe-object.h" 50 #include "src/objects/microtask-inl.h" 51 #include "src/objects/module-inl.h" 52 #include "src/objects/promise-inl.h" 53 #include "src/objects/stack-frame-info-inl.h" 54 #include "src/ostreams.h" 55 #include "src/regexp/jsregexp.h" 56 #include "src/transitions.h" 57 #include "src/wasm/wasm-objects-inl.h" 86 void Object::ObjectVerify(Isolate* isolate) {
88 Smi::cast(
this)->SmiVerify(isolate);
90 HeapObject::cast(
this)->HeapObjectVerify(isolate);
92 CHECK(!IsConstructor() || IsCallable());
95 void Object::VerifyPointer(Isolate* isolate, Object* p) {
96 if (p->IsHeapObject()) {
97 HeapObject::VerifyHeapPointer(isolate, p);
103 void ObjectPtr::VerifyPointer(Isolate* isolate, Object* p) {
104 Object::VerifyPointer(isolate, p);
107 void MaybeObject::VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject p) {
108 HeapObject* heap_object;
109 if (p->GetHeapObject(&heap_object)) {
110 HeapObject::VerifyHeapPointer(isolate, heap_object);
112 CHECK(p->IsSmi() || p->IsCleared());
117 void VerifyForeignPointer(Isolate* isolate, HeapObject* host, Object* foreign) {
118 host->VerifyPointer(isolate, foreign);
119 CHECK(foreign->IsUndefined(isolate) || Foreign::IsNormalized(foreign));
123 void Smi::SmiVerify(Isolate* isolate) {
125 CHECK(!IsCallable());
126 CHECK(!IsConstructor());
129 void HeapObject::HeapObjectVerify(Isolate* isolate) {
130 VerifyHeapPointer(isolate, map());
131 CHECK(map()->IsMap());
133 switch (map()->instance_type()) {
134 #define STRING_TYPE_CASE(TYPE, size, name, CamelName) case TYPE: 135 STRING_TYPE_LIST(STRING_TYPE_CASE)
136 #undef STRING_TYPE_CASE 137 String::cast(
this)->StringVerify(isolate);
140 Symbol::cast(
this)->SymbolVerify(isolate);
143 Map::cast(
this)->MapVerify(isolate);
145 case HEAP_NUMBER_TYPE:
146 CHECK(IsHeapNumber());
148 case MUTABLE_HEAP_NUMBER_TYPE:
149 CHECK(IsMutableHeapNumber());
152 BigInt::cast(
this)->BigIntVerify(isolate);
154 case CALL_HANDLER_INFO_TYPE:
155 CallHandlerInfo::cast(
this)->CallHandlerInfoVerify(isolate);
157 case OBJECT_BOILERPLATE_DESCRIPTION_TYPE:
158 ObjectBoilerplateDescription::cast(
this)
159 ->ObjectBoilerplateDescriptionVerify(isolate);
161 case EMBEDDER_DATA_ARRAY_TYPE:
162 EmbedderDataArray::cast(
this)->EmbedderDataArrayVerify(isolate);
165 case HASH_TABLE_TYPE:
166 case ORDERED_HASH_MAP_TYPE:
167 case ORDERED_HASH_SET_TYPE:
168 case ORDERED_NAME_DICTIONARY_TYPE:
169 case NAME_DICTIONARY_TYPE:
170 case GLOBAL_DICTIONARY_TYPE:
171 case NUMBER_DICTIONARY_TYPE:
172 case SIMPLE_NUMBER_DICTIONARY_TYPE:
173 case STRING_TABLE_TYPE:
174 case EPHEMERON_HASH_TABLE_TYPE:
175 case FIXED_ARRAY_TYPE:
176 case SCOPE_INFO_TYPE:
177 case SCRIPT_CONTEXT_TABLE_TYPE:
178 FixedArray::cast(
this)->FixedArrayVerify(isolate);
180 case AWAIT_CONTEXT_TYPE:
181 case BLOCK_CONTEXT_TYPE:
182 case CATCH_CONTEXT_TYPE:
183 case DEBUG_EVALUATE_CONTEXT_TYPE:
184 case EVAL_CONTEXT_TYPE:
185 case FUNCTION_CONTEXT_TYPE:
186 case MODULE_CONTEXT_TYPE:
187 case SCRIPT_CONTEXT_TYPE:
188 case WITH_CONTEXT_TYPE:
189 Context::cast(
this)->ContextVerify(isolate);
191 case NATIVE_CONTEXT_TYPE:
192 NativeContext::cast(
this)->NativeContextVerify(isolate);
194 case WEAK_FIXED_ARRAY_TYPE:
195 WeakFixedArray::cast(
this)->WeakFixedArrayVerify(isolate);
197 case WEAK_ARRAY_LIST_TYPE:
198 WeakArrayList::cast(
this)->WeakArrayListVerify(isolate);
200 case FIXED_DOUBLE_ARRAY_TYPE:
201 FixedDoubleArray::cast(
this)->FixedDoubleArrayVerify(isolate);
203 case FEEDBACK_METADATA_TYPE:
204 FeedbackMetadata::cast(
this)->FeedbackMetadataVerify(isolate);
206 case BYTE_ARRAY_TYPE:
207 ByteArray::cast(
this)->ByteArrayVerify(isolate);
209 case BYTECODE_ARRAY_TYPE:
210 BytecodeArray::cast(
this)->BytecodeArrayVerify(isolate);
212 case DESCRIPTOR_ARRAY_TYPE:
213 DescriptorArray::cast(
this)->DescriptorArrayVerify(isolate);
215 case TRANSITION_ARRAY_TYPE:
216 TransitionArray::cast(
this)->TransitionArrayVerify(isolate);
218 case PROPERTY_ARRAY_TYPE:
219 PropertyArray::cast(
this)->PropertyArrayVerify(isolate);
221 case FREE_SPACE_TYPE:
222 FreeSpace::cast(
this)->FreeSpaceVerify(isolate);
224 case FEEDBACK_CELL_TYPE:
225 FeedbackCell::cast(
this)->FeedbackCellVerify(isolate);
227 case FEEDBACK_VECTOR_TYPE:
228 FeedbackVector::cast(
this)->FeedbackVectorVerify(isolate);
231 #define VERIFY_TYPED_ARRAY(Type, type, TYPE, ctype) \ 232 case FIXED_##TYPE##_ARRAY_TYPE: \ 233 Fixed##Type##Array::cast(this)->FixedTypedArrayVerify(isolate); \ 236 TYPED_ARRAYS(VERIFY_TYPED_ARRAY)
237 #undef VERIFY_TYPED_ARRAY 240 Code::cast(
this)->CodeVerify(isolate);
243 Oddball::cast(
this)->OddballVerify(isolate);
247 case JS_API_OBJECT_TYPE:
248 case JS_SPECIAL_API_OBJECT_TYPE:
249 case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
250 case WASM_EXCEPTION_TYPE:
251 case WASM_GLOBAL_TYPE:
252 case WASM_MEMORY_TYPE:
253 case WASM_TABLE_TYPE:
254 JSObject::cast(
this)->JSObjectVerify(isolate);
256 case WASM_MODULE_TYPE:
257 WasmModuleObject::cast(
this)->WasmModuleObjectVerify(isolate);
259 case WASM_INSTANCE_TYPE:
260 WasmInstanceObject::cast(
this)->WasmInstanceObjectVerify(isolate);
262 case JS_ARGUMENTS_TYPE:
263 JSArgumentsObject::cast(
this)->JSArgumentsObjectVerify(isolate);
265 case JS_GENERATOR_OBJECT_TYPE:
266 JSGeneratorObject::cast(
this)->JSGeneratorObjectVerify(isolate);
268 case JS_ASYNC_FUNCTION_OBJECT_TYPE:
269 JSAsyncFunctionObject::cast(
this)->JSAsyncFunctionObjectVerify(isolate);
271 case JS_ASYNC_GENERATOR_OBJECT_TYPE:
272 JSAsyncGeneratorObject::cast(
this)->JSAsyncGeneratorObjectVerify(isolate);
275 JSValue::cast(
this)->JSValueVerify(isolate);
278 JSDate::cast(
this)->JSDateVerify(isolate);
280 case JS_BOUND_FUNCTION_TYPE:
281 JSBoundFunction::cast(
this)->JSBoundFunctionVerify(isolate);
283 case JS_FUNCTION_TYPE:
284 JSFunction::cast(
this)->JSFunctionVerify(isolate);
286 case JS_GLOBAL_PROXY_TYPE:
287 JSGlobalProxy::cast(
this)->JSGlobalProxyVerify(isolate);
289 case JS_GLOBAL_OBJECT_TYPE:
290 JSGlobalObject::cast(
this)->JSGlobalObjectVerify(isolate);
293 Cell::cast(
this)->CellVerify(isolate);
295 case PROPERTY_CELL_TYPE:
296 PropertyCell::cast(
this)->PropertyCellVerify(isolate);
299 JSArray::cast(
this)->JSArrayVerify(isolate);
301 case JS_MODULE_NAMESPACE_TYPE:
302 JSModuleNamespace::cast(
this)->JSModuleNamespaceVerify(isolate);
305 JSSet::cast(
this)->JSSetVerify(isolate);
308 JSMap::cast(
this)->JSMapVerify(isolate);
310 case JS_SET_KEY_VALUE_ITERATOR_TYPE:
311 case JS_SET_VALUE_ITERATOR_TYPE:
312 JSSetIterator::cast(
this)->JSSetIteratorVerify(isolate);
314 case JS_MAP_KEY_ITERATOR_TYPE:
315 case JS_MAP_KEY_VALUE_ITERATOR_TYPE:
316 case JS_MAP_VALUE_ITERATOR_TYPE:
317 JSMapIterator::cast(
this)->JSMapIteratorVerify(isolate);
319 case JS_ARRAY_ITERATOR_TYPE:
320 JSArrayIterator::cast(
this)->JSArrayIteratorVerify(isolate);
322 case JS_STRING_ITERATOR_TYPE:
323 JSStringIterator::cast(
this)->JSStringIteratorVerify(isolate);
325 case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE:
326 JSAsyncFromSyncIterator::cast(
this)->JSAsyncFromSyncIteratorVerify(
329 case JS_WEAK_CELL_TYPE:
330 case JS_WEAK_REF_TYPE:
331 JSWeakCell::cast(
this)->JSWeakCellVerify(isolate);
333 case JS_WEAK_FACTORY_TYPE:
334 JSWeakFactory::cast(
this)->JSWeakFactoryVerify(isolate);
336 case JS_WEAK_FACTORY_CLEANUP_ITERATOR_TYPE:
337 JSWeakFactoryCleanupIterator::cast(
this)
338 ->JSWeakFactoryCleanupIteratorVerify(isolate);
340 case JS_WEAK_MAP_TYPE:
341 JSWeakMap::cast(
this)->JSWeakMapVerify(isolate);
343 case JS_WEAK_SET_TYPE:
344 JSWeakSet::cast(
this)->JSWeakSetVerify(isolate);
346 case JS_PROMISE_TYPE:
347 JSPromise::cast(
this)->JSPromiseVerify(isolate);
350 JSRegExp::cast(
this)->JSRegExpVerify(isolate);
352 case JS_REGEXP_STRING_ITERATOR_TYPE:
353 JSRegExpStringIterator::cast(
this)->JSRegExpStringIteratorVerify(isolate);
358 JSProxy::cast(
this)->JSProxyVerify(isolate);
361 Foreign::cast(
this)->ForeignVerify(isolate);
363 case PRE_PARSED_SCOPE_DATA_TYPE:
364 PreParsedScopeData::cast(
this)->PreParsedScopeDataVerify(isolate);
366 case UNCOMPILED_DATA_WITHOUT_PRE_PARSED_SCOPE_TYPE:
367 UncompiledDataWithoutPreParsedScope::cast(
this)
368 ->UncompiledDataWithoutPreParsedScopeVerify(isolate);
370 case UNCOMPILED_DATA_WITH_PRE_PARSED_SCOPE_TYPE:
371 UncompiledDataWithPreParsedScope::cast(
this)
372 ->UncompiledDataWithPreParsedScopeVerify(isolate);
374 case SHARED_FUNCTION_INFO_TYPE:
375 SharedFunctionInfo::cast(
this)->SharedFunctionInfoVerify(isolate);
377 case JS_MESSAGE_OBJECT_TYPE:
378 JSMessageObject::cast(
this)->JSMessageObjectVerify(isolate);
380 case JS_ARRAY_BUFFER_TYPE:
381 JSArrayBuffer::cast(
this)->JSArrayBufferVerify(isolate);
383 case JS_TYPED_ARRAY_TYPE:
384 JSTypedArray::cast(
this)->JSTypedArrayVerify(isolate);
386 case JS_DATA_VIEW_TYPE:
387 JSDataView::cast(
this)->JSDataViewVerify(isolate);
389 case SMALL_ORDERED_HASH_SET_TYPE:
390 SmallOrderedHashSet::cast(
this)->SmallOrderedHashTableVerify(isolate);
392 case SMALL_ORDERED_HASH_MAP_TYPE:
393 SmallOrderedHashMap::cast(
this)->SmallOrderedHashTableVerify(isolate);
395 case SMALL_ORDERED_NAME_DICTIONARY_TYPE:
396 SmallOrderedNameDictionary::cast(
this)->SmallOrderedHashTableVerify(
399 case CODE_DATA_CONTAINER_TYPE:
400 CodeDataContainer::cast(
this)->CodeDataContainerVerify(isolate);
402 #ifdef V8_INTL_SUPPORT 403 case JS_INTL_V8_BREAK_ITERATOR_TYPE:
404 JSV8BreakIterator::cast(
this)->JSV8BreakIteratorVerify(isolate);
406 case JS_INTL_COLLATOR_TYPE:
407 JSCollator::cast(
this)->JSCollatorVerify(isolate);
409 case JS_INTL_DATE_TIME_FORMAT_TYPE:
410 JSDateTimeFormat::cast(
this)->JSDateTimeFormatVerify(isolate);
412 case JS_INTL_LIST_FORMAT_TYPE:
413 JSListFormat::cast(
this)->JSListFormatVerify(isolate);
415 case JS_INTL_LOCALE_TYPE:
416 JSLocale::cast(
this)->JSLocaleVerify(isolate);
418 case JS_INTL_NUMBER_FORMAT_TYPE:
419 JSNumberFormat::cast(
this)->JSNumberFormatVerify(isolate);
421 case JS_INTL_PLURAL_RULES_TYPE:
422 JSPluralRules::cast(
this)->JSPluralRulesVerify(isolate);
424 case JS_INTL_RELATIVE_TIME_FORMAT_TYPE:
425 JSRelativeTimeFormat::cast(
this)->JSRelativeTimeFormatVerify(isolate);
427 case JS_INTL_SEGMENT_ITERATOR_TYPE:
428 JSSegmentIterator::cast(
this)->JSSegmentIteratorVerify(isolate);
430 case JS_INTL_SEGMENTER_TYPE:
431 JSSegmenter::cast(
this)->JSSegmenterVerify(isolate);
433 #endif // V8_INTL_SUPPORT 435 #define MAKE_STRUCT_CASE(TYPE, Name, name) \ 437 Name::cast(this)->Name##Verify(isolate); \ 439 STRUCT_LIST(MAKE_STRUCT_CASE)
440 #undef MAKE_STRUCT_CASE 442 case ALLOCATION_SITE_TYPE:
443 AllocationSite::cast(
this)->AllocationSiteVerify(isolate);
446 case LOAD_HANDLER_TYPE:
447 LoadHandler::cast(
this)->LoadHandlerVerify(isolate);
450 case STORE_HANDLER_TYPE:
451 StoreHandler::cast(
this)->StoreHandlerVerify(isolate);
456 void HeapObjectPtr::HeapObjectVerify(Isolate* isolate) {
457 reinterpret_cast<HeapObject*
>(ptr())->HeapObjectVerify(isolate);
460 void HeapObject::VerifyHeapPointer(Isolate* isolate, Object* p) {
461 CHECK(p->IsHeapObject());
462 HeapObject* ho = HeapObject::cast(p);
463 CHECK(isolate->heap()->Contains(ho));
466 void HeapObjectPtr::VerifyHeapPointer(Isolate* isolate, Object* p) {
467 HeapObject::VerifyHeapPointer(isolate, p);
470 void Symbol::SymbolVerify(Isolate* isolate) {
472 CHECK(HasHashCode());
474 CHECK(name()->IsUndefined(isolate) || name()->IsString());
475 CHECK_IMPLIES(IsPrivateName(), IsPrivate());
478 void ByteArray::ByteArrayVerify(Isolate* isolate) { CHECK(IsByteArray()); }
480 void BytecodeArray::BytecodeArrayVerify(Isolate* isolate) {
486 CHECK(IsBytecodeArray());
487 CHECK(constant_pool()->IsFixedArray());
488 VerifyHeapPointer(isolate, constant_pool());
491 void FreeSpace::FreeSpaceVerify(Isolate* isolate) { CHECK(IsFreeSpace()); }
493 void FeedbackCell::FeedbackCellVerify(Isolate* isolate) {
494 CHECK(IsFeedbackCell());
496 VerifyHeapPointer(isolate, value());
497 CHECK(value()->IsUndefined(isolate) || value()->IsFeedbackVector());
500 void FeedbackVector::FeedbackVectorVerify(Isolate* isolate) {
501 CHECK(IsFeedbackVector());
502 MaybeObject code = optimized_code_weak_or_smi();
503 MaybeObject::VerifyMaybeObjectPointer(isolate, code);
504 CHECK(code->IsSmi() || code->IsWeakOrCleared());
507 template <
class Traits>
508 void FixedTypedArray<Traits>::FixedTypedArrayVerify(Isolate* isolate) {
509 CHECK(IsHeapObject() && map()->instance_type() == Traits::kInstanceType);
510 if (base_pointer()->ptr() == ptr()) {
511 CHECK(reinterpret_cast<Address>(external_pointer()) ==
512 ExternalReference::fixed_typed_array_base_data_offset().address());
514 CHECK_EQ(base_pointer(), Smi::kZero);
518 bool JSObject::ElementsAreSafeToExamine()
const {
521 return elements() != GetReadOnlyRoots().one_pointer_filler_map();
525 void VerifyJSObjectElements(Isolate* isolate, JSObject*
object) {
527 if (object->IsJSTypedArray()) {
534 CHECK(!object->HasFixedTypedArrayElements());
535 CHECK(!object->elements()->IsFixedTypedArrayBase());
537 if (object->HasDoubleElements()) {
538 if (object->elements()->length() > 0) {
539 CHECK(object->elements()->IsFixedDoubleArray());
544 FixedArray elements = FixedArray::cast(object->elements());
545 if (object->HasSmiElements()) {
548 for (
int i = 0;
i < elements->length();
i++) {
549 Object* value = elements->get(
i);
550 CHECK(value->IsSmi() || value->IsTheHole(isolate));
552 }
else if (object->HasObjectElements()) {
553 for (
int i = 0;
i < elements->length();
i++) {
554 Object* element = elements->get(
i);
555 CHECK_IMPLIES(!element->IsSmi(), !HasWeakHeapObjectTag(element));
561 void JSObject::JSObjectVerify(Isolate* isolate) {
562 VerifyPointer(isolate, raw_properties_or_hash());
563 VerifyHeapPointer(isolate, elements());
565 CHECK_IMPLIES(HasSloppyArgumentsElements(), IsJSArgumentsObject());
566 if (HasFastProperties()) {
567 int actual_unused_property_fields = map()->GetInObjectProperties() +
568 property_array()->length() -
569 map()->NextFreePropertyIndex();
570 if (map()->UnusedPropertyFields() != actual_unused_property_fields) {
577 CHECK_GT(actual_unused_property_fields, map()->UnusedPropertyFields());
578 int delta = actual_unused_property_fields - map()->UnusedPropertyFields();
579 CHECK_EQ(0, delta % JSObject::kFieldsAdded);
581 DescriptorArray* descriptors = map()->instance_descriptors();
582 bool is_transitionable_fast_elements_kind =
583 IsTransitionableFastElementsKind(map()->elements_kind());
585 for (
int i = 0;
i < map()->NumberOfOwnDescriptors();
i++) {
586 PropertyDetails details = descriptors->GetDetails(
i);
587 if (details.location() == kField) {
588 DCHECK_EQ(kData, details.kind());
589 Representation r = details.representation();
590 FieldIndex index = FieldIndex::ForDescriptor(map(),
i);
591 if (IsUnboxedDoubleField(index)) {
592 DCHECK(r.IsDouble());
595 Object* value = RawFastPropertyAt(index);
596 if (r.IsDouble()) DCHECK(value->IsMutableHeapNumber());
597 if (value->IsUninitialized(isolate))
continue;
598 if (r.IsSmi()) DCHECK(value->IsSmi());
599 if (r.IsHeapObject()) DCHECK(value->IsHeapObject());
600 FieldType field_type = descriptors->GetFieldType(
i);
601 bool type_is_none = field_type->IsNone();
602 bool type_is_any = field_type->IsAny();
605 }
else if (!type_is_any && !(type_is_none && r.IsHeapObject())) {
606 CHECK(!field_type->NowStable() || field_type->NowContains(value));
608 CHECK_IMPLIES(is_transitionable_fast_elements_kind,
609 !Map::IsInplaceGeneralizableField(details.constness(), r,
614 if (map()->EnumLength() != kInvalidEnumCacheSentinel) {
615 EnumCache* enum_cache = descriptors->enum_cache();
616 FixedArray keys = enum_cache->keys();
617 FixedArray indices = enum_cache->indices();
618 CHECK_LE(map()->EnumLength(), keys->length());
619 CHECK_IMPLIES(indices != ReadOnlyRoots(isolate).empty_fixed_array(),
620 keys->length() == indices->length());
626 if (ElementsAreSafeToExamine()) {
627 CHECK_EQ((map()->has_fast_smi_or_object_elements() ||
628 (elements() == GetReadOnlyRoots().empty_fixed_array()) ||
629 HasFastStringWrapperElements()),
630 (elements()->map() == GetReadOnlyRoots().fixed_array_map() ||
631 elements()->map() == GetReadOnlyRoots().fixed_cow_array_map()));
632 CHECK_EQ(map()->has_fast_object_elements(), HasObjectElements());
633 VerifyJSObjectElements(isolate,
this);
637 void Map::MapVerify(Isolate* isolate) {
638 Heap* heap = isolate->heap();
639 CHECK(!Heap::InNewSpace(*
this));
640 CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE);
641 CHECK(instance_size() == kVariableSizeSentinel ||
642 (kPointerSize <= instance_size() &&
643 static_cast<size_t>(instance_size()) < heap->Capacity()));
644 CHECK(GetBackPointer()->IsUndefined(heap->isolate()) ||
645 !Map::cast(GetBackPointer())->is_stable());
646 HeapObject::VerifyHeapPointer(isolate, prototype());
647 HeapObject::VerifyHeapPointer(isolate, instance_descriptors());
648 SLOW_DCHECK(instance_descriptors()->IsSortedNoDuplicates());
649 DisallowHeapAllocation no_gc;
651 TransitionsAccessor(isolate, *
this, &no_gc).IsSortedNoDuplicates());
652 SLOW_DCHECK(TransitionsAccessor(isolate, *
this, &no_gc)
653 .IsConsistentWithBackPointers());
654 SLOW_DCHECK(!FLAG_unbox_double_fields ||
655 layout_descriptor()->IsConsistentWithMap(*
this));
656 if (!may_have_interesting_symbols()) {
657 CHECK(!has_named_interceptor());
658 CHECK(!is_dictionary_map());
659 CHECK(!is_access_check_needed());
660 DescriptorArray*
const descriptors = instance_descriptors();
661 for (
int i = 0;
i < NumberOfOwnDescriptors(); ++
i) {
662 CHECK(!descriptors->GetKey(
i)->IsInterestingSymbol());
665 CHECK_IMPLIES(has_named_interceptor(), may_have_interesting_symbols());
666 CHECK_IMPLIES(is_dictionary_map(), may_have_interesting_symbols());
667 CHECK_IMPLIES(is_access_check_needed(), may_have_interesting_symbols());
668 CHECK_IMPLIES(IsJSObjectMap() && !CanHaveFastTransitionableElementsKind(),
669 IsDictionaryElementsKind(elements_kind()) ||
670 IsTerminalElementsKind(elements_kind()));
671 if (is_prototype_map()) {
672 DCHECK(prototype_info() == Smi::kZero ||
673 prototype_info()->IsPrototypeInfo());
675 CHECK(prototype_validity_cell()->IsSmi() ||
676 prototype_validity_cell()->IsCell());
679 void Map::DictionaryMapVerify(Isolate* isolate) {
681 CHECK(is_dictionary_map());
682 CHECK_EQ(kInvalidEnumCacheSentinel, EnumLength());
683 CHECK_EQ(ReadOnlyRoots(isolate).empty_descriptor_array(),
684 instance_descriptors());
685 CHECK_EQ(0, UnusedPropertyFields());
686 CHECK_EQ(Map::GetVisitorId(*
this), visitor_id());
689 void AliasedArgumentsEntry::AliasedArgumentsEntryVerify(Isolate* isolate) {
690 VerifySmiField(kAliasedContextSlot);
693 void EmbedderDataArray::EmbedderDataArrayVerify(Isolate* isolate) {
694 EmbedderDataSlot start(*
this, 0);
695 EmbedderDataSlot end(*
this, length());
696 for (EmbedderDataSlot slot = start; slot < end; ++slot) {
697 Object* e = slot.load_tagged();
698 Object::VerifyPointer(isolate, e);
702 void FixedArray::FixedArrayVerify(Isolate* isolate) {
703 for (
int i = 0;
i < length();
i++) {
705 VerifyPointer(isolate, e);
709 void WeakFixedArray::WeakFixedArrayVerify(Isolate* isolate) {
710 for (
int i = 0;
i < length();
i++) {
711 MaybeObject::VerifyMaybeObjectPointer(isolate, Get(
i));
715 void WeakArrayList::WeakArrayListVerify(Isolate* isolate) {
716 for (
int i = 0;
i < length();
i++) {
717 MaybeObject::VerifyMaybeObjectPointer(isolate, Get(
i));
721 void PropertyArray::PropertyArrayVerify(Isolate* isolate) {
723 CHECK_EQ(*
this, ReadOnlyRoots(isolate).empty_property_array());
727 CHECK_LT(0, length());
728 for (
int i = 0;
i < length();
i++) {
730 Object::VerifyPointer(isolate, e);
734 void FixedDoubleArray::FixedDoubleArrayVerify(Isolate* isolate) {
735 for (
int i = 0;
i < length();
i++) {
736 if (!is_the_hole(
i)) {
737 uint64_t value = get_representation(
i);
738 uint64_t unexpected =
739 bit_cast<uint64_t>(std::numeric_limits<double>::quiet_NaN()) &
740 uint64_t{0x7FF8000000000000};
742 unexpected ^= uint64_t{0x0008000000000000};
743 CHECK((value & uint64_t{0x7FF8000000000000}) != unexpected ||
744 (value & uint64_t{0x0007FFFFFFFFFFFF}) == uint64_t{0});
749 void Context::ContextVerify(Isolate* isolate) {
750 VerifySmiField(kLengthOffset);
751 VerifyObjectField(isolate, kScopeInfoOffset);
752 VerifyObjectField(isolate, kPreviousOffset);
753 VerifyObjectField(isolate, kExtensionOffset);
754 VerifyObjectField(isolate, kNativeContextOffset);
755 for (
int i = 0;
i < length();
i++) {
756 VerifyObjectField(isolate, OffsetOfElementAt(
i));
760 void NativeContext::NativeContextVerify(Isolate* isolate) {
761 ContextVerify(isolate);
762 CHECK_EQ(length(), NativeContext::NATIVE_CONTEXT_SLOTS);
763 CHECK_EQ(kSize, map()->instance_size());
766 void FeedbackMetadata::FeedbackMetadataVerify(Isolate* isolate) {
767 if (slot_count() == 0) {
768 CHECK_EQ(ReadOnlyRoots(isolate).empty_feedback_metadata(),
this);
770 FeedbackMetadataIterator iter(
this);
771 while (iter.HasNext()) {
773 FeedbackSlotKind kind = iter.kind();
774 CHECK_NE(FeedbackSlotKind::kInvalid, kind);
775 CHECK_GT(FeedbackSlotKind::kKindsNumber, kind);
780 void DescriptorArray::DescriptorArrayVerify(Isolate* isolate) {
781 for (
int i = 0;
i < number_of_all_descriptors();
i++) {
782 MaybeObject::VerifyMaybeObjectPointer(isolate,
get(ToKeyIndex(
i)));
783 MaybeObject::VerifyMaybeObjectPointer(isolate,
get(ToDetailsIndex(
i)));
784 MaybeObject::VerifyMaybeObjectPointer(isolate,
get(ToValueIndex(
i)));
786 if (number_of_all_descriptors() == 0) {
787 Heap* heap = isolate->heap();
788 CHECK_EQ(ReadOnlyRoots(heap).empty_descriptor_array(),
this);
789 CHECK_EQ(0, number_of_all_descriptors());
790 CHECK_EQ(0, number_of_descriptors());
791 CHECK_EQ(ReadOnlyRoots(heap).empty_enum_cache(), enum_cache());
793 CHECK_LT(0, number_of_all_descriptors());
794 CHECK_LE(number_of_descriptors(), number_of_all_descriptors());
797 for (
int descriptor = 0; descriptor < number_of_descriptors();
799 Object* key =
get(ToKeyIndex(descriptor))->cast<Object>();
802 if (key->IsUndefined(isolate))
continue;
803 PropertyDetails details = GetDetails(descriptor);
804 if (Name::cast(key)->IsPrivate()) {
805 CHECK_NE(details.attributes() & DONT_ENUM, 0);
807 MaybeObject value =
get(ToValueIndex(descriptor));
808 HeapObject* heap_object;
809 if (details.location() == kField) {
811 value == MaybeObject::FromObject(FieldType::None()) ||
812 value == MaybeObject::FromObject(FieldType::Any()) ||
813 value->IsCleared() ||
814 (value->GetHeapObjectIfWeak(&heap_object) && heap_object->IsMap()));
816 CHECK(!value->IsWeakOrCleared());
817 CHECK(!value->cast<Object>()->IsMap());
823 void TransitionArray::TransitionArrayVerify(Isolate* isolate) {
824 WeakFixedArrayVerify(isolate);
825 CHECK_LE(LengthFor(number_of_transitions()), length());
828 void JSArgumentsObject::JSArgumentsObjectVerify(Isolate* isolate) {
829 if (IsSloppyArgumentsElementsKind(GetElementsKind())) {
830 SloppyArgumentsElements::cast(elements())
831 ->SloppyArgumentsElementsVerify(isolate,
this);
833 if (isolate->IsInAnyContext(map(), Context::SLOPPY_ARGUMENTS_MAP_INDEX) ||
834 isolate->IsInAnyContext(map(),
835 Context::SLOW_ALIASED_ARGUMENTS_MAP_INDEX) ||
836 isolate->IsInAnyContext(map(),
837 Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX)) {
838 VerifyObjectField(isolate, JSSloppyArgumentsObject::kLengthOffset);
839 VerifyObjectField(isolate, JSSloppyArgumentsObject::kCalleeOffset);
840 }
else if (isolate->IsInAnyContext(map(),
841 Context::STRICT_ARGUMENTS_MAP_INDEX)) {
842 VerifyObjectField(isolate, JSStrictArgumentsObject::kLengthOffset);
844 JSObjectVerify(isolate);
847 void SloppyArgumentsElements::SloppyArgumentsElementsVerify(Isolate* isolate,
849 FixedArrayVerify(isolate);
852 if (
get(kArgumentsIndex)->IsUndefined(isolate))
return;
854 ElementsKind kind = holder->GetElementsKind();
855 bool is_fast = kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS;
856 CHECK(IsFixedArray());
857 CHECK_GE(length(), 2);
858 CHECK_EQ(map(), ReadOnlyRoots(isolate).sloppy_arguments_elements_map());
859 Context context_object = context();
860 FixedArray arg_elements = FixedArray::cast(arguments());
861 if (arg_elements->length() == 0) {
862 CHECK(arg_elements == ReadOnlyRoots(isolate).empty_fixed_array());
865 ElementsAccessor* accessor;
867 accessor = ElementsAccessor::ForKind(HOLEY_ELEMENTS);
869 accessor = ElementsAccessor::ForKind(DICTIONARY_ELEMENTS);
871 int nofMappedParameters = 0;
872 int maxMappedIndex = 0;
873 for (
int i = 0;
i < nofMappedParameters;
i++) {
876 Object* mapped = get_mapped_entry(
i);
877 if (mapped->IsTheHole(isolate)) {
879 if (!is_fast)
continue;
882 CHECK(accessor->HasElement(holder,
i, arg_elements));
885 int mappedIndex = Smi::ToInt(mapped);
886 nofMappedParameters++;
887 CHECK_LE(maxMappedIndex, mappedIndex);
888 maxMappedIndex = mappedIndex;
889 Object* value = context_object->get(mappedIndex);
890 CHECK(value->IsObject());
893 CHECK(!accessor->HasElement(holder,
i, arg_elements));
895 CHECK_LE(nofMappedParameters, context_object->length());
896 CHECK_LE(nofMappedParameters, arg_elements->length());
897 CHECK_LE(maxMappedIndex, context_object->length());
898 CHECK_LE(maxMappedIndex, arg_elements->length());
901 void JSGeneratorObject::JSGeneratorObjectVerify(Isolate* isolate) {
905 VerifyObjectField(isolate, kFunctionOffset);
906 VerifyObjectField(isolate, kContextOffset);
907 VerifyObjectField(isolate, kReceiverOffset);
908 VerifyObjectField(isolate, kParametersAndRegistersOffset);
909 VerifyObjectField(isolate, kContinuationOffset);
912 void JSAsyncFunctionObject::JSAsyncFunctionObjectVerify(Isolate* isolate) {
914 JSGeneratorObjectVerify(isolate);
915 VerifyObjectField(isolate, kPromiseOffset);
916 promise()->HeapObjectVerify(isolate);
919 void JSAsyncGeneratorObject::JSAsyncGeneratorObjectVerify(Isolate* isolate) {
921 JSGeneratorObjectVerify(isolate);
922 VerifyObjectField(isolate, kQueueOffset);
923 queue()->HeapObjectVerify(isolate);
926 void JSValue::JSValueVerify(Isolate* isolate) {
928 if (v->IsHeapObject()) {
929 VerifyHeapPointer(isolate, v);
933 void JSDate::JSDateVerify(Isolate* isolate) {
934 if (value()->IsHeapObject()) {
935 VerifyHeapPointer(isolate, value());
937 CHECK(value()->IsUndefined(isolate) || value()->IsSmi() ||
938 value()->IsHeapNumber());
939 CHECK(year()->IsUndefined(isolate) || year()->IsSmi() || year()->IsNaN());
940 CHECK(month()->IsUndefined(isolate) || month()->IsSmi() || month()->IsNaN());
941 CHECK(day()->IsUndefined(isolate) || day()->IsSmi() || day()->IsNaN());
942 CHECK(weekday()->IsUndefined(isolate) || weekday()->IsSmi() ||
944 CHECK(hour()->IsUndefined(isolate) || hour()->IsSmi() || hour()->IsNaN());
945 CHECK(min()->IsUndefined(isolate) || min()->IsSmi() || min()->IsNaN());
946 CHECK(sec()->IsUndefined(isolate) || sec()->IsSmi() || sec()->IsNaN());
947 CHECK(cache_stamp()->IsUndefined(isolate) || cache_stamp()->IsSmi() ||
948 cache_stamp()->IsNaN());
950 if (month()->IsSmi()) {
951 int month = Smi::ToInt(this->month());
952 CHECK(0 <= month && month <= 11);
954 if (day()->IsSmi()) {
955 int day = Smi::ToInt(this->day());
956 CHECK(1 <= day && day <= 31);
958 if (hour()->IsSmi()) {
959 int hour = Smi::ToInt(this->hour());
960 CHECK(0 <= hour && hour <= 23);
962 if (min()->IsSmi()) {
963 int min = Smi::ToInt(this->min());
964 CHECK(0 <= min && min <= 59);
966 if (sec()->IsSmi()) {
967 int sec = Smi::ToInt(this->sec());
968 CHECK(0 <= sec && sec <= 59);
970 if (weekday()->IsSmi()) {
971 int weekday = Smi::ToInt(this->weekday());
972 CHECK(0 <= weekday && weekday <= 6);
974 if (cache_stamp()->IsSmi()) {
975 CHECK(Smi::ToInt(cache_stamp()) <=
976 Smi::ToInt(isolate->date_cache()->stamp()));
980 void JSMessageObject::JSMessageObjectVerify(Isolate* isolate) {
981 CHECK(IsJSMessageObject());
982 VerifyObjectField(isolate, kStartPositionOffset);
983 VerifyObjectField(isolate, kEndPositionOffset);
984 VerifyObjectField(isolate, kArgumentsOffset);
985 VerifyObjectField(isolate, kScriptOffset);
986 VerifyObjectField(isolate, kStackFramesOffset);
989 void String::StringVerify(Isolate* isolate) {
991 CHECK(length() >= 0 && length() <= Smi::kMaxValue);
992 CHECK_IMPLIES(length() == 0, *
this == ReadOnlyRoots(isolate).empty_string());
993 if (IsInternalizedString()) {
994 CHECK(!Heap::InNewSpace(*
this));
996 if (IsConsString()) {
997 ConsString::cast(*this)->ConsStringVerify(isolate);
998 }
else if (IsSlicedString()) {
999 SlicedString::cast(*this)->SlicedStringVerify(isolate);
1000 }
else if (IsThinString()) {
1001 ThinString::cast(*this)->ThinStringVerify(isolate);
1005 void ConsString::ConsStringVerify(Isolate* isolate) {
1006 CHECK(this->first()->IsString());
1007 CHECK(this->second() == ReadOnlyRoots(isolate).empty_string() ||
1008 this->second()->IsString());
1009 CHECK_GE(this->length(), ConsString::kMinLength);
1010 CHECK(this->length() == this->first()->length() + this->second()->length());
1011 if (this->IsFlat()) {
1014 CHECK(this->first()->IsSeqString() || this->first()->IsExternalString() ||
1015 this->first()->IsThinString());
1019 void ThinString::ThinStringVerify(Isolate* isolate) {
1020 CHECK(this->actual()->IsInternalizedString());
1021 CHECK(this->actual()->IsSeqString() || this->actual()->IsExternalString());
1024 void SlicedString::SlicedStringVerify(Isolate* isolate) {
1025 CHECK(!this->parent()->IsConsString());
1026 CHECK(!this->parent()->IsSlicedString());
1027 CHECK_GE(this->length(), SlicedString::kMinLength);
1030 void JSBoundFunction::JSBoundFunctionVerify(Isolate* isolate) {
1031 CHECK(IsJSBoundFunction());
1032 JSObjectVerify(isolate);
1033 VerifyObjectField(isolate, kBoundThisOffset);
1034 VerifyObjectField(isolate, kBoundTargetFunctionOffset);
1035 VerifyObjectField(isolate, kBoundArgumentsOffset);
1036 CHECK(IsCallable());
1038 if (!raw_bound_target_function()->IsUndefined(isolate)) {
1039 CHECK(bound_target_function()->IsCallable());
1040 CHECK_EQ(IsConstructor(), bound_target_function()->IsConstructor());
1044 void JSFunction::JSFunctionVerify(Isolate* isolate) {
1045 CHECK(IsJSFunction());
1046 JSObjectVerify(isolate);
1047 VerifyHeapPointer(isolate, feedback_cell());
1048 CHECK(feedback_cell()->IsFeedbackCell());
1049 CHECK(code()->IsCode());
1050 CHECK(map()->is_callable());
1051 Handle<JSFunction>
function(
this, isolate);
1052 LookupIterator it(isolate,
function, isolate->factory()->prototype_string(),
1053 LookupIterator::OWN_SKIP_INTERCEPTOR);
1054 if (has_prototype_slot()) {
1055 VerifyObjectField(isolate, kPrototypeOrInitialMapOffset);
1058 if (has_prototype_property()) {
1059 CHECK(it.IsFound());
1060 CHECK_EQ(LookupIterator::ACCESSOR, it.state());
1061 CHECK(it.GetAccessors()->IsAccessorInfo());
1063 CHECK(!it.IsFound() || it.state() != LookupIterator::ACCESSOR ||
1064 !it.GetAccessors()->IsAccessorInfo());
1068 void SharedFunctionInfo::SharedFunctionInfoVerify(Isolate* isolate) {
1069 CHECK(IsSharedFunctionInfo());
1071 VerifyObjectField(isolate, kFunctionDataOffset);
1072 VerifyObjectField(isolate, kOuterScopeInfoOrFeedbackMetadataOffset);
1073 VerifyObjectField(isolate, kScriptOrDebugInfoOffset);
1074 VerifyObjectField(isolate, kNameOrScopeInfoOffset);
1076 Object* value = name_or_scope_info();
1077 CHECK(value == kNoSharedNameSentinel || value->IsString() ||
1078 value->IsScopeInfo());
1079 if (value->IsScopeInfo()) {
1080 CHECK_LT(0, ScopeInfo::cast(value)->length());
1081 CHECK_NE(value, ReadOnlyRoots(isolate).empty_scope_info());
1084 CHECK(HasWasmExportedFunctionData() || IsApiFunction() ||
1085 HasBytecodeArray() || HasAsmWasmData() || HasBuiltinId() ||
1086 HasUncompiledDataWithPreParsedScope() ||
1087 HasUncompiledDataWithoutPreParsedScope());
1089 CHECK(script_or_debug_info()->IsUndefined(isolate) ||
1090 script_or_debug_info()->IsScript() || HasDebugInfo());
1092 if (!is_compiled()) {
1093 CHECK(!HasFeedbackMetadata());
1094 CHECK(outer_scope_info()->IsScopeInfo() ||
1095 outer_scope_info()->IsTheHole(isolate));
1096 }
else if (HasBytecodeArray()) {
1097 CHECK(HasFeedbackMetadata());
1098 CHECK(feedback_metadata()->IsFeedbackMetadata());
1101 int expected_map_index = Context::FunctionMapIndex(
1102 language_mode(), kind(),
true, HasSharedName(), needs_home_object());
1103 CHECK_EQ(expected_map_index, function_map_index());
1105 if (scope_info()->length() > 0) {
1106 ScopeInfo info = scope_info();
1107 CHECK(kind() == info->function_kind());
1108 CHECK_EQ(kind() == kModule, info->scope_type() == MODULE_SCOPE);
1111 if (IsApiFunction()) {
1112 CHECK(construct_as_builtin());
1113 }
else if (!HasBuiltinId()) {
1114 CHECK(!construct_as_builtin());
1116 int id = builtin_id();
1117 if (
id != Builtins::kCompileLazy &&
id != Builtins::kEmptyFunction) {
1118 CHECK(construct_as_builtin());
1120 CHECK(!construct_as_builtin());
1125 void JSGlobalProxy::JSGlobalProxyVerify(Isolate* isolate) {
1126 CHECK(IsJSGlobalProxy());
1127 JSObjectVerify(isolate);
1128 VerifyObjectField(isolate, JSGlobalProxy::kNativeContextOffset);
1129 CHECK(map()->is_access_check_needed());
1131 CHECK_EQ(0, FixedArray::cast(elements())->length());
1134 void JSGlobalObject::JSGlobalObjectVerify(Isolate* isolate) {
1135 CHECK(IsJSGlobalObject());
1137 if (global_dictionary()->NumberOfElements() == 0 &&
1138 elements()->length() == 0) {
1141 JSObjectVerify(isolate);
1144 void Oddball::OddballVerify(Isolate* isolate) {
1146 Heap* heap = isolate->heap();
1147 VerifyHeapPointer(isolate, to_string());
1148 Object* number = to_number();
1149 if (number->IsHeapObject()) {
1150 CHECK(number == ReadOnlyRoots(heap).nan_value() ||
1151 number == ReadOnlyRoots(heap).hole_nan_value());
1153 CHECK(number->IsSmi());
1154 int value = Smi::ToInt(number);
1156 const int kLeastHiddenOddballNumber = -7;
1158 CHECK_GE(value, kLeastHiddenOddballNumber);
1161 ReadOnlyRoots roots(heap);
1162 if (map() == roots.undefined_map()) {
1163 CHECK(
this == roots.undefined_value());
1164 }
else if (map() == roots.the_hole_map()) {
1165 CHECK(
this == roots.the_hole_value());
1166 }
else if (map() == roots.null_map()) {
1167 CHECK(
this == roots.null_value());
1168 }
else if (map() == roots.boolean_map()) {
1169 CHECK(
this == roots.true_value() ||
this == roots.false_value());
1170 }
else if (map() == roots.uninitialized_map()) {
1171 CHECK(
this == roots.uninitialized_value());
1172 }
else if (map() == roots.arguments_marker_map()) {
1173 CHECK(
this == roots.arguments_marker());
1174 }
else if (map() == roots.termination_exception_map()) {
1175 CHECK(
this == roots.termination_exception());
1176 }
else if (map() == roots.exception_map()) {
1177 CHECK(
this == roots.exception());
1178 }
else if (map() == roots.optimized_out_map()) {
1179 CHECK(
this == roots.optimized_out());
1180 }
else if (map() == roots.stale_register_map()) {
1181 CHECK(
this == roots.stale_register());
1182 }
else if (map() == roots.self_reference_marker_map()) {
1184 CHECK_EQ(kind(), Oddball::kSelfReferenceMarker);
1190 void Cell::CellVerify(Isolate* isolate) {
1192 VerifyObjectField(isolate, kValueOffset);
1195 void PropertyCell::PropertyCellVerify(Isolate* isolate) {
1196 CHECK(IsPropertyCell());
1197 VerifyObjectField(isolate, kValueOffset);
1200 void CodeDataContainer::CodeDataContainerVerify(Isolate* isolate) {
1201 CHECK(IsCodeDataContainer());
1202 VerifyObjectField(isolate, kNextCodeLinkOffset);
1203 CHECK(next_code_link()->IsCode() || next_code_link()->IsUndefined(isolate));
1206 void Code::CodeVerify(Isolate* isolate) {
1207 CHECK_LE(constant_pool_offset(), InstructionSize());
1208 CHECK(IsAligned(raw_instruction_start(), kCodeAlignment));
1209 relocation_info()->ObjectVerify(isolate);
1210 Address last_gc_pc = kNullAddress;
1212 for (RelocIterator it(*
this); !it.done(); it.next()) {
1213 it.rinfo()->Verify(isolate);
1215 if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) {
1216 CHECK(it.rinfo()->pc() != last_gc_pc);
1217 last_gc_pc = it.rinfo()->pc();
1222 void JSArray::JSArrayVerify(Isolate* isolate) {
1223 JSObjectVerify(isolate);
1224 CHECK(length()->IsNumber() || length()->IsUndefined(isolate));
1227 if (!ElementsAreSafeToExamine())
return;
1228 if (elements()->IsUndefined(isolate))
return;
1229 CHECK(elements()->IsFixedArray() || elements()->IsFixedDoubleArray());
1230 if (elements()->length() == 0) {
1231 CHECK_EQ(elements(), ReadOnlyRoots(isolate).empty_fixed_array());
1233 if (!length()->IsNumber())
return;
1235 if (length()->IsSmi() && HasFastElements()) {
1236 if (elements()->length() > 0) {
1237 CHECK_IMPLIES(HasDoubleElements(), elements()->IsFixedDoubleArray());
1239 int size = Smi::ToInt(length());
1242 CHECK(size <= elements()->length() ||
1243 elements() == ReadOnlyRoots(isolate).empty_fixed_array());
1245 CHECK(HasDictionaryElements());
1247 CHECK(length()->ToArrayLength(&array_length));
1248 if (array_length == 0xFFFFFFFF) {
1249 CHECK(length()->ToArrayLength(&array_length));
1251 if (array_length != 0) {
1252 NumberDictionary dict = NumberDictionary::cast(elements());
1257 if (nof_elements != 0) nof_elements--;
1258 CHECK_LE(nof_elements, array_length);
1263 void JSSet::JSSetVerify(Isolate* isolate) {
1265 JSObjectVerify(isolate);
1266 VerifyHeapPointer(isolate, table());
1267 CHECK(table()->IsOrderedHashSet() || table()->IsUndefined(isolate));
1271 void JSMap::JSMapVerify(Isolate* isolate) {
1273 JSObjectVerify(isolate);
1274 VerifyHeapPointer(isolate, table());
1275 CHECK(table()->IsOrderedHashMap() || table()->IsUndefined(isolate));
1279 void JSSetIterator::JSSetIteratorVerify(Isolate* isolate) {
1280 CHECK(IsJSSetIterator());
1281 JSObjectVerify(isolate);
1282 VerifyHeapPointer(isolate, table());
1283 CHECK(table()->IsOrderedHashSet());
1284 CHECK(index()->IsSmi());
1287 void JSMapIterator::JSMapIteratorVerify(Isolate* isolate) {
1288 CHECK(IsJSMapIterator());
1289 JSObjectVerify(isolate);
1290 VerifyHeapPointer(isolate, table());
1291 CHECK(table()->IsOrderedHashMap());
1292 CHECK(index()->IsSmi());
1295 void JSWeakCell::JSWeakCellVerify(Isolate* isolate) {
1296 CHECK(IsJSWeakCell());
1297 JSObjectVerify(isolate);
1299 CHECK(next()->IsJSWeakCell() || next()->IsUndefined(isolate));
1300 if (next()->IsJSWeakCell()) {
1301 CHECK_EQ(JSWeakCell::cast(next())->prev(),
this);
1303 CHECK(prev()->IsJSWeakCell() || prev()->IsUndefined(isolate));
1304 if (prev()->IsJSWeakCell()) {
1305 CHECK_EQ(JSWeakCell::cast(prev())->next(),
this);
1308 CHECK(factory()->IsUndefined(isolate) || factory()->IsJSWeakFactory());
1311 void JSWeakFactory::JSWeakFactoryVerify(Isolate* isolate) {
1312 CHECK(IsJSWeakFactory());
1313 JSObjectVerify(isolate);
1314 VerifyHeapPointer(isolate, cleanup());
1315 CHECK(active_cells()->IsUndefined(isolate) || active_cells()->IsJSWeakCell());
1316 if (active_cells()->IsJSWeakCell()) {
1317 CHECK(JSWeakCell::cast(active_cells())->prev()->IsUndefined(isolate));
1319 CHECK(cleared_cells()->IsUndefined(isolate) ||
1320 cleared_cells()->IsJSWeakCell());
1321 if (cleared_cells()->IsJSWeakCell()) {
1322 CHECK(JSWeakCell::cast(cleared_cells())->prev()->IsUndefined(isolate));
1326 void JSWeakFactoryCleanupIterator::JSWeakFactoryCleanupIteratorVerify(
1328 CHECK(IsJSWeakFactoryCleanupIterator());
1329 JSObjectVerify(isolate);
1330 VerifyHeapPointer(isolate, factory());
1333 void WeakFactoryCleanupJobTask::WeakFactoryCleanupJobTaskVerify(
1335 CHECK(IsWeakFactoryCleanupJobTask());
1336 CHECK(factory()->IsJSWeakFactory());
1339 void JSWeakMap::JSWeakMapVerify(Isolate* isolate) {
1340 CHECK(IsJSWeakMap());
1341 JSObjectVerify(isolate);
1342 VerifyHeapPointer(isolate, table());
1343 CHECK(table()->IsEphemeronHashTable() || table()->IsUndefined(isolate));
1346 void JSArrayIterator::JSArrayIteratorVerify(Isolate* isolate) {
1347 CHECK(IsJSArrayIterator());
1348 JSObjectVerify(isolate);
1349 CHECK(iterated_object()->IsJSReceiver());
1351 CHECK_GE(next_index()->Number(), 0);
1352 CHECK_LE(next_index()->Number(), kMaxSafeInteger);
1354 if (iterated_object()->IsJSTypedArray()) {
1356 CHECK(next_index()->IsSmi());
1357 CHECK_LE(next_index()->Number(), Smi::kMaxValue);
1358 }
else if (iterated_object()->IsJSArray()) {
1360 CHECK_LE(next_index()->Number(), kMaxUInt32);
1364 void JSStringIterator::JSStringIteratorVerify(Isolate* isolate) {
1365 CHECK(IsJSStringIterator());
1366 JSObjectVerify(isolate);
1367 CHECK(
string()->IsString());
1369 CHECK_GE(index(), 0);
1370 CHECK_LE(index(), String::kMaxLength);
1373 void JSAsyncFromSyncIterator::JSAsyncFromSyncIteratorVerify(Isolate* isolate) {
1374 CHECK(IsJSAsyncFromSyncIterator());
1375 JSObjectVerify(isolate);
1376 VerifyHeapPointer(isolate, sync_iterator());
1379 void JSWeakSet::JSWeakSetVerify(Isolate* isolate) {
1380 CHECK(IsJSWeakSet());
1381 JSObjectVerify(isolate);
1382 VerifyHeapPointer(isolate, table());
1383 CHECK(table()->IsEphemeronHashTable() || table()->IsUndefined(isolate));
1386 void Microtask::MicrotaskVerify(Isolate* isolate) { CHECK(IsMicrotask()); }
1388 void CallableTask::CallableTaskVerify(Isolate* isolate) {
1389 CHECK(IsCallableTask());
1390 MicrotaskVerify(isolate);
1391 VerifyHeapPointer(isolate, callable());
1392 CHECK(callable()->IsCallable());
1393 VerifyHeapPointer(isolate, context());
1394 CHECK(context()->IsContext());
1397 void CallbackTask::CallbackTaskVerify(Isolate* isolate) {
1398 CHECK(IsCallbackTask());
1399 MicrotaskVerify(isolate);
1400 VerifyHeapPointer(isolate, callback());
1401 VerifyHeapPointer(isolate, data());
1404 void PromiseReactionJobTask::PromiseReactionJobTaskVerify(Isolate* isolate) {
1405 CHECK(IsPromiseReactionJobTask());
1406 MicrotaskVerify(isolate);
1407 VerifyPointer(isolate, argument());
1408 VerifyHeapPointer(isolate, context());
1409 CHECK(context()->IsContext());
1410 VerifyHeapPointer(isolate, handler());
1411 CHECK(handler()->IsUndefined(isolate) || handler()->IsCallable());
1412 VerifyHeapPointer(isolate, promise_or_capability());
1413 CHECK(promise_or_capability()->IsJSPromise() ||
1414 promise_or_capability()->IsPromiseCapability() ||
1415 promise_or_capability()->IsUndefined(isolate));
1418 void PromiseFulfillReactionJobTask::PromiseFulfillReactionJobTaskVerify(
1420 CHECK(IsPromiseFulfillReactionJobTask());
1421 PromiseReactionJobTaskVerify(isolate);
1424 void PromiseRejectReactionJobTask::PromiseRejectReactionJobTaskVerify(
1426 CHECK(IsPromiseRejectReactionJobTask());
1427 PromiseReactionJobTaskVerify(isolate);
1430 void PromiseResolveThenableJobTask::PromiseResolveThenableJobTaskVerify(
1432 CHECK(IsPromiseResolveThenableJobTask());
1433 MicrotaskVerify(isolate);
1434 VerifyHeapPointer(isolate, context());
1435 CHECK(context()->IsContext());
1436 VerifyHeapPointer(isolate, promise_to_resolve());
1437 CHECK(promise_to_resolve()->IsJSPromise());
1438 VerifyHeapPointer(isolate, then());
1439 CHECK(then()->IsCallable());
1440 CHECK(then()->IsJSReceiver());
1441 VerifyHeapPointer(isolate, thenable());
1442 CHECK(thenable()->IsJSReceiver());
1445 void PromiseCapability::PromiseCapabilityVerify(Isolate* isolate) {
1446 CHECK(IsPromiseCapability());
1448 VerifyHeapPointer(isolate, promise());
1449 CHECK(promise()->IsJSReceiver() || promise()->IsUndefined(isolate));
1450 VerifyPointer(isolate, resolve());
1451 VerifyPointer(isolate, reject());
1454 void PromiseReaction::PromiseReactionVerify(Isolate* isolate) {
1455 CHECK(IsPromiseReaction());
1457 VerifyPointer(isolate, next());
1458 CHECK(next()->IsSmi() || next()->IsPromiseReaction());
1459 VerifyHeapPointer(isolate, reject_handler());
1460 CHECK(reject_handler()->IsUndefined(isolate) ||
1461 reject_handler()->IsCallable());
1462 VerifyHeapPointer(isolate, fulfill_handler());
1463 CHECK(fulfill_handler()->IsUndefined(isolate) ||
1464 fulfill_handler()->IsCallable());
1465 VerifyHeapPointer(isolate, promise_or_capability());
1466 CHECK(promise_or_capability()->IsJSPromise() ||
1467 promise_or_capability()->IsPromiseCapability() ||
1468 promise_or_capability()->IsUndefined(isolate));
1471 void JSPromise::JSPromiseVerify(Isolate* isolate) {
1472 CHECK(IsJSPromise());
1473 JSObjectVerify(isolate);
1474 VerifyPointer(isolate, reactions_or_result());
1475 VerifySmiField(kFlagsOffset);
1476 if (status() == Promise::kPending) {
1477 CHECK(reactions()->IsSmi() || reactions()->IsPromiseReaction());
1481 template <
typename Derived>
1482 void SmallOrderedHashTable<Derived>::SmallOrderedHashTableVerify(
1484 CHECK(IsSmallOrderedHashTable());
1486 int capacity = Capacity();
1487 CHECK_GE(capacity, kMinCapacity);
1488 CHECK_LE(capacity, kMaxCapacity);
1490 for (
int entry = 0; entry < NumberOfBuckets(); entry++) {
1491 int bucket = GetFirstEntry(entry);
1492 if (bucket == kNotFound)
continue;
1493 CHECK_GE(bucket, 0);
1494 CHECK_LE(bucket, capacity);
1497 for (
int entry = 0; entry < NumberOfElements(); entry++) {
1498 int chain = GetNextEntry(entry);
1499 if (chain == kNotFound)
continue;
1501 CHECK_LE(chain, capacity);
1504 for (
int entry = 0; entry < NumberOfElements(); entry++) {
1505 for (
int offset = 0; offset < Derived::kEntrySize; offset++) {
1506 Object* val = GetDataEntry(entry, offset);
1507 VerifyPointer(isolate, val);
1511 for (
int entry = NumberOfElements(); entry < NumberOfDeletedElements();
1513 for (
int offset = 0; offset < Derived::kEntrySize; offset++) {
1514 Object* val = GetDataEntry(entry, offset);
1515 CHECK(val->IsTheHole(isolate));
1519 for (
int entry = NumberOfElements() + NumberOfDeletedElements();
1520 entry < Capacity(); entry++) {
1521 for (
int offset = 0; offset < Derived::kEntrySize; offset++) {
1522 Object* val = GetDataEntry(entry, offset);
1523 CHECK(val->IsTheHole(isolate));
1528 template void SmallOrderedHashTable<
1529 SmallOrderedHashMap>::SmallOrderedHashTableVerify(Isolate* isolate);
1530 template void SmallOrderedHashTable<
1531 SmallOrderedHashSet>::SmallOrderedHashTableVerify(Isolate* isolate);
1532 template void SmallOrderedHashTable<
1533 SmallOrderedNameDictionary>::SmallOrderedHashTableVerify(Isolate* isolate);
1535 void JSRegExp::JSRegExpVerify(Isolate* isolate) {
1536 JSObjectVerify(isolate);
1537 CHECK(data()->IsUndefined(isolate) || data()->IsFixedArray());
1538 switch (TypeTag()) {
1539 case JSRegExp::ATOM: {
1540 FixedArray arr = FixedArray::cast(data());
1541 CHECK(arr->get(JSRegExp::kAtomPatternIndex)->IsString());
1544 case JSRegExp::IRREGEXP: {
1545 bool is_native = RegExpImpl::UsesNativeRegExp();
1547 FixedArray arr = FixedArray::cast(data());
1548 Object* one_byte_data = arr->get(JSRegExp::kIrregexpLatin1CodeIndex);
1552 (one_byte_data->IsSmi() &&
1553 Smi::ToInt(one_byte_data) == JSRegExp::kUninitializedValue) ||
1554 (is_native ? one_byte_data->IsCode() : one_byte_data->IsByteArray()));
1555 Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex);
1556 CHECK((uc16_data->IsSmi() &&
1557 Smi::ToInt(uc16_data) == JSRegExp::kUninitializedValue) ||
1558 (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray()));
1560 CHECK(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi());
1561 CHECK(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi());
1565 CHECK_EQ(JSRegExp::NOT_COMPILED, TypeTag());
1566 CHECK(data()->IsUndefined(isolate));
1571 void JSRegExpStringIterator::JSRegExpStringIteratorVerify(Isolate* isolate) {
1572 CHECK(IsJSRegExpStringIterator());
1573 JSObjectVerify(isolate);
1574 CHECK(iterating_string()->IsString());
1575 CHECK(iterating_regexp()->IsObject());
1576 VerifySmiField(kFlagsOffset);
1579 void JSProxy::JSProxyVerify(Isolate* isolate) {
1581 CHECK(map()->GetConstructor()->IsJSFunction());
1582 VerifyPointer(isolate, target());
1583 VerifyPointer(isolate, handler());
1585 CHECK_EQ(target()->IsCallable(), map()->is_callable());
1586 CHECK_EQ(target()->IsConstructor(), map()->is_constructor());
1588 CHECK(map()->prototype()->IsNull(isolate));
1590 CHECK_EQ(0, map()->NumberOfOwnDescriptors());
1593 void JSArrayBuffer::JSArrayBufferVerify(Isolate* isolate) {
1594 CHECK(IsJSArrayBuffer());
1595 if (FIELD_SIZE(kOptionalPaddingOffset)) {
1596 CHECK_EQ(4, FIELD_SIZE(kOptionalPaddingOffset));
1598 *reinterpret_cast<uint32_t*>(address() + kOptionalPaddingOffset));
1600 JSObjectVerify(isolate);
1603 void JSArrayBufferView::JSArrayBufferViewVerify(Isolate* isolate) {
1604 CHECK(IsJSArrayBufferView());
1605 JSObjectVerify(isolate);
1606 VerifyPointer(isolate, buffer());
1607 CHECK(buffer()->IsJSArrayBuffer() || buffer()->IsUndefined(isolate) ||
1608 buffer() == Smi::kZero);
1609 CHECK_LE(byte_length(), JSArrayBuffer::kMaxByteLength);
1610 CHECK_LE(byte_offset(), JSArrayBuffer::kMaxByteLength);
1613 void JSTypedArray::JSTypedArrayVerify(Isolate* isolate) {
1614 CHECK(IsJSTypedArray());
1615 JSArrayBufferViewVerify(isolate);
1616 VerifyPointer(isolate, raw_length());
1617 CHECK(raw_length()->IsSmi() || raw_length()->IsUndefined(isolate));
1618 VerifyPointer(isolate, elements());
1621 void JSDataView::JSDataViewVerify(Isolate* isolate) {
1622 CHECK(IsJSDataView());
1623 JSArrayBufferViewVerify(isolate);
1626 void Foreign::ForeignVerify(Isolate* isolate) { CHECK(IsForeign()); }
1628 void AsyncGeneratorRequest::AsyncGeneratorRequestVerify(Isolate* isolate) {
1629 CHECK(IsAsyncGeneratorRequest());
1630 VerifySmiField(kResumeModeOffset);
1631 CHECK_GE(resume_mode(), JSGeneratorObject::kNext);
1632 CHECK_LE(resume_mode(), JSGeneratorObject::kThrow);
1633 CHECK(promise()->IsJSPromise());
1634 VerifyPointer(isolate, value());
1635 VerifyPointer(isolate, next());
1636 next()->ObjectVerify(isolate);
1639 void BigInt::BigIntVerify(Isolate* isolate) {
1641 CHECK_GE(length(), 0);
1642 CHECK_IMPLIES(is_zero(), !sign());
1645 void JSModuleNamespace::JSModuleNamespaceVerify(Isolate* isolate) {
1646 CHECK(IsJSModuleNamespace());
1647 VerifyPointer(isolate, module());
1650 void ModuleInfoEntry::ModuleInfoEntryVerify(Isolate* isolate) {
1651 CHECK(IsModuleInfoEntry());
1653 CHECK(export_name()->IsUndefined(isolate) || export_name()->IsString());
1654 CHECK(local_name()->IsUndefined(isolate) || local_name()->IsString());
1655 CHECK(import_name()->IsUndefined(isolate) || import_name()->IsString());
1657 VerifySmiField(kModuleRequestOffset);
1658 VerifySmiField(kCellIndexOffset);
1659 VerifySmiField(kBegPosOffset);
1660 VerifySmiField(kEndPosOffset);
1662 CHECK_IMPLIES(import_name()->IsString(), module_request() >= 0);
1663 CHECK_IMPLIES(export_name()->IsString() && import_name()->IsString(),
1664 local_name()->IsUndefined(isolate));
1667 void Module::ModuleVerify(Isolate* isolate) {
1670 VerifyPointer(isolate, code());
1671 VerifyPointer(isolate, exports());
1672 VerifyPointer(isolate, module_namespace());
1673 VerifyPointer(isolate, requested_modules());
1674 VerifyPointer(isolate, script());
1675 VerifyPointer(isolate, import_meta());
1676 VerifyPointer(isolate, exception());
1677 VerifySmiField(kHashOffset);
1678 VerifySmiField(kStatusOffset);
1680 CHECK((status() >= kEvaluating && code()->IsModuleInfo()) ||
1681 (status() == kInstantiated && code()->IsJSGeneratorObject()) ||
1682 (status() == kInstantiating && code()->IsJSFunction()) ||
1683 (code()->IsSharedFunctionInfo()));
1685 CHECK_EQ(status() == kErrored, !exception()->IsTheHole(isolate));
1687 CHECK(module_namespace()->IsUndefined(isolate) ||
1688 module_namespace()->IsJSModuleNamespace());
1689 if (module_namespace()->IsJSModuleNamespace()) {
1690 CHECK_LE(kInstantiating, status());
1691 CHECK_EQ(JSModuleNamespace::cast(module_namespace())->module(),
this);
1694 CHECK_EQ(requested_modules()->length(), info()->module_requests()->length());
1696 CHECK(import_meta()->IsTheHole(isolate) || import_meta()->IsJSObject());
1698 CHECK_NE(hash(), 0);
1701 void PrototypeInfo::PrototypeInfoVerify(Isolate* isolate) {
1702 CHECK(IsPrototypeInfo());
1703 Object* module_ns = module_namespace();
1704 CHECK(module_ns->IsJSModuleNamespace() || module_ns->IsUndefined(isolate));
1705 if (prototype_users()->IsWeakArrayList()) {
1706 PrototypeUsers::Verify(WeakArrayList::cast(prototype_users()));
1708 CHECK(prototype_users()->IsSmi());
1712 void PrototypeUsers::Verify(WeakArrayList* array) {
1713 if (array->length() == 0) {
1718 int empty_slot = Smi::ToInt(empty_slot_index(array));
1719 int empty_slots_count = 0;
1720 while (empty_slot != kNoEmptySlotsMarker) {
1721 CHECK_GT(empty_slot, 0);
1722 CHECK_LT(empty_slot, array->length());
1723 empty_slot = array->Get(empty_slot).ToSmi().value();
1724 ++empty_slots_count;
1729 int weak_maps_count = 0;
1730 for (
int i = kFirstIndex;
i < array->length(); ++
i) {
1731 HeapObject* heap_object;
1732 MaybeObject
object = array->Get(
i);
1733 if ((object->GetHeapObjectIfWeak(&heap_object) && heap_object->IsMap()) ||
1734 object->IsCleared()) {
1737 CHECK(object->IsSmi());
1741 CHECK_EQ(weak_maps_count + empty_slots_count + 1, array->length());
1744 void Tuple2::Tuple2Verify(Isolate* isolate) {
1746 Heap* heap = isolate->heap();
1747 if (
this == ReadOnlyRoots(heap).empty_enum_cache()) {
1748 CHECK_EQ(ReadOnlyRoots(heap).empty_fixed_array(),
1749 EnumCache::cast(
this)->keys());
1750 CHECK_EQ(ReadOnlyRoots(heap).empty_fixed_array(),
1751 EnumCache::cast(
this)->indices());
1753 VerifyObjectField(isolate, kValue1Offset);
1754 VerifyObjectField(isolate, kValue2Offset);
1758 void Tuple3::Tuple3Verify(Isolate* isolate) {
1760 VerifyObjectField(isolate, kValue1Offset);
1761 VerifyObjectField(isolate, kValue2Offset);
1762 VerifyObjectField(isolate, kValue3Offset);
1765 void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionVerify(
1767 CHECK(IsObjectBoilerplateDescription());
1768 CHECK_GE(this->length(),
1769 ObjectBoilerplateDescription::kDescriptionStartIndex);
1770 this->FixedArrayVerify(isolate);
1773 void ArrayBoilerplateDescription::ArrayBoilerplateDescriptionVerify(
1775 CHECK(IsArrayBoilerplateDescription());
1776 CHECK(constant_elements()->IsFixedArrayBase());
1777 VerifyObjectField(isolate, kConstantElementsOffset);
1780 void AsmWasmData::AsmWasmDataVerify(Isolate* isolate) {
1781 CHECK(IsAsmWasmData());
1782 VerifyObjectField(isolate, kManagedNativeModuleOffset);
1783 VerifyObjectField(isolate, kExportWrappersOffset);
1784 VerifyObjectField(isolate, kAsmJsOffsetTableOffset);
1785 CHECK(uses_bitset()->IsHeapNumber());
1786 VerifyObjectField(isolate, kUsesBitsetOffset);
1789 void WasmDebugInfo::WasmDebugInfoVerify(Isolate* isolate) {
1790 CHECK(IsWasmDebugInfo());
1791 VerifyObjectField(isolate, kInstanceOffset);
1792 CHECK(wasm_instance()->IsWasmInstanceObject());
1793 VerifyObjectField(isolate, kInterpreterHandleOffset);
1794 CHECK(interpreter_handle()->IsUndefined(isolate) ||
1795 interpreter_handle()->IsForeign());
1796 VerifyObjectField(isolate, kInterpretedFunctionsOffset);
1797 VerifyObjectField(isolate, kLocalsNamesOffset);
1798 VerifyObjectField(isolate, kCWasmEntriesOffset);
1799 VerifyObjectField(isolate, kCWasmEntryMapOffset);
1802 void WasmInstanceObject::WasmInstanceObjectVerify(Isolate* isolate) {
1803 JSObjectVerify(isolate);
1804 CHECK(IsWasmInstanceObject());
1809 for (
int offset = kHeaderSize; offset < kFirstUntaggedOffset;
1810 offset += kPointerSize) {
1811 VerifyObjectField(isolate, offset);
1815 void WasmExportedFunctionData::WasmExportedFunctionDataVerify(
1817 CHECK(IsWasmExportedFunctionData());
1818 VerifyObjectField(isolate, kWrapperCodeOffset);
1819 CHECK(wrapper_code()->kind() == Code::JS_TO_WASM_FUNCTION ||
1820 wrapper_code()->kind() == Code::C_WASM_ENTRY);
1821 VerifyObjectField(isolate, kInstanceOffset);
1822 VerifySmiField(kJumpTableOffsetOffset);
1823 VerifySmiField(kFunctionIndexOffset);
1826 void WasmModuleObject::WasmModuleObjectVerify(Isolate* isolate) {
1827 CHECK(IsWasmModuleObject());
1828 VerifyObjectField(isolate, kNativeModuleOffset);
1829 CHECK(managed_native_module()->IsForeign());
1830 VerifyObjectField(isolate, kExportWrappersOffset);
1831 CHECK(export_wrappers()->IsFixedArray());
1832 VerifyObjectField(isolate, kScriptOffset);
1833 VerifyObjectField(isolate, kAsmJsOffsetTableOffset);
1834 VerifyObjectField(isolate, kBreakPointInfosOffset);
1837 void DataHandler::DataHandlerVerify(Isolate* isolate) {
1838 CHECK(IsDataHandler());
1839 CHECK_IMPLIES(!smi_handler()->IsSmi(),
1840 smi_handler()->IsCode() && IsStoreHandler());
1841 CHECK(validity_cell()->IsSmi() || validity_cell()->IsCell());
1842 int data_count = data_field_count();
1843 if (data_count >= 1) {
1844 VerifyMaybeObjectField(isolate, kData1Offset);
1846 if (data_count >= 2) {
1847 VerifyMaybeObjectField(isolate, kData2Offset);
1849 if (data_count >= 3) {
1850 VerifyMaybeObjectField(isolate, kData3Offset);
1854 void LoadHandler::LoadHandlerVerify(Isolate* isolate) {
1855 DataHandler::DataHandlerVerify(isolate);
1859 void StoreHandler::StoreHandlerVerify(Isolate* isolate) {
1860 DataHandler::DataHandlerVerify(isolate);
1864 void AccessorInfo::AccessorInfoVerify(Isolate* isolate) {
1865 CHECK(IsAccessorInfo());
1866 VerifyPointer(isolate, name());
1867 VerifyPointer(isolate, expected_receiver_type());
1868 VerifyForeignPointer(isolate,
this, getter());
1869 VerifyForeignPointer(isolate,
this, setter());
1870 VerifyForeignPointer(isolate,
this, js_getter());
1871 VerifyPointer(isolate, data());
1874 void AccessorPair::AccessorPairVerify(Isolate* isolate) {
1875 CHECK(IsAccessorPair());
1876 VerifyPointer(isolate, getter());
1877 VerifyPointer(isolate, setter());
1880 void AccessCheckInfo::AccessCheckInfoVerify(Isolate* isolate) {
1881 CHECK(IsAccessCheckInfo());
1882 VerifyPointer(isolate, callback());
1883 VerifyPointer(isolate, named_interceptor());
1884 VerifyPointer(isolate, indexed_interceptor());
1885 VerifyPointer(isolate, data());
1888 void CallHandlerInfo::CallHandlerInfoVerify(Isolate* isolate) {
1889 CHECK(IsCallHandlerInfo());
1890 CHECK(map() == ReadOnlyRoots(isolate).side_effect_call_handler_info_map() ||
1892 ReadOnlyRoots(isolate).side_effect_free_call_handler_info_map() ||
1893 map() == ReadOnlyRoots(isolate)
1894 .next_call_side_effect_free_call_handler_info_map());
1895 VerifyPointer(isolate, callback());
1896 VerifyPointer(isolate, js_callback());
1897 VerifyPointer(isolate, data());
1900 void InterceptorInfo::InterceptorInfoVerify(Isolate* isolate) {
1901 CHECK(IsInterceptorInfo());
1902 VerifyForeignPointer(isolate,
this, getter());
1903 VerifyForeignPointer(isolate,
this, setter());
1904 VerifyForeignPointer(isolate,
this, query());
1905 VerifyForeignPointer(isolate,
this, deleter());
1906 VerifyForeignPointer(isolate,
this, enumerator());
1907 VerifyPointer(isolate, data());
1908 VerifySmiField(kFlagsOffset);
1911 void TemplateInfo::TemplateInfoVerify(Isolate* isolate) {
1912 VerifyPointer(isolate, tag());
1913 VerifyPointer(isolate, property_list());
1914 VerifyPointer(isolate, property_accessors());
1917 void FunctionTemplateInfo::FunctionTemplateInfoVerify(Isolate* isolate) {
1918 CHECK(IsFunctionTemplateInfo());
1919 TemplateInfoVerify(isolate);
1920 VerifyPointer(isolate, serial_number());
1921 VerifyPointer(isolate, call_code());
1922 VerifyPointer(isolate, signature());
1923 VerifyPointer(isolate, cached_property_name());
1924 VerifyPointer(isolate, rare_data());
1927 void FunctionTemplateRareData::FunctionTemplateRareDataVerify(
1929 CHECK(IsFunctionTemplateRareData());
1930 VerifyPointer(isolate, prototype_template());
1931 VerifyPointer(isolate, parent_template());
1932 VerifyPointer(isolate, named_property_handler());
1933 VerifyPointer(isolate, indexed_property_handler());
1934 VerifyPointer(isolate, instance_template());
1935 VerifyPointer(isolate, access_check_info());
1938 void ObjectTemplateInfo::ObjectTemplateInfoVerify(Isolate* isolate) {
1939 CHECK(IsObjectTemplateInfo());
1940 TemplateInfoVerify(isolate);
1941 VerifyPointer(isolate, constructor());
1942 VerifyPointer(isolate, data());
1945 void AllocationSite::AllocationSiteVerify(Isolate* isolate) {
1946 CHECK(IsAllocationSite());
1949 void AllocationMemento::AllocationMementoVerify(Isolate* isolate) {
1950 CHECK(IsAllocationMemento());
1951 VerifyHeapPointer(isolate, allocation_site());
1952 CHECK(!IsValid() || GetAllocationSite()->IsAllocationSite());
1955 void Script::ScriptVerify(Isolate* isolate) {
1957 VerifyPointer(isolate, source());
1958 VerifyPointer(isolate, name());
1959 VerifyPointer(isolate, line_ends());
1960 for (
int i = 0;
i < shared_function_infos()->length(); ++
i) {
1961 MaybeObject maybe_object = shared_function_infos()->Get(
i);
1962 HeapObject* heap_object;
1963 CHECK(maybe_object->IsWeak() || maybe_object->IsCleared() ||
1964 (maybe_object->GetHeapObjectIfStrong(&heap_object) &&
1965 heap_object->IsUndefined(isolate)));
1969 void NormalizedMapCache::NormalizedMapCacheVerify(Isolate* isolate) {
1970 WeakFixedArray::cast(
this)->WeakFixedArrayVerify(isolate);
1971 if (FLAG_enable_slow_asserts) {
1972 for (
int i = 0;
i < length();
i++) {
1973 MaybeObject e = WeakFixedArray::Get(
i);
1974 HeapObject* heap_object;
1975 if (e->GetHeapObjectIfWeak(&heap_object)) {
1976 Map::cast(heap_object)->DictionaryMapVerify(isolate);
1978 CHECK(e->IsCleared() || (e->GetHeapObjectIfStrong(&heap_object) &&
1979 heap_object->IsUndefined(isolate)));
1985 void DebugInfo::DebugInfoVerify(Isolate* isolate) {
1986 CHECK(IsDebugInfo());
1987 VerifyPointer(isolate, shared());
1988 VerifyPointer(isolate, script());
1989 VerifyPointer(isolate, original_bytecode_array());
1990 VerifyPointer(isolate, break_points());
1993 void StackFrameInfo::StackFrameInfoVerify(Isolate* isolate) {
1994 CHECK(IsStackFrameInfo());
1995 VerifyPointer(isolate, script_name());
1996 VerifyPointer(isolate, script_name_or_source_url());
1997 VerifyPointer(isolate, function_name());
2000 void PreParsedScopeData::PreParsedScopeDataVerify(Isolate* isolate) {
2001 CHECK(IsPreParsedScopeData());
2002 CHECK(scope_data()->IsByteArray());
2003 CHECK_GE(length(), 0);
2005 for (
int i = 0;
i < length(); ++
i) {
2006 Object* child = child_data(
i);
2007 CHECK(child->IsPreParsedScopeData() || child->IsNull());
2008 VerifyPointer(isolate, child);
2012 void UncompiledDataWithPreParsedScope::UncompiledDataWithPreParsedScopeVerify(
2014 CHECK(IsUncompiledDataWithPreParsedScope());
2015 VerifyPointer(isolate, inferred_name());
2016 VerifyPointer(isolate, pre_parsed_scope_data());
2019 void UncompiledDataWithoutPreParsedScope::
2020 UncompiledDataWithoutPreParsedScopeVerify(Isolate* isolate) {
2021 CHECK(IsUncompiledDataWithoutPreParsedScope());
2022 VerifyPointer(isolate, inferred_name());
2025 void InterpreterData::InterpreterDataVerify(Isolate* isolate) {
2026 CHECK(IsInterpreterData());
2027 CHECK(bytecode_array()->IsBytecodeArray());
2028 CHECK(interpreter_trampoline()->IsCode());
2031 #ifdef V8_INTL_SUPPORT 2032 void JSV8BreakIterator::JSV8BreakIteratorVerify(Isolate* isolate) {
2033 JSObjectVerify(isolate);
2034 VerifyObjectField(isolate, kLocaleOffset);
2035 VerifyObjectField(isolate, kTypeOffset);
2036 VerifyObjectField(isolate, kBreakIteratorOffset);
2037 VerifyObjectField(isolate, kUnicodeStringOffset);
2038 VerifyObjectField(isolate, kBoundAdoptTextOffset);
2039 VerifyObjectField(isolate, kBoundFirstOffset);
2040 VerifyObjectField(isolate, kBoundNextOffset);
2041 VerifyObjectField(isolate, kBoundCurrentOffset);
2042 VerifyObjectField(isolate, kBoundBreakTypeOffset);
2045 void JSCollator::JSCollatorVerify(Isolate* isolate) {
2046 CHECK(IsJSCollator());
2047 JSObjectVerify(isolate);
2048 VerifyObjectField(isolate, kICUCollatorOffset);
2049 VerifyObjectField(isolate, kBoundCompareOffset);
2052 void JSDateTimeFormat::JSDateTimeFormatVerify(Isolate* isolate) {
2053 JSObjectVerify(isolate);
2054 VerifyObjectField(isolate, kICULocaleOffset);
2055 VerifyObjectField(isolate, kICUSimpleDateFormatOffset);
2056 VerifyObjectField(isolate, kBoundFormatOffset);
2059 void JSListFormat::JSListFormatVerify(Isolate* isolate) {
2060 JSObjectVerify(isolate);
2061 VerifyObjectField(isolate, kLocaleOffset);
2062 VerifyObjectField(isolate, kICUFormatterOffset);
2063 VerifyObjectField(isolate, kFlagsOffset);
2066 void JSLocale::JSLocaleVerify(Isolate* isolate) {
2067 JSObjectVerify(isolate);
2068 VerifyObjectField(isolate, kLanguageOffset);
2069 VerifyObjectField(isolate, kScriptOffset);
2070 VerifyObjectField(isolate, kRegionOffset);
2071 VerifyObjectField(isolate, kBaseNameOffset);
2072 VerifyObjectField(isolate, kLocaleOffset);
2074 VerifyObjectField(isolate, kFlagsOffset);
2075 VerifyObjectField(isolate, kCalendarOffset);
2076 VerifyObjectField(isolate, kCollationOffset);
2077 VerifyObjectField(isolate, kNumberingSystemOffset);
2080 void JSNumberFormat::JSNumberFormatVerify(Isolate* isolate) {
2081 CHECK(IsJSNumberFormat());
2082 JSObjectVerify(isolate);
2083 VerifyObjectField(isolate, kLocaleOffset);
2084 VerifyObjectField(isolate, kICUNumberFormatOffset);
2085 VerifyObjectField(isolate, kBoundFormatOffset);
2086 VerifyObjectField(isolate, kFlagsOffset);
2089 void JSPluralRules::JSPluralRulesVerify(Isolate* isolate) {
2090 CHECK(IsJSPluralRules());
2091 JSObjectVerify(isolate);
2092 VerifyObjectField(isolate, kLocaleOffset);
2093 VerifyObjectField(isolate, kFlagsOffset);
2094 VerifyObjectField(isolate, kICUPluralRulesOffset);
2095 VerifyObjectField(isolate, kICUDecimalFormatOffset);
2098 void JSRelativeTimeFormat::JSRelativeTimeFormatVerify(Isolate* isolate) {
2099 JSObjectVerify(isolate);
2100 VerifyObjectField(isolate, kLocaleOffset);
2101 VerifyObjectField(isolate, kICUFormatterOffset);
2102 VerifyObjectField(isolate, kFlagsOffset);
2105 void JSSegmentIterator::JSSegmentIteratorVerify(Isolate* isolate) {
2106 JSObjectVerify(isolate);
2107 VerifyObjectField(isolate, kICUBreakIteratorOffset);
2108 VerifyObjectField(isolate, kUnicodeStringOffset);
2109 VerifyObjectField(isolate, kFlagsOffset);
2112 void JSSegmenter::JSSegmenterVerify(Isolate* isolate) {
2113 JSObjectVerify(isolate);
2114 VerifyObjectField(isolate, kLocaleOffset);
2115 VerifyObjectField(isolate, kICUBreakIteratorOffset);
2116 VerifyObjectField(isolate, kFlagsOffset);
2118 #endif // V8_INTL_SUPPORT 2120 #endif // VERIFY_HEAP 2124 void JSObject::IncrementSpillStatistics(Isolate* isolate,
2125 SpillInformation* info) {
2126 info->number_of_objects_++;
2128 if (HasFastProperties()) {
2129 info->number_of_objects_with_fast_properties_++;
2130 info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex();
2131 info->number_of_fast_unused_fields_ += map()->UnusedPropertyFields();
2132 }
else if (IsJSGlobalObject()) {
2133 GlobalDictionary dict = JSGlobalObject::cast(
this)->global_dictionary();
2134 info->number_of_slow_used_properties_ += dict->NumberOfElements();
2135 info->number_of_slow_unused_properties_ +=
2136 dict->Capacity() - dict->NumberOfElements();
2138 NameDictionary dict = property_dictionary();
2139 info->number_of_slow_used_properties_ += dict->NumberOfElements();
2140 info->number_of_slow_unused_properties_ +=
2141 dict->Capacity() - dict->NumberOfElements();
2144 switch (GetElementsKind()) {
2145 case HOLEY_SMI_ELEMENTS:
2146 case PACKED_SMI_ELEMENTS:
2147 case HOLEY_DOUBLE_ELEMENTS:
2148 case PACKED_DOUBLE_ELEMENTS:
2149 case HOLEY_ELEMENTS:
2150 case PACKED_ELEMENTS:
2151 case FAST_STRING_WRAPPER_ELEMENTS: {
2152 info->number_of_objects_with_fast_elements_++;
2154 FixedArray e = FixedArray::cast(elements());
2155 int len = e->length();
2156 for (
int i = 0;
i < len;
i++) {
2157 if (e->get(
i)->IsTheHole(isolate)) holes++;
2159 info->number_of_fast_used_elements_ += len - holes;
2160 info->number_of_fast_unused_elements_ += holes;
2164 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype) case TYPE##_ELEMENTS: 2166 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2167 #undef TYPED_ARRAY_CASE 2169 info->number_of_objects_with_fast_elements_++;
2170 FixedArrayBase e = FixedArrayBase::cast(elements());
2171 info->number_of_fast_used_elements_ += e->length();
2174 case DICTIONARY_ELEMENTS:
2175 case SLOW_STRING_WRAPPER_ELEMENTS: {
2176 NumberDictionary dict = element_dictionary();
2177 info->number_of_slow_used_elements_ += dict->NumberOfElements();
2178 info->number_of_slow_unused_elements_ +=
2179 dict->Capacity() - dict->NumberOfElements();
2182 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
2183 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
2190 void JSObject::SpillInformation::Clear() {
2191 number_of_objects_ = 0;
2192 number_of_objects_with_fast_properties_ = 0;
2193 number_of_objects_with_fast_elements_ = 0;
2194 number_of_fast_used_fields_ = 0;
2195 number_of_fast_unused_fields_ = 0;
2196 number_of_slow_used_properties_ = 0;
2197 number_of_slow_unused_properties_ = 0;
2198 number_of_fast_used_elements_ = 0;
2199 number_of_fast_unused_elements_ = 0;
2200 number_of_slow_used_elements_ = 0;
2201 number_of_slow_unused_elements_ = 0;
2205 void JSObject::SpillInformation::Print() {
2206 PrintF(
"\n JSObject Spill Statistics (#%d):\n", number_of_objects_);
2208 PrintF(
" - fast properties (#%d): %d (used) %d (unused)\n",
2209 number_of_objects_with_fast_properties_,
2210 number_of_fast_used_fields_, number_of_fast_unused_fields_);
2212 PrintF(
" - slow properties (#%d): %d (used) %d (unused)\n",
2213 number_of_objects_ - number_of_objects_with_fast_properties_,
2214 number_of_slow_used_properties_, number_of_slow_unused_properties_);
2216 PrintF(
" - fast elements (#%d): %d (used) %d (unused)\n",
2217 number_of_objects_with_fast_elements_,
2218 number_of_fast_used_elements_, number_of_fast_unused_elements_);
2220 PrintF(
" - slow elements (#%d): %d (used) %d (unused)\n",
2221 number_of_objects_ - number_of_objects_with_fast_elements_,
2222 number_of_slow_used_elements_, number_of_slow_unused_elements_);
2227 bool DescriptorArray::IsSortedNoDuplicates(
int valid_entries) {
2228 if (valid_entries == -1) valid_entries = number_of_descriptors();
2231 for (
int i = 0;
i < number_of_descriptors();
i++) {
2232 Name key = GetSortedKey(
i);
2233 if (key == current_key) {
2238 uint32_t hash = GetSortedKey(
i)->Hash();
2239 if (hash < current) {
2248 bool TransitionArray::IsSortedNoDuplicates(
int valid_entries) {
2249 DCHECK_EQ(valid_entries, -1);
2251 PropertyKind prev_kind = kData;
2252 PropertyAttributes prev_attributes = NONE;
2255 for (
int i = 0;
i < number_of_transitions();
i++) {
2256 Name key = GetSortedKey(
i);
2258 PropertyKind kind = kData;
2259 PropertyAttributes attributes = NONE;
2260 if (!TransitionsAccessor::IsSpecialTransition(key->GetReadOnlyRoots(),
2262 Map target = GetTarget(
i);
2263 PropertyDetails details =
2264 TransitionsAccessor::GetTargetDetails(key, target);
2265 kind = details.kind();
2266 attributes = details.attributes();
2269 DCHECK_NE(prev_key, key);
2272 int cmp = CompareKeys(prev_key, prev_hash, prev_kind, prev_attributes, key,
2273 hash, kind, attributes);
2280 prev_attributes = attributes;
2286 bool TransitionsAccessor::IsSortedNoDuplicates() {
2288 if (encoding() != kFullTransitionArray)
return true;
2289 return transitions()->IsSortedNoDuplicates();
2292 static bool CheckOneBackPointer(Map current_map, Object* target) {
2293 return !target->IsMap() || Map::cast(target)->GetBackPointer() == current_map;
2296 bool TransitionsAccessor::IsConsistentWithBackPointers() {
2297 int num_transitions = NumberOfTransitions();
2298 for (
int i = 0;
i < num_transitions;
i++) {
2299 Map target = GetTarget(
i);
2300 if (!CheckOneBackPointer(map_, target))
return false;
2308 bool CanLeak(Object* obj, Isolate* isolate) {
2309 if (!obj->IsHeapObject())
return false;
2310 if (obj->IsCell()) {
2311 return CanLeak(Cell::cast(obj)->value(), isolate);
2313 if (obj->IsPropertyCell()) {
2314 return CanLeak(PropertyCell::cast(obj)->value(), isolate);
2316 if (obj->IsContext())
return true;
2318 Map map = Map::cast(obj);
2319 for (RootIndex root_index = RootIndex::kFirstStrongOrReadOnlyRoot;
2320 root_index <= RootIndex::kLastStrongOrReadOnlyRoot; ++root_index) {
2321 if (map == isolate->root(root_index))
return false;
2325 return CanLeak(HeapObject::cast(obj)->map(), isolate);
2328 void Code::VerifyEmbeddedObjects(Isolate* isolate, VerifyMode mode) {
2329 if (kind() == OPTIMIZED_FUNCTION)
return;
2330 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
2331 for (RelocIterator it(*
this, mask); !it.done(); it.next()) {
2332 Object* target = it.rinfo()->target_object();
2333 DCHECK(!CanLeak(target, isolate));