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
This commit is contained in:
parent
c7532f0f0b
commit
9cbb34a0b5
33
src/api.cc
33
src/api.cc
@ -6478,11 +6478,12 @@ const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
|
|||||||
void CpuProfile::Delete() {
|
void CpuProfile::Delete() {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfile::Delete");
|
IsDeadCheck(isolate, "v8::CpuProfile::Delete");
|
||||||
i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
|
i::CpuProfiler* profiler = isolate->cpu_profiler();
|
||||||
if (i::CpuProfiler::GetProfilesCount() == 0 &&
|
ASSERT(profiler != NULL);
|
||||||
!i::CpuProfiler::HasDetachedProfiles()) {
|
profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
|
||||||
|
if (profiler->GetProfilesCount() == 0 && !profiler->HasDetachedProfiles()) {
|
||||||
// If this was the last profile, clean up all accessory data as well.
|
// 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() {
|
int CpuProfiler::GetProfilesCount() {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount");
|
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<Value> security_token) {
|
Handle<Value> security_token) {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
|
IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
|
||||||
|
i::CpuProfiler* profiler = isolate->cpu_profiler();
|
||||||
|
ASSERT(profiler != NULL);
|
||||||
return reinterpret_cast<const CpuProfile*>(
|
return reinterpret_cast<const CpuProfile*>(
|
||||||
i::CpuProfiler::GetProfile(
|
profiler->GetProfile(
|
||||||
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
||||||
index));
|
index));
|
||||||
}
|
}
|
||||||
@ -6544,8 +6549,10 @@ const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
|
|||||||
Handle<Value> security_token) {
|
Handle<Value> security_token) {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
|
IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
|
||||||
|
i::CpuProfiler* profiler = isolate->cpu_profiler();
|
||||||
|
ASSERT(profiler != NULL);
|
||||||
return reinterpret_cast<const CpuProfile*>(
|
return reinterpret_cast<const CpuProfile*>(
|
||||||
i::CpuProfiler::FindProfile(
|
profiler->FindProfile(
|
||||||
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
||||||
uid));
|
uid));
|
||||||
}
|
}
|
||||||
@ -6554,7 +6561,9 @@ const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
|
|||||||
void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) {
|
void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling");
|
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<String> title,
|
|||||||
Handle<Value> security_token) {
|
Handle<Value> security_token) {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
|
IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
|
||||||
|
i::CpuProfiler* profiler = isolate->cpu_profiler();
|
||||||
|
ASSERT(profiler != NULL);
|
||||||
return reinterpret_cast<const CpuProfile*>(
|
return reinterpret_cast<const CpuProfile*>(
|
||||||
i::CpuProfiler::StopProfiling(
|
profiler->StopProfiling(
|
||||||
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
||||||
*Utils::OpenHandle(*title)));
|
*Utils::OpenHandle(*title)));
|
||||||
}
|
}
|
||||||
@ -6572,7 +6583,9 @@ const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
|
|||||||
void CpuProfiler::DeleteAllProfiles() {
|
void CpuProfiler::DeleteAllProfiles() {
|
||||||
i::Isolate* isolate = i::Isolate::Current();
|
i::Isolate* isolate = i::Isolate::Current();
|
||||||
IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
|
IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
|
||||||
i::CpuProfiler::DeleteAllProfiles();
|
i::CpuProfiler* profiler = isolate->cpu_profiler();
|
||||||
|
ASSERT(profiler != NULL);
|
||||||
|
profiler->DeleteAllProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,7 +171,8 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
|
|||||||
bool CodeGenerator::ShouldGenerateLog(Expression* type) {
|
bool CodeGenerator::ShouldGenerateLog(Expression* type) {
|
||||||
ASSERT(type != NULL);
|
ASSERT(type != NULL);
|
||||||
Isolate* isolate = Isolate::Current();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle());
|
Handle<String> name = Handle<String>::cast(type->AsLiteral()->handle());
|
||||||
|
@ -1134,7 +1134,7 @@ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
|
|||||||
// script name and line number. Check explicitly whether logging is
|
// script name and line number. Check explicitly whether logging is
|
||||||
// enabled as finding the line number is not free.
|
// enabled as finding the line number is not free.
|
||||||
if (info->isolate()->logger()->is_logging_code_events() ||
|
if (info->isolate()->logger()->is_logging_code_events() ||
|
||||||
CpuProfiler::is_profiling(info->isolate())) {
|
info->isolate()->cpu_profiler()->is_profiling()) {
|
||||||
Handle<Script> script = info->script();
|
Handle<Script> script = info->script();
|
||||||
Handle<Code> code = info->code();
|
Handle<Code> code = info->code();
|
||||||
if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))
|
if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))
|
||||||
|
@ -258,110 +258,66 @@ void ProfilerEventsProcessor::Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::StartProfiling(const char* title) {
|
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
|
||||||
Isolate::Current()->cpu_profiler()->StartCollectingProfile(title, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::StartProfiling(String* title, bool record_samples) {
|
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
|
||||||
Isolate::Current()->cpu_profiler()->StartCollectingProfile(
|
|
||||||
title, record_samples);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CpuProfile* CpuProfiler::StopProfiling(const char* title) {
|
|
||||||
Isolate* isolate = Isolate::Current();
|
|
||||||
return is_profiling(isolate) ?
|
|
||||||
isolate->cpu_profiler()->StopCollectingProfile(title) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
|
|
||||||
Isolate* isolate = Isolate::Current();
|
|
||||||
return is_profiling(isolate) ?
|
|
||||||
isolate->cpu_profiler()->StopCollectingProfile(
|
|
||||||
security_token, title) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CpuProfiler::GetProfilesCount() {
|
int CpuProfiler::GetProfilesCount() {
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
|
||||||
// The count of profiles doesn't depend on a security token.
|
// The count of profiles doesn't depend on a security token.
|
||||||
return Isolate::Current()->cpu_profiler()->profiles_->Profiles(
|
return profiles_->Profiles(TokenEnumerator::kNoSecurityToken)->length();
|
||||||
TokenEnumerator::kNoSecurityToken)->length();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CpuProfile* CpuProfiler::GetProfile(Object* security_token, int index) {
|
CpuProfile* CpuProfiler::GetProfile(Object* security_token, int index) {
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
const int token = token_enumerator_->GetTokenId(security_token);
|
||||||
CpuProfiler* profiler = Isolate::Current()->cpu_profiler();
|
return profiles_->Profiles(token)->at(index);
|
||||||
const int token = profiler->token_enumerator_->GetTokenId(security_token);
|
|
||||||
return profiler->profiles_->Profiles(token)->at(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CpuProfile* CpuProfiler::FindProfile(Object* security_token, unsigned uid) {
|
CpuProfile* CpuProfiler::FindProfile(Object* security_token, unsigned uid) {
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
const int token = token_enumerator_->GetTokenId(security_token);
|
||||||
CpuProfiler* profiler = Isolate::Current()->cpu_profiler();
|
return profiles_->GetProfile(token, uid);
|
||||||
const int token = profiler->token_enumerator_->GetTokenId(security_token);
|
|
||||||
return profiler->profiles_->GetProfile(token, uid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) {
|
TickSample* CpuProfiler::TickSampleEvent() {
|
||||||
if (CpuProfiler::is_profiling(isolate)) {
|
if (is_profiling_) return processor_->TickSampleEvent();
|
||||||
return isolate->cpu_profiler()->processor_->TickSampleEvent();
|
return NULL;
|
||||||
} else {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::DeleteAllProfiles() {
|
void CpuProfiler::DeleteAllProfiles() {
|
||||||
Isolate* isolate = Isolate::Current();
|
if (is_profiling_) StopProcessor();
|
||||||
ASSERT(isolate->cpu_profiler() != NULL);
|
ResetProfiles();
|
||||||
if (is_profiling(isolate)) {
|
|
||||||
isolate->cpu_profiler()->StopProcessor();
|
|
||||||
}
|
|
||||||
isolate->cpu_profiler()->ResetProfiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::DeleteProfile(CpuProfile* profile) {
|
void CpuProfiler::DeleteProfile(CpuProfile* profile) {
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
profiles_->RemoveProfile(profile);
|
||||||
Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile);
|
|
||||||
delete profile;
|
delete profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CpuProfiler::HasDetachedProfiles() {
|
bool CpuProfiler::HasDetachedProfiles() {
|
||||||
ASSERT(Isolate::Current()->cpu_profiler() != NULL);
|
return profiles_->HasDetachedProfiles();
|
||||||
return Isolate::Current()->cpu_profiler()->profiles_->HasDetachedProfiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::CallbackEvent(Name* name, Address entry_point) {
|
void CpuProfiler::CallbackEvent(Name* name, Address entry_point) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent(
|
processor_->CallbackCreateEvent(
|
||||||
Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point);
|
Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code, const char* comment) {
|
Code* code, const char* comment) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent(
|
processor_->CodeCreateEvent(
|
||||||
tag, comment, code->address(), code->ExecutableSize());
|
tag, comment, code->address(), code->ExecutableSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code, Name* name) {
|
Code* code, Name* name) {
|
||||||
Isolate* isolate = Isolate::Current();
|
processor_->CodeCreateEvent(
|
||||||
isolate->cpu_profiler()->processor_->CodeCreateEvent(
|
|
||||||
tag,
|
tag,
|
||||||
name,
|
name,
|
||||||
isolate->heap()->empty_string(),
|
isolate_->heap()->empty_string(),
|
||||||
v8::CpuProfileNode::kNoLineNumberInfo,
|
v8::CpuProfileNode::kNoLineNumberInfo,
|
||||||
code->address(),
|
code->address(),
|
||||||
code->ExecutableSize(),
|
code->ExecutableSize(),
|
||||||
@ -373,11 +329,10 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|||||||
Code* code,
|
Code* code,
|
||||||
SharedFunctionInfo* shared,
|
SharedFunctionInfo* shared,
|
||||||
Name* name) {
|
Name* name) {
|
||||||
Isolate* isolate = Isolate::Current();
|
processor_->CodeCreateEvent(
|
||||||
isolate->cpu_profiler()->processor_->CodeCreateEvent(
|
|
||||||
tag,
|
tag,
|
||||||
name,
|
name,
|
||||||
isolate->heap()->empty_string(),
|
isolate_->heap()->empty_string(),
|
||||||
v8::CpuProfileNode::kNoLineNumberInfo,
|
v8::CpuProfileNode::kNoLineNumberInfo,
|
||||||
code->address(),
|
code->address(),
|
||||||
code->ExecutableSize(),
|
code->ExecutableSize(),
|
||||||
@ -389,7 +344,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|||||||
Code* code,
|
Code* code,
|
||||||
SharedFunctionInfo* shared,
|
SharedFunctionInfo* shared,
|
||||||
String* source, int line) {
|
String* source, int line) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent(
|
processor_->CodeCreateEvent(
|
||||||
tag,
|
tag,
|
||||||
shared->DebugName(),
|
shared->DebugName(),
|
||||||
source,
|
source,
|
||||||
@ -402,7 +357,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|||||||
|
|
||||||
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code, int args_count) {
|
Code* code, int args_count) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent(
|
processor_->CodeCreateEvent(
|
||||||
tag,
|
tag,
|
||||||
args_count,
|
args_count,
|
||||||
code->address(),
|
code->address(),
|
||||||
@ -411,7 +366,7 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
|||||||
|
|
||||||
|
|
||||||
void CpuProfiler::CodeMoveEvent(Address from, Address to) {
|
void CpuProfiler::CodeMoveEvent(Address from, Address to) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CodeMoveEvent(from, to);
|
processor_->CodeMoveEvent(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -420,19 +375,18 @@ void CpuProfiler::CodeDeleteEvent(Address from) {
|
|||||||
|
|
||||||
|
|
||||||
void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) {
|
void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) {
|
||||||
CpuProfiler* profiler = Isolate::Current()->cpu_profiler();
|
processor_->SharedFunctionInfoMoveEvent(from, to);
|
||||||
profiler->processor_->SharedFunctionInfoMoveEvent(from, to);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
|
void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent(
|
processor_->CallbackCreateEvent(
|
||||||
Logger::CALLBACK_TAG, "get ", name, entry_point);
|
Logger::CALLBACK_TAG, "get ", name, entry_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
|
void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->RegExpCodeCreateEvent(
|
processor_->RegExpCodeCreateEvent(
|
||||||
Logger::REG_EXP_TAG,
|
Logger::REG_EXP_TAG,
|
||||||
"RegExp: ",
|
"RegExp: ",
|
||||||
source,
|
source,
|
||||||
@ -442,13 +396,14 @@ void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
|
|||||||
|
|
||||||
|
|
||||||
void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
|
void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
|
||||||
Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent(
|
processor_->CallbackCreateEvent(
|
||||||
Logger::CALLBACK_TAG, "set ", name, entry_point);
|
Logger::CALLBACK_TAG, "set ", name, entry_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CpuProfiler::CpuProfiler()
|
CpuProfiler::CpuProfiler(Isolate* isolate)
|
||||||
: profiles_(new CpuProfilesCollection()),
|
: isolate_(isolate),
|
||||||
|
profiles_(new CpuProfilesCollection()),
|
||||||
next_profile_uid_(1),
|
next_profile_uid_(1),
|
||||||
token_enumerator_(new TokenEnumerator()),
|
token_enumerator_(new TokenEnumerator()),
|
||||||
generator_(NULL),
|
generator_(NULL),
|
||||||
@ -469,8 +424,7 @@ void CpuProfiler::ResetProfiles() {
|
|||||||
profiles_ = new CpuProfilesCollection();
|
profiles_ = new CpuProfilesCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuProfiler::StartCollectingProfile(const char* title,
|
void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
|
||||||
bool record_samples) {
|
|
||||||
if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) {
|
if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) {
|
||||||
StartProcessorIfNotStarted();
|
StartProcessorIfNotStarted();
|
||||||
}
|
}
|
||||||
@ -478,35 +432,33 @@ void CpuProfiler::StartCollectingProfile(const char* title,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::StartCollectingProfile(String* title, bool record_samples) {
|
void CpuProfiler::StartProfiling(String* title, bool record_samples) {
|
||||||
StartCollectingProfile(profiles_->GetName(title), record_samples);
|
StartProfiling(profiles_->GetName(title), record_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::StartProcessorIfNotStarted() {
|
void CpuProfiler::StartProcessorIfNotStarted() {
|
||||||
if (processor_ == NULL) {
|
if (processor_ == NULL) {
|
||||||
Isolate* isolate = Isolate::Current();
|
|
||||||
|
|
||||||
// Disable logging when using the new implementation.
|
// Disable logging when using the new implementation.
|
||||||
saved_logging_nesting_ = isolate->logger()->logging_nesting_;
|
saved_logging_nesting_ = isolate_->logger()->logging_nesting_;
|
||||||
isolate->logger()->logging_nesting_ = 0;
|
isolate_->logger()->logging_nesting_ = 0;
|
||||||
generator_ = new ProfileGenerator(profiles_);
|
generator_ = new ProfileGenerator(profiles_);
|
||||||
processor_ = new ProfilerEventsProcessor(generator_);
|
processor_ = new ProfilerEventsProcessor(generator_);
|
||||||
is_profiling_ = true;
|
is_profiling_ = true;
|
||||||
processor_->Start();
|
processor_->Start();
|
||||||
// Enumerate stuff we already have in the heap.
|
// Enumerate stuff we already have in the heap.
|
||||||
if (isolate->heap()->HasBeenSetUp()) {
|
if (isolate_->heap()->HasBeenSetUp()) {
|
||||||
if (!FLAG_prof_browser_mode) {
|
if (!FLAG_prof_browser_mode) {
|
||||||
bool saved_log_code_flag = FLAG_log_code;
|
bool saved_log_code_flag = FLAG_log_code;
|
||||||
FLAG_log_code = true;
|
FLAG_log_code = true;
|
||||||
isolate->logger()->LogCodeObjects();
|
isolate_->logger()->LogCodeObjects();
|
||||||
FLAG_log_code = saved_log_code_flag;
|
FLAG_log_code = saved_log_code_flag;
|
||||||
}
|
}
|
||||||
isolate->logger()->LogCompiledFunctions();
|
isolate_->logger()->LogCompiledFunctions();
|
||||||
isolate->logger()->LogAccessorCallbacks();
|
isolate_->logger()->LogAccessorCallbacks();
|
||||||
}
|
}
|
||||||
// Enable stack sampling.
|
// Enable stack sampling.
|
||||||
Sampler* sampler = reinterpret_cast<Sampler*>(isolate->logger()->ticker_);
|
Sampler* sampler = reinterpret_cast<Sampler*>(isolate_->logger()->ticker_);
|
||||||
if (!sampler->IsActive()) {
|
if (!sampler->IsActive()) {
|
||||||
sampler->Start();
|
sampler->Start();
|
||||||
need_to_stop_sampler_ = true;
|
need_to_stop_sampler_ = true;
|
||||||
@ -516,7 +468,8 @@ void CpuProfiler::StartProcessorIfNotStarted() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
|
CpuProfile* CpuProfiler::StopProfiling(const char* title) {
|
||||||
|
if (!is_profiling_) return NULL;
|
||||||
const double actual_sampling_rate = generator_->actual_sampling_rate();
|
const double actual_sampling_rate = generator_->actual_sampling_rate();
|
||||||
StopProcessorIfLastProfile(title);
|
StopProcessorIfLastProfile(title);
|
||||||
CpuProfile* result =
|
CpuProfile* result =
|
||||||
@ -530,8 +483,8 @@ CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CpuProfile* CpuProfiler::StopCollectingProfile(Object* security_token,
|
CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
|
||||||
String* title) {
|
if (!is_profiling_) return NULL;
|
||||||
const double actual_sampling_rate = generator_->actual_sampling_rate();
|
const double actual_sampling_rate = generator_->actual_sampling_rate();
|
||||||
const char* profile_title = profiles_->GetName(title);
|
const char* profile_title = profiles_->GetName(title);
|
||||||
StopProcessorIfLastProfile(profile_title);
|
StopProcessorIfLastProfile(profile_title);
|
||||||
@ -546,7 +499,7 @@ void CpuProfiler::StopProcessorIfLastProfile(const char* title) {
|
|||||||
|
|
||||||
|
|
||||||
void CpuProfiler::StopProcessor() {
|
void CpuProfiler::StopProcessor() {
|
||||||
Logger* logger = Isolate::Current()->logger();
|
Logger* logger = isolate_->logger();
|
||||||
Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_);
|
Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_);
|
||||||
sampler->DecreaseProfilingDepth();
|
sampler->DecreaseProfilingDepth();
|
||||||
if (need_to_stop_sampler_) {
|
if (need_to_stop_sampler_) {
|
||||||
@ -564,20 +517,4 @@ void CpuProfiler::StopProcessor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::SetUp() {
|
|
||||||
Isolate* isolate = Isolate::Current();
|
|
||||||
if (isolate->cpu_profiler() == NULL) {
|
|
||||||
isolate->set_cpu_profiler(new CpuProfiler());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CpuProfiler::TearDown() {
|
|
||||||
Isolate* isolate = Isolate::Current();
|
|
||||||
if (isolate->cpu_profiler() != NULL) {
|
|
||||||
delete isolate->cpu_profiler();
|
|
||||||
}
|
|
||||||
isolate->set_cpu_profiler(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
} } // namespace v8::internal
|
} } // namespace v8::internal
|
||||||
|
@ -184,84 +184,71 @@ class ProfilerEventsProcessor : public Thread {
|
|||||||
unsigned enqueue_order_;
|
unsigned enqueue_order_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} } // namespace v8::internal
|
|
||||||
|
|
||||||
|
#define PROFILE(IsolateGetter, Call) \
|
||||||
#define PROFILE(isolate, Call) \
|
do { \
|
||||||
LOG_CODE_EVENT(isolate, Call); \
|
Isolate* cpu_profiler_isolate = (IsolateGetter); \
|
||||||
do { \
|
LOG_CODE_EVENT(cpu_profiler_isolate, Call); \
|
||||||
if (v8::internal::CpuProfiler::is_profiling(isolate)) { \
|
CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \
|
||||||
v8::internal::CpuProfiler::Call; \
|
if (cpu_profiler->is_profiling()) { \
|
||||||
} \
|
cpu_profiler->Call; \
|
||||||
|
} \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
|
|
||||||
namespace v8 {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
|
|
||||||
// TODO(isolates): isolatify this class.
|
|
||||||
class CpuProfiler {
|
class CpuProfiler {
|
||||||
public:
|
public:
|
||||||
static void SetUp();
|
explicit CpuProfiler(Isolate* isolate);
|
||||||
static void TearDown();
|
~CpuProfiler();
|
||||||
|
|
||||||
static void StartProfiling(const char* title);
|
void StartProfiling(const char* title, bool record_samples = false);
|
||||||
static void StartProfiling(String* title, bool record_samples);
|
void StartProfiling(String* title, bool record_samples);
|
||||||
static CpuProfile* StopProfiling(const char* title);
|
CpuProfile* StopProfiling(const char* title);
|
||||||
static CpuProfile* StopProfiling(Object* security_token, String* title);
|
CpuProfile* StopProfiling(Object* security_token, String* title);
|
||||||
static int GetProfilesCount();
|
int GetProfilesCount();
|
||||||
static CpuProfile* GetProfile(Object* security_token, int index);
|
CpuProfile* GetProfile(Object* security_token, int index);
|
||||||
static CpuProfile* FindProfile(Object* security_token, unsigned uid);
|
CpuProfile* FindProfile(Object* security_token, unsigned uid);
|
||||||
static void DeleteAllProfiles();
|
void DeleteAllProfiles();
|
||||||
static void DeleteProfile(CpuProfile* profile);
|
void DeleteProfile(CpuProfile* profile);
|
||||||
static bool HasDetachedProfiles();
|
bool HasDetachedProfiles();
|
||||||
|
|
||||||
// Invoked from stack sampler (thread or signal handler.)
|
// Invoked from stack sampler (thread or signal handler.)
|
||||||
static TickSample* TickSampleEvent(Isolate* isolate);
|
TickSample* TickSampleEvent();
|
||||||
|
|
||||||
// Must be called via PROFILE macro, otherwise will crash when
|
// Must be called via PROFILE macro, otherwise will crash when
|
||||||
// profiling is not enabled.
|
// profiling is not enabled.
|
||||||
static void CallbackEvent(Name* name, Address entry_point);
|
void CallbackEvent(Name* name, Address entry_point);
|
||||||
static void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code, const char* comment);
|
Code* code, const char* comment);
|
||||||
static void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code, Name* name);
|
Code* code, Name* name);
|
||||||
static void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code,
|
Code* code,
|
||||||
SharedFunctionInfo* shared,
|
SharedFunctionInfo* shared,
|
||||||
Name* name);
|
Name* name);
|
||||||
static void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code,
|
Code* code,
|
||||||
SharedFunctionInfo* shared,
|
SharedFunctionInfo* shared,
|
||||||
String* source, int line);
|
String* source, int line);
|
||||||
static void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
void CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||||
Code* code, int args_count);
|
Code* code, int args_count);
|
||||||
static void CodeMovingGCEvent() {}
|
void CodeMovingGCEvent() {}
|
||||||
static void CodeMoveEvent(Address from, Address to);
|
void CodeMoveEvent(Address from, Address to);
|
||||||
static void CodeDeleteEvent(Address from);
|
void CodeDeleteEvent(Address from);
|
||||||
static void GetterCallbackEvent(Name* name, Address entry_point);
|
void GetterCallbackEvent(Name* name, Address entry_point);
|
||||||
static void RegExpCodeCreateEvent(Code* code, String* source);
|
void RegExpCodeCreateEvent(Code* code, String* source);
|
||||||
static void SetterCallbackEvent(Name* name, Address entry_point);
|
void SetterCallbackEvent(Name* name, Address entry_point);
|
||||||
static void SharedFunctionInfoMoveEvent(Address from, Address to);
|
void SharedFunctionInfoMoveEvent(Address from, Address to);
|
||||||
|
|
||||||
static INLINE(bool is_profiling(Isolate* isolate)) {
|
INLINE(bool is_profiling() const) { return is_profiling_; }
|
||||||
CpuProfiler* profiler = isolate->cpu_profiler();
|
|
||||||
return profiler != NULL && profiler->is_profiling_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CpuProfiler();
|
|
||||||
~CpuProfiler();
|
|
||||||
void StartCollectingProfile(const char* title, bool record_samples);
|
|
||||||
void StartCollectingProfile(String* title, bool record_samples);
|
|
||||||
void StartProcessorIfNotStarted();
|
void StartProcessorIfNotStarted();
|
||||||
CpuProfile* StopCollectingProfile(const char* title);
|
|
||||||
CpuProfile* StopCollectingProfile(Object* security_token, String* title);
|
|
||||||
void StopProcessorIfLastProfile(const char* title);
|
void StopProcessorIfLastProfile(const char* title);
|
||||||
void StopProcessor();
|
void StopProcessor();
|
||||||
void ResetProfiles();
|
void ResetProfiles();
|
||||||
|
|
||||||
|
Isolate* isolate_;
|
||||||
CpuProfilesCollection* profiles_;
|
CpuProfilesCollection* profiles_;
|
||||||
unsigned next_profile_uid_;
|
unsigned next_profile_uid_;
|
||||||
TokenEnumerator* token_enumerator_;
|
TokenEnumerator* token_enumerator_;
|
||||||
|
@ -1858,7 +1858,7 @@ class ScavengingVisitor : public StaticVisitorBase {
|
|||||||
HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address()));
|
HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address()));
|
||||||
Isolate* isolate = heap->isolate();
|
Isolate* isolate = heap->isolate();
|
||||||
if (isolate->logger()->is_logging_code_events() ||
|
if (isolate->logger()->is_logging_code_events() ||
|
||||||
CpuProfiler::is_profiling(isolate)) {
|
isolate->cpu_profiler()->is_profiling()) {
|
||||||
if (target->IsSharedFunctionInfo()) {
|
if (target->IsSharedFunctionInfo()) {
|
||||||
PROFILE(isolate, SharedFunctionInfoMoveEvent(
|
PROFILE(isolate, SharedFunctionInfoMoveEvent(
|
||||||
source->address(), target->address()));
|
source->address(), target->address()));
|
||||||
@ -2114,7 +2114,7 @@ static void InitializeScavengingVisitorsTables() {
|
|||||||
void Heap::SelectScavengingVisitorsTable() {
|
void Heap::SelectScavengingVisitorsTable() {
|
||||||
bool logging_and_profiling =
|
bool logging_and_profiling =
|
||||||
isolate()->logger()->is_logging() ||
|
isolate()->logger()->is_logging() ||
|
||||||
CpuProfiler::is_profiling(isolate()) ||
|
isolate()->cpu_profiler()->is_profiling() ||
|
||||||
(isolate()->heap_profiler() != NULL &&
|
(isolate()->heap_profiler() != NULL &&
|
||||||
isolate()->heap_profiler()->is_profiling());
|
isolate()->heap_profiler()->is_profiling());
|
||||||
|
|
||||||
|
@ -1693,6 +1693,7 @@ Isolate::Isolate()
|
|||||||
date_cache_(NULL),
|
date_cache_(NULL),
|
||||||
code_stub_interface_descriptors_(NULL),
|
code_stub_interface_descriptors_(NULL),
|
||||||
context_exit_happened_(false),
|
context_exit_happened_(false),
|
||||||
|
cpu_profiler_(NULL),
|
||||||
deferred_handles_head_(NULL),
|
deferred_handles_head_(NULL),
|
||||||
optimizing_compiler_thread_(this),
|
optimizing_compiler_thread_(this),
|
||||||
marking_thread_(NULL),
|
marking_thread_(NULL),
|
||||||
@ -1825,7 +1826,9 @@ void Isolate::Deinit() {
|
|||||||
PreallocatedMemoryThreadStop();
|
PreallocatedMemoryThreadStop();
|
||||||
|
|
||||||
HeapProfiler::TearDown();
|
HeapProfiler::TearDown();
|
||||||
CpuProfiler::TearDown();
|
delete cpu_profiler_;
|
||||||
|
cpu_profiler_ = NULL;
|
||||||
|
|
||||||
if (runtime_profiler_ != NULL) {
|
if (runtime_profiler_ != NULL) {
|
||||||
runtime_profiler_->TearDown();
|
runtime_profiler_->TearDown();
|
||||||
delete runtime_profiler_;
|
delete runtime_profiler_;
|
||||||
@ -2054,7 +2057,7 @@ bool Isolate::Init(Deserializer* des) {
|
|||||||
// Enable logging before setting up the heap
|
// Enable logging before setting up the heap
|
||||||
logger_->SetUp();
|
logger_->SetUp();
|
||||||
|
|
||||||
CpuProfiler::SetUp();
|
cpu_profiler_ = new CpuProfiler(this);
|
||||||
HeapProfiler::SetUp();
|
HeapProfiler::SetUp();
|
||||||
|
|
||||||
// Initialize other runtime facilities
|
// Initialize other runtime facilities
|
||||||
|
@ -357,9 +357,6 @@ typedef List<HeapObject*, PreallocatedStorageAllocationPolicy> DebugObjectCache;
|
|||||||
V(FunctionInfoListener*, active_function_info_listener, NULL) \
|
V(FunctionInfoListener*, active_function_info_listener, NULL) \
|
||||||
/* State for Relocatable. */ \
|
/* State for Relocatable. */ \
|
||||||
V(Relocatable*, relocatable_top, NULL) \
|
V(Relocatable*, relocatable_top, NULL) \
|
||||||
/* State for CodeEntry in profile-generator. */ \
|
|
||||||
V(CodeGenerator*, current_code_generator, NULL) \
|
|
||||||
V(bool, jump_target_compiling_deferred_code, false) \
|
|
||||||
V(DebugObjectCache*, string_stream_debug_object_cache, NULL) \
|
V(DebugObjectCache*, string_stream_debug_object_cache, NULL) \
|
||||||
V(Object*, string_stream_current_security_token, NULL) \
|
V(Object*, string_stream_current_security_token, NULL) \
|
||||||
/* TODO(isolates): Release this on destruction? */ \
|
/* TODO(isolates): Release this on destruction? */ \
|
||||||
@ -371,7 +368,6 @@ typedef List<HeapObject*, PreallocatedStorageAllocationPolicy> DebugObjectCache;
|
|||||||
V(unsigned, ast_node_count, 0) \
|
V(unsigned, ast_node_count, 0) \
|
||||||
/* SafeStackFrameIterator activations count. */ \
|
/* SafeStackFrameIterator activations count. */ \
|
||||||
V(int, safe_stack_iterator_counter, 0) \
|
V(int, safe_stack_iterator_counter, 0) \
|
||||||
V(CpuProfiler*, cpu_profiler, NULL) \
|
|
||||||
V(HeapProfiler*, heap_profiler, NULL) \
|
V(HeapProfiler*, heap_profiler, NULL) \
|
||||||
V(bool, observer_delivery_pending, false) \
|
V(bool, observer_delivery_pending, false) \
|
||||||
V(HStatistics*, hstatistics, NULL) \
|
V(HStatistics*, hstatistics, NULL) \
|
||||||
@ -979,6 +975,8 @@ class Isolate {
|
|||||||
inline bool IsDebuggerActive();
|
inline bool IsDebuggerActive();
|
||||||
inline bool DebuggerHasBreakPoints();
|
inline bool DebuggerHasBreakPoints();
|
||||||
|
|
||||||
|
CpuProfiler* cpu_profiler() const { return cpu_profiler_; }
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
HistogramInfo* heap_histograms() { return heap_histograms_; }
|
HistogramInfo* heap_histograms() { return heap_histograms_; }
|
||||||
|
|
||||||
@ -1314,6 +1312,7 @@ class Isolate {
|
|||||||
Debugger* debugger_;
|
Debugger* debugger_;
|
||||||
Debug* debug_;
|
Debug* debug_;
|
||||||
#endif
|
#endif
|
||||||
|
CpuProfiler* cpu_profiler_;
|
||||||
|
|
||||||
#define GLOBAL_BACKING_STORE(type, name, initialvalue) \
|
#define GLOBAL_BACKING_STORE(type, name, initialvalue) \
|
||||||
type name##_;
|
type name##_;
|
||||||
|
16
src/log.cc
16
src/log.cc
@ -1682,7 +1682,7 @@ void Logger::LogCodeObject(Object* object) {
|
|||||||
tag = Logger::KEYED_CALL_IC_TAG;
|
tag = Logger::KEYED_CALL_IC_TAG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PROFILE(ISOLATE, CodeCreateEvent(tag, code_object, description));
|
PROFILE(isolate_, CodeCreateEvent(tag, code_object, description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1786,20 +1786,20 @@ void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
|
|||||||
Handle<String> script_name(String::cast(script->name()));
|
Handle<String> script_name(String::cast(script->name()));
|
||||||
int line_num = GetScriptLineNumber(script, shared->start_position());
|
int line_num = GetScriptLineNumber(script, shared->start_position());
|
||||||
if (line_num > 0) {
|
if (line_num > 0) {
|
||||||
PROFILE(ISOLATE,
|
PROFILE(isolate_,
|
||||||
CodeCreateEvent(
|
CodeCreateEvent(
|
||||||
Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
|
Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
|
||||||
*code, *shared,
|
*code, *shared,
|
||||||
*script_name, line_num + 1));
|
*script_name, line_num + 1));
|
||||||
} else {
|
} else {
|
||||||
// Can't distinguish eval and script here, so always use Script.
|
// Can't distinguish eval and script here, so always use Script.
|
||||||
PROFILE(ISOLATE,
|
PROFILE(isolate_,
|
||||||
CodeCreateEvent(
|
CodeCreateEvent(
|
||||||
Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
|
Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
|
||||||
*code, *shared, *script_name));
|
*code, *shared, *script_name));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PROFILE(ISOLATE,
|
PROFILE(isolate_,
|
||||||
CodeCreateEvent(
|
CodeCreateEvent(
|
||||||
Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
|
Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG, *script),
|
||||||
*code, *shared, *func_name));
|
*code, *shared, *func_name));
|
||||||
@ -1812,10 +1812,10 @@ void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
|
|||||||
CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
|
CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data);
|
||||||
Object* callback_obj = call_data->callback();
|
Object* callback_obj = call_data->callback();
|
||||||
Address entry_point = v8::ToCData<Address>(callback_obj);
|
Address entry_point = v8::ToCData<Address>(callback_obj);
|
||||||
PROFILE(ISOLATE, CallbackEvent(*func_name, entry_point));
|
PROFILE(isolate_, CallbackEvent(*func_name, entry_point));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PROFILE(ISOLATE,
|
PROFILE(isolate_,
|
||||||
CodeCreateEvent(
|
CodeCreateEvent(
|
||||||
Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name));
|
Logger::LAZY_COMPILE_TAG, *code, *shared, *func_name));
|
||||||
}
|
}
|
||||||
@ -1856,11 +1856,11 @@ void Logger::LogAccessorCallbacks() {
|
|||||||
Address getter_entry = v8::ToCData<Address>(ai->getter());
|
Address getter_entry = v8::ToCData<Address>(ai->getter());
|
||||||
Name* name = Name::cast(ai->name());
|
Name* name = Name::cast(ai->name());
|
||||||
if (getter_entry != 0) {
|
if (getter_entry != 0) {
|
||||||
PROFILE(ISOLATE, GetterCallbackEvent(name, getter_entry));
|
PROFILE(isolate_, GetterCallbackEvent(name, getter_entry));
|
||||||
}
|
}
|
||||||
Address setter_entry = v8::ToCData<Address>(ai->setter());
|
Address setter_entry = v8::ToCData<Address>(ai->setter());
|
||||||
if (setter_entry != 0) {
|
if (setter_entry != 0) {
|
||||||
PROFILE(ISOLATE, SetterCallbackEvent(name, setter_entry));
|
PROFILE(isolate_, SetterCallbackEvent(name, setter_entry));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -687,13 +687,14 @@ class SamplerThread : public Thread {
|
|||||||
CONTEXT context;
|
CONTEXT context;
|
||||||
memset(&context, 0, sizeof(context));
|
memset(&context, 0, sizeof(context));
|
||||||
|
|
||||||
|
Isolate* isolate = sampler->isolate();
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
|
static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
|
||||||
if (SuspendThread(profiled_thread) == kSuspendFailed) return;
|
if (SuspendThread(profiled_thread) == kSuspendFailed) return;
|
||||||
sample->state = sampler->isolate()->current_vm_state();
|
sample->state = isolate->current_vm_state();
|
||||||
|
|
||||||
context.ContextFlags = CONTEXT_FULL;
|
context.ContextFlags = CONTEXT_FULL;
|
||||||
if (GetThreadContext(profiled_thread, &context) != 0) {
|
if (GetThreadContext(profiled_thread, &context) != 0) {
|
||||||
|
@ -715,7 +715,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||||||
if (sampler == NULL || !sampler->IsActive()) return;
|
if (sampler == NULL || !sampler->IsActive()) return;
|
||||||
|
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(isolate);
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
// Extracting the sample from the context is extremely machine dependent.
|
// Extracting the sample from the context is extremely machine dependent.
|
||||||
|
@ -1088,7 +1088,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||||||
if (sampler == NULL || !sampler->IsActive()) return;
|
if (sampler == NULL || !sampler->IsActive()) return;
|
||||||
|
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(isolate);
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
// Extracting the sample from the context is extremely machine dependent.
|
// Extracting the sample from the context is extremely machine dependent.
|
||||||
|
@ -818,8 +818,9 @@ class SamplerThread : public Thread {
|
|||||||
|
|
||||||
void SampleContext(Sampler* sampler) {
|
void SampleContext(Sampler* sampler) {
|
||||||
thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
|
thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
|
||||||
|
Isolate* isolate = sampler->isolate();
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
if (KERN_SUCCESS != thread_suspend(profiled_thread)) return;
|
if (KERN_SUCCESS != thread_suspend(profiled_thread)) return;
|
||||||
@ -850,7 +851,7 @@ class SamplerThread : public Thread {
|
|||||||
flavor,
|
flavor,
|
||||||
reinterpret_cast<natural_t*>(&state),
|
reinterpret_cast<natural_t*>(&state),
|
||||||
&count) == KERN_SUCCESS) {
|
&count) == KERN_SUCCESS) {
|
||||||
sample->state = sampler->isolate()->current_vm_state();
|
sample->state = isolate->current_vm_state();
|
||||||
sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
|
sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
|
||||||
sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
|
sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
|
||||||
sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
|
sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
|
||||||
|
@ -748,7 +748,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||||||
if (sampler == NULL || !sampler->IsActive()) return;
|
if (sampler == NULL || !sampler->IsActive()) return;
|
||||||
|
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(isolate);
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
// Extracting the sample from the context is extremely machine dependent.
|
// Extracting the sample from the context is extremely machine dependent.
|
||||||
|
@ -682,7 +682,7 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
|||||||
if (sampler == NULL || !sampler->IsActive()) return;
|
if (sampler == NULL || !sampler->IsActive()) return;
|
||||||
|
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(isolate);
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
// Extracting the sample from the context is extremely machine dependent.
|
// Extracting the sample from the context is extremely machine dependent.
|
||||||
|
@ -2064,13 +2064,14 @@ class SamplerThread : public Thread {
|
|||||||
CONTEXT context;
|
CONTEXT context;
|
||||||
memset(&context, 0, sizeof(context));
|
memset(&context, 0, sizeof(context));
|
||||||
|
|
||||||
|
Isolate* isolate = sampler->isolate();
|
||||||
TickSample sample_obj;
|
TickSample sample_obj;
|
||||||
TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
|
TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
||||||
if (sample == NULL) sample = &sample_obj;
|
if (sample == NULL) sample = &sample_obj;
|
||||||
|
|
||||||
static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
|
static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
|
||||||
if (SuspendThread(profiled_thread) == kSuspendFailed) return;
|
if (SuspendThread(profiled_thread) == kSuspendFailed) return;
|
||||||
sample->state = sampler->isolate()->current_vm_state();
|
sample->state = isolate->current_vm_state();
|
||||||
|
|
||||||
context.ContextFlags = CONTEXT_FULL;
|
context.ContextFlags = CONTEXT_FULL;
|
||||||
if (GetThreadContext(profiled_thread, &context) != 0) {
|
if (GetThreadContext(profiled_thread, &context) != 0) {
|
||||||
|
@ -2364,7 +2364,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) {
|
|||||||
target->set_literals(*literals);
|
target->set_literals(*literals);
|
||||||
|
|
||||||
if (isolate->logger()->is_logging_code_events() ||
|
if (isolate->logger()->is_logging_code_events() ||
|
||||||
CpuProfiler::is_profiling(isolate)) {
|
isolate->cpu_profiler()->is_profiling()) {
|
||||||
isolate->logger()->LogExistingFunction(
|
isolate->logger()->LogExistingFunction(
|
||||||
source_shared, Handle<Code>(source_shared->code()));
|
source_shared, Handle<Code>(source_shared->code()));
|
||||||
}
|
}
|
||||||
|
@ -219,12 +219,11 @@ TEST(TickEvents) {
|
|||||||
TEST(CrashIfStoppingLastNonExistentProfile) {
|
TEST(CrashIfStoppingLastNonExistentProfile) {
|
||||||
InitializeVM();
|
InitializeVM();
|
||||||
TestSetup test_setup;
|
TestSetup test_setup;
|
||||||
CpuProfiler::SetUp();
|
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
|
||||||
CpuProfiler::StartProfiling("1");
|
profiler->StartProfiling("1");
|
||||||
CpuProfiler::StopProfiling("2");
|
profiler->StopProfiling("2");
|
||||||
CpuProfiler::StartProfiling("1");
|
profiler->StartProfiling("1");
|
||||||
CpuProfiler::StopProfiling("");
|
profiler->StopProfiling("");
|
||||||
CpuProfiler::TearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -271,32 +270,30 @@ TEST(Issue1398) {
|
|||||||
TEST(DeleteAllCpuProfiles) {
|
TEST(DeleteAllCpuProfiles) {
|
||||||
InitializeVM();
|
InitializeVM();
|
||||||
TestSetup test_setup;
|
TestSetup test_setup;
|
||||||
CpuProfiler::SetUp();
|
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
CpuProfiler::DeleteAllProfiles();
|
profiler->DeleteAllProfiles();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
|
|
||||||
CpuProfiler::StartProfiling("1");
|
profiler->StartProfiling("1");
|
||||||
CpuProfiler::StopProfiling("1");
|
profiler->StopProfiling("1");
|
||||||
CHECK_EQ(1, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(1, profiler->GetProfilesCount());
|
||||||
CpuProfiler::DeleteAllProfiles();
|
profiler->DeleteAllProfiles();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
CpuProfiler::StartProfiling("1");
|
profiler->StartProfiling("1");
|
||||||
CpuProfiler::StartProfiling("2");
|
profiler->StartProfiling("2");
|
||||||
CpuProfiler::StopProfiling("2");
|
profiler->StopProfiling("2");
|
||||||
CpuProfiler::StopProfiling("1");
|
profiler->StopProfiling("1");
|
||||||
CHECK_EQ(2, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(2, profiler->GetProfilesCount());
|
||||||
CpuProfiler::DeleteAllProfiles();
|
profiler->DeleteAllProfiles();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
|
|
||||||
// Test profiling cancellation by the 'delete' command.
|
// Test profiling cancellation by the 'delete' command.
|
||||||
CpuProfiler::StartProfiling("1");
|
profiler->StartProfiling("1");
|
||||||
CpuProfiler::StartProfiling("2");
|
profiler->StartProfiling("2");
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
CpuProfiler::DeleteAllProfiles();
|
profiler->DeleteAllProfiles();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
|
|
||||||
CpuProfiler::TearDown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -313,7 +310,7 @@ TEST(DeleteCpuProfile) {
|
|||||||
unsigned uid1 = p1->GetUid();
|
unsigned uid1 = p1->GetUid();
|
||||||
CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
|
CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1));
|
||||||
const_cast<v8::CpuProfile*>(p1)->Delete();
|
const_cast<v8::CpuProfile*>(p1)->Delete();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
|
||||||
|
|
||||||
v8::Local<v8::String> name2 = v8::String::New("2");
|
v8::Local<v8::String> name2 = v8::String::New("2");
|
||||||
@ -339,7 +336,7 @@ TEST(DeleteCpuProfile) {
|
|||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
|
||||||
CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
|
CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
|
||||||
const_cast<v8::CpuProfile*>(p3)->Delete();
|
const_cast<v8::CpuProfile*>(p3)->Delete();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
|
||||||
@ -364,11 +361,11 @@ TEST(DeleteCpuProfileDifferentTokens) {
|
|||||||
CHECK_NE(p1, p1_t1);
|
CHECK_NE(p1, p1_t1);
|
||||||
CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
|
CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount());
|
||||||
const_cast<v8::CpuProfile*>(p1)->Delete();
|
const_cast<v8::CpuProfile*>(p1)->Delete();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1));
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1));
|
||||||
const_cast<v8::CpuProfile*>(p1_t1)->Delete();
|
const_cast<v8::CpuProfile*>(p1_t1)->Delete();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
|
||||||
|
|
||||||
v8::Local<v8::String> name2 = v8::String::New("2");
|
v8::Local<v8::String> name2 = v8::String::New("2");
|
||||||
v8::CpuProfiler::StartProfiling(name2);
|
v8::CpuProfiler::StartProfiling(name2);
|
||||||
@ -397,6 +394,6 @@ TEST(DeleteCpuProfileDifferentTokens) {
|
|||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2));
|
||||||
CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
|
CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3));
|
||||||
const_cast<v8::CpuProfile*>(p3)->Delete();
|
const_cast<v8::CpuProfile*>(p3)->Delete();
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
|
||||||
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
|
CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3));
|
||||||
}
|
}
|
||||||
|
@ -876,16 +876,16 @@ TEST(RecordStackTraceAtStartProfiling) {
|
|||||||
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
||||||
env->Enter();
|
env->Enter();
|
||||||
|
|
||||||
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
|
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
|
||||||
|
CHECK_EQ(0, profiler->GetProfilesCount());
|
||||||
CompileRun(
|
CompileRun(
|
||||||
"function c() { startProfiling(); }\n"
|
"function c() { startProfiling(); }\n"
|
||||||
"function b() { c(); }\n"
|
"function b() { c(); }\n"
|
||||||
"function a() { b(); }\n"
|
"function a() { b(); }\n"
|
||||||
"a();\n"
|
"a();\n"
|
||||||
"stopProfiling();");
|
"stopProfiling();");
|
||||||
CHECK_EQ(1, CpuProfiler::GetProfilesCount());
|
CHECK_EQ(1, profiler->GetProfilesCount());
|
||||||
CpuProfile* profile =
|
CpuProfile* profile = profiler->GetProfile(NULL, 0);
|
||||||
CpuProfiler::GetProfile(NULL, 0);
|
|
||||||
const ProfileTree* topDown = profile->top_down();
|
const ProfileTree* topDown = profile->top_down();
|
||||||
const ProfileNode* current = topDown->root();
|
const ProfileNode* current = topDown->root();
|
||||||
const_cast<ProfileNode*>(current)->Print(0);
|
const_cast<ProfileNode*>(current)->Print(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user