Move old-space allocation tracking into Heap::AllocateRaw.
authormstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 11 Nov 2013 17:46:08 +0000 (17:46 +0000)
committermstarzinger@chromium.org <mstarzinger@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 11 Nov 2013 17:46:08 +0000 (17:46 +0000)
R=yurys@chromium.org

Review URL: https://codereview.chromium.org/68663002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17625 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/heap-inl.h
src/heap.cc
src/mark-compact.cc
src/spaces-inl.h
src/spaces.h

index f24c582..168aa50 100644 (file)
@@ -259,6 +259,9 @@ MaybeObject* Heap::AllocateRaw(int size_in_bytes,
     result = map_space_->AllocateRaw(size_in_bytes);
   }
   if (result->IsFailure()) old_gen_exhausted_ = true;
+  if (profiler->is_tracking_allocations() && result->To(&object)) {
+    profiler->NewObjectEvent(object->address(), size_in_bytes);
+  }
   return result;
 }
 
index f11ad96..8eb8ae2 100644 (file)
@@ -4197,7 +4197,7 @@ MaybeObject* Heap::CreateCode(const CodeDesc& desc,
   if (force_lo_space) {
     maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE);
   } else {
-    maybe_result = code_space_->AllocateRaw(obj_size);
+    maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE);
   }
   if (!maybe_result->To<HeapObject>(&result)) return maybe_result;
 
@@ -4268,7 +4268,7 @@ MaybeObject* Heap::CopyCode(Code* code) {
   if (obj_size > code_space()->AreaSize()) {
     maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE);
   } else {
-    maybe_result = code_space_->AllocateRaw(obj_size);
+    maybe_result = AllocateRaw(obj_size, CODE_SPACE, CODE_SPACE);
   }
 
   Object* result;
@@ -4311,7 +4311,7 @@ MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
   if (new_obj_size > code_space()->AreaSize()) {
     maybe_result = lo_space_->AllocateRaw(new_obj_size, EXECUTABLE);
   } else {
-    maybe_result = code_space_->AllocateRaw(new_obj_size);
+    maybe_result = AllocateRaw(new_obj_size, CODE_SPACE, CODE_SPACE);
   }
 
   Object* result;
index 8ef7c3c..b82149e 100644 (file)
@@ -2939,9 +2939,7 @@ bool MarkCompactCollector::TryPromoteObject(HeapObject* object,
   ASSERT(target_space == heap()->old_pointer_space() ||
          target_space == heap()->old_data_space());
   Object* result;
-  MaybeObject* maybe_result = target_space->AllocateRaw(
-      object_size,
-      PagedSpace::MOVE_OBJECT);
+  MaybeObject* maybe_result = target_space->AllocateRaw(object_size);
   if (maybe_result->ToObject(&result)) {
     HeapObject* target = HeapObject::cast(result);
     MigrateObject(target->address(),
@@ -3014,7 +3012,7 @@ void MarkCompactCollector::EvacuateLiveObjectsFromPage(Page* p) {
 
       int size = object->Size();
 
-      MaybeObject* target = space->AllocateRaw(size, PagedSpace::MOVE_OBJECT);
+      MaybeObject* target = space->AllocateRaw(size);
       if (target->IsFailure()) {
         // OS refused to give us memory.
         V8::FatalProcessOutOfMemory("Evacuation");
index ffa47cf..87de29c 100644 (file)
@@ -274,18 +274,12 @@ HeapObject* PagedSpace::AllocateLinearly(int size_in_bytes) {
 
 
 // Raw allocation.
-MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes,
-                                     AllocationType event) {
-  HeapProfiler* profiler = heap()->isolate()->heap_profiler();
-
+MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes) {
   HeapObject* object = AllocateLinearly(size_in_bytes);
   if (object != NULL) {
     if (identity() == CODE_SPACE) {
       SkipList::Update(object->address(), size_in_bytes);
     }
-    if (event == NEW_OBJECT && profiler->is_tracking_allocations()) {
-      profiler->NewObjectEvent(object->address(), size_in_bytes);
-    }
     return object;
   }
 
@@ -298,9 +292,6 @@ MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes,
     if (identity() == CODE_SPACE) {
       SkipList::Update(object->address(), size_in_bytes);
     }
-    if (event == NEW_OBJECT && profiler->is_tracking_allocations()) {
-      profiler->NewObjectEvent(object->address(), size_in_bytes);
-    }
     return object;
   }
 
@@ -309,9 +300,6 @@ MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes,
     if (identity() == CODE_SPACE) {
       SkipList::Update(object->address(), size_in_bytes);
     }
-    if (event == NEW_OBJECT && profiler->is_tracking_allocations()) {
-      profiler->NewObjectEvent(object->address(), size_in_bytes);
-    }
     return object;
   }
 
index db0415b..06f444d 100644 (file)
@@ -1764,16 +1764,9 @@ class PagedSpace : public Space {
     return allocation_info_.limit_address();
   }
 
-  enum AllocationType {
-    NEW_OBJECT,
-    MOVE_OBJECT
-  };
-
   // Allocate the requested number of bytes in the space if possible, return a
   // failure object if not.
-  MUST_USE_RESULT inline MaybeObject* AllocateRaw(
-      int size_in_bytes,
-      AllocationType event = NEW_OBJECT);
+  MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes);
 
   virtual bool ReserveSpace(int bytes);