OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 mcontext_t uc_mcontext; | 796 mcontext_t uc_mcontext; |
797 __sigset_t uc_sigmask; | 797 __sigset_t uc_sigmask; |
798 } ucontext_t; | 798 } ucontext_t; |
799 enum ArmRegisters {R15 = 15, R13 = 13, R11 = 11}; | 799 enum ArmRegisters {R15 = 15, R13 = 13, R11 = 11}; |
800 | 800 |
801 #endif | 801 #endif |
802 | 802 |
803 | 803 |
804 static int GetThreadID() { | 804 static int GetThreadID() { |
805 // Glibc doesn't provide a wrapper for gettid(2). | 805 // Glibc doesn't provide a wrapper for gettid(2). |
| 806 #if defined(ANDROID) |
| 807 return syscall(__NR_gettid); |
| 808 #else |
806 return syscall(SYS_gettid); | 809 return syscall(SYS_gettid); |
| 810 #endif |
807 } | 811 } |
808 | 812 |
809 | 813 |
810 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { | 814 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
811 #ifndef V8_HOST_ARCH_MIPS | 815 #ifndef V8_HOST_ARCH_MIPS |
812 USE(info); | 816 USE(info); |
813 if (signal != SIGPROF) return; | 817 if (signal != SIGPROF) return; |
814 Isolate* isolate = Isolate::UncheckedCurrent(); | 818 Isolate* isolate = Isolate::UncheckedCurrent(); |
815 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { | 819 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { |
816 // We require a fully initialized and entered isolate. | 820 // We require a fully initialized and entered isolate. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 } | 964 } |
961 | 965 |
962 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { | 966 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { |
963 if (!sampler->isolate()->IsInitialized()) return; | 967 if (!sampler->isolate()->IsInitialized()) return; |
964 sampler->isolate()->runtime_profiler()->NotifyTick(); | 968 sampler->isolate()->runtime_profiler()->NotifyTick(); |
965 } | 969 } |
966 | 970 |
967 void SendProfilingSignal(int tid) { | 971 void SendProfilingSignal(int tid) { |
968 if (!signal_handler_installed_) return; | 972 if (!signal_handler_installed_) return; |
969 // Glibc doesn't provide a wrapper for tgkill(2). | 973 // Glibc doesn't provide a wrapper for tgkill(2). |
| 974 #if defined(ANDROID) |
| 975 syscall(__NR_tgkill, vm_tgid_, tid, SIGPROF); |
| 976 #else |
970 syscall(SYS_tgkill, vm_tgid_, tid, SIGPROF); | 977 syscall(SYS_tgkill, vm_tgid_, tid, SIGPROF); |
| 978 #endif |
971 } | 979 } |
972 | 980 |
973 void Sleep(SleepInterval full_or_half) { | 981 void Sleep(SleepInterval full_or_half) { |
974 // Convert ms to us and subtract 100 us to compensate delays | 982 // Convert ms to us and subtract 100 us to compensate delays |
975 // occuring during signal delivery. | 983 // occuring during signal delivery. |
976 useconds_t interval = interval_ * 1000 - 100; | 984 useconds_t interval = interval_ * 1000 - 100; |
977 if (full_or_half == HALF_INTERVAL) interval /= 2; | 985 if (full_or_half == HALF_INTERVAL) interval /= 2; |
978 int result = usleep(interval); | 986 int result = usleep(interval); |
979 #ifdef DEBUG | 987 #ifdef DEBUG |
980 if (result != 0 && errno != EINTR) { | 988 if (result != 0 && errno != EINTR) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 | 1041 |
1034 void Sampler::Stop() { | 1042 void Sampler::Stop() { |
1035 ASSERT(IsActive()); | 1043 ASSERT(IsActive()); |
1036 SignalSender::RemoveActiveSampler(this); | 1044 SignalSender::RemoveActiveSampler(this); |
1037 SetActive(false); | 1045 SetActive(false); |
1038 } | 1046 } |
1039 | 1047 |
1040 #endif // ENABLE_LOGGING_AND_PROFILING | 1048 #endif // ENABLE_LOGGING_AND_PROFILING |
1041 | 1049 |
1042 } } // namespace v8::internal | 1050 } } // namespace v8::internal |
OLD | NEW |