From 9c8d6254222ffb2df49187756d3d18a4ceb7275e Mon Sep 17 00:00:00 2001 From: "hpayer@chromium.org" Date: Wed, 18 Dec 2013 20:08:54 +0000 Subject: [PATCH] Generalize AllocationMemento::FindForHeapObject and remove corresponding new space check. BUG= R=mvstanton@chromium.org Review URL: https://codereview.chromium.org/104903002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18366 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap-inl.h | 7 ++++--- src/objects.cc | 20 +++++++++++--------- src/objects.h | 4 ++-- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index 11783b3..3094016 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -484,9 +484,10 @@ void Heap::ScavengePointer(HeapObject** p) { void Heap::UpdateAllocationSiteFeedback(HeapObject* object) { - if (FLAG_allocation_site_pretenuring && object->IsJSObject()) { - AllocationMemento* memento = AllocationMemento::FindForJSObject( - JSObject::cast(object), true); + if (FLAG_allocation_site_pretenuring && + AllocationSite::CanTrack(object->map()->instance_type())) { + AllocationMemento* memento = AllocationMemento::FindForHeapObject( + object, true); if (memento != NULL) { ASSERT(memento->IsValid()); memento->GetAllocationSite()->IncrementMementoFoundCount(); diff --git a/src/objects.cc b/src/objects.cc index bfe1f55..aa7f500 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -9184,14 +9184,14 @@ Handle SeqString::Truncate(Handle string, int new_length) { } -AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object, - bool in_GC) { - // Currently, AllocationMemento objects are only allocated immediately - // after JSArrays and some JSObjects in NewSpace. Detecting whether a - // memento is present involves carefully checking the object immediately - // after the current object (if there is one) to see if it's an - // AllocationMemento. - if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { +AllocationMemento* AllocationMemento::FindForHeapObject(HeapObject* object, + bool in_GC) { + // AllocationMemento objects are only allocated immediately after objects in + // NewSpace. Detecting whether a memento is present involves carefully + // checking the object immediately after the current object (if there is one) + // to see if it's an AllocationMemento. + ASSERT(object->GetHeap()->InNewSpace(object)); + if (FLAG_track_allocation_sites) { Address ptr_end = (reinterpret_cast
(object) - kHeapObjectTag) + object->Size(); Address top; @@ -12899,7 +12899,9 @@ MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { return this; } - AllocationMemento* memento = AllocationMemento::FindForJSObject(this); + if (!GetHeap()->InNewSpace(this)) return this; + + AllocationMemento* memento = AllocationMemento::FindForHeapObject(this); if (memento == NULL || !memento->IsValid()) { return this; } diff --git a/src/objects.h b/src/objects.h index 28de179..52d15af 100644 --- a/src/objects.h +++ b/src/objects.h @@ -8259,8 +8259,8 @@ class AllocationMemento: public Struct { DECLARE_VERIFIER(AllocationMemento) // Returns NULL if no AllocationMemento is available for object. - static AllocationMemento* FindForJSObject(JSObject* object, - bool in_GC = false); + static AllocationMemento* FindForHeapObject(HeapObject* object, + bool in_GC = false); static inline AllocationMemento* cast(Object* obj); private: -- 2.7.4