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

Side by Side Diff: src/sampler.cc

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