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

Side by Side Diff: src/platform-openbsd.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: Added simulator support to other platforms 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include <strings.h> // index 46 #include <strings.h> // index
47 #include <errno.h> 47 #include <errno.h>
48 #include <stdarg.h> 48 #include <stdarg.h>
49 49
50 #undef MAP_TYPE 50 #undef MAP_TYPE
51 51
52 #include "v8.h" 52 #include "v8.h"
53 53
54 #include "platform-posix.h" 54 #include "platform-posix.h"
55 #include "platform.h" 55 #include "platform.h"
56 #include "simulator.h"
56 #include "v8threads.h" 57 #include "v8threads.h"
57 #include "vm-state-inl.h" 58 #include "vm-state-inl.h"
58 59
59 60
60 namespace v8 { 61 namespace v8 {
61 namespace internal { 62 namespace internal {
62 63
63 // 0 is never a valid thread id on Linux and OpenBSD since tids and pids share a 64 // 0 is never a valid thread id on Linux and OpenBSD since tids and pids share a
64 // name space and pid 0 is reserved (see man 2 kill). 65 // name space and pid 0 is reserved (see man 2 kill).
65 static const pthread_t kNoThread = (pthread_t) 0; 66 static const pthread_t kNoThread = (pthread_t) 0;
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 return; 742 return;
742 } 743 }
743 if (v8::Locker::IsActive() && 744 if (v8::Locker::IsActive() &&
744 !isolate->thread_manager()->IsLockedByCurrentThread()) { 745 !isolate->thread_manager()->IsLockedByCurrentThread()) {
745 return; 746 return;
746 } 747 }
747 748
748 Sampler* sampler = isolate->logger()->sampler(); 749 Sampler* sampler = isolate->logger()->sampler();
749 if (sampler == NULL || !sampler->IsActive()) return; 750 if (sampler == NULL || !sampler->IsActive()) return;
750 751
752 #if defined(USE_SIMULATOR)
753 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
754 Isolate::PerIsolateThreadData* per_thread_data =
755 isolate->FindPerThreadDataForThisThread();
756 if (!per_thread_data) return;
757 Simulator* sim = per_thread_data->simulator();
758 // Check if there is active simulator before allocating TickSample.
759 if (!sim) return;
760 #endif
761 #endif // USE_SIMULATOR
762
751 TickSample sample_obj; 763 TickSample sample_obj;
752 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); 764 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
753 if (sample == NULL) sample = &sample_obj; 765 if (sample == NULL) sample = &sample_obj;
754 766
755 // Extracting the sample from the context is extremely machine dependent. 767 // Extracting the sample from the context is extremely machine dependent.
756 sample->state = isolate->current_vm_state(); 768 sample->state = isolate->current_vm_state();
757 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 769 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
770 #if defined(USE_SIMULATOR)
771 #if V8_TARGET_ARCH_ARM
772 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc));
773 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp));
774 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11));
775 #elif V8_TARGET_ARCH_MIPS
776 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc));
777 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp));
778 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp));
779 #endif
780 #else
758 #ifdef __NetBSD__ 781 #ifdef __NetBSD__
759 mcontext_t& mcontext = ucontext->uc_mcontext; 782 mcontext_t& mcontext = ucontext->uc_mcontext;
760 #if V8_HOST_ARCH_IA32 783 #if V8_HOST_ARCH_IA32
761 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); 784 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]);
762 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); 785 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]);
763 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); 786 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]);
764 #elif V8_HOST_ARCH_X64 787 #elif V8_HOST_ARCH_X64
765 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); 788 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]);
766 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); 789 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]);
767 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); 790 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]);
768 #endif // V8_HOST_ARCH 791 #endif // V8_HOST_ARCH
769 #else // OpenBSD 792 #else // OpenBSD
770 #if V8_HOST_ARCH_IA32 793 #if V8_HOST_ARCH_IA32
771 sample->pc = reinterpret_cast<Address>(ucontext->sc_eip); 794 sample->pc = reinterpret_cast<Address>(ucontext->sc_eip);
772 sample->sp = reinterpret_cast<Address>(ucontext->sc_esp); 795 sample->sp = reinterpret_cast<Address>(ucontext->sc_esp);
773 sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp); 796 sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp);
774 #elif V8_HOST_ARCH_X64 797 #elif V8_HOST_ARCH_X64
775 sample->pc = reinterpret_cast<Address>(ucontext->sc_rip); 798 sample->pc = reinterpret_cast<Address>(ucontext->sc_rip);
776 sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp); 799 sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp);
777 sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp); 800 sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp);
778 #endif // V8_HOST_ARCH 801 #endif // V8_HOST_ARCH
779 #endif // __NetBSD__ 802 #endif // __NetBSD__
803 #endif // USE_SIMULATOR
780 sampler->SampleStack(sample); 804 sampler->SampleStack(sample);
781 sampler->Tick(sample); 805 sampler->Tick(sample);
782 } 806 }
783 807
784 808
785 class Sampler::PlatformData : public Malloced { 809 class Sampler::PlatformData : public Malloced {
786 public: 810 public:
787 PlatformData() : vm_tid_(GetThreadID()) {} 811 PlatformData() : vm_tid_(GetThreadID()) {}
788 812
789 pthread_t vm_tid() const { return vm_tid_; } 813 pthread_t vm_tid() const { return vm_tid_; }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 973
950 974
951 void Sampler::Stop() { 975 void Sampler::Stop() {
952 ASSERT(IsActive()); 976 ASSERT(IsActive());
953 SignalSender::RemoveActiveSampler(this); 977 SignalSender::RemoveActiveSampler(this);
954 SetActive(false); 978 SetActive(false);
955 } 979 }
956 980
957 981
958 } } // namespace v8::internal 982 } } // namespace v8::internal
OLDNEW
« src/platform-freebsd.cc ('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