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

Side by Side Diff: src/sampler.cc

Issue 20734002: Implement correct OS and CC detection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reverted changes to atomicops*.h Created 7 years, 4 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
« no previous file with comments | « src/preparser.cc ('k') | src/snapshot-common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_DARWIN
31 || defined(__NetBSD__) || defined(__sun) || defined(__ANDROID__) \ 31
32 || defined(__native_client__) 32 #include <mach/mach.h>
33
34 #elif V8_OS_UNIX && !V8_OS_CYGWIN
33 35
34 #define USE_SIGNALS 36 #define USE_SIGNALS
35 37
36 #include <errno.h> 38 #include <errno.h>
37 #include <pthread.h> 39 #include <pthread.h>
38 #include <signal.h> 40 #include <signal.h>
39 #include <sys/time.h> 41 #include <sys/time.h>
40 #include <sys/syscall.h> 42 #include <sys/syscall.h>
41 #if !defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T) 43 #if !V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)
42 #include <ucontext.h> 44 #include <ucontext.h>
43 #endif 45 #endif
44 #include <unistd.h> 46 #include <unistd.h>
45 47
46 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. 48 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
47 // Old versions of the C library <signal.h> didn't define the type. 49 // Old versions of the C library <signal.h> didn't define the type.
48 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ 50 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
49 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) 51 V8_HOST_ARCH_ARM && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
50 #include <asm/sigcontext.h> 52 #include <asm/sigcontext.h>
51 #endif 53 #endif
52 54
53 #elif defined(__MACH__) 55 #elif V8_OS_CYGWIN || V8_OS_WIN32
54
55 #include <mach/mach.h>
56
57 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
58 56
59 #include "win32-headers.h" 57 #include "win32-headers.h"
60 58
61 #endif 59 #endif
62 60
63 #include "v8.h" 61 #include "v8.h"
64 62
65 #include "cpu-profiler.h" 63 #include "cpu-profiler.h"
66 #include "flags.h" 64 #include "flags.h"
67 #include "frames-inl.h" 65 #include "frames-inl.h"
68 #include "log.h" 66 #include "log.h"
69 #include "platform.h" 67 #include "platform.h"
70 #include "simulator.h" 68 #include "simulator.h"
71 #include "v8threads.h" 69 #include "v8threads.h"
72 #include "vm-state-inl.h" 70 #include "vm-state-inl.h"
73 71
74 72
75 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) 73 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
76 74
77 // Not all versions of Android's C library provide ucontext_t. 75 // Not all versions of Android's C library provide ucontext_t.
78 // Detect this and provide custom but compatible definitions. Note that these 76 // Detect this and provide custom but compatible definitions. Note that these
79 // follow the GLibc naming convention to access register values from 77 // follow the GLibc naming convention to access register values from
80 // mcontext_t. 78 // mcontext_t.
81 // 79 //
82 // See http://code.google.com/p/android/issues/detail?id=34784 80 // See http://code.google.com/p/android/issues/detail?id=34784
83 81
84 #if defined(__arm__) 82 #if V8_HOST_ARCH_ARM
85 83
86 typedef struct sigcontext mcontext_t; 84 typedef struct sigcontext mcontext_t;
87 85
88 typedef struct ucontext { 86 typedef struct ucontext {
89 uint32_t uc_flags; 87 uint32_t uc_flags;
90 struct ucontext* uc_link; 88 struct ucontext* uc_link;
91 stack_t uc_stack; 89 stack_t uc_stack;
92 mcontext_t uc_mcontext; 90 mcontext_t uc_mcontext;
93 // Other fields are not used by V8, don't define them here. 91 // Other fields are not used by V8, don't define them here.
94 } ucontext_t; 92 } ucontext_t;
95 93
96 #elif defined(__mips__) 94 #elif V8_HOST_ARCH_MIPS
97 // MIPS version of sigcontext, for Android bionic. 95 // MIPS version of sigcontext, for Android bionic.
98 typedef struct { 96 typedef struct {
99 uint32_t regmask; 97 uint32_t regmask;
100 uint32_t status; 98 uint32_t status;
101 uint64_t pc; 99 uint64_t pc;
102 uint64_t gregs[32]; 100 uint64_t gregs[32];
103 uint64_t fpregs[32]; 101 uint64_t fpregs[32];
104 uint32_t acx; 102 uint32_t acx;
105 uint32_t fpc_csr; 103 uint32_t fpc_csr;
106 uint32_t fpc_eir; 104 uint32_t fpc_eir;
(...skipping 10 matching lines...) Expand all
117 } mcontext_t; 115 } mcontext_t;
118 116
119 typedef struct ucontext { 117 typedef struct ucontext {
120 uint32_t uc_flags; 118 uint32_t uc_flags;
121 struct ucontext* uc_link; 119 struct ucontext* uc_link;
122 stack_t uc_stack; 120 stack_t uc_stack;
123 mcontext_t uc_mcontext; 121 mcontext_t uc_mcontext;
124 // Other fields are not used by V8, don't define them here. 122 // Other fields are not used by V8, don't define them here.
125 } ucontext_t; 123 } ucontext_t;
126 124
127 #elif defined(__i386__) 125 #elif V8_HOST_ARCH_IA32
128 // x86 version for Android. 126 // x86 version for Android.
129 typedef struct { 127 typedef struct {
130 uint32_t gregs[19]; 128 uint32_t gregs[19];
131 void* fpregs; 129 void* fpregs;
132 uint32_t oldmask; 130 uint32_t oldmask;
133 uint32_t cr2; 131 uint32_t cr2;
134 } mcontext_t; 132 } mcontext_t;
135 133
136 typedef uint32_t kernel_sigset_t[2]; // x86 kernel uses 64-bit signal masks 134 typedef uint32_t kernel_sigset_t[2]; // x86 kernel uses 64-bit signal masks
137 typedef struct ucontext { 135 typedef struct ucontext {
138 uint32_t uc_flags; 136 uint32_t uc_flags;
139 struct ucontext* uc_link; 137 struct ucontext* uc_link;
140 stack_t uc_stack; 138 stack_t uc_stack;
141 mcontext_t uc_mcontext; 139 mcontext_t uc_mcontext;
142 // Other fields are not used by V8, don't define them here. 140 // Other fields are not used by V8, don't define them here.
143 } ucontext_t; 141 } ucontext_t;
144 enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 }; 142 enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 };
145 #endif 143 #endif
146 144
147 #endif // __ANDROID__ && !defined(__BIONIC_HAVE_UCONTEXT_T) 145 #endif // V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
148 146
149 147
150 namespace v8 { 148 namespace v8 {
151 namespace internal { 149 namespace internal {
152 150
153 namespace { 151 namespace {
154 152
155 class PlatformDataCommon : public Malloced { 153 class PlatformDataCommon : public Malloced {
156 public: 154 public:
157 PlatformDataCommon() : profiled_thread_id_(ThreadId::Current()) {} 155 PlatformDataCommon() : profiled_thread_id_(ThreadId::Current()) {}
(...skipping 12 matching lines...) Expand all
170 168
171 class Sampler::PlatformData : public PlatformDataCommon { 169 class Sampler::PlatformData : public PlatformDataCommon {
172 public: 170 public:
173 PlatformData() : vm_tid_(pthread_self()) {} 171 PlatformData() : vm_tid_(pthread_self()) {}
174 pthread_t vm_tid() const { return vm_tid_; } 172 pthread_t vm_tid() const { return vm_tid_; }
175 173
176 private: 174 private:
177 pthread_t vm_tid_; 175 pthread_t vm_tid_;
178 }; 176 };
179 177
180 #elif defined(__MACH__) 178 #elif V8_OS_DARWIN
181 179
182 class Sampler::PlatformData : public PlatformDataCommon { 180 class Sampler::PlatformData : public PlatformDataCommon {
183 public: 181 public:
184 PlatformData() : profiled_thread_(mach_thread_self()) {} 182 PlatformData() : profiled_thread_(mach_thread_self()) {}
185 183
186 ~PlatformData() { 184 ~PlatformData() {
187 // Deallocate Mach port for thread. 185 // Deallocate Mach port for thread.
188 mach_port_deallocate(mach_task_self(), profiled_thread_); 186 mach_port_deallocate(mach_task_self(), profiled_thread_);
189 } 187 }
190 188
191 thread_act_t profiled_thread() { return profiled_thread_; } 189 thread_act_t profiled_thread() { return profiled_thread_; }
192 190
193 private: 191 private:
194 // Note: for profiled_thread_ Mach primitives are used instead of PThread's 192 // Note: for profiled_thread_ Mach primitives are used instead of PThread's
195 // because the latter doesn't provide thread manipulation primitives required. 193 // because the latter doesn't provide thread manipulation primitives required.
196 // For details, consult "Mac OS X Internals" book, Section 7.3. 194 // For details, consult "Mac OS X Internals" book, Section 7.3.
197 thread_act_t profiled_thread_; 195 thread_act_t profiled_thread_;
198 }; 196 };
199 197
200 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) 198 #elif V8_OS_CYGWIN || V8_OS_WIN32
201 199
202 // ---------------------------------------------------------------------------- 200 // ----------------------------------------------------------------------------
203 // Win32 profiler support. On Cygwin we use the same sampler implementation as 201 // Win32 profiler support. On Cygwin we use the same sampler implementation as
204 // on Win32. 202 // on Win32.
205 203
206 class Sampler::PlatformData : public PlatformDataCommon { 204 class Sampler::PlatformData : public PlatformDataCommon {
207 public: 205 public:
208 // Get a handle to the calling thread. This is the thread that we are 206 // Get a handle to the calling thread. This is the thread that we are
209 // going to profile. We need to make a copy of the handle because we are 207 // going to profile. We need to make a copy of the handle because we are
210 // going to use it in the sampler thread. Using GetThreadHandle() will 208 // going to use it in the sampler thread. Using GetThreadHandle() will
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 static bool signal_handler_installed_; 292 static bool signal_handler_installed_;
295 static struct sigaction old_signal_handler_; 293 static struct sigaction old_signal_handler_;
296 }; 294 };
297 295
298 struct sigaction SignalHandler::old_signal_handler_; 296 struct sigaction SignalHandler::old_signal_handler_;
299 bool SignalHandler::signal_handler_installed_ = false; 297 bool SignalHandler::signal_handler_installed_ = false;
300 298
301 299
302 void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info, 300 void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
303 void* context) { 301 void* context) {
304 #if defined(__native_client__) 302 #if V8_OS_NACL
305 // As Native Client does not support signal handling, profiling 303 // As Native Client does not support signal handling, profiling
306 // is disabled. 304 // is disabled.
307 return; 305 return;
308 #else 306 #else
309 USE(info); 307 USE(info);
310 if (signal != SIGPROF) return; 308 if (signal != SIGPROF) return;
311 Isolate* isolate = Isolate::UncheckedCurrent(); 309 Isolate* isolate = Isolate::UncheckedCurrent();
312 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) { 310 if (isolate == NULL || !isolate->IsInitialized() || !isolate->IsInUse()) {
313 // We require a fully initialized and entered isolate. 311 // We require a fully initialized and entered isolate.
314 return; 312 return;
315 } 313 }
316 if (v8::Locker::IsActive() && 314 if (v8::Locker::IsActive() &&
317 !isolate->thread_manager()->IsLockedByCurrentThread()) { 315 !isolate->thread_manager()->IsLockedByCurrentThread()) {
318 return; 316 return;
319 } 317 }
320 318
321 Sampler* sampler = isolate->logger()->sampler(); 319 Sampler* sampler = isolate->logger()->sampler();
322 if (sampler == NULL || !sampler->IsActive()) return; 320 if (sampler == NULL || !sampler->IsActive()) return;
323 321
324 RegisterState state; 322 RegisterState state;
325 323
326 #if defined(USE_SIMULATOR) 324 #if defined(USE_SIMULATOR)
327 SimulatorHelper helper; 325 SimulatorHelper helper;
328 if (!helper.Init(sampler, isolate)) return; 326 if (!helper.Init(sampler, isolate)) return;
329 helper.FillRegisters(&state); 327 helper.FillRegisters(&state);
330 #else 328 #else
331 // Extracting the sample from the context is extremely machine dependent. 329 // Extracting the sample from the context is extremely machine dependent.
332 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 330 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
333 mcontext_t& mcontext = ucontext->uc_mcontext; 331 mcontext_t& mcontext = ucontext->uc_mcontext;
334 #if defined(__linux__) || defined(__ANDROID__) 332 #if V8_OS_LINUX
335 #if V8_HOST_ARCH_IA32 333 #if V8_HOST_ARCH_IA32
336 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); 334 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
337 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); 335 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]);
338 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); 336 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]);
339 #elif V8_HOST_ARCH_X64 337 #elif V8_HOST_ARCH_X64
340 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); 338 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]);
341 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); 339 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]);
342 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); 340 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]);
343 #elif V8_HOST_ARCH_ARM 341 #elif V8_HOST_ARCH_ARM
344 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \ 342 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \
345 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) 343 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
346 // Old GLibc ARM versions used a gregs[] array to access the register 344 // Old GLibc ARM versions used a gregs[] array to access the register
347 // values from mcontext_t. 345 // values from mcontext_t.
348 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); 346 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]);
349 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); 347 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]);
350 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); 348 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]);
351 #else 349 #else
352 state.pc = reinterpret_cast<Address>(mcontext.arm_pc); 350 state.pc = reinterpret_cast<Address>(mcontext.arm_pc);
353 state.sp = reinterpret_cast<Address>(mcontext.arm_sp); 351 state.sp = reinterpret_cast<Address>(mcontext.arm_sp);
354 state.fp = reinterpret_cast<Address>(mcontext.arm_fp); 352 state.fp = reinterpret_cast<Address>(mcontext.arm_fp);
355 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && 353 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) &&
356 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) 354 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
357 #elif V8_HOST_ARCH_MIPS 355 #elif V8_HOST_ARCH_MIPS
358 state.pc = reinterpret_cast<Address>(mcontext.pc); 356 state.pc = reinterpret_cast<Address>(mcontext.pc);
359 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); 357 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]);
360 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); 358 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]);
361 #endif // V8_HOST_ARCH_* 359 #endif // V8_HOST_ARCH_*
362 #elif defined(__FreeBSD__) 360 #elif V8_OS_FREEBSD
363 #if V8_HOST_ARCH_IA32 361 #if V8_HOST_ARCH_IA32
364 state.pc = reinterpret_cast<Address>(mcontext.mc_eip); 362 state.pc = reinterpret_cast<Address>(mcontext.mc_eip);
365 state.sp = reinterpret_cast<Address>(mcontext.mc_esp); 363 state.sp = reinterpret_cast<Address>(mcontext.mc_esp);
366 state.fp = reinterpret_cast<Address>(mcontext.mc_ebp); 364 state.fp = reinterpret_cast<Address>(mcontext.mc_ebp);
367 #elif V8_HOST_ARCH_X64 365 #elif V8_HOST_ARCH_X64
368 state.pc = reinterpret_cast<Address>(mcontext.mc_rip); 366 state.pc = reinterpret_cast<Address>(mcontext.mc_rip);
369 state.sp = reinterpret_cast<Address>(mcontext.mc_rsp); 367 state.sp = reinterpret_cast<Address>(mcontext.mc_rsp);
370 state.fp = reinterpret_cast<Address>(mcontext.mc_rbp); 368 state.fp = reinterpret_cast<Address>(mcontext.mc_rbp);
371 #elif V8_HOST_ARCH_ARM 369 #elif V8_HOST_ARCH_ARM
372 state.pc = reinterpret_cast<Address>(mcontext.mc_r15); 370 state.pc = reinterpret_cast<Address>(mcontext.mc_r15);
373 state.sp = reinterpret_cast<Address>(mcontext.mc_r13); 371 state.sp = reinterpret_cast<Address>(mcontext.mc_r13);
374 state.fp = reinterpret_cast<Address>(mcontext.mc_r11); 372 state.fp = reinterpret_cast<Address>(mcontext.mc_r11);
375 #endif // V8_HOST_ARCH_* 373 #endif // V8_HOST_ARCH_*
376 #elif defined(__NetBSD__) 374 #elif V8_OS_NETBSD
377 #if V8_HOST_ARCH_IA32 375 #if V8_HOST_ARCH_IA32
378 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); 376 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]);
379 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); 377 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]);
380 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); 378 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]);
381 #elif V8_HOST_ARCH_X64 379 #elif V8_HOST_ARCH_X64
382 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); 380 state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]);
383 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); 381 state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]);
384 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); 382 state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]);
385 #endif // V8_HOST_ARCH_* 383 #endif // V8_HOST_ARCH_*
386 #elif defined(__OpenBSD__) 384 #elif V8_OS_OPENBSD
387 USE(mcontext); 385 USE(mcontext);
388 #if V8_HOST_ARCH_IA32 386 #if V8_HOST_ARCH_IA32
389 state.pc = reinterpret_cast<Address>(ucontext->sc_eip); 387 state.pc = reinterpret_cast<Address>(ucontext->sc_eip);
390 state.sp = reinterpret_cast<Address>(ucontext->sc_esp); 388 state.sp = reinterpret_cast<Address>(ucontext->sc_esp);
391 state.fp = reinterpret_cast<Address>(ucontext->sc_ebp); 389 state.fp = reinterpret_cast<Address>(ucontext->sc_ebp);
392 #elif V8_HOST_ARCH_X64 390 #elif V8_HOST_ARCH_X64
393 state.pc = reinterpret_cast<Address>(ucontext->sc_rip); 391 state.pc = reinterpret_cast<Address>(ucontext->sc_rip);
394 state.sp = reinterpret_cast<Address>(ucontext->sc_rsp); 392 state.sp = reinterpret_cast<Address>(ucontext->sc_rsp);
395 state.fp = reinterpret_cast<Address>(ucontext->sc_rbp); 393 state.fp = reinterpret_cast<Address>(ucontext->sc_rbp);
396 #endif // V8_HOST_ARCH_* 394 #endif // V8_HOST_ARCH_*
397 #elif defined(__sun) 395 #elif V8_OS_SOLARIS
398 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); 396 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]);
399 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); 397 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]);
400 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); 398 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]);
401 #endif // __sun 399 #endif // V8_OS_SOLARIS
402 #endif // USE_SIMULATOR 400 #endif // USE_SIMULATOR
403 sampler->SampleStack(state); 401 sampler->SampleStack(state);
404 #endif // __native_client__ 402 #endif // __native_client__
405 } 403 }
406 404
407 #endif 405 #endif
408 406
409 407
410 class SamplerThread : public Thread { 408 class SamplerThread : public Thread {
411 public: 409 public:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 484
487 private: 485 private:
488 #if defined(USE_SIGNALS) 486 #if defined(USE_SIGNALS)
489 487
490 void SampleContext(Sampler* sampler) { 488 void SampleContext(Sampler* sampler) {
491 if (!SignalHandler::Installed()) return; 489 if (!SignalHandler::Installed()) return;
492 pthread_t tid = sampler->platform_data()->vm_tid(); 490 pthread_t tid = sampler->platform_data()->vm_tid();
493 pthread_kill(tid, SIGPROF); 491 pthread_kill(tid, SIGPROF);
494 } 492 }
495 493
496 #elif defined(__MACH__) 494 #elif V8_OS_DARWIN
497 495
498 void SampleContext(Sampler* sampler) { 496 void SampleContext(Sampler* sampler) {
499 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); 497 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
500 498
501 #if defined(USE_SIMULATOR) 499 #if defined(USE_SIMULATOR)
502 SimulatorHelper helper; 500 SimulatorHelper helper;
503 Isolate* isolate = sampler->isolate(); 501 Isolate* isolate = sampler->isolate();
504 if (!helper.Init(sampler, isolate)) return; 502 if (!helper.Init(sampler, isolate)) return;
505 #endif 503 #endif
506 504
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 state.pc = reinterpret_cast<Address>(thread_state.REGISTER_FIELD(ip)); 537 state.pc = reinterpret_cast<Address>(thread_state.REGISTER_FIELD(ip));
540 state.sp = reinterpret_cast<Address>(thread_state.REGISTER_FIELD(sp)); 538 state.sp = reinterpret_cast<Address>(thread_state.REGISTER_FIELD(sp));
541 state.fp = reinterpret_cast<Address>(thread_state.REGISTER_FIELD(bp)); 539 state.fp = reinterpret_cast<Address>(thread_state.REGISTER_FIELD(bp));
542 #endif // USE_SIMULATOR 540 #endif // USE_SIMULATOR
543 #undef REGISTER_FIELD 541 #undef REGISTER_FIELD
544 sampler->SampleStack(state); 542 sampler->SampleStack(state);
545 } 543 }
546 thread_resume(profiled_thread); 544 thread_resume(profiled_thread);
547 } 545 }
548 546
549 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) 547 #elif V8_OS_CYGWIN || V8_OS_WIN32
550 548
551 void SampleContext(Sampler* sampler) { 549 void SampleContext(Sampler* sampler) {
552 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); 550 HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
553 if (profiled_thread == NULL) return; 551 if (profiled_thread == NULL) return;
554 552
555 Isolate* isolate = sampler->isolate(); 553 Isolate* isolate = sampler->isolate();
556 #if defined(USE_SIMULATOR) 554 #if defined(USE_SIMULATOR)
557 SimulatorHelper helper; 555 SimulatorHelper helper;
558 if (!helper.Init(sampler, isolate)) return; 556 if (!helper.Init(sampler, isolate)) return;
559 #endif 557 #endif
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 sample->Init(isolate_, state); 694 sample->Init(isolate_, state);
697 if (is_counting_samples_) { 695 if (is_counting_samples_) {
698 if (sample->state == JS || sample->state == EXTERNAL) { 696 if (sample->state == JS || sample->state == EXTERNAL) {
699 ++js_and_external_sample_count_; 697 ++js_and_external_sample_count_;
700 } 698 }
701 } 699 }
702 Tick(sample); 700 Tick(sample);
703 } 701 }
704 702
705 } } // namespace v8::internal 703 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | src/snapshot-common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698