OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "sampler.h" | 28 #include "sampler.h" |
29 | 29 |
30 #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) \ | 30 #if V8_OS_POSIX && !V8_OS_CYGWIN |
31 || defined(__NetBSD__) || defined(__sun) || defined(__ANDROID__) \ | |
32 || defined(__native_client__) || defined(__MACH__) | |
33 | 31 |
34 #define USE_SIGNALS | 32 #define USE_SIGNALS |
35 | 33 |
36 #include <errno.h> | 34 #include <errno.h> |
37 #include <pthread.h> | 35 #include <pthread.h> |
38 #include <signal.h> | 36 #include <signal.h> |
39 #include <sys/time.h> | 37 #include <sys/time.h> |
40 #include <sys/syscall.h> | 38 #include <sys/syscall.h> |
41 | 39 |
42 #if defined(__MACH__) | 40 #if V8_OS_MACOSX |
43 #include <mach/mach.h> | 41 #include <mach/mach.h> |
44 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h> | 42 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h> |
45 // and is a typedef for struct sigcontext. There is no uc_mcontext. | 43 // and is a typedef for struct sigcontext. There is no uc_mcontext. |
46 #elif(!defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T)) \ | 44 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) \ |
47 && !defined(__OpenBSD__) | 45 && !V8_OS_OPENBSD |
48 #include <ucontext.h> | 46 #include <ucontext.h> |
49 #endif | 47 #endif |
50 #include <unistd.h> | 48 #include <unistd.h> |
51 | 49 |
52 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. | 50 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. |
53 // Old versions of the C library <signal.h> didn't define the type. | 51 // Old versions of the C library <signal.h> didn't define the type. |
54 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | 52 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ |
55 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 53 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |
56 #include <asm/sigcontext.h> | 54 #include <asm/sigcontext.h> |
57 #endif | 55 #endif |
58 | 56 |
59 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) | 57 #elif V8_OS_WIN || V8_OS_CYGWIN |
60 | 58 |
61 #include "win32-headers.h" | 59 #include "win32-headers.h" |
62 | 60 |
63 #endif | 61 #endif |
64 | 62 |
65 #include "v8.h" | 63 #include "v8.h" |
66 | 64 |
67 #include "cpu-profiler-inl.h" | 65 #include "cpu-profiler-inl.h" |
68 #include "flags.h" | 66 #include "flags.h" |
69 #include "frames-inl.h" | 67 #include "frames-inl.h" |
70 #include "log.h" | 68 #include "log.h" |
71 #include "platform.h" | 69 #include "platform.h" |
72 #include "simulator.h" | 70 #include "simulator.h" |
73 #include "v8threads.h" | 71 #include "v8threads.h" |
74 #include "vm-state-inl.h" | 72 #include "vm-state-inl.h" |
75 | 73 |
76 | 74 |
77 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) | 75 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) |
78 | 76 |
79 // Not all versions of Android's C library provide ucontext_t. | 77 // Not all versions of Android's C library provide ucontext_t. |
80 // Detect this and provide custom but compatible definitions. Note that these | 78 // Detect this and provide custom but compatible definitions. Note that these |
81 // follow the GLibc naming convention to access register values from | 79 // follow the GLibc naming convention to access register values from |
82 // mcontext_t. | 80 // mcontext_t. |
83 // | 81 // |
84 // See http://code.google.com/p/android/issues/detail?id=34784 | 82 // See http://code.google.com/p/android/issues/detail?id=34784 |
85 | 83 |
86 #if defined(__arm__) | 84 #if defined(__arm__) |
87 | 85 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 typedef struct ucontext { | 137 typedef struct ucontext { |
140 uint32_t uc_flags; | 138 uint32_t uc_flags; |
141 struct ucontext* uc_link; | 139 struct ucontext* uc_link; |
142 stack_t uc_stack; | 140 stack_t uc_stack; |
143 mcontext_t uc_mcontext; | 141 mcontext_t uc_mcontext; |
144 // Other fields are not used by V8, don't define them here. | 142 // Other fields are not used by V8, don't define them here. |
145 } ucontext_t; | 143 } ucontext_t; |
146 enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 }; | 144 enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 }; |
147 #endif | 145 #endif |
148 | 146 |
149 #endif // __ANDROID__ && !defined(__BIONIC_HAVE_UCONTEXT_T) | 147 #endif // V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) |
150 | 148 |
151 | 149 |
152 namespace v8 { | 150 namespace v8 { |
153 namespace internal { | 151 namespace internal { |
154 | 152 |
155 namespace { | 153 namespace { |
156 | 154 |
157 class PlatformDataCommon : public Malloced { | 155 class PlatformDataCommon : public Malloced { |
158 public: | 156 public: |
159 PlatformDataCommon() : profiled_thread_id_(ThreadId::Current()) {} | 157 PlatformDataCommon() : profiled_thread_id_(ThreadId::Current()) {} |
(...skipping 12 matching lines...) Expand all Loading... |
172 | 170 |
173 class Sampler::PlatformData : public PlatformDataCommon { | 171 class Sampler::PlatformData : public PlatformDataCommon { |
174 public: | 172 public: |
175 PlatformData() : vm_tid_(pthread_self()) {} | 173 PlatformData() : vm_tid_(pthread_self()) {} |
176 pthread_t vm_tid() const { return vm_tid_; } | 174 pthread_t vm_tid() const { return vm_tid_; } |
177 | 175 |
178 private: | 176 private: |
179 pthread_t vm_tid_; | 177 pthread_t vm_tid_; |
180 }; | 178 }; |
181 | 179 |
182 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) | 180 #elif V8_OS_WIN || V8_OS_CYGWIN |
183 | 181 |
184 // ---------------------------------------------------------------------------- | 182 // ---------------------------------------------------------------------------- |
185 // Win32 profiler support. On Cygwin we use the same sampler implementation as | 183 // Win32 profiler support. On Cygwin we use the same sampler implementation as |
186 // on Win32. | 184 // on Win32. |
187 | 185 |
188 class Sampler::PlatformData : public PlatformDataCommon { | 186 class Sampler::PlatformData : public PlatformDataCommon { |
189 public: | 187 public: |
190 // Get a handle to the calling thread. This is the thread that we are | 188 // Get a handle to the calling thread. This is the thread that we are |
191 // going to profile. We need to make a copy of the handle because we are | 189 // going to profile. We need to make a copy of the handle because we are |
192 // going to use it in the sampler thread. Using GetThreadHandle() will | 190 // going to use it in the sampler thread. Using GetThreadHandle() will |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 static bool signal_handler_installed_; | 274 static bool signal_handler_installed_; |
277 static struct sigaction old_signal_handler_; | 275 static struct sigaction old_signal_handler_; |
278 }; | 276 }; |
279 | 277 |
280 struct sigaction SignalHandler::old_signal_handler_; | 278 struct sigaction SignalHandler::old_signal_handler_; |
281 bool SignalHandler::signal_handler_installed_ = false; | 279 bool SignalHandler::signal_handler_installed_ = false; |
282 | 280 |
283 | 281 |
284 void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info, | 282 void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info, |
285 void* context) { | 283 void* context) { |
286 #if defined(__native_client__) | 284 #if V8_OS_NACL |
287 // As Native Client does not support signal handling, profiling | 285 // As Native Client does not support signal handling, profiling |
288 // is disabled. | 286 // is disabled. |
289 return; | 287 return; |
290 #else | 288 #else |
291 USE(info); | 289 USE(info); |
292 if (signal != SIGPROF) return; | 290 if (signal != SIGPROF) return; |
293 Isolate* isolate = Isolate::UncheckedCurrent(); | 291 Isolate* isolate = Isolate::UncheckedCurrent(); |
294 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { | 292 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { |
295 // We require a fully initialized and entered isolate. | 293 // We require a fully initialized and entered isolate. |
296 return; | 294 return; |
297 } | 295 } |
298 if (v8::Locker::IsActive() && | 296 if (v8::Locker::IsActive() && |
299 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 297 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
300 return; | 298 return; |
301 } | 299 } |
302 | 300 |
303 Sampler* sampler = isolate->logger()->sampler(); | 301 Sampler* sampler = isolate->logger()->sampler(); |
304 if (sampler == NULL || !sampler->IsActive()) return; | 302 if (sampler == NULL || !sampler->IsActive()) return; |
305 | 303 |
306 RegisterState state; | 304 RegisterState state; |
307 | 305 |
308 #if defined(USE_SIMULATOR) | 306 #if defined(USE_SIMULATOR) |
309 SimulatorHelper helper; | 307 SimulatorHelper helper; |
310 if (!helper.Init(sampler, isolate)) return; | 308 if (!helper.Init(sampler, isolate)) return; |
311 helper.FillRegisters(&state); | 309 helper.FillRegisters(&state); |
312 #else | 310 #else |
313 // Extracting the sample from the context is extremely machine dependent. | 311 // Extracting the sample from the context is extremely machine dependent. |
314 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 312 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
315 #if !defined(__OpenBSD__) | 313 #if !V8_OS_OPENBSD |
316 mcontext_t& mcontext = ucontext->uc_mcontext; | 314 mcontext_t& mcontext = ucontext->uc_mcontext; |
317 #endif | 315 #endif |
318 #if defined(__linux__) || defined(__ANDROID__) | 316 #if V8_OS_LINUX |
319 #if V8_HOST_ARCH_IA32 | 317 #if V8_HOST_ARCH_IA32 |
320 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 318 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
321 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 319 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
322 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 320 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
323 #elif V8_HOST_ARCH_X64 | 321 #elif V8_HOST_ARCH_X64 |
324 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); | 322 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
325 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); | 323 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
326 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); | 324 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); |
327 #elif V8_HOST_ARCH_ARM | 325 #elif V8_HOST_ARCH_ARM |
328 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \ | 326 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \ |
329 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 327 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
330 // Old GLibc ARM versions used a gregs[] array to access the register | 328 // Old GLibc ARM versions used a gregs[] array to access the register |
331 // values from mcontext_t. | 329 // values from mcontext_t. |
332 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 330 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
333 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 331 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
334 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 332 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
335 #else | 333 #else |
336 state.pc = reinterpret_cast<Address>(mcontext.arm_pc); | 334 state.pc = reinterpret_cast<Address>(mcontext.arm_pc); |
337 state.sp = reinterpret_cast<Address>(mcontext.arm_sp); | 335 state.sp = reinterpret_cast<Address>(mcontext.arm_sp); |
338 state.fp = reinterpret_cast<Address>(mcontext.arm_fp); | 336 state.fp = reinterpret_cast<Address>(mcontext.arm_fp); |
339 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && | 337 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && |
340 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 338 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
341 #elif V8_HOST_ARCH_MIPS | 339 #elif V8_HOST_ARCH_MIPS |
342 state.pc = reinterpret_cast<Address>(mcontext.pc); | 340 state.pc = reinterpret_cast<Address>(mcontext.pc); |
343 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 341 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
344 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 342 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
345 #endif // V8_HOST_ARCH_* | 343 #endif // V8_HOST_ARCH_* |
346 #elif defined(__MACH__) | 344 #elif V8_OS_MACOSX |
347 #if V8_HOST_ARCH_X64 | 345 #if V8_HOST_ARCH_X64 |
348 #if __DARWIN_UNIX03 | 346 #if __DARWIN_UNIX03 |
349 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); | 347 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); |
350 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); | 348 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); |
351 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); | 349 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); |
352 #else // !__DARWIN_UNIX03 | 350 #else // !__DARWIN_UNIX03 |
353 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); | 351 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); |
354 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); | 352 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); |
355 state.fp = reinterpret_cast<Address>(mcontext->ss.rbp); | 353 state.fp = reinterpret_cast<Address>(mcontext->ss.rbp); |
356 #endif // __DARWIN_UNIX03 | 354 #endif // __DARWIN_UNIX03 |
357 #elif V8_HOST_ARCH_IA32 | 355 #elif V8_HOST_ARCH_IA32 |
358 #if __DARWIN_UNIX03 | 356 #if __DARWIN_UNIX03 |
359 state.pc = reinterpret_cast<Address>(mcontext->__ss.__eip); | 357 state.pc = reinterpret_cast<Address>(mcontext->__ss.__eip); |
360 state.sp = reinterpret_cast<Address>(mcontext->__ss.__esp); | 358 state.sp = reinterpret_cast<Address>(mcontext->__ss.__esp); |
361 state.fp = reinterpret_cast<Address>(mcontext->__ss.__ebp); | 359 state.fp = reinterpret_cast<Address>(mcontext->__ss.__ebp); |
362 #else // !__DARWIN_UNIX03 | 360 #else // !__DARWIN_UNIX03 |
363 state.pc = reinterpret_cast<Address>(mcontext->ss.eip); | 361 state.pc = reinterpret_cast<Address>(mcontext->ss.eip); |
364 state.sp = reinterpret_cast<Address>(mcontext->ss.esp); | 362 state.sp = reinterpret_cast<Address>(mcontext->ss.esp); |
365 state.fp = reinterpret_cast<Address>(mcontext->ss.ebp); | 363 state.fp = reinterpret_cast<Address>(mcontext->ss.ebp); |
366 #endif // __DARWIN_UNIX03 | 364 #endif // __DARWIN_UNIX03 |
367 #endif // V8_HOST_ARCH_IA32 | 365 #endif // V8_HOST_ARCH_IA32 |
368 #elif defined(__FreeBSD__) | 366 #elif V8_OS_FREEBSD |
369 #if V8_HOST_ARCH_IA32 | 367 #if V8_HOST_ARCH_IA32 |
370 state.pc = reinterpret_cast<Address>(mcontext.mc_eip); | 368 state.pc = reinterpret_cast<Address>(mcontext.mc_eip); |
371 state.sp = reinterpret_cast<Address>(mcontext.mc_esp); | 369 state.sp = reinterpret_cast<Address>(mcontext.mc_esp); |
372 state.fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 370 state.fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
373 #elif V8_HOST_ARCH_X64 | 371 #elif V8_HOST_ARCH_X64 |
374 state.pc = reinterpret_cast<Address>(mcontext.mc_rip); | 372 state.pc = reinterpret_cast<Address>(mcontext.mc_rip); |
375 state.sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 373 state.sp = reinterpret_cast<Address>(mcontext.mc_rsp); |
376 state.fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 374 state.fp = reinterpret_cast<Address>(mcontext.mc_rbp); |
377 #elif V8_HOST_ARCH_ARM | 375 #elif V8_HOST_ARCH_ARM |
378 state.pc = reinterpret_cast<Address>(mcontext.mc_r15); | 376 state.pc = reinterpret_cast<Address>(mcontext.mc_r15); |
379 state.sp = reinterpret_cast<Address>(mcontext.mc_r13); | 377 state.sp = reinterpret_cast<Address>(mcontext.mc_r13); |
380 state.fp = reinterpret_cast<Address>(mcontext.mc_r11); | 378 state.fp = reinterpret_cast<Address>(mcontext.mc_r11); |
381 #endif // V8_HOST_ARCH_* | 379 #endif // V8_HOST_ARCH_* |
382 #elif defined(__NetBSD__) | 380 #elif V8_OS_NETBSD |
383 #if V8_HOST_ARCH_IA32 | 381 #if V8_HOST_ARCH_IA32 |
384 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); | 382 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); |
385 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); | 383 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); |
386 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); | 384 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); |
387 #elif V8_HOST_ARCH_X64 | 385 #elif V8_HOST_ARCH_X64 |
388 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); | 386 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); |
389 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); | 387 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); |
390 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); | 388 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); |
391 #endif // V8_HOST_ARCH_* | 389 #endif // V8_HOST_ARCH_* |
392 #elif defined(__OpenBSD__) | 390 #elif V8_OS_OPENBSD |
393 #if V8_HOST_ARCH_IA32 | 391 #if V8_HOST_ARCH_IA32 |
394 state.pc = reinterpret_cast<Address>(ucontext->sc_eip); | 392 state.pc = reinterpret_cast<Address>(ucontext->sc_eip); |
395 state.sp = reinterpret_cast<Address>(ucontext->sc_esp); | 393 state.sp = reinterpret_cast<Address>(ucontext->sc_esp); |
396 state.fp = reinterpret_cast<Address>(ucontext->sc_ebp); | 394 state.fp = reinterpret_cast<Address>(ucontext->sc_ebp); |
397 #elif V8_HOST_ARCH_X64 | 395 #elif V8_HOST_ARCH_X64 |
398 state.pc = reinterpret_cast<Address>(ucontext->sc_rip); | 396 state.pc = reinterpret_cast<Address>(ucontext->sc_rip); |
399 state.sp = reinterpret_cast<Address>(ucontext->sc_rsp); | 397 state.sp = reinterpret_cast<Address>(ucontext->sc_rsp); |
400 state.fp = reinterpret_cast<Address>(ucontext->sc_rbp); | 398 state.fp = reinterpret_cast<Address>(ucontext->sc_rbp); |
401 #endif // V8_HOST_ARCH_* | 399 #endif // V8_HOST_ARCH_* |
402 #elif defined(__sun) | 400 #elif V8_OS_SOLARIS |
403 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); | 401 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); |
404 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); | 402 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); |
405 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); | 403 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); |
406 #endif // __sun | 404 #endif // V8_OS_SOLARIS |
407 #endif // USE_SIMULATOR | 405 #endif // USE_SIMULATOR |
408 sampler->SampleStack(state); | 406 sampler->SampleStack(state); |
409 #endif // __native_client__ | 407 #endif // V8_OS_NACL |
410 } | 408 } |
411 | 409 |
412 #endif | 410 #endif |
413 | 411 |
414 | 412 |
415 class SamplerThread : public Thread { | 413 class SamplerThread : public Thread { |
416 public: | 414 public: |
417 static const int kSamplerThreadStackSize = 64 * KB; | 415 static const int kSamplerThreadStackSize = 64 * KB; |
418 | 416 |
419 explicit SamplerThread(int interval) | 417 explicit SamplerThread(int interval) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 615 } |
618 | 616 |
619 | 617 |
620 #if defined(USE_SIGNALS) | 618 #if defined(USE_SIGNALS) |
621 | 619 |
622 void Sampler::DoSample() { | 620 void Sampler::DoSample() { |
623 if (!SignalHandler::Installed()) return; | 621 if (!SignalHandler::Installed()) return; |
624 pthread_kill(platform_data()->vm_tid(), SIGPROF); | 622 pthread_kill(platform_data()->vm_tid(), SIGPROF); |
625 } | 623 } |
626 | 624 |
627 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) | 625 #elif V8_OS_WIN || V8_OS_CYGWIN |
628 | 626 |
629 void Sampler::DoSample() { | 627 void Sampler::DoSample() { |
630 HANDLE profiled_thread = platform_data()->profiled_thread(); | 628 HANDLE profiled_thread = platform_data()->profiled_thread(); |
631 if (profiled_thread == NULL) return; | 629 if (profiled_thread == NULL) return; |
632 | 630 |
633 #if defined(USE_SIMULATOR) | 631 #if defined(USE_SIMULATOR) |
634 SimulatorHelper helper; | 632 SimulatorHelper helper; |
635 if (!helper.Init(this, isolate())) return; | 633 if (!helper.Init(this, isolate())) return; |
636 #endif | 634 #endif |
637 | 635 |
(...skipping 21 matching lines...) Expand all Loading... |
659 #endif // USE_SIMULATOR | 657 #endif // USE_SIMULATOR |
660 SampleStack(state); | 658 SampleStack(state); |
661 } | 659 } |
662 ResumeThread(profiled_thread); | 660 ResumeThread(profiled_thread); |
663 } | 661 } |
664 | 662 |
665 #endif // USE_SIGNALS | 663 #endif // USE_SIGNALS |
666 | 664 |
667 | 665 |
668 } } // namespace v8::internal | 666 } } // namespace v8::internal |
OLD | NEW |