Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Unified Diff: src/heap/spaces.h

Issue 1625753002: Allocation sampling for paged/lo spaces (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: "Rebase" Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index b7aad77a8ec57de202d9f55e57748b9f85a3740d..4342be241bd63094409516b6a42c55c862c27955 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -20,10 +20,10 @@ namespace v8 {
namespace internal {
class AllocationInfo;
+class AllocationObserver;
class CompactionSpace;
class CompactionSpaceCollection;
class FreeList;
-class InlineAllocationObserver;
class Isolate;
class MemoryAllocator;
class MemoryChunk;
@@ -947,7 +947,8 @@ class LargePage : public MemoryChunk {
class Space : public Malloced {
public:
Space(Heap* heap, AllocationSpace id, Executability executable)
- : heap_(heap),
+ : allocation_observers_paused_(false),
+ heap_(heap),
id_(id),
executable_(executable),
committed_(0),
@@ -963,6 +964,26 @@ class Space : public Malloced {
// Identity used in error reporting.
AllocationSpace identity() { return id_; }
+ virtual void AddAllocationObserver(AllocationObserver* observer) {
+ allocation_observers_->Add(observer);
+ }
+
+ virtual void RemoveAllocationObserver(AllocationObserver* observer) {
+ bool removed = allocation_observers_->RemoveElement(observer);
+ static_cast<void>(removed);
Hannes Payer (out of office) 2016/02/08 10:13:48 USE(removed);
mattloring 2016/02/09 20:20:05 Done.
+ DCHECK(removed);
+ }
+
+ virtual void PauseAllocationObservers() {
+ allocation_observers_paused_ = true;
+ }
+
+ virtual void ResumeAllocationObservers() {
+ allocation_observers_paused_ = false;
+ }
+
+ void AllocationStep(Address soon_object, int size);
+
// Return the total amount committed memory for this space, i.e., allocatable
// memory and page headers.
virtual intptr_t CommittedMemory() { return committed_; }
@@ -1009,6 +1030,15 @@ class Space : public Malloced {
DCHECK_GE(committed_, 0);
}
+ // When inline allocation stepping is active, either because of incremental
+ // marking or because of idle scavenge, we 'interrupt' inline allocation every
Hannes Payer (out of office) 2016/02/08 10:13:48 This list is not complete: allocation statistics g
mattloring 2016/02/09 20:20:05 Done.
+ // once in a while. This is done by setting allocation_info_.limit to be lower
+ // than the actual limit and and increasing it in steps to guarantee that the
+ // observers are notified periodically.
+ List<AllocationObserver*>* allocation_observers_ =
Hannes Payer (out of office) 2016/02/08 10:13:48 allocate the allocation_observers in the construct
mattloring 2016/02/09 20:20:05 What is the best strategy for deallocating a list
ofrobots 2016/02/10 08:15:38 Does allocation_observers_ need to be dynamically
mattloring 2016/02/10 13:19:23 If I do not dynamically allocate it, it causes the
Hannes Payer (out of office) 2016/02/11 11:50:08 I am not sure if I understand your question. When
mattloring 2016/02/11 14:54:14 Sorry for the confusion. This should be handled no
+ new List<AllocationObserver*>();
+ bool allocation_observers_paused_;
+
private:
Heap* heap_;
AllocationSpace id_;
@@ -2557,8 +2587,7 @@ class NewSpace : public Space {
to_space_(heap, kToSpace),
from_space_(heap, kFromSpace),
reservation_(),
- top_on_previous_step_(0),
- inline_allocation_observers_paused_(false) {}
+ top_on_previous_step_(0) {}
// Sets up the new space using the given chunk.
bool SetUp(int reserved_semispace_size_, int max_semi_space_size);
@@ -2730,19 +2759,18 @@ class NewSpace : public Space {
void UpdateInlineAllocationLimit(int size_in_bytes);
+ void DisableInlineAllocationSteps() {
+ top_on_previous_step_ = 0;
+ UpdateInlineAllocationLimit(0);
+ }
+
// Allows observation of inline allocation. The observer->Step() method gets
// called after every step_size bytes have been allocated (approximately).
// This works by adjusting the allocation limit to a lower value and adjusting
// it after each step.
- void AddInlineAllocationObserver(InlineAllocationObserver* observer);
+ void AddAllocationObserver(AllocationObserver* observer) override;
- // Removes a previously installed observer.
- void RemoveInlineAllocationObserver(InlineAllocationObserver* observer);
-
- void DisableInlineAllocationSteps() {
- top_on_previous_step_ = 0;
- UpdateInlineAllocationLimit(0);
- }
+ void RemoveAllocationObserver(AllocationObserver* observer) override;
// Get the extent of the inactive semispace (for use as a marking stack,
// or to zap it). Notice: space-addresses are not necessarily on the
@@ -2814,6 +2842,9 @@ class NewSpace : public Space {
SemiSpace* active_space() { return &to_space_; }
+ void PauseAllocationObservers() override;
+ void ResumeAllocationObservers() override;
+
private:
// Update allocation info to match the current to-space page.
void UpdateAllocationInfo();
@@ -2839,14 +2870,7 @@ class NewSpace : public Space {
// mark-compact collection.
AllocationInfo allocation_info_;
- // When inline allocation stepping is active, either because of incremental
- // marking or because of idle scavenge, we 'interrupt' inline allocation every
- // once in a while. This is done by setting allocation_info_.limit to be lower
- // than the actual limit and and increasing it in steps to guarantee that the
- // observers are notified periodically.
- List<InlineAllocationObserver*> inline_allocation_observers_;
Address top_on_previous_step_;
- bool inline_allocation_observers_paused_;
HistogramInfo* allocated_histogram_;
HistogramInfo* promoted_histogram_;
@@ -2863,26 +2887,18 @@ class NewSpace : public Space {
size_t size);
intptr_t GetNextInlineAllocationStepSize();
void StartNextInlineAllocationStep();
- void PauseInlineAllocationObservers();
- void ResumeInlineAllocationObservers();
- friend class PauseInlineAllocationObserversScope;
friend class SemiSpaceIterator;
};
-class PauseInlineAllocationObserversScope {
+class PauseAllocationObserversScope {
public:
- explicit PauseInlineAllocationObserversScope(NewSpace* new_space)
- : new_space_(new_space) {
- new_space_->PauseInlineAllocationObservers();
- }
- ~PauseInlineAllocationObserversScope() {
- new_space_->ResumeInlineAllocationObservers();
- }
+ explicit PauseAllocationObserversScope(Heap* heap);
+ ~PauseAllocationObserversScope();
private:
- NewSpace* new_space_;
- DISALLOW_COPY_AND_ASSIGN(PauseInlineAllocationObserversScope);
+ Heap* heap_;
+ DISALLOW_COPY_AND_ASSIGN(PauseAllocationObserversScope);
};
// -----------------------------------------------------------------------------
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/spaces.cc » ('j') | src/heap/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698