Version 3.24.15

Introduce an API mirroring the gc extension.

Performance and stability improvements on all platforms.

git-svn-id: http://v8.googlecode.com/svn/trunk@18575 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/heap-inl.h b/src/heap-inl.h
index 5e6fb2b..f70b6f7 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -485,22 +485,32 @@
 
 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();
   }
 }
 
@@ -532,10 +542,13 @@
 }
 
 
-bool Heap::CollectGarbage(AllocationSpace space, const char* gc_reason) {
+bool Heap::CollectGarbage(AllocationSpace space,
+                          const char* gc_reason,
+                          const v8::GCCallbackFlags callbackFlags) {
   const char* collector_reason = NULL;
   GarbageCollector collector = SelectGarbageCollector(space, &collector_reason);
-  return CollectGarbage(space, collector, gc_reason, collector_reason);
+  return CollectGarbage(
+      space, collector, gc_reason, collector_reason, callbackFlags);
 }