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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 return; | 1005 return; |
1006 } | 1006 } |
1007 if (v8::Locker::IsActive() && | 1007 if (v8::Locker::IsActive() && |
1008 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 1008 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
1009 return; | 1009 return; |
1010 } | 1010 } |
1011 | 1011 |
1012 Sampler* sampler = isolate->logger()->sampler(); | 1012 Sampler* sampler = isolate->logger()->sampler(); |
1013 if (sampler == NULL || !sampler->IsActive()) return; | 1013 if (sampler == NULL || !sampler->IsActive()) return; |
1014 | 1014 |
1015 TickSample sample_obj; | 1015 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate); |
1016 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); | 1016 if (sample == NULL) return; |
1017 if (sample == NULL) sample = &sample_obj; | |
1018 | 1017 |
1019 // Extracting the sample from the context is extremely machine dependent. | 1018 // Extracting the sample from the context is extremely machine dependent. |
1020 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 1019 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
1021 mcontext_t& mcontext = ucontext->uc_mcontext; | 1020 mcontext_t& mcontext = ucontext->uc_mcontext; |
1022 sample->state = isolate->current_vm_state(); | 1021 sample->state = isolate->current_vm_state(); |
1023 #if V8_HOST_ARCH_IA32 | 1022 #if V8_HOST_ARCH_IA32 |
1024 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 1023 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
1025 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 1024 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
1026 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 1025 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
1027 #elif V8_HOST_ARCH_X64 | 1026 #elif V8_HOST_ARCH_X64 |
(...skipping 14 matching lines...) Expand all Loading... |
1042 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); | 1041 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
1043 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && | 1042 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && |
1044 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 1043 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
1045 #elif V8_HOST_ARCH_MIPS | 1044 #elif V8_HOST_ARCH_MIPS |
1046 sample->pc = reinterpret_cast<Address>(mcontext.pc); | 1045 sample->pc = reinterpret_cast<Address>(mcontext.pc); |
1047 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 1046 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
1048 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 1047 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
1049 #endif // V8_HOST_ARCH_* | 1048 #endif // V8_HOST_ARCH_* |
1050 sampler->SampleStack(sample); | 1049 sampler->SampleStack(sample); |
1051 sampler->Tick(sample); | 1050 sampler->Tick(sample); |
| 1051 CpuProfiler::FinishTickSampleEvent(isolate); |
1052 } | 1052 } |
1053 | 1053 |
1054 | 1054 |
1055 class CpuProfilerSignalHandler { | 1055 class CpuProfilerSignalHandler { |
1056 public: | 1056 public: |
1057 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } | 1057 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } |
1058 static void TearDown() { delete mutex_; } | 1058 static void TearDown() { delete mutex_; } |
1059 | 1059 |
1060 static void InstallSignalHandler() { | 1060 static void InstallSignalHandler() { |
1061 struct sigaction sa; | 1061 struct sigaction sa; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 | 1284 |
1285 void Sampler::Stop() { | 1285 void Sampler::Stop() { |
1286 ASSERT(IsActive()); | 1286 ASSERT(IsActive()); |
1287 CpuProfilerSignalHandler::RestoreSignalHandler(); | 1287 CpuProfilerSignalHandler::RestoreSignalHandler(); |
1288 SignalSender::RemoveActiveSampler(this); | 1288 SignalSender::RemoveActiveSampler(this); |
1289 SetActive(false); | 1289 SetActive(false); |
1290 } | 1290 } |
1291 | 1291 |
1292 | 1292 |
1293 } } // namespace v8::internal | 1293 } } // namespace v8::internal |
OLD | NEW |