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

Side by Side Diff: src/platform-openbsd.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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 return; 724 return;
725 } 725 }
726 if (v8::Locker::IsActive() && 726 if (v8::Locker::IsActive() &&
727 !isolate->thread_manager()->IsLockedByCurrentThread()) { 727 !isolate->thread_manager()->IsLockedByCurrentThread()) {
728 return; 728 return;
729 } 729 }
730 730
731 Sampler* sampler = isolate->logger()->sampler(); 731 Sampler* sampler = isolate->logger()->sampler();
732 if (sampler == NULL || !sampler->IsActive()) return; 732 if (sampler == NULL || !sampler->IsActive()) return;
733 733
734 TickSample sample_obj; 734 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate);
735 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); 735 if (sample == NULL) return;
736 if (sample == NULL) sample = &sample_obj;
737 736
738 // Extracting the sample from the context is extremely machine dependent. 737 // Extracting the sample from the context is extremely machine dependent.
739 sample->state = isolate->current_vm_state(); 738 sample->state = isolate->current_vm_state();
740 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 739 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
741 #ifdef __NetBSD__ 740 #ifdef __NetBSD__
742 mcontext_t& mcontext = ucontext->uc_mcontext; 741 mcontext_t& mcontext = ucontext->uc_mcontext;
743 #if V8_HOST_ARCH_IA32 742 #if V8_HOST_ARCH_IA32
744 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); 743 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]);
745 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); 744 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]);
746 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); 745 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]);
747 #elif V8_HOST_ARCH_X64 746 #elif V8_HOST_ARCH_X64
748 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); 747 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]);
749 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); 748 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]);
750 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); 749 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]);
751 #endif // V8_HOST_ARCH 750 #endif // V8_HOST_ARCH
752 #else // OpenBSD 751 #else // OpenBSD
753 #if V8_HOST_ARCH_IA32 752 #if V8_HOST_ARCH_IA32
754 sample->pc = reinterpret_cast<Address>(ucontext->sc_eip); 753 sample->pc = reinterpret_cast<Address>(ucontext->sc_eip);
755 sample->sp = reinterpret_cast<Address>(ucontext->sc_esp); 754 sample->sp = reinterpret_cast<Address>(ucontext->sc_esp);
756 sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp); 755 sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp);
757 #elif V8_HOST_ARCH_X64 756 #elif V8_HOST_ARCH_X64
758 sample->pc = reinterpret_cast<Address>(ucontext->sc_rip); 757 sample->pc = reinterpret_cast<Address>(ucontext->sc_rip);
759 sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp); 758 sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp);
760 sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp); 759 sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp);
761 #endif // V8_HOST_ARCH 760 #endif // V8_HOST_ARCH
762 #endif // __NetBSD__ 761 #endif // __NetBSD__
763 sampler->SampleStack(sample); 762 sampler->SampleStack(sample);
764 sampler->Tick(sample); 763 sampler->Tick(sample);
764 CpuProfiler::FinishTickSampleEvent(isolate);
765 } 765 }
766 766
767 767
768 class Sampler::PlatformData : public Malloced { 768 class Sampler::PlatformData : public Malloced {
769 public: 769 public:
770 PlatformData() : vm_tid_(GetThreadID()) {} 770 PlatformData() : vm_tid_(GetThreadID()) {}
771 771
772 pthread_t vm_tid() const { return vm_tid_; } 772 pthread_t vm_tid() const { return vm_tid_; }
773 773
774 private: 774 private:
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 977
978 978
979 void Sampler::Stop() { 979 void Sampler::Stop() {
980 ASSERT(IsActive()); 980 ASSERT(IsActive());
981 SignalSender::RemoveActiveSampler(this); 981 SignalSender::RemoveActiveSampler(this);
982 SetActive(false); 982 SetActive(false);
983 } 983 }
984 984
985 985
986 } } // namespace v8::internal 986 } } // namespace v8::internal
OLDNEW
« src/cpu-profiler-inl.h ('K') | « src/platform-macos.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698