| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 561 |
| 562 static Sampler* active_sampler_ = NULL; | 562 static Sampler* active_sampler_ = NULL; |
| 563 | 563 |
| 564 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { | 564 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
| 565 USE(info); | 565 USE(info); |
| 566 if (signal != SIGPROF) return; | 566 if (signal != SIGPROF) return; |
| 567 if (active_sampler_ == NULL) return; | 567 if (active_sampler_ == NULL) return; |
| 568 | 568 |
| 569 TickSample sample; | 569 TickSample sample; |
| 570 | 570 |
| 571 // We always sample the VM state. |
| 572 sample.state = Logger::state(); |
| 573 |
| 571 // If profiling, we extract the current pc and sp. | 574 // If profiling, we extract the current pc and sp. |
| 572 if (active_sampler_->IsProfiling()) { | 575 if (active_sampler_->IsProfiling()) { |
| 573 // Extracting the sample from the context is extremely machine dependent. | 576 // Extracting the sample from the context is extremely machine dependent. |
| 574 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 577 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 575 mcontext_t& mcontext = ucontext->uc_mcontext; | 578 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 576 #if V8_HOST_ARCH_IA32 | 579 #if V8_HOST_ARCH_IA32 |
| 577 sample.pc = reinterpret_cast<Address>(mcontext.mc_eip); | 580 sample.pc = reinterpret_cast<Address>(mcontext.mc_eip); |
| 578 sample.sp = reinterpret_cast<Address>(mcontext.mc_esp); | 581 sample.sp = reinterpret_cast<Address>(mcontext.mc_esp); |
| 579 sample.fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 582 sample.fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
| 580 #elif V8_HOST_ARCH_X64 | 583 #elif V8_HOST_ARCH_X64 |
| 581 sample.pc = reinterpret_cast<Address>(mcontext.mc_rip); | 584 sample.pc = reinterpret_cast<Address>(mcontext.mc_rip); |
| 582 sample.sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 585 sample.sp = reinterpret_cast<Address>(mcontext.mc_rsp); |
| 583 sample.fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 586 sample.fp = reinterpret_cast<Address>(mcontext.mc_rbp); |
| 584 #elif V8_HOST_ARCH_ARM | 587 #elif V8_HOST_ARCH_ARM |
| 585 sample.pc = reinterpret_cast<Address>(mcontext.mc_r15); | 588 sample.pc = reinterpret_cast<Address>(mcontext.mc_r15); |
| 586 sample.sp = reinterpret_cast<Address>(mcontext.mc_r13); | 589 sample.sp = reinterpret_cast<Address>(mcontext.mc_r13); |
| 587 sample.fp = reinterpret_cast<Address>(mcontext.mc_r11); | 590 sample.fp = reinterpret_cast<Address>(mcontext.mc_r11); |
| 588 #endif | 591 #endif |
| 589 active_sampler_->SampleStack(&sample); | 592 active_sampler_->SampleStack(&sample); |
| 590 } | 593 } |
| 591 | 594 |
| 592 // We always sample the VM state. | |
| 593 sample.state = Logger::state(); | |
| 594 | |
| 595 active_sampler_->Tick(&sample); | 595 active_sampler_->Tick(&sample); |
| 596 } | 596 } |
| 597 | 597 |
| 598 | 598 |
| 599 class Sampler::PlatformData : public Malloced { | 599 class Sampler::PlatformData : public Malloced { |
| 600 public: | 600 public: |
| 601 PlatformData() { | 601 PlatformData() { |
| 602 signal_handler_installed_ = false; | 602 signal_handler_installed_ = false; |
| 603 } | 603 } |
| 604 | 604 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 655 } |
| 656 | 656 |
| 657 // This sampler is no longer the active sampler. | 657 // This sampler is no longer the active sampler. |
| 658 active_sampler_ = NULL; | 658 active_sampler_ = NULL; |
| 659 active_ = false; | 659 active_ = false; |
| 660 } | 660 } |
| 661 | 661 |
| 662 #endif // ENABLE_LOGGING_AND_PROFILING | 662 #endif // ENABLE_LOGGING_AND_PROFILING |
| 663 | 663 |
| 664 } } // namespace v8::internal | 664 } } // namespace v8::internal |
| OLD | NEW |