25#define DEPENDENCY_LIST(V) \
26 V(ConsistentJSFunctionView) \
27 V(ConstantInDictionaryPrototypeChain) \
29 V(EmptyContextExtension) \
31 V(FieldRepresentation) \
35 V(InitialMapInstanceSizePrediction) \
36 V(NoSlackTrackingChange) \
37 V(OwnConstantDataProperty) \
38 V(OwnConstantDoubleProperty) \
39 V(OwnConstantDictionaryProperty) \
40 V(OwnConstantElement) \
43 V(PrototypeProperty) \
44 V(ScriptContextSlotProperty) \
57enum CompilationDependencyKind {
58#define V(Name) k##Name,
63#define V(Name) class Name##Dependency;
67const char* CompilationDependencyKindToString(CompilationDependencyKind
kind) {
68#define V(Name) #Name "Dependency",
74class PendingDependencies;
85 PendingDependencies* deps)
const = 0;
88 bool Is##Name() const { return kind == k##Name; } \
89 V8_ALLOW_UNUSED const Name##Dependency* As##Name() const;
94 return CompilationDependencyKindToString(
kind);
97 const CompilationDependencyKind
kind;
100 virtual size_t Hash()
const = 0;
122class PendingDependencies final {
124 explicit PendingDependencies(
Zone* zone)
134 if (HeapLayout::InWritableSharedSpace(*
object) ||
135 HeapLayout::InReadOnlySpace(*
object))
137 deps_.LookupOrInsert(
object, HandleValueHash(
object))->value |= group;
142 InstallAllPredictable(isolate, code);
148 AllowGarbageCollection yes_gc;
149 for (
auto* entry =
deps_.Start(); entry !=
nullptr;
150 entry =
deps_.Next(entry)) {
151 DependentCode::InstallDependency(isolate, code, entry->key, entry->value);
156 void InstallAllPredictable(Isolate* isolate, Handle<Code> code) {
159 using DepsMap =
decltype(
deps_);
160 std::vector<const DepsMap::Entry*>
entries;
162 for (
auto* entry =
deps_.Start(); entry !=
nullptr;
163 entry =
deps_.Next(entry)) {
168 [](
const DepsMap::Entry* lhs,
const DepsMap::Entry* rhs) {
169 return lhs->key->ptr() < rhs->key->ptr();
175 for (
const auto* entry :
entries) {
176 DependentCode::InstallDependency(isolate, code, entry->key, entry->value);
182 uint32_t HandleValueHash(DirectHandle<HeapObject> handle) {
183 return static_cast<uint32_t
>(base::hash_value(
handle->ptr()));
185 struct HandleValueEqual {
186 bool operator()(uint32_t hash1, uint32_t hash2,
187 DirectHandle<HeapObject> lhs,
188 Handle<HeapObject> rhs)
const {
189 return hash1 == hash2 && lhs.is_identical_to(rhs);
193 base::TemplateHashMapImpl<Handle<HeapObject>, DependentCode::DependencyGroups,
194 HandleValueEqual, ZoneAllocationPolicy>
198class InitialMapDependency final :
public CompilationDependency {
200 InitialMapDependency(JSHeapBroker*
broker, JSFunctionRef function,
202 : CompilationDependency(kInitialMap),
206 bool IsValid(JSHeapBroker*
broker)
const override {
207 DirectHandle<JSFunction> function =
function_.object();
208 return function->has_initial_map() &&
212 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
215 DependentCode::kInitialMapChangedGroup);
219 size_t Hash()
const override {
224 bool Equals(
const CompilationDependency* that)
const override {
225 const InitialMapDependency*
const zat = that->AsInitialMap();
226 return function_.equals(zat->function_) &&
234class PrototypePropertyDependency final :
public CompilationDependency {
236 PrototypePropertyDependency(JSHeapBroker*
broker, JSFunctionRef function,
238 : CompilationDependency(kPrototypeProperty),
246 bool IsValid(JSHeapBroker*
broker)
const override {
247 DirectHandle<JSFunction> function =
function_.object();
248 return function->has_prototype_slot() &&
249 function->has_instance_prototype() &&
250 !function->PrototypeRequiresRuntimeLookup() &&
251 function->instance_prototype() == *
prototype_.object();
254 void PrepareInstall(JSHeapBroker*
broker)
const override {
256 DirectHandle<JSFunction> function =
function_.object();
257 if (!function->has_initial_map()) JSFunction::EnsureHasInitialMap(function);
260 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
262 DirectHandle<JSFunction> function =
function_.object();
263 CHECK(function->has_initial_map());
265 deps->Register(initial_map, DependentCode::kInitialMapChangedGroup);
269 size_t Hash()
const override {
274 bool Equals(
const CompilationDependency* that)
const override {
275 const PrototypePropertyDependency*
const zat = that->AsPrototypeProperty();
276 return function_.equals(zat->function_) &&
284class StableMapDependency final :
public CompilationDependency {
286 explicit StableMapDependency(MapRef map)
287 : CompilationDependency(kStableMap),
map_(map) {}
289 bool IsValid(JSHeapBroker*
broker)
const override {
293 return !
map_.object()->is_dictionary_map() &&
map_.object()->is_stable();
295 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
297 deps->Register(
map_.object(), DependentCode::kPrototypeCheckGroup);
301 size_t Hash()
const override {
303 return base::hash_combine(h(
map_));
306 bool Equals(
const CompilationDependency* that)
const override {
307 const StableMapDependency*
const zat = that->AsStableMap();
308 return map_.equals(zat->map_);
314class ConstantInDictionaryPrototypeChainDependency final
315 :
public CompilationDependency {
317 explicit ConstantInDictionaryPrototypeChainDependency(
318 const MapRef receiver_map,
const NameRef property_name,
320 : CompilationDependency(kConstantInDictionaryPrototypeChain),
330 bool IsValid(JSHeapBroker*
broker)
const override {
331 return !GetHolderIfValid(
broker).is_null();
334 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
336 Isolate* isolate =
broker->isolate();
337 DirectHandle<JSObject> holder = GetHolderIfValid(
broker).ToHandleChecked();
340 while (map->prototype() != *holder) {
341 map =
handle(map->prototype()->map(), isolate);
342 DCHECK(IsJSObjectMap(*map));
343 deps->Register(map, DependentCode::kPrototypeCheckGroup);
346 DCHECK(IsJSObjectMap(map->prototype()->map()));
347 deps->Register(
handle(map->prototype()->map(), isolate),
348 DependentCode::kPrototypeCheckGroup);
357 MaybeHandle<JSObject> GetHolderIfValid(JSHeapBroker*
broker)
const {
359 Isolate* isolate =
broker->isolate();
361 Tagged<HeapObject> prototype =
receiver_map_.object()->prototype();
363 enum class ValidationResult { kFoundCorrect, kFoundIncorrect,
kNotFound };
364 auto try_load = [&](
auto dictionary) -> ValidationResult {
365 InternalIndex entry =
367 if (entry.is_not_found()) {
368 return ValidationResult::kNotFound;
371 PropertyDetails details = dictionary->DetailsAt(entry);
372 if (details.constness() != PropertyConstness::kConst) {
373 return ValidationResult::kFoundIncorrect;
376 Tagged<Object> dictionary_value = dictionary->ValueAt(entry);
377 Tagged<Object>
value;
384 if (details.kind() !=
kind_) {
385 return ValidationResult::kFoundIncorrect;
387 if (
kind_ == PropertyKind::kAccessor) {
388 if (!IsAccessorPair(dictionary_value)) {
389 return ValidationResult::kFoundIncorrect;
393 value = Cast<AccessorPair>(dictionary_value)
394 ->get(AccessorComponent::ACCESSOR_GETTER);
396 value = dictionary_value;
398 return value == *
constant_.object() ? ValidationResult::kFoundCorrect
399 : ValidationResult::kFoundIncorrect;
402 while (IsJSObject(prototype)) {
406 Tagged<JSObject>
object = Cast<JSObject>(prototype);
410 CHECK(!object->HasFastProperties());
414 ? try_load(object->property_dictionary_swiss())
415 : try_load(object->property_dictionary());
417 if (
result == ValidationResult::kFoundCorrect) {
418 return handle(
object, isolate);
419 }
else if (
result == ValidationResult::kFoundIncorrect) {
420 return MaybeHandle<JSObject>();
424 prototype =
object->map()->prototype();
427 return MaybeHandle<JSObject>();
430 size_t Hash()
const override {
433 static_cast<int>(
kind_));
436 bool Equals(
const CompilationDependency* that)
const override {
437 const ConstantInDictionaryPrototypeChainDependency*
const zat =
438 that->AsConstantInDictionaryPrototypeChain();
450class OwnConstantDataPropertyDependency final :
public CompilationDependency {
452 OwnConstantDataPropertyDependency(JSHeapBroker*
broker, JSObjectRef holder,
453 MapRef map, FieldIndex index,
455 : CompilationDependency(kOwnConstantDataProperty),
462 bool IsValid(JSHeapBroker*
broker)
const override {
465 "Map change detected in " <<
holder_.object());
469 Tagged<Object> current_value =
holder_.object()->RawFastPropertyAt(
index_);
470 Tagged<Object> used_value = *
value_.object();
471 if (current_value != used_value) {
473 <<
holder_.object() <<
" at FieldIndex "
474 <<
index_.property_index());
480 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
484 size_t Hash()
const override {
490 bool Equals(
const CompilationDependency* that)
const override {
491 const OwnConstantDataPropertyDependency*
const zat =
492 that->AsOwnConstantDataProperty();
493 return holder_.equals(zat->holder_) &&
map_.equals(zat->map_) &&
504class OwnConstantDoublePropertyDependency final :
public CompilationDependency {
506 OwnConstantDoublePropertyDependency(JSHeapBroker*
broker, JSObjectRef holder,
507 MapRef map, FieldIndex index,
509 : CompilationDependency(kOwnConstantDoubleProperty),
516 bool IsValid(JSHeapBroker*
broker)
const override {
519 "Map change detected in " <<
holder_.object());
523 Tagged<Object> current_value =
holder_.object()->RawFastPropertyAt(
index_);
527 if (!IsHeapNumber(current_value) ||
528 Cast<HeapNumber>(current_value)->value_as_bits() !=
529 used_value.get_bits()) {
531 <<
holder_.object() <<
" at FieldIndex "
532 <<
index_.property_index());
539 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
543 size_t Hash()
const override {
549 bool Equals(
const CompilationDependency* that)
const override {
550 const OwnConstantDoublePropertyDependency*
const zat =
551 that->AsOwnConstantDoubleProperty();
552 return holder_.equals(zat->holder_) &&
map_.equals(zat->map_) &&
553 index_ == zat->index_ &&
value_.get_bits() == zat->value_.get_bits();
563class OwnConstantDictionaryPropertyDependency final
564 :
public CompilationDependency {
566 OwnConstantDictionaryPropertyDependency(JSHeapBroker*
broker,
568 InternalIndex index, ObjectRef value)
569 : CompilationDependency(kOwnConstantDictionaryProperty),
575 static_assert(ref_traits<JSObject>::ref_serialization_kind !=
576 RefSerializationKind::kNeverSerialized);
579 bool IsValid(JSHeapBroker*
broker)
const override {
582 "Map change detected in " <<
holder_.object());
586 std::optional<Tagged<Object>> maybe_value = JSObject::DictionaryPropertyAt(
592 <<
"has a value that might not safe to read at index "
597 if (*maybe_value != *
value_.object()) {
600 <<
" at InternalIndex "
607 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
611 size_t Hash()
const override {
617 bool Equals(
const CompilationDependency* that)
const override {
618 const OwnConstantDictionaryPropertyDependency*
const zat =
619 that->AsOwnConstantDictionaryProperty();
620 return holder_.equals(zat->holder_) &&
map_.equals(zat->map_) &&
626 InternalIndex
const index_;
630class ConsistentJSFunctionViewDependency final :
public CompilationDependency {
632 explicit ConsistentJSFunctionViewDependency(JSFunctionRef function)
633 : CompilationDependency(kConsistentJSFunctionView),
function_(function) {}
635 bool IsValid(JSHeapBroker*
broker)
const override {
639 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
643 size_t Hash()
const override {
648 bool Equals(
const CompilationDependency* that)
const override {
649 const ConsistentJSFunctionViewDependency*
const zat =
650 that->AsConsistentJSFunctionView();
657class TransitionDependency final :
public CompilationDependency {
659 explicit TransitionDependency(MapRef map)
660 : CompilationDependency(kTransition),
map_(map) {
664 bool IsValid(JSHeapBroker*
broker)
const override {
665 return !
map_.object()->is_deprecated();
668 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
670 deps->Register(
map_.object(), DependentCode::kTransitionGroup);
674 size_t Hash()
const override {
676 return base::hash_combine(h(
map_));
679 bool Equals(
const CompilationDependency* that)
const override {
680 const TransitionDependency*
const zat = that->AsTransition();
681 return map_.equals(zat->map_);
687class PretenureModeDependency final :
public CompilationDependency {
689 PretenureModeDependency(AllocationSiteRef site, AllocationType allocation)
690 : CompilationDependency(kPretenureMode),
694 bool IsValid(JSHeapBroker*
broker)
const override {
697 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
699 deps->Register(
site_.object(),
700 DependentCode::kAllocationSiteTenuringChangedGroup);
704 size_t Hash()
const override {
709 bool Equals(
const CompilationDependency* that)
const override {
710 const PretenureModeDependency*
const zat = that->AsPretenureMode();
718class FieldRepresentationDependency final :
public CompilationDependency {
720 FieldRepresentationDependency(MapRef map, MapRef owner,
721 InternalIndex descriptor,
722 Representation representation)
723 : CompilationDependency(kFieldRepresentation),
729 bool IsValid(JSHeapBroker*
broker)
const override {
731 if (
map_.object()->is_deprecated())
return false;
733 ->instance_descriptors(
broker->isolate())
738 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
740 Isolate* isolate =
broker->isolate();
741 Handle<Map> owner =
owner_.object();
742 CHECK(!owner->is_deprecated());
746 deps->Register(owner, DependentCode::kFieldRepresentationGroup);
749 bool DependsOn(
const Handle<Map>& receiver_map)
const {
750 return map_.object().equals(receiver_map);
754 size_t Hash()
const override {
760 bool Equals(
const CompilationDependency* that)
const override {
761 const FieldRepresentationDependency*
const zat =
762 that->AsFieldRepresentation();
773class FieldTypeDependency final :
public CompilationDependency {
775 FieldTypeDependency(MapRef map, MapRef owner, InternalIndex descriptor,
777 : CompilationDependency(kFieldType),
783 bool IsValid(JSHeapBroker*
broker)
const override {
785 if (
map_.object()->is_deprecated())
return false;
787 ->instance_descriptors(
broker->isolate())
791 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
793 Isolate* isolate =
broker->isolate();
794 Handle<Map> owner =
owner_.object();
795 CHECK(!owner->is_deprecated());
797 owner->instance_descriptors(isolate)->GetFieldType(
descriptor_));
798 deps->Register(owner, DependentCode::kFieldTypeGroup);
802 size_t Hash()
const override {
807 bool Equals(
const CompilationDependency* that)
const override {
808 const FieldTypeDependency*
const zat = that->AsFieldType();
810 type_.equals(zat->type_);
819class FieldConstnessDependency final :
public CompilationDependency {
821 FieldConstnessDependency(MapRef map, MapRef owner, InternalIndex descriptor)
822 : CompilationDependency(kFieldConstness),
827 bool IsValid(JSHeapBroker*
broker)
const override {
829 if (
map_.object()->is_deprecated())
return false;
830 return PropertyConstness::kConst ==
832 ->instance_descriptors(
broker->isolate())
837 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
839 Isolate* isolate =
broker->isolate();
840 Handle<Map> owner =
owner_.object();
841 CHECK(!owner->is_deprecated());
842 CHECK_EQ(PropertyConstness::kConst, owner->instance_descriptors(isolate)
845 deps->Register(owner, DependentCode::kFieldConstGroup);
849 size_t Hash()
const override {
854 bool Equals(
const CompilationDependency* that)
const override {
855 const FieldConstnessDependency*
const zat = that->AsFieldConstness();
864class GlobalPropertyDependency final :
public CompilationDependency {
866 GlobalPropertyDependency(PropertyCellRef cell, PropertyCellType type,
868 : CompilationDependency(kGlobalProperty),
876 bool IsValid(JSHeapBroker*
broker)
const override {
877 DirectHandle<PropertyCell> cell =
cell_.object();
881 *(
broker->isolate()->factory()->property_cell_hole_value())) {
884 return type_ == cell->property_details().cell_type() &&
885 read_only_ == cell->property_details().IsReadOnly();
887 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
889 deps->Register(
cell_.object(), DependentCode::kPropertyCellChangedGroup);
893 size_t Hash()
const override {
898 bool Equals(
const CompilationDependency* that)
const override {
899 const GlobalPropertyDependency*
const zat = that->AsGlobalProperty();
900 return cell_.equals(zat->cell_) &&
type_ == zat->type_ &&
905 const PropertyCellType
type_;
909class ScriptContextSlotPropertyDependency final :
public CompilationDependency {
911 ScriptContextSlotPropertyDependency(
912 ContextRef script_context,
size_t index,
913 ContextSidePropertyCell::Property property)
914 : CompilationDependency(kScriptContextSlotProperty),
922 bool IsValid(JSHeapBroker*
broker)
const override {
927 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
929 Isolate* isolate =
broker->isolate();
931 handle(Context::GetOrCreateContextSidePropertyCell(
934 DependentCode::kScriptContextSlotPropertyChangedGroup);
938 size_t Hash()
const override {
943 bool Equals(
const CompilationDependency* that)
const override {
944 const ScriptContextSlotPropertyDependency*
const zat =
945 that->AsScriptContextSlotProperty();
955class EmptyContextExtensionDependency final :
public CompilationDependency {
957 explicit EmptyContextExtensionDependency(ScopeInfoRef scope_info)
958 : CompilationDependency(kEmptyContextExtension),
scope_info_(scope_info) {
960 DCHECK(scope_info.SloppyEvalCanExtendVars());
961 DCHECK(!HeapLayout::InReadOnlySpace(*scope_info.object()));
964 bool IsValid(JSHeapBroker*
broker)
const override {
968 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
971 DependentCode::kEmptyContextExtensionGroup);
975 size_t Hash()
const override {
980 bool Equals(
const CompilationDependency* that)
const override {
981 const EmptyContextExtensionDependency*
const zat =
982 that->AsEmptyContextExtension();
989class ProtectorDependency final :
public CompilationDependency {
991 explicit ProtectorDependency(PropertyCellRef cell)
992 : CompilationDependency(kProtector),
cell_(cell) {}
994 bool IsValid(JSHeapBroker*
broker)
const override {
995 DirectHandle<PropertyCell> cell =
cell_.object();
996 return cell->value() == Smi::FromInt(Protectors::kProtectorValid);
998 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
1000 deps->Register(
cell_.object(), DependentCode::kPropertyCellChangedGroup);
1004 size_t Hash()
const override {
1006 return base::hash_combine(h(
cell_));
1009 bool Equals(
const CompilationDependency* that)
const override {
1010 const ProtectorDependency*
const zat = that->AsProtector();
1011 return cell_.equals(zat->cell_);
1014 const PropertyCellRef
cell_;
1018class ObjectSlotValueDependency final :
public CompilationDependency {
1020 explicit ObjectSlotValueDependency(HeapObjectRef
object,
int offset,
1022 : CompilationDependency(kObjectSlotValue),
1025 value_(value.object()) {}
1027 bool IsValid(JSHeapBroker*
broker)
const override {
1029 Tagged<Object> current_value =
1030 offset_ == HeapObject::kMapOffset
1032 : TaggedField<Object>::Relaxed_Load(cage_base, *
object_,
offset_);
1033 return *
value_ == current_value;
1035 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
1039 size_t Hash()
const override {
1043 bool Equals(
const CompilationDependency* that)
const override {
1044 const ObjectSlotValueDependency*
const zat = that->AsObjectSlotValue();
1045 return object_->address() == zat->object_->address() &&
1046 offset_ == zat->offset_ &&
value_.address() == zat->value_.address();
1054class ElementsKindDependency final :
public CompilationDependency {
1057 : CompilationDependency(kElementsKind),
site_(site),
kind_(
kind) {
1061 bool IsValid(JSHeapBroker*
broker)
const override {
1062 DirectHandle<AllocationSite> site =
site_.object();
1064 site->PointsToLiteral()
1065 ? site->boilerplate(kAcquireLoad)->map()->elements_kind()
1066 : site->GetElementsKind();
1069 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
1071 deps->Register(
site_.object(),
1072 DependentCode::kAllocationSiteTransitionChangedGroup);
1076 size_t Hash()
const override {
1078 return base::hash_combine(h(
site_),
static_cast<int>(
kind_));
1081 bool Equals(
const CompilationDependency* that)
const override {
1082 const ElementsKindDependency*
const zat = that->AsElementsKind();
1083 return site_.equals(zat->site_) &&
kind_ == zat->kind_;
1086 const AllocationSiteRef
site_;
1092class OwnConstantElementDependency final :
public CompilationDependency {
1094 OwnConstantElementDependency(JSObjectRef holder, uint32_t index,
1096 : CompilationDependency(kOwnConstantElement),
1101 bool IsValid(JSHeapBroker*
broker)
const override {
1103 Tagged<JSObject> holder = *
holder_.object();
1104 std::optional<Tagged<Object>> maybe_element =
1105 holder_.GetOwnConstantElementFromHeap(
1106 broker, holder->elements(), holder->GetElementsKind(),
index_);
1107 if (!maybe_element.has_value())
return false;
1109 return maybe_element.value() == *
element_.object();
1111 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
1115 size_t Hash()
const override {
1120 bool Equals(
const CompilationDependency* that)
const override {
1121 const OwnConstantElementDependency*
const zat =
1122 that->AsOwnConstantElement();
1123 return holder_.equals(zat->holder_) &&
index_ == zat->index_ &&
1132class NoSlackTrackingChangeDependency final :
public CompilationDependency {
1134 explicit NoSlackTrackingChangeDependency(MapRef map)
1135 : CompilationDependency(kNoSlackTrackingChange),
map_(map) {}
1137 bool IsValid(JSHeapBroker*
broker)
const override {
1138 if (
map_.construction_counter() != 0 &&
1139 map_.object()->construction_counter() == 0) {
1143 return map_.UnusedPropertyFields() ==
1144 map_.object()->UnusedPropertyFields() &&
1145 map_.GetInObjectProperties() ==
1146 map_.object()->GetInObjectProperties();
1149 void PrepareInstall(JSHeapBroker*)
const override {}
1150 void Install(JSHeapBroker*, PendingDependencies*)
const override {}
1153 size_t Hash()
const override {
1155 return base::hash_combine(h(
map_));
1158 bool Equals(
const CompilationDependency* that)
const override {
1159 const NoSlackTrackingChangeDependency*
const zat =
1160 that->AsNoSlackTrackingChange();
1161 return map_.equals(zat->map_);
1167class InitialMapInstanceSizePredictionDependency final
1168 :
public CompilationDependency {
1170 InitialMapInstanceSizePredictionDependency(JSFunctionRef function,
1172 : CompilationDependency(kInitialMapInstanceSizePrediction),
1176 bool IsValid(JSHeapBroker*
broker)
const override {
1179 if (!
function_.object()->has_initial_map())
return false;
1181 function_.object()->ComputeInstanceSizeWithMinSlack(
broker->isolate());
1185 void PrepareInstall(JSHeapBroker*
broker)
const override {
1187 function_.object()->CompleteInobjectSlackTrackingIfActive();
1190 void Install(JSHeapBroker*
broker, PendingDependencies* deps)
const override {
1194 ->IsInobjectSlackTrackingInProgress());
1198 size_t Hash()
const override {
1203 bool Equals(
const CompilationDependency* that)
const override {
1204 const InitialMapInstanceSizePredictionDependency*
const zat =
1205 that->AsInitialMapInstanceSizePrediction();
1206 return function_.equals(zat->function_) &&
1218 if (dependency !=
nullptr)
dependencies_.insert(dependency);
1231 zone_->
New<PrototypePropertyDependency>(
broker_, function, prototype));
1236 if (map.CanTransition()) {
1242 MapRef receiver_map,
NameRef property_name, ObjectRef constant,
1245 receiver_map, property_name, constant,
kind));
1259 map.GetPropertyDetails(
broker_, descriptor).constness();
1267 if (!map.is_stable()) {
1275 zone_->
New<FieldConstnessDependency>(map, owner, descriptor));
1290 if (!map.is_stable()) {
1296 return zone_->
New<FieldConstnessDependency>(
map, owner, descriptor);
1301 bool read_only = cell.property_details().IsReadOnly();
1308 if ((
v8_flags.const_tracking_let ||
1309 v8_flags.script_context_mutable_heap_number) &&
1310 script_context.
object()->IsScriptContext() &&
1311 script_context.
object()->GetScriptContextSideProperty(index) ==
1314 script_context, index, property));
1322 if (!
v8_flags.empty_context_extension_dep)
return false;
1325 scope_info.
object()->SomeContextHasExtension()) {
1335 cell.CacheAsProtector(
broker_);
1349#ifdef V8_RUNTIME_CALL_STATS
1350 if (TracingFlags::is_runtime_stats_enabled())
return false;
1412 site.PointsToLiteral()
1414 : site.GetElementsKind();
1429 ObjectRef element) {
1431 zone_->
New<OwnConstantElementDependency>(holder, index, element));
1437 broker_, holder, map, index, value));
1443 broker_, holder, map, index, value));
1449 broker_, holder, index, value));
1456 PrintF(
"Compilation aborted due to invalid dependency: %s\n", d->ToString());
1463 PendingDependencies pending_deps(
zone_);
1472 if (
v8_flags.trace_compilation_dependencies) {
1478 dep->Install(
broker_, &pending_deps);
1496 if (
v8_flags.stress_gc_during_compilation) {
1503 dep->IsPretenureMode() || dep->IsConsistentJSFunctionView());
1518 if (
v8_flags.trace_compilation_dependencies) {
1532 std::vector<const CompilationDependency*> deps(
dependencies_.begin(),
1534 std::sort(deps.begin(), deps.end());
1536 for (
auto dep : deps) {
1538 if (
v8_flags.trace_compilation_dependencies) {
1550 const Name##Dependency* CompilationDependency::As##Name() const { \
1551 DCHECK(Is##Name()); \
1552 return static_cast<const Name##Dependency*>(this); \
1559 OptionalJSObjectRef last_prototype) {
1560 for (
MapRef receiver_map : receiver_maps) {
1567 OptionalJSObjectRef last_prototype) {
1572 OptionalJSFunctionRef constructor =
1575 receiver_map = constructor.value().initial_map(
broker_);
1579 MapRef map = receiver_map;
1582 if (!proto.IsJSObject()) {
1588 if (last_prototype.has_value() && proto.equals(*last_prototype))
break;
1596 if (!current.nested_site(
broker_).IsAllocationSite())
break;
1597 current = current.nested_site(
broker_).AsAllocationSite();
1608 if (map.construction_counter() == 0)
return;
1615 inobject_property_count_(
1617 initial_map.GetInObjectPropertiesStartInWords()) {}
1623 int instance_size = function.InitialMapInstanceSizeWithMinSlack(
broker_);
1628 function, instance_size));
1629 CHECK_LE(instance_size, function.initial_map(
broker_).instance_size());
1635 MapRef target_map)
const {
1637 return zone_->
New<TransitionDependency>(target_map);
1648 return zone_->
New<FieldRepresentationDependency>(
map, owner, descriptor,
1660bool CompilationDependencies::IsFieldRepresentationDependencyOnMap(
1662 return dep->IsFieldRepresentation() &&
1663 dep->AsFieldRepresentation()->DependsOn(receiver_map);
1667#undef DEPENDENCY_LIST
#define SLOW_DCHECK(condition)
static bool ShouldTrack(ElementsKind boilerplate_elements_kind)
static V8_INLINE bool InReadOnlySpace(Tagged< HeapObject > object)
V8_EXPORT_PRIVATE void PreciseCollectAllGarbage(GCFlags gc_flags, GarbageCollectionReason gc_reason, const GCCallbackFlags gc_callback_flags=kNoGCCallbackFlags)
bool is_profiling() const
v8::internal::Factory * factory()
bool CanHaveFastTransitionableElementsKind() const
static const int kProtectorValid
bool DependOnArrayIteratorProtector()
PropertyConstness DependOnFieldConstness(MapRef map, MapRef owner, InternalIndex descriptor)
bool DependOnTypedArrayLengthProtector()
CompilationDependency const * FieldConstnessDependencyOffTheRecord(MapRef map, MapRef owner, InternalIndex descriptor)
void DependOnOwnConstantDataProperty(JSObjectRef holder, MapRef map, FieldIndex index, ObjectRef value)
bool DependOnEmptyContextExtension(ScopeInfoRef scope_info)
CompilationDependency const * FieldRepresentationDependencyOffTheRecord(MapRef map, MapRef owner, InternalIndex descriptor, Representation representation) const
bool DependOnNoProfilingProtector()
void DependOnOwnConstantDictionaryProperty(JSObjectRef holder, InternalIndex index, ObjectRef value)
bool DependOnArraySpeciesProtector()
void DependOnConsistentJSFunctionView(JSFunctionRef function)
void DependOnOwnConstantDoubleProperty(JSObjectRef holder, MapRef map, FieldIndex index, Float64 value)
CompilationDependencySet dependencies_
void DependOnConstantInDictionaryPrototypeChain(MapRef receiver_map, NameRef property_name, ObjectRef constant, PropertyKind kind)
HeapObjectRef DependOnPrototypeProperty(JSFunctionRef function)
void DependOnElementsKind(AllocationSiteRef site)
void DependOnElementsKinds(AllocationSiteRef site)
bool DependOnPromiseThenProtector()
void DependOnNoSlackTrackingChange(MapRef map)
MapRef DependOnInitialMap(JSFunctionRef function)
bool DependOnStringWrapperToPrimitiveProtector()
SlackTrackingPrediction DependOnInitialMapInstanceSizePrediction(JSFunctionRef function)
CompilationDependency const * TransitionDependencyOffTheRecord(MapRef target_map) const
void DependOnGlobalProperty(PropertyCellRef cell)
bool DependOnNoUndetectableObjectsProtector()
V8_WARN_UNUSED_RESULT bool Commit(Handle< Code > code)
void DependOnOwnConstantElement(JSObjectRef holder, uint32_t index, ObjectRef element)
void DependOnObjectSlotValue(HeapObjectRef object, int offset, ObjectRef value)
JSHeapBroker *const broker_
bool DependOnMegaDOMProtector()
void DependOnStablePrototypeChain(MapRef receiver_maps, WhereToStart start, OptionalJSObjectRef last_prototype=OptionalJSObjectRef())
bool DependOnProtector(PropertyCellRef cell)
CompilationDependencies(JSHeapBroker *broker, Zone *zone)
void DependOnStablePrototypeChains(ZoneVector< MapRef > const &receiver_maps, WhereToStart start, OptionalJSObjectRef last_prototype=OptionalJSObjectRef())
void RecordDependency(CompilationDependency const *dependency)
void DependOnStableMap(MapRef map)
bool DependOnScriptContextSlotProperty(ContextRef script_context, size_t index, ContextSidePropertyCell::Property property, JSHeapBroker *broker)
bool DependOnNoElementsProtector()
bool DependOnPromiseSpeciesProtector()
bool DependOnPromiseHookProtector()
bool DependOnArrayBufferDetachingProtector()
CompilationDependency const * FieldTypeDependencyOffTheRecord(MapRef map, MapRef owner, InternalIndex descriptor, ObjectRef type) const
bool PrepareInstallPredictable()
AllocationType DependOnPretenureMode(AllocationSiteRef site)
CompilationDependency(CompilationDependencyKind kind)
virtual void PrepareInstall(JSHeapBroker *broker) const
virtual bool Equals(const CompilationDependency *that) const =0
const char * ToString() const
virtual bool IsValid(JSHeapBroker *broker) const =0
virtual size_t Hash() const =0
const CompilationDependencyKind kind
virtual void Install(JSHeapBroker *broker, PendingDependencies *deps) const =0
IndirectHandle< Context > object() const
V8_EXPORT_PRIVATE MapRef map(JSHeapBroker *broker) const
NativeContextRef target_native_context() const
void set_dependencies(CompilationDependencies *dependencies)
Isolate * isolate() const
bool is_deprecated() const
OddballType oddball_type(JSHeapBroker *broker) const
bool IsPrimitiveMap() const
bool CanBeDeprecated() const
OptionalJSFunctionRef GetConstructorFunction(JSHeapBroker *broker, MapRef map) const
IndirectHandle< ScopeInfo > object() const
bool SloppyEvalCanExtendVars() const
SlackTrackingPrediction(MapRef initial_map, int instance_size)
#define V8_ENABLE_SWISS_NAME_DICTIONARY_BOOL
#define V8_DICT_PROPERTY_CONST_TRACKING_BOOL
const JSFunctionRef function_
const InternalIndex descriptor_
const ScopeInfoRef scope_info_
base::TemplateHashMapImpl< Handle< HeapObject >, DependentCode::DependencyGroups, HandleValueEqual, ZoneAllocationPolicy > deps_
const ContextRef script_context_
const MapRef initial_map_
#define DEPENDENCY_LIST(V)
const MapRef receiver_map_
const NameRef property_name_
const PropertyCellRef cell_
JSObjectRef const holder_
ContextSidePropertyCell::Property property_
JSHeapBroker *const broker_
const ObjectRef constant_
const AllocationSiteRef site_
const AllocationType allocation_
const ObjectRef prototype_
const Representation representation_
#define TRACE_BROKER_MISSING(broker, x)
ZoneVector< RpoNumber > & result
ZoneVector< Entry > entries
V8_INLINE size_t hash_combine(size_t seed, size_t hash)
FloatWithBits< 64 > Float64
V8_INLINE void TraceInvalidCompilationDependency(compiler::JSHeapBroker *broker, const CompilationDependency *d)
ref_traits< T >::ref_type MakeRef(JSHeapBroker *broker, Tagged< T > object)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
void PrintF(const char *format,...)
PerThreadAssertScopeDebugOnly< true, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > AllowGarbageCollection
V8_INLINE PtrComprCageBase GetPtrComprCageBase()
constexpr int kTaggedSizeLog2
V8_EXPORT_PRIVATE FlagValues v8_flags
kInstanceDescriptorsOffset kTransitionsOrPrototypeInfoOffset prototype
#define CHECK_IMPLIES(lhs, rhs)
#define CHECK_LE(lhs, rhs)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
bool operator()(const CompilationDependency *lhs, const CompilationDependency *rhs) const
size_t operator()(const CompilationDependency *dep) const
#define V8_UNLIKELY(condition)
std::unique_ptr< ValueMirror > value