| 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 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Check if there is active simulator before allocating TickSample. | 227 // Check if there is active simulator before allocating TickSample. |
| 228 if (!sim) return; | 228 if (!sim) return; |
| 229 #endif | 229 #endif |
| 230 #endif // USE_SIMULATOR | 230 #endif // USE_SIMULATOR |
| 231 | 231 |
| 232 TickSample sample_obj; | 232 TickSample sample_obj; |
| 233 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 233 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
| 234 if (sample == NULL) sample = &sample_obj; | 234 if (sample == NULL) sample = &sample_obj; |
| 235 | 235 |
| 236 #if defined(USE_SIMULATOR) | 236 #if defined(USE_SIMULATOR) |
| 237 sample->pc = reinterpret_cast<Address>(sim->get_pc()); |
| 238 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
| 237 #if V8_TARGET_ARCH_ARM | 239 #if V8_TARGET_ARCH_ARM |
| 238 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
| 239 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
| 240 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); | 240 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); |
| 241 #elif V8_TARGET_ARCH_MIPS | 241 #elif V8_TARGET_ARCH_MIPS |
| 242 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
| 243 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
| 244 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); | 242 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); |
| 245 #endif // V8_TARGET_ARCH_* | 243 #endif // V8_TARGET_ARCH_* |
| 246 #else | 244 #else |
| 247 // Extracting the sample from the context is extremely machine dependent. | 245 // Extracting the sample from the context is extremely machine dependent. |
| 248 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 246 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 249 mcontext_t& mcontext = ucontext->uc_mcontext; | 247 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 250 sample->state = isolate->current_vm_state(); | 248 sample->state = isolate->current_vm_state(); |
| 251 #if defined(__linux__) || defined(__ANDROID__) | 249 #if defined(__linux__) || defined(__ANDROID__) |
| 252 #if V8_HOST_ARCH_IA32 | 250 #if V8_HOST_ARCH_IA32 |
| 253 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 251 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 #else | 514 #else |
| 517 #error Unsupported Mac OS X host architecture. | 515 #error Unsupported Mac OS X host architecture. |
| 518 #endif // V8_HOST_ARCH | 516 #endif // V8_HOST_ARCH |
| 519 | 517 |
| 520 if (thread_get_state(profiled_thread, | 518 if (thread_get_state(profiled_thread, |
| 521 flavor, | 519 flavor, |
| 522 reinterpret_cast<natural_t*>(&state), | 520 reinterpret_cast<natural_t*>(&state), |
| 523 &count) == KERN_SUCCESS) { | 521 &count) == KERN_SUCCESS) { |
| 524 sample->state = isolate->current_vm_state(); | 522 sample->state = isolate->current_vm_state(); |
| 525 #if defined(USE_SIMULATOR) | 523 #if defined(USE_SIMULATOR) |
| 524 sample->pc = reinterpret_cast<Address>(sim->get_pc()); |
| 525 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
| 526 #if V8_TARGET_ARCH_ARM | 526 #if V8_TARGET_ARCH_ARM |
| 527 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
| 528 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
| 529 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); | 527 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); |
| 530 #elif V8_TARGET_ARCH_MIPS | 528 #elif V8_TARGET_ARCH_MIPS |
| 531 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
| 532 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
| 533 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); | 529 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); |
| 534 #endif | 530 #endif |
| 535 #else | 531 #else |
| 536 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); | 532 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); |
| 537 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); | 533 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); |
| 538 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); | 534 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); |
| 539 #endif // USE_SIMULATOR | 535 #endif // USE_SIMULATOR |
| 540 #undef REGISTER_FIELD | 536 #undef REGISTER_FIELD |
| 541 sampler->SampleStack(sample); | 537 sampler->SampleStack(sample); |
| 542 sampler->Tick(sample); | 538 sampler->Tick(sample); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 570 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 566 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
| 571 if (sample == NULL) sample = &sample_obj; | 567 if (sample == NULL) sample = &sample_obj; |
| 572 | 568 |
| 573 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); | 569 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); |
| 574 if (SuspendThread(profiled_thread) == kSuspendFailed) return; | 570 if (SuspendThread(profiled_thread) == kSuspendFailed) return; |
| 575 sample->state = isolate->current_vm_state(); | 571 sample->state = isolate->current_vm_state(); |
| 576 | 572 |
| 577 context.ContextFlags = CONTEXT_FULL; | 573 context.ContextFlags = CONTEXT_FULL; |
| 578 if (GetThreadContext(profiled_thread, &context) != 0) { | 574 if (GetThreadContext(profiled_thread, &context) != 0) { |
| 579 #if defined(USE_SIMULATOR) | 575 #if defined(USE_SIMULATOR) |
| 576 sample->pc = reinterpret_cast<Address>(sim->get_pc()); |
| 577 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); |
| 580 #if V8_TARGET_ARCH_ARM | 578 #if V8_TARGET_ARCH_ARM |
| 581 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
| 582 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
| 583 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); | 579 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); |
| 584 #elif V8_TARGET_ARCH_MIPS | 580 #elif V8_TARGET_ARCH_MIPS |
| 585 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
| 586 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
| 587 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); | 581 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); |
| 588 #endif | 582 #endif |
| 589 #else | 583 #else |
| 590 #if V8_HOST_ARCH_X64 | 584 #if V8_HOST_ARCH_X64 |
| 591 sample->pc = reinterpret_cast<Address>(context.Rip); | 585 sample->pc = reinterpret_cast<Address>(context.Rip); |
| 592 sample->sp = reinterpret_cast<Address>(context.Rsp); | 586 sample->sp = reinterpret_cast<Address>(context.Rsp); |
| 593 sample->fp = reinterpret_cast<Address>(context.Rbp); | 587 sample->fp = reinterpret_cast<Address>(context.Rbp); |
| 594 #else | 588 #else |
| 595 sample->pc = reinterpret_cast<Address>(context.Eip); | 589 sample->pc = reinterpret_cast<Address>(context.Eip); |
| 596 sample->sp = reinterpret_cast<Address>(context.Esp); | 590 sample->sp = reinterpret_cast<Address>(context.Esp); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 SamplerThread::RemoveActiveSampler(this); | 689 SamplerThread::RemoveActiveSampler(this); |
| 696 SetActive(false); | 690 SetActive(false); |
| 697 } | 691 } |
| 698 | 692 |
| 699 void Sampler::SampleStack(TickSample* sample) { | 693 void Sampler::SampleStack(TickSample* sample) { |
| 700 sample->Trace(isolate_); | 694 sample->Trace(isolate_); |
| 701 if (++samples_taken_ < 0) samples_taken_ = 0; | 695 if (++samples_taken_ < 0) samples_taken_ = 0; |
| 702 } | 696 } |
| 703 | 697 |
| 704 } } // namespace v8::internal | 698 } } // namespace v8::internal |
| OLD | NEW |