OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 685 } |
686 | 686 |
687 void SampleContext(Sampler* sampler) { | 687 void SampleContext(Sampler* sampler) { |
688 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); | 688 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); |
689 if (profiled_thread == NULL) return; | 689 if (profiled_thread == NULL) return; |
690 | 690 |
691 // Context used for sampling the register state of the profiled thread. | 691 // Context used for sampling the register state of the profiled thread. |
692 CONTEXT context; | 692 CONTEXT context; |
693 memset(&context, 0, sizeof(context)); | 693 memset(&context, 0, sizeof(context)); |
694 | 694 |
695 TickSample sample_obj; | 695 TickSample* sample = CpuProfiler::StartTickSampleEvent(sampler->isolate()); |
696 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); | 696 if (sample == NULL) return; |
697 if (sample == NULL) sample = &sample_obj; | |
698 | 697 |
699 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); | 698 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); |
700 if (SuspendThread(profiled_thread) == kSuspendFailed) return; | 699 if (SuspendThread(profiled_thread) == kSuspendFailed) return; |
701 sample->state = sampler->isolate()->current_vm_state(); | 700 sample->state = sampler->isolate()->current_vm_state(); |
702 | 701 |
703 context.ContextFlags = CONTEXT_FULL; | 702 context.ContextFlags = CONTEXT_FULL; |
704 if (GetThreadContext(profiled_thread, &context) != 0) { | 703 if (GetThreadContext(profiled_thread, &context) != 0) { |
705 #if V8_HOST_ARCH_X64 | 704 #if V8_HOST_ARCH_X64 |
706 sample->pc = reinterpret_cast<Address>(context.Rip); | 705 sample->pc = reinterpret_cast<Address>(context.Rip); |
707 sample->sp = reinterpret_cast<Address>(context.Rsp); | 706 sample->sp = reinterpret_cast<Address>(context.Rsp); |
708 sample->fp = reinterpret_cast<Address>(context.Rbp); | 707 sample->fp = reinterpret_cast<Address>(context.Rbp); |
709 #else | 708 #else |
710 sample->pc = reinterpret_cast<Address>(context.Eip); | 709 sample->pc = reinterpret_cast<Address>(context.Eip); |
711 sample->sp = reinterpret_cast<Address>(context.Esp); | 710 sample->sp = reinterpret_cast<Address>(context.Esp); |
712 sample->fp = reinterpret_cast<Address>(context.Ebp); | 711 sample->fp = reinterpret_cast<Address>(context.Ebp); |
713 #endif | 712 #endif |
714 sampler->SampleStack(sample); | 713 sampler->SampleStack(sample); |
715 sampler->Tick(sample); | 714 sampler->Tick(sample); |
716 } | 715 } |
| 716 CpuProfiler::FinishTickSampleEvent(sampler->isolate()); |
717 ResumeThread(profiled_thread); | 717 ResumeThread(profiled_thread); |
718 } | 718 } |
719 | 719 |
720 const int interval_; | 720 const int interval_; |
721 RuntimeProfilerRateLimiter rate_limiter_; | 721 RuntimeProfilerRateLimiter rate_limiter_; |
722 | 722 |
723 // Protects the process wide state below. | 723 // Protects the process wide state below. |
724 static Mutex* mutex_; | 724 static Mutex* mutex_; |
725 static SamplerThread* instance_; | 725 static SamplerThread* instance_; |
726 | 726 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 781 |
782 | 782 |
783 void Sampler::Stop() { | 783 void Sampler::Stop() { |
784 ASSERT(IsActive()); | 784 ASSERT(IsActive()); |
785 SamplerThread::RemoveActiveSampler(this); | 785 SamplerThread::RemoveActiveSampler(this); |
786 SetActive(false); | 786 SetActive(false); |
787 } | 787 } |
788 | 788 |
789 | 789 |
790 } } // namespace v8::internal | 790 } } // namespace v8::internal |
OLD | NEW |