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

Unified Diff: src/heap-inl.h

Issue 136633002: Inline AllocationMemento::FindForHeapObject() into the two call sites. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 | « no previous file | src/objects.h » ('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 cc653893308d8726c19b5bbbd13c6d1170d51ca5..f70b6f701b0f1e184ae77f357508214d3f1f9994 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -485,22 +485,32 @@ void Heap::ScavengePointer(HeapObject** p) {
void Heap::UpdateAllocationSiteFeedback(HeapObject* object) {
Heap* heap = object->GetHeap();
- if (FLAG_allocation_site_pretenuring &&
- heap->new_space_high_promotion_mode_active_ &&
- AllocationSite::CanTrack(object->map()->instance_type())) {
- AllocationMemento* memento = AllocationMemento::FindForHeapObject(
- object, heap, true);
- if (memento != NULL) {
- ASSERT(memento->IsValid());
- bool add_to_scratchpad =
- memento->GetAllocationSite()->IncrementMementoFoundCount();
- if (add_to_scratchpad && heap->allocation_sites_scratchpad_length <
- kAllocationSiteScratchpadSize) {
- heap->allocation_sites_scratchpad[
- heap->allocation_sites_scratchpad_length++] =
- memento->GetAllocationSite();
- }
- }
+ ASSERT(heap->InNewSpace(object));
+
+ if (!FLAG_allocation_site_pretenuring ||
+ !heap->new_space_high_promotion_mode_active_ ||
+ !AllocationSite::CanTrack(object->map()->instance_type())) return;
+
+ // Either object is the last object in the from 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.
+ Address ptr = object->address() + object->Size();
+ Address top = heap->new_space()->FromSpacePageHigh();
+ ASSERT(ptr == top || ptr + HeapObject::kHeaderSize <= top);
+ if (ptr == top) return;
+
+ HeapObject* candidate = HeapObject::FromAddress(ptr);
+ if (candidate->map() != heap->allocation_memento_map()) return;
+
+ AllocationMemento* memento = AllocationMemento::cast(candidate);
+ if (!memento->IsValid()) return;
+
+ if (memento->GetAllocationSite()->IncrementMementoFoundCount() &&
+ heap->allocation_sites_scratchpad_length <
+ kAllocationSiteScratchpadSize) {
+ heap->allocation_sites_scratchpad[
+ heap->allocation_sites_scratchpad_length++] =
+ memento->GetAllocationSite();
}
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698