Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Unified Diff: src/heap-inl.h

Issue 234703003: Unify mechanism to find trailing AllocationMementos (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.h ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index ea7dcda3b0acd8aee62f2507a5ab5852bd7196d1..ae10b3a121a30d4f064eea7091e4b2f384309290 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -490,33 +490,51 @@ void Heap::ScavengePointer(HeapObject** p) {
}
-void Heap::UpdateAllocationSiteFeedback(HeapObject* object,
- ScratchpadSlotMode mode) {
- Heap* heap = object->GetHeap();
- ASSERT(heap->InFromSpace(object));
-
- if (!FLAG_allocation_site_pretenuring ||
- !AllocationSite::CanTrack(object->map()->instance_type())) return;
-
+AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
// Check if there is potentially a memento behind the object. If
// the last word of the momento is on another page we return
- // immediatelly. Note that we do not have to compare with the current
- // top pointer of the from space page, since we always install filler
- // objects above the top pointer of a from space page when performing
- // a garbage collection.
+ // immediately.
Address object_address = object->address();
Address memento_address = object_address + object->Size();
Address last_memento_word_address = memento_address + kPointerSize;
if (!NewSpacePage::OnSamePage(object_address,
last_memento_word_address)) {
- return;
+ return NULL;
}
HeapObject* candidate = HeapObject::FromAddress(memento_address);
- if (candidate->map() != heap->allocation_memento_map()) return;
+ if (candidate->map() != allocation_memento_map()) return NULL;
+
+ // Either the object is the last object in the new space, or there is another
+ // object of at least word size (the header map word) following it, so
+ // suffices to compare ptr and top here. Note that technically we do not have
+ // to compare with the current top pointer of the from space page during GC,
+ // since we always install filler objects above the top pointer of a from
+ // space page when performing a garbage collection. However, always performing
+ // the test makes it possible to have a single, unified version of
+ // FindAllocationMemento that is used both by the GC and the mutator.
+ Address top = NewSpaceTop();
+ ASSERT(memento_address == top ||
+ memento_address + HeapObject::kHeaderSize <= top ||
+ !NewSpacePage::OnSamePage(memento_address, top));
+ if (memento_address == top) return NULL;
AllocationMemento* memento = AllocationMemento::cast(candidate);
- if (!memento->IsValid()) return;
+ if (!memento->IsValid()) return NULL;
+ return memento;
+}
+
+
+void Heap::UpdateAllocationSiteFeedback(HeapObject* object,
+ ScratchpadSlotMode mode) {
+ Heap* heap = object->GetHeap();
+ ASSERT(heap->InFromSpace(object));
+
+ if (!FLAG_allocation_site_pretenuring ||
+ !AllocationSite::CanTrack(object->map()->instance_type())) return;
+
+ AllocationMemento* memento = heap->FindAllocationMemento(object);
+ if (memento == NULL) return;
if (memento->GetAllocationSite()->IncrementMementoFoundCount()) {
heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite(), mode);
« no previous file with comments | « src/heap.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698