diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 1a6ae007ba..0e1c941fd2 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -474,14 +474,22 @@ HValue* CodeStubGraphBuilder::BuildCodeStub() { HObjectAccess::ForAllocationSiteTransitionInfo(), initial_elements_kind); + // Store an empty fixed array for the code dependency. + HConstant* empty_fixed_array = + Add(isolate()->factory()->empty_fixed_array()); + HStoreNamedField* store = Add( + object, + HObjectAccess::ForAllocationSiteDependentCode(), + empty_fixed_array); + // Link the object to the allocation site list HValue* site_list = Add( ExternalReference::allocation_sites_list_address(isolate())); HValue* site = Add(site_list, HObjectAccess::ForAllocationSiteList()); - HStoreNamedField* store = - Add(object, HObjectAccess::ForAllocationSiteWeakNext(), - site); + store = Add(object, + HObjectAccess::ForAllocationSiteWeakNext(), + site); store->SkipWriteBarrier(); Add(site_list, HObjectAccess::ForAllocationSiteList(), object); diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc index 2d31ca49d1..57991322a6 100644 --- a/src/heap-snapshot-generator.cc +++ b/src/heap-snapshot-generator.cc @@ -1301,6 +1301,8 @@ void V8HeapExplorer::ExtractAllocationSiteReferences(int entry, AllocationSite* site) { SetInternalReference(site, entry, "transition_info", site->transition_info(), AllocationSite::kTransitionInfoOffset); + SetInternalReference(site, entry, "dependent_code", site->dependent_code(), + AllocationSite::kDependentCodeOffset); } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 5bb7f484b5..75b18f4ba6 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -351,6 +351,7 @@ class UniqueValueId V8_FINAL { IMMOVABLE_UNIQUE_VALUE_ID(false_value) IMMOVABLE_UNIQUE_VALUE_ID(the_hole_value) IMMOVABLE_UNIQUE_VALUE_ID(empty_string) + IMMOVABLE_UNIQUE_VALUE_ID(empty_fixed_array) #undef IMMOVABLE_UNIQUE_VALUE_ID @@ -3366,7 +3367,8 @@ class HConstant V8_FINAL : public HTemplateInstruction<0> { unique_id_ == UniqueValueId::true_value(heap) || unique_id_ == UniqueValueId::false_value(heap) || unique_id_ == UniqueValueId::the_hole_value(heap) || - unique_id_ == UniqueValueId::empty_string(heap); + unique_id_ == UniqueValueId::empty_string(heap) || + unique_id_ == UniqueValueId::empty_fixed_array(heap); } bool IsCell() const { @@ -5671,6 +5673,10 @@ class HObjectAccess V8_FINAL { return HObjectAccess(kInobject, AllocationSite::kTransitionInfoOffset); } + static HObjectAccess ForAllocationSiteDependentCode() { + return HObjectAccess(kInobject, AllocationSite::kDependentCodeOffset); + } + static HObjectAccess ForAllocationSiteWeakNext() { return HObjectAccess(kInobject, AllocationSite::kWeakNextOffset); } diff --git a/src/objects-inl.h b/src/objects-inl.h index 56fde30433..4ee437214b 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1323,6 +1323,13 @@ bool JSObject::ShouldTrackAllocationInfo() { } +void AllocationSite::Initialize() { + SetElementsKind(GetInitialFastElementsKind()); + set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), + SKIP_WRITE_BARRIER); +} + + // Heuristic: We only need to create allocation site info if the boilerplate // elements kind is the initial elements kind. AllocationSiteMode AllocationSite::GetMode( @@ -4480,6 +4487,8 @@ ACCESSORS(SignatureInfo, args, Object, kArgsOffset) ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) +ACCESSORS(AllocationSite, dependent_code, DependentCode, + kDependentCodeOffset) ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) diff --git a/src/objects-printer.cc b/src/objects-printer.cc index 0b8fdfda03..26a709848e 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -1100,9 +1100,10 @@ void AllocationSite::AllocationSitePrint(FILE* out) { HeapObject::PrintHeader(out, "AllocationSite"); PrintF(out, " - weak_next: "); weak_next()->ShortPrint(out); - PrintF(out, "\n"); + PrintF(out, "\n - dependent code: "); + dependent_code()->ShortPrint(out); - PrintF(out, " - transition_info: "); + PrintF(out, "\n - transition_info: "); if (transition_info()->IsCell()) { Cell* cell = Cell::cast(transition_info()); Object* cell_contents = cell->value(); diff --git a/src/objects.h b/src/objects.h index 41a513c36b..25a6f76d50 100644 --- a/src/objects.h +++ b/src/objects.h @@ -7837,11 +7837,10 @@ class AllocationSite: public Struct { static const uint32_t kMaximumArrayBytesToPretransition = 8 * 1024; DECL_ACCESSORS(transition_info, Object) + DECL_ACCESSORS(dependent_code, DependentCode) DECL_ACCESSORS(weak_next, Object) - void Initialize() { - SetElementsKind(GetInitialFastElementsKind()); - } + inline void Initialize(); ElementsKind GetElementsKind() { ASSERT(!IsLiteralSite()); @@ -7869,11 +7868,12 @@ class AllocationSite: public Struct { static inline bool CanTrack(InstanceType type); static const int kTransitionInfoOffset = HeapObject::kHeaderSize; - static const int kWeakNextOffset = kTransitionInfoOffset + kPointerSize; + static const int kDependentCodeOffset = kTransitionInfoOffset + kPointerSize; + static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize; static const int kSize = kWeakNextOffset + kPointerSize; typedef FixedBodyDescriptor BodyDescriptor; private: