| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 return; | 662 return; |
| 663 } | 663 } |
| 664 if (v8::Locker::IsActive() && | 664 if (v8::Locker::IsActive() && |
| 665 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 665 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
| 666 return; | 666 return; |
| 667 } | 667 } |
| 668 | 668 |
| 669 Sampler* sampler = isolate->logger()->sampler(); | 669 Sampler* sampler = isolate->logger()->sampler(); |
| 670 if (sampler == NULL || !sampler->IsActive()) return; | 670 if (sampler == NULL || !sampler->IsActive()) return; |
| 671 | 671 |
| 672 TickSample sample_obj; | 672 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate); |
| 673 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); | 673 if (sample == NULL) return; |
| 674 if (sample == NULL) sample = &sample_obj; | |
| 675 | 674 |
| 676 // Extracting the sample from the context is extremely machine dependent. | 675 // Extracting the sample from the context is extremely machine dependent. |
| 677 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 676 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 678 mcontext_t& mcontext = ucontext->uc_mcontext; | 677 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 679 sample->state = isolate->current_vm_state(); | 678 sample->state = isolate->current_vm_state(); |
| 680 | 679 |
| 681 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); | 680 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); |
| 682 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); | 681 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); |
| 683 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); | 682 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); |
| 684 | 683 |
| 685 sampler->SampleStack(sample); | 684 sampler->SampleStack(sample); |
| 686 sampler->Tick(sample); | 685 sampler->Tick(sample); |
| 686 CpuProfiler::FinishTickSampleEvent(isolate); |
| 687 } | 687 } |
| 688 | 688 |
| 689 class Sampler::PlatformData : public Malloced { | 689 class Sampler::PlatformData : public Malloced { |
| 690 public: | 690 public: |
| 691 PlatformData() : vm_tid_(GetThreadID()) {} | 691 PlatformData() : vm_tid_(GetThreadID()) {} |
| 692 | 692 |
| 693 pthread_t vm_tid() const { return vm_tid_; } | 693 pthread_t vm_tid() const { return vm_tid_; } |
| 694 | 694 |
| 695 private: | 695 private: |
| 696 pthread_t vm_tid_; | 696 pthread_t vm_tid_; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 } | 899 } |
| 900 | 900 |
| 901 | 901 |
| 902 void Sampler::Stop() { | 902 void Sampler::Stop() { |
| 903 ASSERT(IsActive()); | 903 ASSERT(IsActive()); |
| 904 SignalSender::RemoveActiveSampler(this); | 904 SignalSender::RemoveActiveSampler(this); |
| 905 SetActive(false); | 905 SetActive(false); |
| 906 } | 906 } |
| 907 | 907 |
| 908 } } // namespace v8::internal | 908 } } // namespace v8::internal |
| OLD | NEW |