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

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: 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 6f470e1f71d1c40dd24ebaef62753971fbdcade3..932222fa8cb7db80c1842ccd2ee67f6b08954aec 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -19,8 +19,8 @@
namespace v8 {
namespace internal {
+class AllocationObserver;
class CompactionSpaceCollection;
-class InlineAllocationObserver;
class Isolate;
// -----------------------------------------------------------------------------
@@ -2043,6 +2043,16 @@ class PagedSpace : public Space {
MUST_USE_RESULT inline AllocationResult AllocateRaw(
int size_in_bytes, AllocationAlignment alignment);
+ void AddAllocationObserver(AllocationObserver* observer) {
+ allocation_observers_.Add(observer);
+ }
+
+ void RemoveAllocationObserver(AllocationObserver* observer) {
+ bool removed = allocation_observers_.RemoveElement(observer);
+ static_cast<void>(removed);
+ DCHECK(removed);
+ }
+
ofrobots 2016/01/23 16:16:31 Suggestion: These seem almost like a copy of the A
mattloring 2016/01/26 00:42:48 Done.
// Give a block of memory to the space's free list. It might be added to
// the free list or accounted as waste.
// If add_to_freelist is false then just accounting stats are updated and
@@ -2197,6 +2207,9 @@ class PagedSpace : public Space {
// The space's free list.
FreeList free_list_;
+ // Allocation observers
+ List<AllocationObserver*> allocation_observers_;
+
// Normal allocation information.
AllocationInfo allocation_info_;
@@ -2756,10 +2769,10 @@ class NewSpace : public Space {
// 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 AddInlineAllocationObserver(AllocationObserver* observer);
// Removes a previously installed observer.
- void RemoveInlineAllocationObserver(InlineAllocationObserver* observer);
+ void RemoveInlineAllocationObserver(AllocationObserver* observer);
void DisableInlineAllocationSteps() {
top_on_previous_step_ = 0;
@@ -2866,7 +2879,7 @@ class NewSpace : public Space {
// 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_;
+ List<AllocationObserver*> inline_allocation_observers_;
Address top_on_previous_step_;
bool inline_allocation_observers_paused_;
@@ -3060,6 +3073,16 @@ class LargeObjectSpace : public Space {
MUST_USE_RESULT AllocationResult
AllocateRaw(int object_size, Executability executable);
+ void AddAllocationObserver(AllocationObserver* observer) {
+ allocation_observers_.Add(observer);
+ }
+
+ void RemoveAllocationObserver(AllocationObserver* observer) {
+ bool removed = allocation_observers_.RemoveElement(observer);
+ static_cast<void>(removed);
+ DCHECK(removed);
+ }
+
// Available bytes for objects in this space.
inline intptr_t Available() override;
@@ -3117,6 +3140,9 @@ class LargeObjectSpace : public Space {
// Map MemoryChunk::kAlignment-aligned chunks to large pages covering them
HashMap chunk_map_;
+ // Allocation observers
+ List<AllocationObserver*> allocation_observers_;
+
friend class LargeObjectIterator;
};

Powered by Google App Engine
This is Rietveld 408576698