Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index c4cc40ca260aa7f65353cb06a16ccbde55c8bf13..8c4ecf2dfbbf7341cd4f596f68be008d0548864f 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -182,6 +182,7 @@ Heap::Heap() |
| memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); |
| native_contexts_list_ = NULL; |
| array_buffers_list_ = Smi::FromInt(0); |
| + allocation_sites_list_ = Smi::FromInt(0); |
| mark_compact_collector_.heap_ = this; |
| external_string_table_.heap_ = this; |
| // Put a dummy entry in the remembered pages so we can find the list the |
| @@ -1664,6 +1665,7 @@ void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { |
| mark_compact_collector()->is_compacting(); |
| ProcessArrayBuffers(retainer, record_slots); |
| ProcessNativeContexts(retainer, record_slots); |
| + ProcessAllocationSites(retainer, record_slots); |
| } |
| void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer, |
| @@ -1757,6 +1759,39 @@ void Heap::TearDownArrayBuffers() { |
| } |
| +template<> |
| +struct WeakListVisitor<AllocationSite> { |
| + static void SetWeakNext(AllocationSite* obj, Object* next) { |
| + obj->set_weak_next(next); |
| + } |
| + |
| + static Object* WeakNext(AllocationSite* obj) { |
| + return obj->weak_next(); |
| + } |
| + |
| + static void VisitLiveObject(Heap* heap, |
| + AllocationSite* array_buffer, |
| + WeakObjectRetainer* retainer, |
| + bool record_slots) {} |
| + |
| + static void VisitPhantomObject(Heap* heap, AllocationSite* phantom) {} |
| + |
| + static int WeakNextOffset() { |
| + return AllocationSite::kWeakNextOffset; |
| + } |
| +}; |
| + |
| + |
| +void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer, |
| + bool record_slots) { |
| + Object* allocation_site_obj = |
| + VisitWeakList<AllocationSite>(this, |
| + allocation_sites_list(), |
|
Michael Starzinger
2013/07/16 18:14:46
nit: Indentation is off.
mvstanton
2013/07/16 19:34:57
weird, how did that happen? Done.
|
| + retainer, record_slots); |
| + set_allocation_sites_list(allocation_site_obj); |
| +} |
| + |
| + |
| void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { |
| DisallowHeapAllocation no_allocation; |
| @@ -2887,7 +2922,12 @@ MaybeObject* Heap::AllocateAllocationSite() { |
| MaybeObject* maybe_result = Allocate(allocation_site_map(), |
| OLD_POINTER_SPACE); |
| if (!maybe_result->ToObject(&result)) return maybe_result; |
| - AllocationSite::cast(result)->Initialize(); |
| + AllocationSite* site = AllocationSite::cast(result); |
| + site->Initialize(); |
| + |
| + // Link the site |
| + site->set_weak_next(allocation_sites_list()); |
| + set_allocation_sites_list(site); |
| return result; |
| } |
| @@ -6889,6 +6929,7 @@ bool Heap::CreateHeapObjects() { |
| native_contexts_list_ = undefined_value(); |
| array_buffers_list_ = undefined_value(); |
| + allocation_sites_list_ = undefined_value(); |
| return true; |
| } |