Reviewers: mvstanton,

Description:
Generalize AllocationMemento::FindForHeapObject and remove corresponding new
space check.

BUG=

Please review this at https://codereview.chromium.org/104903002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+13, -13 lines):
  M src/heap-inl.h
  M src/objects.h
  M src/objects.cc


Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index 525c634da626809c7c1bdfa3ce70b512e8eca621..d3c5b6fc022fa63fa31383a2d5c6078f0931bffa 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -485,8 +485,8 @@ 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);
+    AllocationMemento* memento = AllocationMemento::FindForHeapObject(
+        object, true);
     if (memento != NULL) {
       ASSERT(memento->IsValid());
       memento->GetAllocationSite()->IncrementMementoFoundCount();
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f96fd83849cff3090814484757f26b352932bc87..4fbb5915176ab96a926653874b3ab3e0d3327cbd 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9171,14 +9171,14 @@ Handle<String> SeqString::Truncate(Handle<SeqString> 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<Address>(object) - kHeapObjectTag) +
         object->Size();
     Address top;
@@ -12886,7 +12886,7 @@ MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
     return this;
   }

-  AllocationMemento* memento = AllocationMemento::FindForJSObject(this);
+  AllocationMemento* memento = AllocationMemento::FindForHeapObject(this);
   if (memento == NULL || !memento->IsValid()) {
     return this;
   }
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index bbdefc14a5942122092dd2f82345b4b4d73a2bb6..b4c00788ba2d7b97e95ed1814b127d29ae7d3849 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -8256,8 +8256,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:


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to