blob: 890fb2e5f80a28b63bbf96e7980433d73578918b [file] [log] [blame]
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +00001// Copyright 2011 the V8 project authors. All rights reserved.
fschneider@chromium.org086aac62010-03-17 13:18:24 +00002// 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_PROFILE_GENERATOR_H_
29#define V8_PROFILE_GENERATOR_H_
30
lrn@chromium.org1c092762011-05-09 09:42:16 +000031#include "allocation.h"
fschneider@chromium.org086aac62010-03-17 13:18:24 +000032#include "hashmap.h"
ager@chromium.org2cc82ae2010-06-14 07:35:38 +000033#include "../include/v8-profiler.h"
fschneider@chromium.org086aac62010-03-17 13:18:24 +000034
35namespace v8 {
36namespace internal {
37
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +000038struct OffsetRange;
39
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000040// Provides a storage of strings allocated in C++ heap, to hold them
41// forever, even if they disappear from JS heap or external storage.
42class StringsStorage {
43 public:
hpayer@chromium.orgc5d49712013-09-11 08:25:48 +000044 explicit StringsStorage(Heap* heap);
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000045 ~StringsStorage();
46
whesse@chromium.orgb08986c2011-03-14 16:13:42 +000047 const char* GetCopy(const char* src);
48 const char* GetFormatted(const char* format, ...);
49 const char* GetVFormatted(const char* format, va_list args);
ulan@chromium.org750145a2013-03-07 15:14:13 +000050 const char* GetName(Name* name);
vegorov@chromium.org42841962010-10-18 11:18:59 +000051 const char* GetName(int index);
ulan@chromium.org750145a2013-03-07 15:14:13 +000052 inline const char* GetFunctionName(Name* name);
erik.corry@gmail.com145eff52010-08-23 11:36:18 +000053 inline const char* GetFunctionName(const char* name);
mmassi@chromium.org7028c052012-06-13 11:51:58 +000054 size_t GetUsedMemorySize() const;
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000055
56 private:
danno@chromium.orgc612e022011-11-10 11:38:15 +000057 static const int kMaxNameSize = 1024;
58
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000059 static bool StringsMatch(void* key1, void* key2) {
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000060 return strcmp(reinterpret_cast<char*>(key1),
61 reinterpret_cast<char*>(key2)) == 0;
62 }
whesse@chromium.orgb08986c2011-03-14 16:13:42 +000063 const char* AddOrDisposeString(char* str, uint32_t hash);
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000064
ricow@chromium.org4980dff2010-07-19 08:33:45 +000065 // Mapping of strings by String::Hash to const char* strings.
hpayer@chromium.orgc5d49712013-09-11 08:25:48 +000066 uint32_t hash_seed_;
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +000067 HashMap names_;
68
69 DISALLOW_COPY_AND_ASSIGN(StringsStorage);
70};
71
72
fschneider@chromium.org086aac62010-03-17 13:18:24 +000073class CodeEntry {
74 public:
whesse@chromium.orgcec079d2010-03-22 14:44:04 +000075 // CodeEntry doesn't own name strings, just references them.
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000076 inline CodeEntry(Logger::LogEventsAndTags tag,
lrn@chromium.org25156de2010-04-06 13:10:27 +000077 const char* name,
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +000078 const char* name_prefix = CodeEntry::kEmptyNamePrefix,
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +000079 const char* resource_name = CodeEntry::kEmptyResourceName,
mvstanton@chromium.orgdd6d9ee2013-10-11 10:35:37 +000080 int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000081 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo);
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +000082 ~CodeEntry();
fschneider@chromium.org086aac62010-03-17 13:18:24 +000083
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000084 bool is_js_function() const { return is_js_function_tag(tag_); }
85 const char* name_prefix() const { return name_prefix_; }
86 bool has_name_prefix() const { return name_prefix_[0] != '\0'; }
87 const char* name() const { return name_; }
88 const char* resource_name() const { return resource_name_; }
89 int line_number() const { return line_number_; }
mvstanton@chromium.orgdd6d9ee2013-10-11 10:35:37 +000090 int column_number() const { return column_number_; }
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000091 void set_shared_id(int shared_id) { shared_id_ = shared_id; }
92 int script_id() const { return script_id_; }
93 void set_script_id(int script_id) { script_id_ = script_id; }
94 void set_bailout_reason(const char* bailout_reason) {
jkummerow@chromium.org2c9426b2013-09-05 16:31:13 +000095 bailout_reason_ = bailout_reason;
96 }
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000097 const char* bailout_reason() const { return bailout_reason_; }
ager@chromium.org357bf652010-04-12 11:30:10 +000098
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +000099 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag);
lrn@chromium.org25156de2010-04-06 13:10:27 +0000100
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +0000101 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; }
102 void set_no_frame_ranges(List<OffsetRange>* ranges) {
103 no_frame_ranges_ = ranges;
104 }
105
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000106 void SetBuiltinId(Builtins::Name id);
107 Builtins::Name builtin_id() const { return builtin_id_; }
108
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000109 uint32_t GetCallUid() const;
110 bool IsSameAs(CodeEntry* entry) const;
erik.corry@gmail.com9dfbea42010-05-21 12:58:28 +0000111
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000112 static const char* const kEmptyNamePrefix;
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +0000113 static const char* const kEmptyResourceName;
jkummerow@chromium.org2c9426b2013-09-05 16:31:13 +0000114 static const char* const kEmptyBailoutReason;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000115
116 private:
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000117 Logger::LogEventsAndTags tag_ : 8;
118 Builtins::Name builtin_id_ : 8;
lrn@chromium.org25156de2010-04-06 13:10:27 +0000119 const char* name_prefix_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000120 const char* name_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000121 const char* resource_name_;
122 int line_number_;
mvstanton@chromium.orgdd6d9ee2013-10-11 10:35:37 +0000123 int column_number_;
fschneider@chromium.org3a5fd782011-02-24 10:10:44 +0000124 int shared_id_;
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000125 int script_id_;
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +0000126 List<OffsetRange>* no_frame_ranges_;
jkummerow@chromium.org2c9426b2013-09-05 16:31:13 +0000127 const char* bailout_reason_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000128
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000129 DISALLOW_COPY_AND_ASSIGN(CodeEntry);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000130};
131
132
ricow@chromium.orgc9c80822010-04-21 08:22:37 +0000133class ProfileTree;
134
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000135class ProfileNode {
136 public:
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000137 inline ProfileNode(ProfileTree* tree, CodeEntry* entry);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000138
139 ProfileNode* FindChild(CodeEntry* entry);
140 ProfileNode* FindOrAddChild(CodeEntry* entry);
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000141 void IncrementSelfTicks() { ++self_ticks_; }
142 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; }
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000143
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000144 CodeEntry* entry() const { return entry_; }
145 unsigned self_ticks() const { return self_ticks_; }
146 const List<ProfileNode*>* children() const { return &children_list_; }
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000147 unsigned id() const { return id_; }
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000148
149 void Print(int indent);
150
151 private:
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000152 static bool CodeEntriesMatch(void* entry1, void* entry2) {
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000153 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs(
154 reinterpret_cast<CodeEntry*>(entry2));
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000155 }
156
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000157 static uint32_t CodeEntryHash(CodeEntry* entry) {
fschneider@chromium.orgc20610a2010-09-22 09:44:58 +0000158 return entry->GetCallUid();
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000159 }
160
ricow@chromium.orgc9c80822010-04-21 08:22:37 +0000161 ProfileTree* tree_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000162 CodeEntry* entry_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000163 unsigned self_ticks_;
ricow@chromium.org4980dff2010-07-19 08:33:45 +0000164 // Mapping from CodeEntry* to ProfileNode*
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000165 HashMap children_;
lrn@chromium.org25156de2010-04-06 13:10:27 +0000166 List<ProfileNode*> children_list_;
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000167 unsigned id_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000168
169 DISALLOW_COPY_AND_ASSIGN(ProfileNode);
170};
171
172
lrn@chromium.org25156de2010-04-06 13:10:27 +0000173class ProfileTree {
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000174 public:
ager@chromium.org357bf652010-04-12 11:30:10 +0000175 ProfileTree();
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000176 ~ProfileTree();
177
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000178 ProfileNode* AddPathFromEnd(const Vector<CodeEntry*>& path);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000179 void AddPathFromStart(const Vector<CodeEntry*>& path);
lrn@chromium.org25156de2010-04-06 13:10:27 +0000180 ProfileNode* root() const { return root_; }
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000181 unsigned next_node_id() { return next_node_id_++; }
182
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000183 void Print() {
184 root_->Print(0);
185 }
186
187 private:
188 template <typename Callback>
erik.corry@gmail.com9dfbea42010-05-21 12:58:28 +0000189 void TraverseDepthFirst(Callback* callback);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000190
ager@chromium.org357bf652010-04-12 11:30:10 +0000191 CodeEntry root_entry_;
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000192 unsigned next_node_id_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000193 ProfileNode* root_;
194
195 DISALLOW_COPY_AND_ASSIGN(ProfileTree);
196};
197
198
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000199class CpuProfile {
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000200 public:
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000201 CpuProfile(const char* title, unsigned uid, bool record_samples);
lrn@chromium.org25156de2010-04-06 13:10:27 +0000202
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000203 // Add pc -> ... -> main() call path to the profile.
204 void AddPath(const Vector<CodeEntry*>& path);
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000205 void CalculateTotalTicksAndSamplingRate();
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000206
danno@chromium.org89acc0b2013-08-09 20:55:58 +0000207 const char* title() const { return title_; }
208 unsigned uid() const { return uid_; }
209 const ProfileTree* top_down() const { return &top_down_; }
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000210
danno@chromium.org89acc0b2013-08-09 20:55:58 +0000211 int samples_count() const { return samples_.length(); }
212 ProfileNode* sample(int index) const { return samples_.at(index); }
213
jkummerow@chromium.orgdc94e192013-08-30 11:35:42 +0000214 Time start_time() const { return start_time_; }
215 Time end_time() const { return end_time_; }
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000216
ricow@chromium.orgc9c80822010-04-21 08:22:37 +0000217 void UpdateTicksScale();
218
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000219 void Print();
220
221 private:
lrn@chromium.org25156de2010-04-06 13:10:27 +0000222 const char* title_;
223 unsigned uid_;
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000224 bool record_samples_;
jkummerow@chromium.orgdc94e192013-08-30 11:35:42 +0000225 Time start_time_;
226 Time end_time_;
227 ElapsedTimer timer_;
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000228 List<ProfileNode*> samples_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000229 ProfileTree top_down_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000230
231 DISALLOW_COPY_AND_ASSIGN(CpuProfile);
232};
233
234
lrn@chromium.org25156de2010-04-06 13:10:27 +0000235class CodeMap {
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000236 public:
whesse@chromium.orgb08986c2011-03-14 16:13:42 +0000237 CodeMap() : next_shared_id_(1) { }
lrn@chromium.org34e60782011-09-15 07:25:40 +0000238 void AddCode(Address addr, CodeEntry* entry, unsigned size);
239 void MoveCode(Address from, Address to);
jkummerow@chromium.org4e308cf2013-05-17 13:39:16 +0000240 CodeEntry* FindEntry(Address addr, Address* start = NULL);
whesse@chromium.orgb08986c2011-03-14 16:13:42 +0000241 int GetSharedId(Address addr);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000242
lrn@chromium.org25156de2010-04-06 13:10:27 +0000243 void Print();
244
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000245 private:
246 struct CodeEntryInfo {
247 CodeEntryInfo(CodeEntry* an_entry, unsigned a_size)
248 : entry(an_entry), size(a_size) { }
249 CodeEntry* entry;
250 unsigned size;
251 };
252
253 struct CodeTreeConfig {
254 typedef Address Key;
255 typedef CodeEntryInfo Value;
256 static const Key kNoKey;
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000257 static const Value NoValue() { return CodeEntryInfo(NULL, 0); }
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000258 static int Compare(const Key& a, const Key& b) {
259 return a < b ? -1 : (a > b ? 1 : 0);
260 }
261 };
262 typedef SplayTree<CodeTreeConfig> CodeTree;
263
lrn@chromium.org25156de2010-04-06 13:10:27 +0000264 class CodeTreePrinter {
265 public:
266 void Call(const Address& key, const CodeEntryInfo& value);
267 };
268
lrn@chromium.org34e60782011-09-15 07:25:40 +0000269 void DeleteAllCoveredCode(Address start, Address end);
270
whesse@chromium.orgb08986c2011-03-14 16:13:42 +0000271 // Fake CodeEntry pointer to distinguish shared function entries.
272 static CodeEntry* const kSharedFunctionCodeEntry;
fschneider@chromium.org3a5fd782011-02-24 10:10:44 +0000273
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000274 CodeTree tree_;
whesse@chromium.orgb08986c2011-03-14 16:13:42 +0000275 int next_shared_id_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000276
277 DISALLOW_COPY_AND_ASSIGN(CodeMap);
278};
279
280
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000281class CpuProfilesCollection {
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000282 public:
hpayer@chromium.orgc5d49712013-09-11 08:25:48 +0000283 explicit CpuProfilesCollection(Heap* heap);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000284 ~CpuProfilesCollection();
285
mstarzinger@chromium.orgf705b502013-04-04 11:38:09 +0000286 bool StartProfiling(const char* title, unsigned uid, bool record_samples);
danno@chromium.orgd3c42102013-08-01 16:58:23 +0000287 CpuProfile* StopProfiling(const char* title);
mstarzinger@chromium.orge0e1b0d2013-07-08 08:38:06 +0000288 List<CpuProfile*>* profiles() { return &finished_profiles_; }
ulan@chromium.org750145a2013-03-07 15:14:13 +0000289 const char* GetName(Name* name) {
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +0000290 return function_and_resource_names_.GetName(name);
291 }
vegorov@chromium.org42841962010-10-18 11:18:59 +0000292 const char* GetName(int args_count) {
293 return function_and_resource_names_.GetName(args_count);
294 }
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000295 const char* GetFunctionName(Name* name) {
296 return function_and_resource_names_.GetFunctionName(name);
297 }
298 const char* GetFunctionName(const char* name) {
299 return function_and_resource_names_.GetFunctionName(name);
300 }
vegorov@chromium.org26c16f82010-08-11 13:41:03 +0000301 bool IsLastProfile(const char* title);
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000302 void RemoveProfile(CpuProfile* profile);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000303
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000304 CodeEntry* NewCodeEntry(
305 Logger::LogEventsAndTags tag,
306 const char* name,
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000307 const char* name_prefix = CodeEntry::kEmptyNamePrefix,
308 const char* resource_name = CodeEntry::kEmptyResourceName,
mvstanton@chromium.orgdd6d9ee2013-10-11 10:35:37 +0000309 int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
310 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo);
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000311
lrn@chromium.org25156de2010-04-06 13:10:27 +0000312 // Called from profile generator thread.
313 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path);
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000314
ricow@chromium.orgd236f4d2010-09-01 06:52:08 +0000315 // Limits the number of profiles that can be simultaneously collected.
316 static const int kMaxSimultaneousProfiles = 100;
317
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000318 private:
vegorov@chromium.org2356e6f2010-06-09 09:38:56 +0000319 StringsStorage function_and_resource_names_;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000320 List<CodeEntry*> code_entries_;
mstarzinger@chromium.orge0e1b0d2013-07-08 08:38:06 +0000321 List<CpuProfile*> finished_profiles_;
lrn@chromium.org25156de2010-04-06 13:10:27 +0000322
323 // Accessed by VM thread and profile generator thread.
324 List<CpuProfile*> current_profiles_;
mstarzinger@chromium.orge9000182013-09-03 11:25:39 +0000325 Semaphore current_profiles_semaphore_;
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000326
327 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection);
328};
329
330
331class ProfileGenerator {
332 public:
333 explicit ProfileGenerator(CpuProfilesCollection* profiles);
334
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000335 void RecordTickSample(const TickSample& sample);
336
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000337 CodeMap* code_map() { return &code_map_; }
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000338
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000339 static const char* const kAnonymousFunctionName;
340 static const char* const kProgramEntryName;
danno@chromium.org59400602013-08-13 17:09:37 +0000341 static const char* const kIdleEntryName;
sgjesse@chromium.orgea88ce92011-03-23 11:19:56 +0000342 static const char* const kGarbageCollectorEntryName;
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000343 // Used to represent frames for which we have no reliable way to
344 // detect function.
345 static const char* const kUnresolvedFunctionName;
ager@chromium.org357bf652010-04-12 11:30:10 +0000346
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000347 private:
mstarzinger@chromium.orga2e1a402013-10-15 08:25:05 +0000348 CodeEntry* EntryForVMState(StateTag tag);
ager@chromium.org357bf652010-04-12 11:30:10 +0000349
whesse@chromium.orgcec079d2010-03-22 14:44:04 +0000350 CpuProfilesCollection* profiles_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000351 CodeMap code_map_;
ager@chromium.org357bf652010-04-12 11:30:10 +0000352 CodeEntry* program_entry_;
danno@chromium.org59400602013-08-13 17:09:37 +0000353 CodeEntry* idle_entry_;
ager@chromium.org357bf652010-04-12 11:30:10 +0000354 CodeEntry* gc_entry_;
jkummerow@chromium.org93a47f42013-07-02 14:43:41 +0000355 CodeEntry* unresolved_entry_;
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000356
357 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
358};
359
ager@chromium.org2cc82ae2010-06-14 07:35:38 +0000360
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000361} } // namespace v8::internal
362
fschneider@chromium.org086aac62010-03-17 13:18:24 +0000363#endif // V8_PROFILE_GENERATOR_H_