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

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

Issue 11231002: Perform CPU sampling by CPU sampling thread only iff processing thread is not running. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 8 years, 2 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 = CpuProfiler::StartTickSampleEvent(sampler->isolate()); 695 TickSample sample_obj;
696 if (sample == NULL) return; 696 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate);
697 if (sample == NULL) sample = &sample_obj;
697 698
698 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); 699 static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
699 if (SuspendThread(profiled_thread) == kSuspendFailed) return; 700 if (SuspendThread(profiled_thread) == kSuspendFailed) return;
700 sample->state = sampler->isolate()->current_vm_state(); 701 sample->state = sampler->isolate()->current_vm_state();
701 702
702 context.ContextFlags = CONTEXT_FULL; 703 context.ContextFlags = CONTEXT_FULL;
703 if (GetThreadContext(profiled_thread, &context) != 0) { 704 if (GetThreadContext(profiled_thread, &context) != 0) {
704 #if V8_HOST_ARCH_X64 705 #if V8_HOST_ARCH_X64
705 sample->pc = reinterpret_cast<Address>(context.Rip); 706 sample->pc = reinterpret_cast<Address>(context.Rip);
706 sample->sp = reinterpret_cast<Address>(context.Rsp); 707 sample->sp = reinterpret_cast<Address>(context.Rsp);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 SetActive(true); 779 SetActive(true);
779 SamplerThread::AddActiveSampler(this); 780 SamplerThread::AddActiveSampler(this);
780 } 781 }
781 782
782 783
783 void Sampler::Stop() { 784 void Sampler::Stop() {
784 ASSERT(IsActive()); 785 ASSERT(IsActive());
785 SamplerThread::RemoveActiveSampler(this); 786 SamplerThread::RemoveActiveSampler(this);
786 SetActive(false); 787 SetActive(false);
787 } 788 }
788 789
Jakob Kummerow 2012/10/19 15:56:42 I think the implementation of StartSampling() and
789 790
790 } } // namespace v8::internal 791 } } // namespace v8::internal
OLDNEW
« src/platform.h ('K') | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698