From a6795ea92e3697eea819622d31ab71b36511df81 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Mon, 11 Nov 2013 17:46:08 +0000 Subject: [PATCH] Move old-space allocation tracking into Heap::AllocateRaw. 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 | 3 +++ src/heap.cc | 6 +++--- src/mark-compact.cc | 6 ++---- src/spaces-inl.h | 14 +------------- src/spaces.h | 9 +-------- 5 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/heap-inl.h b/src/heap-inl.h index f24c58283..168aa50b3 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -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; } diff --git a/src/heap.cc b/src/heap.cc index f11ad9671..8eb8ae24b 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -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(&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 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; diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 8ef7c3c99..b82149e3a 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -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"); diff --git a/src/spaces-inl.h b/src/spaces-inl.h index ffa47cf60..87de29c4a 100644 --- a/src/spaces-inl.h +++ b/src/spaces-inl.h @@ -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; } diff --git a/src/spaces.h b/src/spaces.h index db0415b7b..06f444d15 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -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); -- 2.34.1