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

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

Issue 13845014: Fix cctest/test-cpu-profiler/CollectCpuProfile test on Arm and MIPS simulators (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updared OpenBSD Created 7 years, 8 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-cygwin.cc ('k') | src/platform-linux.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include <stdarg.h> 49 #include <stdarg.h>
50 #include <limits.h> 50 #include <limits.h>
51 51
52 #undef MAP_TYPE 52 #undef MAP_TYPE
53 53
54 #include "v8.h" 54 #include "v8.h"
55 #include "v8threads.h" 55 #include "v8threads.h"
56 56
57 #include "platform-posix.h" 57 #include "platform-posix.h"
58 #include "platform.h" 58 #include "platform.h"
59 #include "simulator.h"
59 #include "vm-state-inl.h" 60 #include "vm-state-inl.h"
60 61
61 62
62 namespace v8 { 63 namespace v8 {
63 namespace internal { 64 namespace internal {
64 65
65 // 0 is never a valid thread id on FreeBSD since tids and pids share a 66 // 0 is never a valid thread id on FreeBSD since tids and pids share a
66 // name space and pid 0 is used to kill the group (see man 2 kill). 67 // name space and pid 0 is used to kill the group (see man 2 kill).
67 static const pthread_t kNoThread = (pthread_t) 0; 68 static const pthread_t kNoThread = (pthread_t) 0;
68 69
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 684
684 685
685 static pthread_t GetThreadID() { 686 static pthread_t GetThreadID() {
686 pthread_t thread_id = pthread_self(); 687 pthread_t thread_id = pthread_self();
687 return thread_id; 688 return thread_id;
688 } 689 }
689 690
690 691
691 class Sampler::PlatformData : public Malloced { 692 class Sampler::PlatformData : public Malloced {
692 public: 693 public:
693 PlatformData() : vm_tid_(GetThreadID()) {} 694 PlatformData()
695 : vm_tid_(GetThreadID()),
696 profiled_thread_id_(ThreadId::Current()) {}
694 697
695 pthread_t vm_tid() const { return vm_tid_; } 698 pthread_t vm_tid() const { return vm_tid_; }
699 ThreadId profiled_thread_id() { return profiled_thread_id_; }
696 700
697 private: 701 private:
698 pthread_t vm_tid_; 702 pthread_t vm_tid_;
703 ThreadId profiled_thread_id_;
699 }; 704 };
700 705
701 706
702 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { 707 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
703 USE(info); 708 USE(info);
704 if (signal != SIGPROF) return; 709 if (signal != SIGPROF) return;
705 Isolate* isolate = Isolate::UncheckedCurrent(); 710 Isolate* isolate = Isolate::UncheckedCurrent();
706 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { 711 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) {
707 // We require a fully initialized and entered isolate. 712 // We require a fully initialized and entered isolate.
708 return; 713 return;
709 } 714 }
710 if (v8::Locker::IsActive() && 715 if (v8::Locker::IsActive() &&
711 !isolate->thread_manager()->IsLockedByCurrentThread()) { 716 !isolate->thread_manager()->IsLockedByCurrentThread()) {
712 return; 717 return;
713 } 718 }
714 719
715 Sampler* sampler = isolate->logger()->sampler(); 720 Sampler* sampler = isolate->logger()->sampler();
716 if (sampler == NULL || !sampler->IsActive()) return; 721 if (sampler == NULL || !sampler->IsActive()) return;
717 722
723 #if defined(USE_SIMULATOR)
724 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
725 ThreadId thread_id = sampler->platform_data()->profiled_thread_id();
726 Isolate::PerIsolateThreadData* per_thread_data = isolate->
727 FindPerThreadDataForThread(thread_id);
728 if (!per_thread_data) return;
729 Simulator* sim = per_thread_data->simulator();
730 // Check if there is active simulator before allocating TickSample.
731 if (!sim) return;
732 #endif
733 #endif // USE_SIMULATOR
734
718 TickSample sample_obj; 735 TickSample sample_obj;
719 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); 736 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
720 if (sample == NULL) sample = &sample_obj; 737 if (sample == NULL) sample = &sample_obj;
721 738
722 // Extracting the sample from the context is extremely machine dependent. 739 // Extracting the sample from the context is extremely machine dependent.
723 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 740 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
724 mcontext_t& mcontext = ucontext->uc_mcontext; 741 mcontext_t& mcontext = ucontext->uc_mcontext;
725 sample->state = isolate->current_vm_state(); 742 sample->state = isolate->current_vm_state();
743 #if defined(USE_SIMULATOR)
744 #if V8_TARGET_ARCH_ARM
745 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc));
746 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp));
747 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11));
748 #elif V8_TARGET_ARCH_MIPS
749 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc));
750 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp));
751 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp));
752 #endif
753 #else
726 #if V8_HOST_ARCH_IA32 754 #if V8_HOST_ARCH_IA32
727 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); 755 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip);
728 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); 756 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp);
729 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); 757 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp);
730 #elif V8_HOST_ARCH_X64 758 #elif V8_HOST_ARCH_X64
731 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); 759 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip);
732 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); 760 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp);
733 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); 761 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp);
734 #elif V8_HOST_ARCH_ARM 762 #elif V8_HOST_ARCH_ARM
735 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); 763 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15);
736 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); 764 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13);
737 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); 765 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11);
738 #endif 766 #endif // V8_HOST_ARCH_*
767 #endif // USE_SIMULATOR
739 sampler->SampleStack(sample); 768 sampler->SampleStack(sample);
740 sampler->Tick(sample); 769 sampler->Tick(sample);
741 } 770 }
742 771
743 772
744 class SignalSender : public Thread { 773 class SignalSender : public Thread {
745 public: 774 public:
746 static const int kSignalSenderStackSize = 64 * KB; 775 static const int kSignalSenderStackSize = 64 * KB;
747 776
748 explicit SignalSender(int interval) 777 explicit SignalSender(int interval)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 920
892 921
893 void Sampler::Stop() { 922 void Sampler::Stop() {
894 ASSERT(IsActive()); 923 ASSERT(IsActive());
895 SignalSender::RemoveActiveSampler(this); 924 SignalSender::RemoveActiveSampler(this);
896 SetActive(false); 925 SetActive(false);
897 } 926 }
898 927
899 928
900 } } // namespace v8::internal 929 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-cygwin.cc ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698