| OLD | NEW |
| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include <signal.h> // sigemptyset(), etc | 47 #include <signal.h> // sigemptyset(), etc |
| 48 #include <sys/regset.h> | 48 #include <sys/regset.h> |
| 49 | 49 |
| 50 | 50 |
| 51 #undef MAP_TYPE | 51 #undef MAP_TYPE |
| 52 | 52 |
| 53 #include "v8.h" | 53 #include "v8.h" |
| 54 | 54 |
| 55 #include "platform-posix.h" | 55 #include "platform-posix.h" |
| 56 #include "platform.h" | 56 #include "platform.h" |
| 57 #include "simulator.h" |
| 57 #include "v8threads.h" | 58 #include "v8threads.h" |
| 58 #include "vm-state-inl.h" | 59 #include "vm-state-inl.h" |
| 59 | 60 |
| 60 | 61 |
| 61 // It seems there is a bug in some Solaris distributions (experienced in | 62 // It seems there is a bug in some Solaris distributions (experienced in |
| 62 // SunOS 5.10 Generic_141445-09) which make it difficult or impossible to | 63 // SunOS 5.10 Generic_141445-09) which make it difficult or impossible to |
| 63 // access signbit() despite the availability of other C99 math functions. | 64 // access signbit() despite the availability of other C99 math functions. |
| 64 #ifndef signbit | 65 #ifndef signbit |
| 65 // Test sign - usually defined in math.h | 66 // Test sign - usually defined in math.h |
| 66 int signbit(double x) { | 67 int signbit(double x) { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 return; | 680 return; |
| 680 } | 681 } |
| 681 | 682 |
| 682 Sampler* sampler = isolate->logger()->sampler(); | 683 Sampler* sampler = isolate->logger()->sampler(); |
| 683 if (sampler == NULL || !sampler->IsActive()) return; | 684 if (sampler == NULL || !sampler->IsActive()) return; |
| 684 | 685 |
| 685 TickSample sample_obj; | 686 TickSample sample_obj; |
| 686 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 687 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
| 687 if (sample == NULL) sample = &sample_obj; | 688 if (sample == NULL) sample = &sample_obj; |
| 688 | 689 |
| 690 #if defined(USE_SIMULATOR) |
| 691 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS |
| 692 Isolate::PerIsolateThreadData* per_thread_data = |
| 693 isolate->FindPerThreadDataForThisThread(); |
| 694 if (!per_thread_data) return; |
| 695 Simulator* sim = per_thread_data->simulator(); |
| 696 // Check if there is active simulator before allocating TickSample. |
| 697 if (!sim) return; |
| 698 #endif |
| 699 #endif // USE_SIMULATOR |
| 700 |
| 689 // Extracting the sample from the context is extremely machine dependent. | 701 // Extracting the sample from the context is extremely machine dependent. |
| 690 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 702 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 691 mcontext_t& mcontext = ucontext->uc_mcontext; | 703 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 692 sample->state = isolate->current_vm_state(); | 704 sample->state = isolate->current_vm_state(); |
| 693 | 705 |
| 706 #if defined(USE_SIMULATOR) |
| 707 #if V8_TARGET_ARCH_ARM |
| 708 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); |
| 709 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
| 710 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); |
| 711 #elif V8_TARGET_ARCH_MIPS |
| 712 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); |
| 713 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
| 714 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); |
| 715 #endif |
| 716 #else |
| 694 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); | 717 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); |
| 695 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); | 718 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); |
| 696 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); | 719 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); |
| 720 #endif // USE_SIMULATOR |
| 697 | 721 |
| 698 sampler->SampleStack(sample); | 722 sampler->SampleStack(sample); |
| 699 sampler->Tick(sample); | 723 sampler->Tick(sample); |
| 700 } | 724 } |
| 701 | 725 |
| 702 class Sampler::PlatformData : public Malloced { | 726 class Sampler::PlatformData : public Malloced { |
| 703 public: | 727 public: |
| 704 PlatformData() : vm_tid_(GetThreadID()) {} | 728 PlatformData() : vm_tid_(GetThreadID()) {} |
| 705 | 729 |
| 706 pthread_t vm_tid() const { return vm_tid_; } | 730 pthread_t vm_tid() const { return vm_tid_; } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 } | 890 } |
| 867 | 891 |
| 868 | 892 |
| 869 void Sampler::Stop() { | 893 void Sampler::Stop() { |
| 870 ASSERT(IsActive()); | 894 ASSERT(IsActive()); |
| 871 SignalSender::RemoveActiveSampler(this); | 895 SignalSender::RemoveActiveSampler(this); |
| 872 SetActive(false); | 896 SetActive(false); |
| 873 } | 897 } |
| 874 | 898 |
| 875 } } // namespace v8::internal | 899 } } // namespace v8::internal |
| OLD | NEW |