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

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

Powered by Google App Engine
This is Rietveld 408576698