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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 typedef uint32_t __sigset_t; | 957 typedef uint32_t __sigset_t; |
958 typedef struct sigcontext mcontext_t; | 958 typedef struct sigcontext mcontext_t; |
959 typedef struct ucontext { | 959 typedef struct ucontext { |
960 uint32_t uc_flags; | 960 uint32_t uc_flags; |
961 struct ucontext* uc_link; | 961 struct ucontext* uc_link; |
962 stack_t uc_stack; | 962 stack_t uc_stack; |
963 mcontext_t uc_mcontext; | 963 mcontext_t uc_mcontext; |
964 __sigset_t uc_sigmask; | 964 __sigset_t uc_sigmask; |
965 } ucontext_t; | 965 } ucontext_t; |
966 | 966 |
| 967 #elif !defined(__GLIBC__) && defined(__i386__) |
| 968 // x86 version for Android. |
| 969 struct _libc_fpreg { |
| 970 uint16_t significand[4]; |
| 971 uint16_t exponent; |
| 972 }; |
| 973 |
| 974 struct _libc_fpstate { |
| 975 uint64_t cw; |
| 976 uint64_t sw; |
| 977 uint64_t tag; |
| 978 uint64_t ipoff; |
| 979 uint64_t cssel; |
| 980 uint64_t dataoff; |
| 981 uint64_t datasel; |
| 982 struct _libc_fpreg _st[8]; |
| 983 uint64_t status; |
| 984 }; |
| 985 |
| 986 typedef struct _libc_fpstate *fpregset_t; |
| 987 |
| 988 typedef struct mcontext { |
| 989 int32_t gregs[19]; |
| 990 fpregset_t fpregs; |
| 991 int64_t oldmask; |
| 992 int64_t cr2; |
| 993 } mcontext_t; |
| 994 |
| 995 typedef uint64_t __sigset_t; |
| 996 |
| 997 typedef struct ucontext { |
| 998 uint64_t uc_flags; |
| 999 struct ucontext *uc_link; |
| 1000 stack_t uc_stack; |
| 1001 mcontext_t uc_mcontext; |
| 1002 __sigset_t uc_sigmask; |
| 1003 struct _libc_fpstate __fpregs_mem; |
| 1004 } ucontext_t; |
| 1005 |
| 1006 enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 }; |
967 #endif | 1007 #endif |
968 | 1008 |
969 | 1009 |
970 static int GetThreadID() { | 1010 static int GetThreadID() { |
971 // Glibc doesn't provide a wrapper for gettid(2). | 1011 // Glibc doesn't provide a wrapper for gettid(2). |
972 #if defined(ANDROID) | 1012 #if defined(ANDROID) |
973 return syscall(__NR_gettid); | 1013 return syscall(__NR_gettid); |
974 #else | 1014 #else |
975 return syscall(SYS_gettid); | 1015 return syscall(SYS_gettid); |
976 #endif | 1016 #endif |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 FULL_INTERVAL | 1088 FULL_INTERVAL |
1049 }; | 1089 }; |
1050 | 1090 |
1051 static const int kSignalSenderStackSize = 64 * KB; | 1091 static const int kSignalSenderStackSize = 64 * KB; |
1052 | 1092 |
1053 explicit SignalSender(int interval) | 1093 explicit SignalSender(int interval) |
1054 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), | 1094 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), |
1055 vm_tgid_(getpid()), | 1095 vm_tgid_(getpid()), |
1056 interval_(interval) {} | 1096 interval_(interval) {} |
1057 | 1097 |
1058 static void SetUp() { | 1098 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } |
1059 if (!mutex_) { | 1099 static void TearDown() { delete mutex_; } |
1060 mutex_ = OS::CreateMutex(); | |
1061 } | |
1062 } | |
1063 | 1100 |
1064 static void InstallSignalHandler() { | 1101 static void InstallSignalHandler() { |
1065 struct sigaction sa; | 1102 struct sigaction sa; |
1066 sa.sa_sigaction = ProfilerSignalHandler; | 1103 sa.sa_sigaction = ProfilerSignalHandler; |
1067 sigemptyset(&sa.sa_mask); | 1104 sigemptyset(&sa.sa_mask); |
1068 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 1105 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
1069 signal_handler_installed_ = | 1106 signal_handler_installed_ = |
1070 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 1107 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
1071 } | 1108 } |
1072 | 1109 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 PrintF("ERROR: Binary not compiled with -mfloat-abi=hard but with " | 1268 PrintF("ERROR: Binary not compiled with -mfloat-abi=hard but with " |
1232 "-DUSE_EABI_HARDFLOAT\n"); | 1269 "-DUSE_EABI_HARDFLOAT\n"); |
1233 exit(1); | 1270 exit(1); |
1234 #endif | 1271 #endif |
1235 } | 1272 } |
1236 #endif | 1273 #endif |
1237 SignalSender::SetUp(); | 1274 SignalSender::SetUp(); |
1238 } | 1275 } |
1239 | 1276 |
1240 | 1277 |
| 1278 void OS::TearDown() { |
| 1279 SignalSender::TearDown(); |
| 1280 delete limit_mutex; |
| 1281 } |
| 1282 |
| 1283 |
1241 Sampler::Sampler(Isolate* isolate, int interval) | 1284 Sampler::Sampler(Isolate* isolate, int interval) |
1242 : isolate_(isolate), | 1285 : isolate_(isolate), |
1243 interval_(interval), | 1286 interval_(interval), |
1244 profiling_(false), | 1287 profiling_(false), |
1245 active_(false), | 1288 active_(false), |
1246 samples_taken_(0) { | 1289 samples_taken_(0) { |
1247 data_ = new PlatformData; | 1290 data_ = new PlatformData; |
1248 } | 1291 } |
1249 | 1292 |
1250 | 1293 |
(...skipping 11 matching lines...) Expand all Loading... |
1262 | 1305 |
1263 | 1306 |
1264 void Sampler::Stop() { | 1307 void Sampler::Stop() { |
1265 ASSERT(IsActive()); | 1308 ASSERT(IsActive()); |
1266 SignalSender::RemoveActiveSampler(this); | 1309 SignalSender::RemoveActiveSampler(this); |
1267 SetActive(false); | 1310 SetActive(false); |
1268 } | 1311 } |
1269 | 1312 |
1270 | 1313 |
1271 } } // namespace v8::internal | 1314 } } // namespace v8::internal |
OLD | NEW |