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

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

Issue 12706020: Isolatify CPU profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { 811 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) {
812 if (!sampler->isolate()->IsInitialized()) return; 812 if (!sampler->isolate()->IsInitialized()) return;
813 if (!sampler->IsProfiling()) return; 813 if (!sampler->IsProfiling()) return;
814 SamplerThread* sampler_thread = 814 SamplerThread* sampler_thread =
815 reinterpret_cast<SamplerThread*>(raw_sampler_thread); 815 reinterpret_cast<SamplerThread*>(raw_sampler_thread);
816 sampler_thread->SampleContext(sampler); 816 sampler_thread->SampleContext(sampler);
817 } 817 }
818 818
819 void SampleContext(Sampler* sampler) { 819 void SampleContext(Sampler* sampler) {
820 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); 820 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
821 Isolate* isolate = sampler->isolate();
821 TickSample sample_obj; 822 TickSample sample_obj;
822 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); 823 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
823 if (sample == NULL) sample = &sample_obj; 824 if (sample == NULL) sample = &sample_obj;
824 825
825 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return; 826 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return;
826 827
827 #if V8_HOST_ARCH_X64 828 #if V8_HOST_ARCH_X64
828 thread_state_flavor_t flavor = x86_THREAD_STATE64; 829 thread_state_flavor_t flavor = x86_THREAD_STATE64;
829 x86_thread_state64_t state; 830 x86_thread_state64_t state;
830 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; 831 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT;
831 #if __DARWIN_UNIX03 832 #if __DARWIN_UNIX03
832 #define REGISTER_FIELD(name) __r ## name 833 #define REGISTER_FIELD(name) __r ## name
(...skipping 10 matching lines...) Expand all
843 #define REGISTER_FIELD(name) e ## name 844 #define REGISTER_FIELD(name) e ## name
844 #endif // __DARWIN_UNIX03 845 #endif // __DARWIN_UNIX03
845 #else 846 #else
846 #error Unsupported Mac OS X host architecture. 847 #error Unsupported Mac OS X host architecture.
847 #endif // V8_HOST_ARCH 848 #endif // V8_HOST_ARCH
848 849
849 if (thread_get_state(profiled_thread, 850 if (thread_get_state(profiled_thread,
850 flavor, 851 flavor,
851 reinterpret_cast<natural_t*>(&state), 852 reinterpret_cast<natural_t*>(&state),
852 &count) == KERN_SUCCESS) { 853 &count) == KERN_SUCCESS) {
853 sample->state = sampler->isolate()->current_vm_state(); 854 sample->state = isolate->current_vm_state();
854 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); 855 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
855 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); 856 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
856 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); 857 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
857 sampler->SampleStack(sample); 858 sampler->SampleStack(sample);
858 sampler->Tick(sample); 859 sampler->Tick(sample);
859 } 860 }
860 thread_resume(profiled_thread); 861 thread_resume(profiled_thread);
861 } 862 }
862 863
863 const int interval_; 864 const int interval_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 917
917 918
918 void Sampler::Stop() { 919 void Sampler::Stop() {
919 ASSERT(IsActive()); 920 ASSERT(IsActive());
920 SamplerThread::RemoveActiveSampler(this); 921 SamplerThread::RemoveActiveSampler(this);
921 SetActive(false); 922 SetActive(false);
922 } 923 }
923 924
924 925
925 } } // namespace v8::internal 926 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698