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

Side by Side Diff: src/platform-linux.cc

Issue 10871039: Replacing circular queue by single buffer in CPU Profiler. (Closed) Base URL: http://git.chromium.org/external/v8.git@profiling
Patch Set: fixed tests Created 8 years, 3 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
OLDNEW
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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 return; 1008 return;
1009 } 1009 }
1010 if (v8::Locker::IsActive() && 1010 if (v8::Locker::IsActive() &&
1011 !isolate->thread_manager()->IsLockedByCurrentThread()) { 1011 !isolate->thread_manager()->IsLockedByCurrentThread()) {
1012 return; 1012 return;
1013 } 1013 }
1014 1014
1015 Sampler* sampler = isolate->logger()->sampler(); 1015 Sampler* sampler = isolate->logger()->sampler();
1016 if (sampler == NULL || !sampler->IsActive()) return; 1016 if (sampler == NULL || !sampler->IsActive()) return;
1017 1017
1018 TickSample sample_obj; 1018 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate);
1019 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); 1019 if (sample == NULL) return;
1020 if (sample == NULL) sample = &sample_obj;
1021 1020
1022 // Extracting the sample from the context is extremely machine dependent. 1021 // Extracting the sample from the context is extremely machine dependent.
1023 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 1022 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
1024 mcontext_t& mcontext = ucontext->uc_mcontext; 1023 mcontext_t& mcontext = ucontext->uc_mcontext;
1025 sample->state = isolate->current_vm_state(); 1024 sample->state = isolate->current_vm_state();
1026 #if V8_HOST_ARCH_IA32 1025 #if V8_HOST_ARCH_IA32
1027 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); 1026 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
1028 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); 1027 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]);
1029 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); 1028 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]);
1030 #elif V8_HOST_ARCH_X64 1029 #elif V8_HOST_ARCH_X64
(...skipping 14 matching lines...) Expand all
1045 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); 1044 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp);
1046 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && 1045 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) &&
1047 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) 1046 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
1048 #elif V8_HOST_ARCH_MIPS 1047 #elif V8_HOST_ARCH_MIPS
1049 sample->pc = reinterpret_cast<Address>(mcontext.pc); 1048 sample->pc = reinterpret_cast<Address>(mcontext.pc);
1050 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); 1049 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]);
1051 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); 1050 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]);
1052 #endif // V8_HOST_ARCH_* 1051 #endif // V8_HOST_ARCH_*
1053 sampler->SampleStack(sample); 1052 sampler->SampleStack(sample);
1054 sampler->Tick(sample); 1053 sampler->Tick(sample);
1054 CpuProfiler::FinishTickSampleEvent(isolate);
1055 } 1055 }
1056 1056
1057 1057
1058 class CpuProfilerSignalHandler { 1058 class CpuProfilerSignalHandler {
1059 public: 1059 public:
1060 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } 1060 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
1061 static void TearDown() { delete mutex_; } 1061 static void TearDown() { delete mutex_; }
1062 1062
1063 static void InstallSignalHandler() { 1063 static void InstallSignalHandler() {
1064 struct sigaction sa; 1064 struct sigaction sa;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1287
1288 void Sampler::Stop() { 1288 void Sampler::Stop() {
1289 ASSERT(IsActive()); 1289 ASSERT(IsActive());
1290 CpuProfilerSignalHandler::RestoreSignalHandler(); 1290 CpuProfilerSignalHandler::RestoreSignalHandler();
1291 SignalSender::RemoveActiveSampler(this); 1291 SignalSender::RemoveActiveSampler(this);
1292 SetActive(false); 1292 SetActive(false);
1293 } 1293 }
1294 1294
1295 1295
1296 } } // namespace v8::internal 1296 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698