| 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 281 } |
| 282 | 282 |
| 283 | 283 |
| 284 void CpuProfiler::StartProfiling(String* title) { | 284 void CpuProfiler::StartProfiling(String* title) { |
| 285 ASSERT(Isolate::Current()->cpu_profiler() != NULL); | 285 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 286 Isolate::Current()->cpu_profiler()->StartCollectingProfile(title); | 286 Isolate::Current()->cpu_profiler()->StartCollectingProfile(title); |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 CpuProfile* CpuProfiler::StopProfiling(const char* title) { | 290 CpuProfile* CpuProfiler::StopProfiling(const char* title) { |
| 291 return is_profiling() ? | 291 Isolate* isolate = Isolate::Current(); |
| 292 Isolate::Current()->cpu_profiler()->StopCollectingProfile(title) : NULL; | 292 return is_profiling(isolate) ? |
| 293 isolate->cpu_profiler()->StopCollectingProfile(title) : NULL; |
| 293 } | 294 } |
| 294 | 295 |
| 295 | 296 |
| 296 CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) { | 297 CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) { |
| 297 return is_profiling() ? | 298 Isolate* isolate = Isolate::Current(); |
| 298 Isolate::Current()->cpu_profiler()->StopCollectingProfile( | 299 return is_profiling(isolate) ? |
| 300 isolate->cpu_profiler()->StopCollectingProfile( |
| 299 security_token, title) : NULL; | 301 security_token, title) : NULL; |
| 300 } | 302 } |
| 301 | 303 |
| 302 | 304 |
| 303 int CpuProfiler::GetProfilesCount() { | 305 int CpuProfiler::GetProfilesCount() { |
| 304 ASSERT(Isolate::Current()->cpu_profiler() != NULL); | 306 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 305 // The count of profiles doesn't depend on a security token. | 307 // The count of profiles doesn't depend on a security token. |
| 306 return Isolate::Current()->cpu_profiler()->profiles_->Profiles( | 308 return Isolate::Current()->cpu_profiler()->profiles_->Profiles( |
| 307 TokenEnumerator::kNoSecurityToken)->length(); | 309 TokenEnumerator::kNoSecurityToken)->length(); |
| 308 } | 310 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 329 return isolate->cpu_profiler()->processor_->TickSampleEvent(); | 331 return isolate->cpu_profiler()->processor_->TickSampleEvent(); |
| 330 } else { | 332 } else { |
| 331 return NULL; | 333 return NULL; |
| 332 } | 334 } |
| 333 } | 335 } |
| 334 | 336 |
| 335 | 337 |
| 336 void CpuProfiler::DeleteAllProfiles() { | 338 void CpuProfiler::DeleteAllProfiles() { |
| 337 Isolate* isolate = Isolate::Current(); | 339 Isolate* isolate = Isolate::Current(); |
| 338 ASSERT(isolate->cpu_profiler() != NULL); | 340 ASSERT(isolate->cpu_profiler() != NULL); |
| 339 if (is_profiling()) | 341 if (is_profiling(isolate)) { |
| 340 isolate->cpu_profiler()->StopProcessor(); | 342 isolate->cpu_profiler()->StopProcessor(); |
| 343 } |
| 341 isolate->cpu_profiler()->ResetProfiles(); | 344 isolate->cpu_profiler()->ResetProfiles(); |
| 342 } | 345 } |
| 343 | 346 |
| 344 | 347 |
| 345 void CpuProfiler::DeleteProfile(CpuProfile* profile) { | 348 void CpuProfiler::DeleteProfile(CpuProfile* profile) { |
| 346 ASSERT(Isolate::Current()->cpu_profiler() != NULL); | 349 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 347 Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile); | 350 Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile); |
| 348 delete profile; | 351 delete profile; |
| 349 } | 352 } |
| 350 | 353 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 #ifdef ENABLE_LOGGING_AND_PROFILING | 600 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 598 Isolate* isolate = Isolate::Current(); | 601 Isolate* isolate = Isolate::Current(); |
| 599 if (isolate->cpu_profiler() != NULL) { | 602 if (isolate->cpu_profiler() != NULL) { |
| 600 delete isolate->cpu_profiler(); | 603 delete isolate->cpu_profiler(); |
| 601 } | 604 } |
| 602 isolate->set_cpu_profiler(NULL); | 605 isolate->set_cpu_profiler(NULL); |
| 603 #endif | 606 #endif |
| 604 } | 607 } |
| 605 | 608 |
| 606 } } // namespace v8::internal | 609 } } // namespace v8::internal |
| OLD | NEW |