| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 20 matching lines...) Expand all Loading... |
| 31 #ifdef ENABLE_CPP_PROFILES_PROCESSOR | 31 #ifdef ENABLE_CPP_PROFILES_PROCESSOR |
| 32 | 32 |
| 33 #include "hashmap.h" | 33 #include "hashmap.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 class CodeEntry { | 38 class CodeEntry { |
| 39 public: | 39 public: |
| 40 // CodeEntry doesn't own name strings, just references them. | 40 // CodeEntry doesn't own name strings, just references them. |
| 41 INLINE(CodeEntry(Logger::LogEventsAndTags tag_, | 41 INLINE(CodeEntry(Logger::LogEventsAndTags tag, |
| 42 const char* name_, | 42 const char* name_prefix, |
| 43 const char* resource_name_, | 43 const char* name, |
| 44 int line_number_)); | 44 const char* resource_name, |
| 45 int line_number)); |
| 45 | 46 |
| 46 INLINE(bool is_js_function()); | 47 INLINE(bool is_js_function() const); |
| 47 INLINE(const char* name()) { return name_; } | 48 INLINE(const char* name_prefix() const) { return name_prefix_; } |
| 48 INLINE(const char* resource_name()) { return name_; } | 49 INLINE(bool has_name_prefix() const) { return name_prefix_[0] != '\0'; } |
| 49 INLINE(int line_number()) { return line_number_; } | 50 INLINE(const char* name() const) { return name_; } |
| 51 INLINE(const char* resource_name() const) { return resource_name_; } |
| 52 INLINE(int line_number() const) { return line_number_; } |
| 53 |
| 54 static const char* kEmptyNamePrefix; |
| 55 static const int kNoLineNumberInfo; |
| 50 | 56 |
| 51 private: | 57 private: |
| 52 Logger::LogEventsAndTags tag_; | 58 Logger::LogEventsAndTags tag_; |
| 59 const char* name_prefix_; |
| 53 const char* name_; | 60 const char* name_; |
| 54 const char* resource_name_; | 61 const char* resource_name_; |
| 55 int line_number_; | 62 int line_number_; |
| 56 | 63 |
| 57 DISALLOW_COPY_AND_ASSIGN(CodeEntry); | 64 DISALLOW_COPY_AND_ASSIGN(CodeEntry); |
| 58 }; | 65 }; |
| 59 | 66 |
| 60 | 67 |
| 61 class ProfileNode { | 68 class ProfileNode { |
| 62 public: | 69 public: |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool StartProfiling(String* title, unsigned uid); | 204 bool StartProfiling(String* title, unsigned uid); |
| 198 CpuProfile* StopProfiling(const char* title); | 205 CpuProfile* StopProfiling(const char* title); |
| 199 CpuProfile* StopProfiling(String* title); | 206 CpuProfile* StopProfiling(String* title); |
| 200 INLINE(List<CpuProfile*>* profiles()) { return &profiles_; } | 207 INLINE(List<CpuProfile*>* profiles()) { return &profiles_; } |
| 201 CpuProfile* GetProfile(unsigned uid); | 208 CpuProfile* GetProfile(unsigned uid); |
| 202 inline bool is_last_profile(); | 209 inline bool is_last_profile(); |
| 203 | 210 |
| 204 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 211 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 205 String* name, String* resource_name, int line_number); | 212 String* name, String* resource_name, int line_number); |
| 206 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); | 213 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); |
| 214 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 215 const char* name_prefix, String* name); |
| 207 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); | 216 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); |
| 208 | 217 |
| 209 // Called from profile generator thread. | 218 // Called from profile generator thread. |
| 210 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); | 219 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); |
| 211 | 220 |
| 212 // This will be moved to V8 API. | |
| 213 static const int kNoLineNumberInfo = -1; | |
| 214 | |
| 215 private: | 221 private: |
| 216 const char* GetName(String* name); | 222 const char* GetName(String* name); |
| 217 const char* GetName(int args_count); | 223 const char* GetName(int args_count); |
| 218 | 224 |
| 219 INLINE(static bool StringsMatch(void* key1, void* key2)) { | 225 INLINE(static bool StringsMatch(void* key1, void* key2)) { |
| 220 return strcmp(reinterpret_cast<char*>(key1), | 226 return strcmp(reinterpret_cast<char*>(key1), |
| 221 reinterpret_cast<char*>(key2)) == 0; | 227 reinterpret_cast<char*>(key2)) == 0; |
| 222 } | 228 } |
| 223 | 229 |
| 224 INLINE(static bool CpuProfilesMatch(void* key1, void* key2)) { | 230 INLINE(static bool CpuProfilesMatch(void* key1, void* key2)) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 252 int line_number)) { | 258 int line_number)) { |
| 253 return profiles_->NewCodeEntry(tag, name, resource_name, line_number); | 259 return profiles_->NewCodeEntry(tag, name, resource_name, line_number); |
| 254 } | 260 } |
| 255 | 261 |
| 256 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 262 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 257 const char* name)) { | 263 const char* name)) { |
| 258 return profiles_->NewCodeEntry(tag, name); | 264 return profiles_->NewCodeEntry(tag, name); |
| 259 } | 265 } |
| 260 | 266 |
| 261 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 267 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 268 const char* name_prefix, |
| 269 String* name)) { |
| 270 return profiles_->NewCodeEntry(tag, name_prefix, name); |
| 271 } |
| 272 |
| 273 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 262 int args_count)) { | 274 int args_count)) { |
| 263 return profiles_->NewCodeEntry(tag, args_count); | 275 return profiles_->NewCodeEntry(tag, args_count); |
| 264 } | 276 } |
| 265 | 277 |
| 266 void RecordTickSample(const TickSample& sample); | 278 void RecordTickSample(const TickSample& sample); |
| 267 | 279 |
| 268 INLINE(CodeMap* code_map()) { return &code_map_; } | 280 INLINE(CodeMap* code_map()) { return &code_map_; } |
| 269 | 281 |
| 270 private: | 282 private: |
| 271 CpuProfilesCollection* profiles_; | 283 CpuProfilesCollection* profiles_; |
| 272 CodeMap code_map_; | 284 CodeMap code_map_; |
| 273 | 285 |
| 274 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 286 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
| 275 }; | 287 }; |
| 276 | 288 |
| 277 } } // namespace v8::internal | 289 } } // namespace v8::internal |
| 278 | 290 |
| 279 #endif // ENABLE_CPP_PROFILES_PROCESSOR | 291 #endif // ENABLE_CPP_PROFILES_PROCESSOR |
| 280 | 292 |
| 281 #endif // V8_PROFILE_GENERATOR_H_ | 293 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |