From 9cbb34a0b54c2e53700edc6e88c66f5d9bbb61f1 Mon Sep 17 00:00:00 2001 From: "yurys@chromium.org" Date: Tue, 2 Apr 2013 07:53:50 +0000 Subject: [PATCH] Isolatify CPU profiler Relanding r13987 that was reverted in r14031 TBR=danno BUG=None Review URL: https://codereview.chromium.org/13457002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14105 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 33 ++++-- src/codegen.cc | 3 +- src/compiler.cc | 2 +- src/cpu-profiler.cc | 149 ++++++++------------------ src/cpu-profiler.h | 99 ++++++++--------- src/heap.cc | 4 +- src/isolate.cc | 7 +- src/isolate.h | 7 +- src/log.cc | 16 +-- src/platform-cygwin.cc | 5 +- src/platform-freebsd.cc | 2 +- src/platform-linux.cc | 2 +- src/platform-macos.cc | 5 +- src/platform-openbsd.cc | 2 +- src/platform-solaris.cc | 2 +- src/platform-win32.cc | 5 +- src/runtime.cc | 2 +- test/cctest/test-cpu-profiler.cc | 65 ++++++----- test/cctest/test-profile-generator.cc | 8 +- 19 files changed, 179 insertions(+), 239 deletions(-) diff --git a/src/api.cc b/src/api.cc index 0c63627203..fabf28bc0f 100644 --- a/src/api.cc +++ b/src/api.cc @@ -6478,11 +6478,12 @@ const CpuProfileNode* CpuProfileNode::GetChild(int index) const { void CpuProfile::Delete() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::Delete"); - i::CpuProfiler::DeleteProfile(reinterpret_cast(this)); - if (i::CpuProfiler::GetProfilesCount() == 0 && - !i::CpuProfiler::HasDetachedProfiles()) { + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); + profiler->DeleteProfile(reinterpret_cast(this)); + if (profiler->GetProfilesCount() == 0 && !profiler->HasDetachedProfiles()) { // If this was the last profile, clean up all accessory data as well. - i::CpuProfiler::DeleteAllProfiles(); + profiler->DeleteAllProfiles(); } } @@ -6525,7 +6526,9 @@ int CpuProfile::GetSamplesCount() const { int CpuProfiler::GetProfilesCount() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); - return i::CpuProfiler::GetProfilesCount(); + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); + return profiler->GetProfilesCount(); } @@ -6533,8 +6536,10 @@ const CpuProfile* CpuProfiler::GetProfile(int index, Handle security_token) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); return reinterpret_cast( - i::CpuProfiler::GetProfile( + profiler->GetProfile( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), index)); } @@ -6544,8 +6549,10 @@ const CpuProfile* CpuProfiler::FindProfile(unsigned uid, Handle security_token) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); return reinterpret_cast( - i::CpuProfiler::FindProfile( + profiler->FindProfile( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), uid)); } @@ -6554,7 +6561,9 @@ const CpuProfile* CpuProfiler::FindProfile(unsigned uid, void CpuProfiler::StartProfiling(Handle title, bool record_samples) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); - i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title), record_samples); + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); + profiler->StartProfiling(*Utils::OpenHandle(*title), record_samples); } @@ -6562,8 +6571,10 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle title, Handle security_token) { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); return reinterpret_cast( - i::CpuProfiler::StopProfiling( + profiler->StopProfiling( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), *Utils::OpenHandle(*title))); } @@ -6572,7 +6583,9 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle title, void CpuProfiler::DeleteAllProfiles() { i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); - i::CpuProfiler::DeleteAllProfiles(); + i::CpuProfiler* profiler = isolate->cpu_profiler(); + ASSERT(profiler != NULL); + profiler->DeleteAllProfiles(); } diff --git a/src/codegen.cc b/src/codegen.cc index 508e221eb3..90ab2b5a20 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -171,7 +171,8 @@ void CodeGenerator::PrintCode(Handle code, CompilationInfo* info) { bool CodeGenerator::ShouldGenerateLog(Expression* type) { ASSERT(type != NULL); Isolate* isolate = Isolate::Current(); - if (!isolate->logger()->is_logging() && !CpuProfiler::is_profiling(isolate)) { + if (!isolate->logger()->is_logging() && + !isolate->cpu_profiler()->is_profiling()) { return false; } Handle name = Handle::cast(type->AsLiteral()->handle()); diff --git a/src/compiler.cc b/src/compiler.cc index 21ea25f121..2c4dae5d4e 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1134,7 +1134,7 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, // script name and line number. Check explicitly whether logging is // enabled as finding the line number is not free. if (info->isolate()->logger()->is_logging_code_events() || - CpuProfiler::is_profiling(info->isolate())) { + info->isolate()->cpu_profiler()->is_profiling()) { Handle