| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void* parameter); | 49 void* parameter); |
| 50 void TokenRemoved(Object** token_location); | 50 void TokenRemoved(Object** token_location); |
| 51 | 51 |
| 52 List<Object**> token_locations_; | 52 List<Object**> token_locations_; |
| 53 List<bool> token_removed_; | 53 List<bool> token_removed_; |
| 54 | 54 |
| 55 friend class TokenEnumeratorTester; | 55 friend class TokenEnumeratorTester; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 | 58 |
| 59 // Provides a storage of strings allocated in C++ heap, to hold them |
| 60 // forever, even if they disappear from JS heap or external storage. |
| 61 class StringsStorage { |
| 62 public: |
| 63 StringsStorage(); |
| 64 ~StringsStorage(); |
| 65 |
| 66 const char* GetName(String* name); |
| 67 |
| 68 private: |
| 69 INLINE(static bool StringsMatch(void* key1, void* key2)) { |
| 70 return strcmp(reinterpret_cast<char*>(key1), |
| 71 reinterpret_cast<char*>(key2)) == 0; |
| 72 } |
| 73 |
| 74 // String::Hash -> const char* |
| 75 HashMap names_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(StringsStorage); |
| 78 }; |
| 79 |
| 80 |
| 59 class CodeEntry { | 81 class CodeEntry { |
| 60 public: | 82 public: |
| 61 explicit INLINE(CodeEntry(int security_token_id)); | 83 explicit INLINE(CodeEntry(int security_token_id)); |
| 62 // CodeEntry doesn't own name strings, just references them. | 84 // CodeEntry doesn't own name strings, just references them. |
| 63 INLINE(CodeEntry(Logger::LogEventsAndTags tag, | 85 INLINE(CodeEntry(Logger::LogEventsAndTags tag, |
| 64 const char* name_prefix, | 86 const char* name_prefix, |
| 65 const char* name, | 87 const char* name, |
| 66 const char* resource_name, | 88 const char* resource_name, |
| 67 int line_number, | 89 int line_number, |
| 68 int security_token_id)); | 90 int security_token_id)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 273 |
| 252 bool StartProfiling(const char* title, unsigned uid); | 274 bool StartProfiling(const char* title, unsigned uid); |
| 253 bool StartProfiling(String* title, unsigned uid); | 275 bool StartProfiling(String* title, unsigned uid); |
| 254 CpuProfile* StopProfiling(int security_token_id, | 276 CpuProfile* StopProfiling(int security_token_id, |
| 255 const char* title, | 277 const char* title, |
| 256 double actual_sampling_rate); | 278 double actual_sampling_rate); |
| 257 CpuProfile* StopProfiling(int security_token_id, | 279 CpuProfile* StopProfiling(int security_token_id, |
| 258 String* title, | 280 String* title, |
| 259 double actual_sampling_rate); | 281 double actual_sampling_rate); |
| 260 List<CpuProfile*>* Profiles(int security_token_id); | 282 List<CpuProfile*>* Profiles(int security_token_id); |
| 283 const char* GetName(String* name) { |
| 284 return function_and_resource_names_.GetName(name); |
| 285 } |
| 261 CpuProfile* GetProfile(int security_token_id, unsigned uid); | 286 CpuProfile* GetProfile(int security_token_id, unsigned uid); |
| 262 inline bool is_last_profile(); | 287 inline bool is_last_profile(); |
| 263 | 288 |
| 264 const char* GetName(String* name); | |
| 265 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 289 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 266 String* name, String* resource_name, int line_number); | 290 String* name, String* resource_name, int line_number); |
| 267 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); | 291 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); |
| 268 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 292 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
| 269 const char* name_prefix, String* name); | 293 const char* name_prefix, String* name); |
| 270 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); | 294 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); |
| 271 CodeEntry* NewCodeEntry(int security_token_id); | 295 CodeEntry* NewCodeEntry(int security_token_id); |
| 272 | 296 |
| 273 // Called from profile generator thread. | 297 // Called from profile generator thread. |
| 274 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); | 298 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); |
| 275 | 299 |
| 276 private: | 300 private: |
| 277 INLINE(const char* GetFunctionName(String* name)); | 301 INLINE(const char* GetFunctionName(String* name)); |
| 278 INLINE(const char* GetFunctionName(const char* name)); | 302 INLINE(const char* GetFunctionName(const char* name)); |
| 279 const char* GetName(int args_count); | 303 const char* GetName(int args_count); |
| 280 List<CpuProfile*>* GetProfilesList(int security_token_id); | 304 List<CpuProfile*>* GetProfilesList(int security_token_id); |
| 281 int TokenToIndex(int security_token_id); | 305 int TokenToIndex(int security_token_id); |
| 282 | 306 |
| 283 INLINE(static bool StringsMatch(void* key1, void* key2)) { | |
| 284 return strcmp(reinterpret_cast<char*>(key1), | |
| 285 reinterpret_cast<char*>(key2)) == 0; | |
| 286 } | |
| 287 | |
| 288 INLINE(static bool UidsMatch(void* key1, void* key2)) { | 307 INLINE(static bool UidsMatch(void* key1, void* key2)) { |
| 289 return key1 == key2; | 308 return key1 == key2; |
| 290 } | 309 } |
| 291 | 310 |
| 292 // String::Hash -> const char* | 311 StringsStorage function_and_resource_names_; |
| 293 HashMap function_and_resource_names_; | |
| 294 // args_count -> char* | 312 // args_count -> char* |
| 295 List<char*> args_count_names_; | 313 List<char*> args_count_names_; |
| 296 List<CodeEntry*> code_entries_; | 314 List<CodeEntry*> code_entries_; |
| 297 List<List<CpuProfile*>* > profiles_by_token_; | 315 List<List<CpuProfile*>* > profiles_by_token_; |
| 298 // uid -> index | 316 // uid -> index |
| 299 HashMap profiles_uids_; | 317 HashMap profiles_uids_; |
| 300 | 318 |
| 301 // Accessed by VM thread and profile generator thread. | 319 // Accessed by VM thread and profile generator thread. |
| 302 List<CpuProfile*> current_profiles_; | 320 List<CpuProfile*> current_profiles_; |
| 303 Semaphore* current_profiles_semaphore_; | 321 Semaphore* current_profiles_semaphore_; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 SampleRateCalculator sample_rate_calc_; | 414 SampleRateCalculator sample_rate_calc_; |
| 397 | 415 |
| 398 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 416 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
| 399 }; | 417 }; |
| 400 | 418 |
| 401 } } // namespace v8::internal | 419 } } // namespace v8::internal |
| 402 | 420 |
| 403 #endif // ENABLE_LOGGING_AND_PROFILING | 421 #endif // ENABLE_LOGGING_AND_PROFILING |
| 404 | 422 |
| 405 #endif // V8_PROFILE_GENERATOR_H_ | 423 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |