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

Side by Side Diff: src/allocation-tracker.h

Issue 27227005: Record allocation stack traces (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/allocation-tracker.cc » ('j') | src/allocation-tracker.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_ALLOCATION_TRACKER_H_
29 #define V8_ALLOCATION_TRACKER_H_
30
31 namespace v8 {
32 namespace internal {
33
34 class HeapObjectsMap;
35 class HeapObjectsMap;
loislo 2013/10/16 15:14:08 duplicate
yurys 2013/10/17 15:27:35 Done.
36
37 class AllocationTraceTree;
38
39 class AllocationTraceNode {
40 public:
41 AllocationTraceNode(AllocationTraceTree* tree,
42 SnapshotObjectId shared_function_info_id);
43 ~AllocationTraceNode();
44 AllocationTraceNode* FindChild(SnapshotObjectId shared_function_info_id);
45 AllocationTraceNode* FindOrAddChild(SnapshotObjectId shared_function_info_id);
46 void AddAllocation(unsigned size);
47
48 SnapshotObjectId function_id() const { return function_id_; }
49 unsigned allocation_size() const { return total_size_; }
50 unsigned allocation_count() const { return allocation_count_; }
51 unsigned id() const { return id_; }
52 Vector<AllocationTraceNode*> children() const { return children_.ToVector(); }
53
54 void Print(int indent);
55
56 private:
57 AllocationTraceTree* tree_;
58 SnapshotObjectId function_id_;
59 unsigned total_size_;
60 unsigned allocation_count_;
61 unsigned id_;
62 List<AllocationTraceNode*> children_;
63
64 DISALLOW_COPY_AND_ASSIGN(AllocationTraceNode);
65 };
66
67
68 class AllocationTraceTree {
69 public:
70 AllocationTraceTree();
71 ~AllocationTraceTree();
72 AllocationTraceNode* AddPathFromEnd(const Vector<SnapshotObjectId>& path);
73 AllocationTraceNode* root() { return &root_; }
74 unsigned next_node_id() { return next_node_id_++; }
75 void Print();
76
77 private:
78 unsigned next_node_id_;
79 AllocationTraceNode root_;
80
81 DISALLOW_COPY_AND_ASSIGN(AllocationTraceTree);
82 };
83
84
85 class AllocationTracker {
86 public:
87 struct FunctionInfo {
88 FunctionInfo()
89 : name(NULL),
90 script_name(NULL),
91 script_id(0),
92 line(-1),
93 column(-1) {}
94 const char* name;
95 const char* script_name;
96 int script_id;
97 int line;
98 int column;
99 };
100
101 AllocationTracker(HeapObjectsMap* ids, StringsStorage* names);
102 ~AllocationTracker();
103
104 void PrepareForSerialization();
105 void NewObjectEvent(Address addr, int size);
106
107 AllocationTraceTree* allocation_traces() { return &allocation_traces_; }
108 HashMap* id_to_function_info() { return &id_to_function_info_; }
109
110 private:
111 void AddFunctionInfo(SharedFunctionInfo* info, SnapshotObjectId id);
112
113 class UnresolvedLocation {
114 public:
115 UnresolvedLocation(Script* script, int start, FunctionInfo* info);
116 ~UnresolvedLocation();
117 void Resolve();
118
119 private:
120 static void HandleWeakScript(v8::Isolate* isolate,
121 v8::Persistent<v8::Value>* obj,
122 void* data);
123 Handle<Script> script_;
124 int start_position_;
125 FunctionInfo* info_;
126 };
127 static void DeleteUnresolvedLocation(UnresolvedLocation** location);
128
129 HeapObjectsMap* ids_;
130 StringsStorage* names_;
131 AllocationTraceTree allocation_traces_;
132 static const int kMaxAllocationTraceLength = 64;
133 SnapshotObjectId allocation_trace_buffer_[kMaxAllocationTraceLength];
134 HashMap id_to_function_info_;
135 List<UnresolvedLocation*> unresolved_locations_;
136
137 DISALLOW_COPY_AND_ASSIGN(AllocationTracker);
138 };
139
140 } } // namespace v8::internal
141
142 #endif // V8_ALLOCATION_TRACKER_H_
143
OLDNEW
« no previous file with comments | « no previous file | src/allocation-tracker.cc » ('j') | src/allocation-tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698