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

Unified Diff: src/profiler/sampling-heap-profiler.h

Issue 1714493003: Reland of Sampling heap profiler data structure changes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | src/profiler/sampling-heap-profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profiler/sampling-heap-profiler.h
diff --git a/src/profiler/sampling-heap-profiler.h b/src/profiler/sampling-heap-profiler.h
index 1f98bec849f80f7f068c8e903d6b6b8e190f79e2..9aee282c8aff3da185df0aaea3b732989ab92cdf 100644
--- a/src/profiler/sampling-heap-profiler.h
+++ b/src/profiler/sampling-heap-profiler.h
@@ -48,50 +48,50 @@
StringsStorage* names() const { return names_; }
- class FunctionInfo {
+ class AllocationNode;
+
+ struct Sample {
public:
- FunctionInfo(SharedFunctionInfo* shared, StringsStorage* names);
- explicit FunctionInfo(const char* name)
- : name_(name),
- script_name_(""),
- script_id_(v8::UnboundScript::kNoScriptId),
- start_position_(0) {}
-
- const char* get_name() const { return name_; }
- const char* get_script_name() const { return script_name_; }
- int get_script_id() const { return script_id_; }
- int get_start_position() const { return start_position_; }
+ Sample(size_t size_, AllocationNode* owner_, Local<Value> local_,
+ SamplingHeapProfiler* profiler_)
+ : size(size_),
+ owner(owner_),
+ global(Global<Value>(
+ reinterpret_cast<v8::Isolate*>(profiler_->isolate_), local_)),
+ profiler(profiler_) {}
+ ~Sample() { global.Reset(); }
+ const size_t size;
+ AllocationNode* const owner;
+ Global<Value> global;
+ SamplingHeapProfiler* const profiler;
private:
- const char* const name_;
- const char* script_name_;
- int script_id_;
- const int start_position_;
+ DISALLOW_COPY_AND_ASSIGN(Sample);
};
- class SampledAllocation {
+ class AllocationNode {
public:
- SampledAllocation(SamplingHeapProfiler* sampling_heap_profiler,
- Isolate* isolate, Local<Value> local, size_t size,
- int max_frames);
- ~SampledAllocation() {
- for (auto info : stack_) {
- delete info;
+ AllocationNode(const char* const name, int script_id,
+ const int start_position)
+ : script_id_(script_id),
+ script_position_(start_position),
+ name_(name) {}
+ ~AllocationNode() {
+ for (auto child : children_) {
+ delete child;
}
- global_.Reset(); // drop the reference.
}
- size_t get_size() const { return size_; }
- const std::vector<FunctionInfo*>& get_stack() const { return stack_; }
private:
- static void OnWeakCallback(const WeakCallbackInfo<SampledAllocation>& data);
+ std::map<size_t, unsigned int> allocations_;
+ std::vector<AllocationNode*> children_;
+ const int script_id_;
+ const int script_position_;
+ const char* const name_;
- SamplingHeapProfiler* const sampling_heap_profiler_;
- Global<Value> global_;
- std::vector<FunctionInfo*> stack_;
- const size_t size_;
+ friend class SamplingHeapProfiler;
- DISALLOW_COPY_AND_ASSIGN(SampledAllocation);
+ DISALLOW_COPY_AND_ASSIGN(AllocationNode);
};
private:
@@ -99,23 +99,29 @@
void SampleObject(Address soon_object, size_t size);
+ static void OnWeakCallback(const WeakCallbackInfo<Sample>& data);
+
// Methods that construct v8::AllocationProfile.
- v8::AllocationProfile::Node* AddStack(
- AllocationProfile* profile, const std::map<int, Script*>& scripts,
- const std::vector<FunctionInfo*>& stack);
- v8::AllocationProfile::Node* FindOrAddChildNode(
- AllocationProfile* profile, const std::map<int, Script*>& scripts,
- v8::AllocationProfile::Node* parent, FunctionInfo* function_info);
- v8::AllocationProfile::Node* AllocateNode(
- AllocationProfile* profile, const std::map<int, Script*>& scripts,
- FunctionInfo* function_info);
+
+ // Translates the provided AllocationNode *node* returning an equivalent
+ // AllocationProfile::Node. The newly created AllocationProfile::Node is added
+ // to the provided AllocationProfile *profile*. Line numbers, column numbers,
+ // and script names are resolved using *scripts* which maps all currently
+ // loaded scripts keyed by their script id.
+ v8::AllocationProfile::Node* TranslateAllocationNode(
+ AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node,
+ const std::map<int, Script*>& scripts);
+ AllocationNode* AddStack();
+ AllocationNode* FindOrAddChildNode(AllocationNode* parent, const char* name,
+ int script_id, int start_position);
Isolate* const isolate_;
Heap* const heap_;
base::SmartPointer<SamplingAllocationObserver> new_space_observer_;
base::SmartPointer<SamplingAllocationObserver> other_spaces_observer_;
StringsStorage* const names_;
- std::set<SampledAllocation*> samples_;
+ AllocationNode profile_root_;
+ std::set<Sample*> samples_;
const int stack_depth_;
friend class SamplingAllocationObserver;
« no previous file with comments | « no previous file | src/profiler/sampling-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698