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

Side by Side Diff: src/sampler.cc

Issue 148293020: Merge experimental/a64 to bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove ARM from OWNERS Created 6 years, 10 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/regexp-macro-assembler-tracer.cc ('k') | src/simulator.h » ('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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) \ 47 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) \
48 && !V8_OS_OPENBSD 48 && !V8_OS_OPENBSD
49 #include <ucontext.h> 49 #include <ucontext.h>
50 #endif 50 #endif
51 51
52 #include <unistd.h> 52 #include <unistd.h>
53 53
54 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. 54 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
55 // Old versions of the C library <signal.h> didn't define the type. 55 // Old versions of the C library <signal.h> didn't define the type.
56 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ 56 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
57 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) 57 (defined(__arm__) || defined(__aarch64__)) && \
58 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
58 #include <asm/sigcontext.h> 59 #include <asm/sigcontext.h>
59 #endif 60 #endif
60 61
61 #elif V8_OS_WIN || V8_OS_CYGWIN 62 #elif V8_OS_WIN || V8_OS_CYGWIN
62 63
63 #include "win32-headers.h" 64 #include "win32-headers.h"
64 65
65 #endif 66 #endif
66 67
67 #include "v8.h" 68 #include "v8.h"
(...skipping 22 matching lines...) Expand all
90 typedef struct sigcontext mcontext_t; 91 typedef struct sigcontext mcontext_t;
91 92
92 typedef struct ucontext { 93 typedef struct ucontext {
93 uint32_t uc_flags; 94 uint32_t uc_flags;
94 struct ucontext* uc_link; 95 struct ucontext* uc_link;
95 stack_t uc_stack; 96 stack_t uc_stack;
96 mcontext_t uc_mcontext; 97 mcontext_t uc_mcontext;
97 // Other fields are not used by V8, don't define them here. 98 // Other fields are not used by V8, don't define them here.
98 } ucontext_t; 99 } ucontext_t;
99 100
101 #elif defined(__aarch64__)
102
103 typedef struct sigcontext mcontext_t;
104
105 typedef struct ucontext {
106 uint64_t uc_flags;
107 struct ucontext *uc_link;
108 stack_t uc_stack;
109 mcontext_t uc_mcontext;
110 // Other fields are not used by V8, don't define them here.
111 } ucontext_t;
112
100 #elif defined(__mips__) 113 #elif defined(__mips__)
101 // MIPS version of sigcontext, for Android bionic. 114 // MIPS version of sigcontext, for Android bionic.
102 typedef struct { 115 typedef struct {
103 uint32_t regmask; 116 uint32_t regmask;
104 uint32_t status; 117 uint32_t status;
105 uint64_t pc; 118 uint64_t pc;
106 uint64_t gregs[32]; 119 uint64_t gregs[32];
107 uint64_t fpregs[32]; 120 uint64_t fpregs[32];
108 uint32_t acx; 121 uint32_t acx;
109 uint32_t fpc_csr; 122 uint32_t fpc_csr;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 #if defined(USE_SIMULATOR) 232 #if defined(USE_SIMULATOR)
220 class SimulatorHelper { 233 class SimulatorHelper {
221 public: 234 public:
222 inline bool Init(Sampler* sampler, Isolate* isolate) { 235 inline bool Init(Sampler* sampler, Isolate* isolate) {
223 simulator_ = isolate->thread_local_top()->simulator_; 236 simulator_ = isolate->thread_local_top()->simulator_;
224 // Check if there is active simulator. 237 // Check if there is active simulator.
225 return simulator_ != NULL; 238 return simulator_ != NULL;
226 } 239 }
227 240
228 inline void FillRegisters(RegisterState* state) { 241 inline void FillRegisters(RegisterState* state) {
242 #if V8_TARGET_ARCH_ARM
229 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); 243 state->pc = reinterpret_cast<Address>(simulator_->get_pc());
230 state->sp = reinterpret_cast<Address>(simulator_->get_register( 244 state->sp = reinterpret_cast<Address>(simulator_->get_register(
231 Simulator::sp)); 245 Simulator::sp));
232 #if V8_TARGET_ARCH_ARM
233 state->fp = reinterpret_cast<Address>(simulator_->get_register( 246 state->fp = reinterpret_cast<Address>(simulator_->get_register(
234 Simulator::r11)); 247 Simulator::r11));
248 #elif V8_TARGET_ARCH_A64
249 if (simulator_->sp() == 0 || simulator_->fp() == 0) {
250 // It possible that the simulator is interrupted while it is updating
251 // the sp or fp register. A64 simulator does this in two steps:
252 // first setting it to zero and then setting it to the new value.
253 // Bailout if sp/fp doesn't contain the new value.
254 return;
255 }
256 state->pc = reinterpret_cast<Address>(simulator_->pc());
257 state->sp = reinterpret_cast<Address>(simulator_->sp());
258 state->fp = reinterpret_cast<Address>(simulator_->fp());
235 #elif V8_TARGET_ARCH_MIPS 259 #elif V8_TARGET_ARCH_MIPS
260 state->pc = reinterpret_cast<Address>(simulator_->get_pc());
261 state->sp = reinterpret_cast<Address>(simulator_->get_register(
262 Simulator::sp));
236 state->fp = reinterpret_cast<Address>(simulator_->get_register( 263 state->fp = reinterpret_cast<Address>(simulator_->get_register(
237 Simulator::fp)); 264 Simulator::fp));
238 #endif 265 #endif
239 } 266 }
240 267
241 private: 268 private:
242 Simulator* simulator_; 269 Simulator* simulator_;
243 }; 270 };
244 #endif // USE_SIMULATOR 271 #endif // USE_SIMULATOR
245 272
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 349
323 Sampler* sampler = isolate->logger()->sampler(); 350 Sampler* sampler = isolate->logger()->sampler();
324 if (sampler == NULL) return; 351 if (sampler == NULL) return;
325 352
326 RegisterState state; 353 RegisterState state;
327 354
328 #if defined(USE_SIMULATOR) 355 #if defined(USE_SIMULATOR)
329 SimulatorHelper helper; 356 SimulatorHelper helper;
330 if (!helper.Init(sampler, isolate)) return; 357 if (!helper.Init(sampler, isolate)) return;
331 helper.FillRegisters(&state); 358 helper.FillRegisters(&state);
359 // It possible that the simulator is interrupted while it is updating
360 // the sp or fp register. A64 simulator does this in two steps:
361 // first setting it to zero and then setting it to the new value.
362 // Bailout if sp/fp doesn't contain the new value.
363 if (state.sp == 0 || state.fp == 0) return;
332 #else 364 #else
333 // Extracting the sample from the context is extremely machine dependent. 365 // Extracting the sample from the context is extremely machine dependent.
334 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 366 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
335 #if !V8_OS_OPENBSD 367 #if !V8_OS_OPENBSD
336 mcontext_t& mcontext = ucontext->uc_mcontext; 368 mcontext_t& mcontext = ucontext->uc_mcontext;
337 #endif 369 #endif
338 #if V8_OS_LINUX 370 #if V8_OS_LINUX
339 #if V8_HOST_ARCH_IA32 371 #if V8_HOST_ARCH_IA32
340 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); 372 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
341 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); 373 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]);
342 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); 374 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]);
343 #elif V8_HOST_ARCH_X64 375 #elif V8_HOST_ARCH_X64
344 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); 376 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]);
345 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); 377 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]);
346 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); 378 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]);
347 #elif V8_HOST_ARCH_ARM 379 #elif V8_HOST_ARCH_ARM
348 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \ 380 #if defined(__GLIBC__) && !defined(__UCLIBC__) && \
349 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) 381 (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
350 // Old GLibc ARM versions used a gregs[] array to access the register 382 // Old GLibc ARM versions used a gregs[] array to access the register
351 // values from mcontext_t. 383 // values from mcontext_t.
352 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); 384 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]);
353 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); 385 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]);
354 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); 386 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]);
355 #else 387 #else
356 state.pc = reinterpret_cast<Address>(mcontext.arm_pc); 388 state.pc = reinterpret_cast<Address>(mcontext.arm_pc);
357 state.sp = reinterpret_cast<Address>(mcontext.arm_sp); 389 state.sp = reinterpret_cast<Address>(mcontext.arm_sp);
358 state.fp = reinterpret_cast<Address>(mcontext.arm_fp); 390 state.fp = reinterpret_cast<Address>(mcontext.arm_fp);
359 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && 391 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) &&
360 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) 392 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
393 #elif V8_HOST_ARCH_A64
394 state.pc = reinterpret_cast<Address>(mcontext.pc);
395 state.sp = reinterpret_cast<Address>(mcontext.sp);
396 // FP is an alias for x29.
397 state.fp = reinterpret_cast<Address>(mcontext.regs[29]);
361 #elif V8_HOST_ARCH_MIPS 398 #elif V8_HOST_ARCH_MIPS
362 state.pc = reinterpret_cast<Address>(mcontext.pc); 399 state.pc = reinterpret_cast<Address>(mcontext.pc);
363 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); 400 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]);
364 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); 401 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]);
365 #endif // V8_HOST_ARCH_* 402 #endif // V8_HOST_ARCH_*
366 #elif V8_OS_MACOSX 403 #elif V8_OS_MACOSX
367 #if V8_HOST_ARCH_X64 404 #if V8_HOST_ARCH_X64
368 #if __DARWIN_UNIX03 405 #if __DARWIN_UNIX03
369 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); 406 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip);
370 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); 407 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 #endif // USE_SIMULATOR 733 #endif // USE_SIMULATOR
697 SampleStack(state); 734 SampleStack(state);
698 } 735 }
699 ResumeThread(profiled_thread); 736 ResumeThread(profiled_thread);
700 } 737 }
701 738
702 #endif // USE_SIGNALS 739 #endif // USE_SIGNALS
703 740
704 741
705 } } // namespace v8::internal 742 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-tracer.cc ('k') | src/simulator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698