OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 const char* GetVFormatted(const char* format, va_list args); | 49 const char* GetVFormatted(const char* format, va_list args); |
50 const char* GetName(Name* name); | 50 const char* GetName(Name* name); |
51 const char* GetName(int index); | 51 const char* GetName(int index); |
52 inline const char* GetFunctionName(Name* name); | 52 inline const char* GetFunctionName(Name* name); |
53 inline const char* GetFunctionName(const char* name); | 53 inline const char* GetFunctionName(const char* name); |
54 size_t GetUsedMemorySize() const; | 54 size_t GetUsedMemorySize() const; |
55 | 55 |
56 private: | 56 private: |
57 static const int kMaxNameSize = 1024; | 57 static const int kMaxNameSize = 1024; |
58 | 58 |
59 INLINE(static bool StringsMatch(void* key1, void* key2)) { | 59 static bool StringsMatch(void* key1, void* key2) { |
60 return strcmp(reinterpret_cast<char*>(key1), | 60 return strcmp(reinterpret_cast<char*>(key1), |
61 reinterpret_cast<char*>(key2)) == 0; | 61 reinterpret_cast<char*>(key2)) == 0; |
62 } | 62 } |
63 const char* AddOrDisposeString(char* str, uint32_t hash); | 63 const char* AddOrDisposeString(char* str, uint32_t hash); |
64 | 64 |
65 // Mapping of strings by String::Hash to const char* strings. | 65 // Mapping of strings by String::Hash to const char* strings. |
66 uint32_t hash_seed_; | 66 uint32_t hash_seed_; |
67 HashMap names_; | 67 HashMap names_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(StringsStorage); | 69 DISALLOW_COPY_AND_ASSIGN(StringsStorage); |
70 }; | 70 }; |
71 | 71 |
72 | 72 |
73 class CodeEntry { | 73 class CodeEntry { |
74 public: | 74 public: |
75 // CodeEntry doesn't own name strings, just references them. | 75 // CodeEntry doesn't own name strings, just references them. |
76 INLINE(CodeEntry(Logger::LogEventsAndTags tag, | 76 inline CodeEntry(Logger::LogEventsAndTags tag, |
77 const char* name, | 77 const char* name, |
78 const char* name_prefix = CodeEntry::kEmptyNamePrefix, | 78 const char* name_prefix = CodeEntry::kEmptyNamePrefix, |
79 const char* resource_name = CodeEntry::kEmptyResourceName, | 79 const char* resource_name = CodeEntry::kEmptyResourceName, |
80 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, | 80 int line_number = v8::CpuProfileNode::kNoLineNumberInfo, |
81 int column_number = | 81 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo); |
82 v8::CpuProfileNode::kNoColumnNumberInfo)); | |
83 ~CodeEntry(); | 82 ~CodeEntry(); |
84 | 83 |
85 INLINE(bool is_js_function() const) { return is_js_function_tag(tag_); } | 84 bool is_js_function() const { return is_js_function_tag(tag_); } |
86 INLINE(const char* name_prefix() const) { return name_prefix_; } | 85 const char* name_prefix() const { return name_prefix_; } |
87 INLINE(bool has_name_prefix() const) { return name_prefix_[0] != '\0'; } | 86 bool has_name_prefix() const { return name_prefix_[0] != '\0'; } |
88 INLINE(const char* name() const) { return name_; } | 87 const char* name() const { return name_; } |
89 INLINE(const char* resource_name() const) { return resource_name_; } | 88 const char* resource_name() const { return resource_name_; } |
90 INLINE(int line_number() const) { return line_number_; } | 89 int line_number() const { return line_number_; } |
91 int column_number() const { return column_number_; } | 90 int column_number() const { return column_number_; } |
92 INLINE(void set_shared_id(int shared_id)) { shared_id_ = shared_id; } | 91 void set_shared_id(int shared_id) { shared_id_ = shared_id; } |
93 INLINE(int script_id() const) { return script_id_; } | 92 int script_id() const { return script_id_; } |
94 INLINE(void set_script_id(int script_id)) { script_id_ = script_id; } | 93 void set_script_id(int script_id) { script_id_ = script_id; } |
95 INLINE(void set_bailout_reason(const char* bailout_reason)) { | 94 void set_bailout_reason(const char* bailout_reason) { |
96 bailout_reason_ = bailout_reason; | 95 bailout_reason_ = bailout_reason; |
97 } | 96 } |
98 INLINE(const char* bailout_reason() const) { return bailout_reason_; } | 97 const char* bailout_reason() const { return bailout_reason_; } |
99 | 98 |
100 INLINE(static bool is_js_function_tag(Logger::LogEventsAndTags tag)); | 99 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag); |
101 | 100 |
102 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; } | 101 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; } |
103 void set_no_frame_ranges(List<OffsetRange>* ranges) { | 102 void set_no_frame_ranges(List<OffsetRange>* ranges) { |
104 no_frame_ranges_ = ranges; | 103 no_frame_ranges_ = ranges; |
105 } | 104 } |
106 | 105 |
107 void SetBuiltinId(Builtins::Name id); | 106 void SetBuiltinId(Builtins::Name id); |
108 Builtins::Name builtin_id() const { return builtin_id_; } | 107 Builtins::Name builtin_id() const { return builtin_id_; } |
109 | 108 |
110 void CopyData(const CodeEntry& source); | |
111 uint32_t GetCallUid() const; | 109 uint32_t GetCallUid() const; |
112 bool IsSameAs(CodeEntry* entry) const; | 110 bool IsSameAs(CodeEntry* entry) const; |
113 | 111 |
114 static const char* const kEmptyNamePrefix; | 112 static const char* const kEmptyNamePrefix; |
115 static const char* const kEmptyResourceName; | 113 static const char* const kEmptyResourceName; |
116 static const char* const kEmptyBailoutReason; | 114 static const char* const kEmptyBailoutReason; |
117 | 115 |
118 private: | 116 private: |
119 Logger::LogEventsAndTags tag_ : 8; | 117 Logger::LogEventsAndTags tag_ : 8; |
120 Builtins::Name builtin_id_ : 8; | 118 Builtins::Name builtin_id_ : 8; |
121 const char* name_prefix_; | 119 const char* name_prefix_; |
122 const char* name_; | 120 const char* name_; |
123 const char* resource_name_; | 121 const char* resource_name_; |
124 int line_number_; | 122 int line_number_; |
125 int column_number_; | 123 int column_number_; |
126 int shared_id_; | 124 int shared_id_; |
127 int script_id_; | 125 int script_id_; |
128 List<OffsetRange>* no_frame_ranges_; | 126 List<OffsetRange>* no_frame_ranges_; |
129 const char* bailout_reason_; | 127 const char* bailout_reason_; |
130 | 128 |
131 DISALLOW_COPY_AND_ASSIGN(CodeEntry); | 129 DISALLOW_COPY_AND_ASSIGN(CodeEntry); |
132 }; | 130 }; |
133 | 131 |
134 | 132 |
135 class ProfileTree; | 133 class ProfileTree; |
136 | 134 |
137 class ProfileNode { | 135 class ProfileNode { |
138 public: | 136 public: |
139 INLINE(ProfileNode(ProfileTree* tree, CodeEntry* entry)); | 137 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); |
140 | 138 |
141 ProfileNode* FindChild(CodeEntry* entry); | 139 ProfileNode* FindChild(CodeEntry* entry); |
142 ProfileNode* FindOrAddChild(CodeEntry* entry); | 140 ProfileNode* FindOrAddChild(CodeEntry* entry); |
143 INLINE(void IncrementSelfTicks()) { ++self_ticks_; } | 141 void IncrementSelfTicks() { ++self_ticks_; } |
144 INLINE(void IncreaseSelfTicks(unsigned amount)) { self_ticks_ += amount; } | 142 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; } |
145 | 143 |
146 INLINE(CodeEntry* entry() const) { return entry_; } | 144 CodeEntry* entry() const { return entry_; } |
147 INLINE(unsigned self_ticks() const) { return self_ticks_; } | 145 unsigned self_ticks() const { return self_ticks_; } |
148 INLINE(const List<ProfileNode*>* children() const) { return &children_list_; } | 146 const List<ProfileNode*>* children() const { return &children_list_; } |
149 unsigned id() const { return id_; } | 147 unsigned id() const { return id_; } |
150 | 148 |
151 void Print(int indent); | 149 void Print(int indent); |
152 | 150 |
153 private: | 151 private: |
154 INLINE(static bool CodeEntriesMatch(void* entry1, void* entry2)) { | 152 static bool CodeEntriesMatch(void* entry1, void* entry2) { |
155 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( | 153 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( |
156 reinterpret_cast<CodeEntry*>(entry2)); | 154 reinterpret_cast<CodeEntry*>(entry2)); |
157 } | 155 } |
158 | 156 |
159 INLINE(static uint32_t CodeEntryHash(CodeEntry* entry)) { | 157 static uint32_t CodeEntryHash(CodeEntry* entry) { |
160 return entry->GetCallUid(); | 158 return entry->GetCallUid(); |
161 } | 159 } |
162 | 160 |
163 ProfileTree* tree_; | 161 ProfileTree* tree_; |
164 CodeEntry* entry_; | 162 CodeEntry* entry_; |
165 unsigned self_ticks_; | 163 unsigned self_ticks_; |
166 // Mapping from CodeEntry* to ProfileNode* | 164 // Mapping from CodeEntry* to ProfileNode* |
167 HashMap children_; | 165 HashMap children_; |
168 List<ProfileNode*> children_list_; | 166 List<ProfileNode*> children_list_; |
169 unsigned id_; | 167 unsigned id_; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); | 327 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); |
330 }; | 328 }; |
331 | 329 |
332 | 330 |
333 class ProfileGenerator { | 331 class ProfileGenerator { |
334 public: | 332 public: |
335 explicit ProfileGenerator(CpuProfilesCollection* profiles); | 333 explicit ProfileGenerator(CpuProfilesCollection* profiles); |
336 | 334 |
337 void RecordTickSample(const TickSample& sample); | 335 void RecordTickSample(const TickSample& sample); |
338 | 336 |
339 INLINE(CodeMap* code_map()) { return &code_map_; } | 337 CodeMap* code_map() { return &code_map_; } |
340 | 338 |
341 static const char* const kAnonymousFunctionName; | 339 static const char* const kAnonymousFunctionName; |
342 static const char* const kProgramEntryName; | 340 static const char* const kProgramEntryName; |
343 static const char* const kIdleEntryName; | 341 static const char* const kIdleEntryName; |
344 static const char* const kGarbageCollectorEntryName; | 342 static const char* const kGarbageCollectorEntryName; |
345 // Used to represent frames for which we have no reliable way to | 343 // Used to represent frames for which we have no reliable way to |
346 // detect function. | 344 // detect function. |
347 static const char* const kUnresolvedFunctionName; | 345 static const char* const kUnresolvedFunctionName; |
348 | 346 |
349 private: | 347 private: |
350 INLINE(CodeEntry* EntryForVMState(StateTag tag)); | 348 CodeEntry* EntryForVMState(StateTag tag); |
351 | 349 |
352 CpuProfilesCollection* profiles_; | 350 CpuProfilesCollection* profiles_; |
353 CodeMap code_map_; | 351 CodeMap code_map_; |
354 CodeEntry* program_entry_; | 352 CodeEntry* program_entry_; |
355 CodeEntry* idle_entry_; | 353 CodeEntry* idle_entry_; |
356 CodeEntry* gc_entry_; | 354 CodeEntry* gc_entry_; |
357 CodeEntry* unresolved_entry_; | 355 CodeEntry* unresolved_entry_; |
358 | 356 |
359 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 357 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
360 }; | 358 }; |
361 | 359 |
362 | 360 |
363 } } // namespace v8::internal | 361 } } // namespace v8::internal |
364 | 362 |
365 #endif // V8_PROFILE_GENERATOR_H_ | 363 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |