Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: src/platform-cygwin.cc

Issue 10871039: Replacing circular queue by single buffer in CPU Profiler. (Closed) Base URL: http://git.chromium.org/external/v8.git@profiling
Patch Set: an attempt to fix a test that strangely crashed only once Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« src/cpu-profiler-inl.h ('K') | « src/cpu-profiler-inl.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698