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

Unified Diff: src/heap/heap.h

Issue 1618693004: Revert "Revert of [profiler] Implement POC Sampling Heap Profiler (patchset #12 id:220001 of https:… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add flag to suppress randomness from sampling heap profiler tests 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
« no previous file with comments | « src/flag-definitions.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 4c2aace8e2ebe0552b2dacc8bcac4d1b0ba8fd20..3c17dc7d9fbfca808679178857ca57e3e1fa96f4 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -478,6 +478,7 @@ class GCTracer;
class HeapObjectsFilter;
class HeapStats;
class HistogramTimer;
+class InlineAllocationObserver;
class Isolate;
class MemoryReducer;
class ObjectStats;
@@ -2792,6 +2793,60 @@ class PathTracer : public ObjectVisitor {
DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
};
#endif // DEBUG
+
+// -----------------------------------------------------------------------------
+// Allows observation of inline allocation in the new space.
+class InlineAllocationObserver {
+ public:
+ explicit InlineAllocationObserver(intptr_t step_size)
+ : step_size_(step_size), bytes_to_next_step_(step_size) {
+ DCHECK(step_size >= kPointerSize);
+ }
+ virtual ~InlineAllocationObserver() {}
+
+ // Called each time the new space does an inline allocation step. This may be
+ // more frequently than the step_size we are monitoring (e.g. when there are
+ // multiple observers, or when page or space boundary is encountered.)
+ void InlineAllocationStep(int bytes_allocated, Address soon_object,
+ size_t size) {
+ bytes_to_next_step_ -= bytes_allocated;
+ if (bytes_to_next_step_ <= 0) {
+ Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object,
+ size);
+ step_size_ = GetNextStepSize();
+ bytes_to_next_step_ = step_size_;
+ }
+ }
+
+ protected:
+ intptr_t step_size() const { return step_size_; }
+ intptr_t bytes_to_next_step() const { return bytes_to_next_step_; }
+
+ // Pure virtual method provided by the subclasses that gets called when at
+ // least step_size bytes have been allocated. soon_object is the address just
+ // allocated (but not yet initialized.) size is the size of the object as
+ // requested (i.e. w/o the alignment fillers). Some complexities to be aware
+ // of:
+ // 1) soon_object will be nullptr in cases where we end up observing an
+ // allocation that happens to be a filler space (e.g. page boundaries.)
+ // 2) size is the requested size at the time of allocation. Right-trimming
+ // may change the object size dynamically.
+ // 3) soon_object may actually be the first object in an allocation-folding
+ // group. In such a case size is the size of the group rather than the
+ // first object.
+ virtual void Step(int bytes_allocated, Address soon_object, size_t size) = 0;
+
+ // Subclasses can override this method to make step size dynamic.
+ virtual intptr_t GetNextStepSize() { return step_size_; }
+
+ intptr_t step_size_;
+ intptr_t bytes_to_next_step_;
+
+ private:
+ friend class NewSpace;
+ DISALLOW_COPY_AND_ASSIGN(InlineAllocationObserver);
+};
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/flag-definitions.h ('k') | src/heap/incremental-marking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698