Delete deprecated CPU profiler code that supports filtering by security token
The methods that allow to filter CPU profile by security token were introduced to support console.profiles in WebKit. Now that console.profiles is removed and corresponding V8 API methods have been deprecated in 3.19 branch(https://code.google.com/p/v8/source/browse/branches/3.19/include/v8-profiler.h) it is safe to remove all that code. BUG=None R=jkummerow@chromium.org, loislo@chromium.org Review URL: https://codereview.chromium.org/18709003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15528 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
a925b6b8de
commit
696090196d
@ -181,18 +181,9 @@ class V8EXPORT CpuProfiler {
|
||||
*/
|
||||
int GetProfileCount();
|
||||
|
||||
/** Deprecated. Use GetCpuProfile with single parameter. */
|
||||
V8_DEPRECATED(const CpuProfile* GetCpuProfile(
|
||||
int index,
|
||||
Handle<Value> security_token));
|
||||
/** Returns a profile by index. */
|
||||
const CpuProfile* GetCpuProfile(int index);
|
||||
|
||||
/** Returns a profile by uid. */
|
||||
V8_DEPRECATED(const CpuProfile* FindCpuProfile(
|
||||
unsigned uid,
|
||||
Handle<Value> security_token = Handle<Value>()));
|
||||
|
||||
/**
|
||||
* Starts collecting CPU profile. Title may be an empty string. It
|
||||
* is allowed to have several profiles being collected at
|
||||
@ -206,12 +197,6 @@ class V8EXPORT CpuProfiler {
|
||||
*/
|
||||
void StartCpuProfiling(Handle<String> title, bool record_samples = false);
|
||||
|
||||
/**
|
||||
* Deprecated. Use StopCpuProfiling with one parameter instead.
|
||||
*/
|
||||
V8_DEPRECATED(const CpuProfile* StopCpuProfiling(
|
||||
Handle<String> title,
|
||||
Handle<Value> security_token));
|
||||
/**
|
||||
* Stops collecting CPU profile with a given title and returns it.
|
||||
* If the title given is empty, finishes the last profile started.
|
||||
|
32
src/api.cc
32
src/api.cc
@ -7453,7 +7453,7 @@ void CpuProfile::Delete() {
|
||||
i::CpuProfiler* profiler = isolate->cpu_profiler();
|
||||
ASSERT(profiler != NULL);
|
||||
profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
|
||||
if (profiler->GetProfilesCount() == 0 && !profiler->HasDetachedProfiles()) {
|
||||
if (profiler->GetProfilesCount() == 0) {
|
||||
// If this was the last profile, clean up all accessory data as well.
|
||||
profiler->DeleteAllProfiles();
|
||||
}
|
||||
@ -7500,27 +7500,9 @@ int CpuProfiler::GetProfileCount() {
|
||||
}
|
||||
|
||||
|
||||
const CpuProfile* CpuProfiler::GetCpuProfile(int index,
|
||||
Handle<Value> security_token) {
|
||||
return reinterpret_cast<const CpuProfile*>(
|
||||
reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(
|
||||
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
||||
index));
|
||||
}
|
||||
|
||||
|
||||
const CpuProfile* CpuProfiler::GetCpuProfile(int index) {
|
||||
return reinterpret_cast<const CpuProfile*>(
|
||||
reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(NULL, index));
|
||||
}
|
||||
|
||||
|
||||
const CpuProfile* CpuProfiler::FindCpuProfile(unsigned uid,
|
||||
Handle<Value> security_token) {
|
||||
return reinterpret_cast<const CpuProfile*>(
|
||||
reinterpret_cast<i::CpuProfiler*>(this)->FindProfile(
|
||||
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
||||
uid));
|
||||
reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(index));
|
||||
}
|
||||
|
||||
|
||||
@ -7530,19 +7512,9 @@ void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
|
||||
}
|
||||
|
||||
|
||||
const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title,
|
||||
Handle<Value> security_token) {
|
||||
return reinterpret_cast<const CpuProfile*>(
|
||||
reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
|
||||
security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
|
||||
*Utils::OpenHandle(*title)));
|
||||
}
|
||||
|
||||
|
||||
const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) {
|
||||
return reinterpret_cast<const CpuProfile*>(
|
||||
reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling(
|
||||
NULL,
|
||||
*Utils::OpenHandle(*title)));
|
||||
}
|
||||
|
||||
|
@ -152,19 +152,12 @@ void ProfilerEventsProcessor::Run() {
|
||||
|
||||
int CpuProfiler::GetProfilesCount() {
|
||||
// The count of profiles doesn't depend on a security token.
|
||||
return profiles_->Profiles(TokenEnumerator::kNoSecurityToken)->length();
|
||||
return profiles_->profiles()->length();
|
||||
}
|
||||
|
||||
|
||||
CpuProfile* CpuProfiler::GetProfile(Object* security_token, int index) {
|
||||
const int token = token_enumerator_->GetTokenId(security_token);
|
||||
return profiles_->Profiles(token)->at(index);
|
||||
}
|
||||
|
||||
|
||||
CpuProfile* CpuProfiler::FindProfile(Object* security_token, unsigned uid) {
|
||||
const int token = token_enumerator_->GetTokenId(security_token);
|
||||
return profiles_->GetProfile(token, uid);
|
||||
CpuProfile* CpuProfiler::GetProfile(int index) {
|
||||
return profiles_->profiles()->at(index);
|
||||
}
|
||||
|
||||
|
||||
@ -186,11 +179,6 @@ void CpuProfiler::DeleteProfile(CpuProfile* profile) {
|
||||
}
|
||||
|
||||
|
||||
bool CpuProfiler::HasDetachedProfiles() {
|
||||
return profiles_->HasDetachedProfiles();
|
||||
}
|
||||
|
||||
|
||||
static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag) {
|
||||
return FLAG_prof_browser_mode
|
||||
&& (tag != Logger::CALLBACK_TAG
|
||||
@ -208,8 +196,7 @@ void CpuProfiler::CallbackEvent(Name* name, Address entry_point) {
|
||||
rec->start = entry_point;
|
||||
rec->entry = profiles_->NewCodeEntry(
|
||||
Logger::CALLBACK_TAG,
|
||||
profiles_->GetName(name),
|
||||
TokenEnumerator::kInheritsSecurityToken);
|
||||
profiles_->GetName(name));
|
||||
rec->size = 1;
|
||||
rec->shared = NULL;
|
||||
processor_->Enqueue(evt_rec);
|
||||
@ -280,7 +267,6 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||
rec->entry = profiles_->NewCodeEntry(
|
||||
tag,
|
||||
profiles_->GetFunctionName(shared->DebugName()),
|
||||
TokenEnumerator::kNoSecurityToken,
|
||||
CodeEntry::kEmptyNamePrefix,
|
||||
profiles_->GetName(source),
|
||||
line);
|
||||
@ -306,7 +292,6 @@ void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
|
||||
rec->entry = profiles_->NewCodeEntry(
|
||||
tag,
|
||||
profiles_->GetName(args_count),
|
||||
TokenEnumerator::kInheritsSecurityToken,
|
||||
"args_count: ");
|
||||
rec->size = code->ExecutableSize();
|
||||
rec->shared = NULL;
|
||||
@ -345,7 +330,6 @@ void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
|
||||
rec->entry = profiles_->NewCodeEntry(
|
||||
Logger::CALLBACK_TAG,
|
||||
profiles_->GetName(name),
|
||||
TokenEnumerator::kInheritsSecurityToken,
|
||||
"get ");
|
||||
rec->size = 1;
|
||||
rec->shared = NULL;
|
||||
@ -361,7 +345,6 @@ void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
|
||||
rec->entry = profiles_->NewCodeEntry(
|
||||
Logger::REG_EXP_TAG,
|
||||
profiles_->GetName(source),
|
||||
TokenEnumerator::kInheritsSecurityToken,
|
||||
"RegExp: ");
|
||||
rec->size = code->ExecutableSize();
|
||||
processor_->Enqueue(evt_rec);
|
||||
@ -376,7 +359,6 @@ void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
|
||||
rec->entry = profiles_->NewCodeEntry(
|
||||
Logger::CALLBACK_TAG,
|
||||
profiles_->GetName(name),
|
||||
TokenEnumerator::kInheritsSecurityToken,
|
||||
"set ");
|
||||
rec->size = 1;
|
||||
rec->shared = NULL;
|
||||
@ -388,7 +370,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate)
|
||||
: isolate_(isolate),
|
||||
profiles_(new CpuProfilesCollection()),
|
||||
next_profile_uid_(1),
|
||||
token_enumerator_(new TokenEnumerator()),
|
||||
generator_(NULL),
|
||||
processor_(NULL),
|
||||
need_to_stop_sampler_(false),
|
||||
@ -403,7 +384,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate,
|
||||
: isolate_(isolate),
|
||||
profiles_(test_profiles),
|
||||
next_profile_uid_(1),
|
||||
token_enumerator_(new TokenEnumerator()),
|
||||
generator_(test_generator),
|
||||
processor_(test_processor),
|
||||
need_to_stop_sampler_(false),
|
||||
@ -413,7 +393,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate,
|
||||
|
||||
CpuProfiler::~CpuProfiler() {
|
||||
ASSERT(!is_profiling_);
|
||||
delete token_enumerator_;
|
||||
delete profiles_;
|
||||
}
|
||||
|
||||
@ -470,10 +449,7 @@ CpuProfile* CpuProfiler::StopProfiling(const char* title) {
|
||||
if (!is_profiling_) return NULL;
|
||||
const double actual_sampling_rate = generator_->actual_sampling_rate();
|
||||
StopProcessorIfLastProfile(title);
|
||||
CpuProfile* result =
|
||||
profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken,
|
||||
title,
|
||||
actual_sampling_rate);
|
||||
CpuProfile* result = profiles_->StopProfiling(title, actual_sampling_rate);
|
||||
if (result != NULL) {
|
||||
result->Print();
|
||||
}
|
||||
@ -481,13 +457,12 @@ CpuProfile* CpuProfiler::StopProfiling(const char* title) {
|
||||
}
|
||||
|
||||
|
||||
CpuProfile* CpuProfiler::StopProfiling(Object* security_token, String* title) {
|
||||
CpuProfile* CpuProfiler::StopProfiling(String* title) {
|
||||
if (!is_profiling_) return NULL;
|
||||
const double actual_sampling_rate = generator_->actual_sampling_rate();
|
||||
const char* profile_title = profiles_->GetName(title);
|
||||
StopProcessorIfLastProfile(profile_title);
|
||||
int token = token_enumerator_->GetTokenId(security_token);
|
||||
return profiles_->StopProfiling(token, profile_title, actual_sampling_rate);
|
||||
return profiles_->StopProfiling(profile_title, actual_sampling_rate);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,6 @@ class CompilationInfo;
|
||||
class CpuProfile;
|
||||
class CpuProfilesCollection;
|
||||
class ProfileGenerator;
|
||||
class TokenEnumerator;
|
||||
|
||||
#define CODE_EVENTS_TYPE_LIST(V) \
|
||||
V(CODE_CREATION, CodeCreateEventRecord) \
|
||||
@ -208,13 +207,11 @@ class CpuProfiler {
|
||||
void StartProfiling(const char* title, bool record_samples = false);
|
||||
void StartProfiling(String* title, bool record_samples);
|
||||
CpuProfile* StopProfiling(const char* title);
|
||||
CpuProfile* StopProfiling(Object* security_token, String* title);
|
||||
CpuProfile* StopProfiling(String* title);
|
||||
int GetProfilesCount();
|
||||
CpuProfile* GetProfile(Object* security_token, int index);
|
||||
CpuProfile* FindProfile(Object* security_token, unsigned uid);
|
||||
CpuProfile* GetProfile(int index);
|
||||
void DeleteAllProfiles();
|
||||
void DeleteProfile(CpuProfile* profile);
|
||||
bool HasDetachedProfiles();
|
||||
|
||||
// Invoked from stack sampler (thread or signal handler.)
|
||||
TickSample* TickSampleEvent();
|
||||
@ -261,7 +258,6 @@ class CpuProfiler {
|
||||
Isolate* isolate_;
|
||||
CpuProfilesCollection* profiles_;
|
||||
unsigned next_profile_uid_;
|
||||
TokenEnumerator* token_enumerator_;
|
||||
ProfileGenerator* generator_;
|
||||
ProfilerEventsProcessor* processor_;
|
||||
int saved_logging_nesting_;
|
||||
|
@ -573,7 +573,6 @@ size_t HeapObjectsMap::GetUsedMemorySize() const {
|
||||
|
||||
HeapSnapshotsCollection::HeapSnapshotsCollection(Heap* heap)
|
||||
: is_tracking_objects_(false),
|
||||
token_enumerator_(new TokenEnumerator()),
|
||||
ids_(heap) {
|
||||
}
|
||||
|
||||
@ -584,7 +583,6 @@ static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) {
|
||||
|
||||
|
||||
HeapSnapshotsCollection::~HeapSnapshotsCollection() {
|
||||
delete token_enumerator_;
|
||||
snapshots_.Iterate(DeleteHeapSnapshot);
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,6 @@ class HeapSnapshotsCollection {
|
||||
void RemoveSnapshot(HeapSnapshot* snapshot);
|
||||
|
||||
StringsStorage* names() { return &names_; }
|
||||
TokenEnumerator* token_enumerator() { return token_enumerator_; }
|
||||
|
||||
SnapshotObjectId FindObjectId(Address object_addr) {
|
||||
return ids_.FindEntry(object_addr);
|
||||
@ -325,7 +324,6 @@ class HeapSnapshotsCollection {
|
||||
bool is_tracking_objects_; // Whether tracking object moves is needed.
|
||||
List<HeapSnapshot*> snapshots_;
|
||||
StringsStorage names_;
|
||||
TokenEnumerator* token_enumerator_;
|
||||
// Mapping from HeapObject addresses to objects' uids.
|
||||
HeapObjectsMap ids_;
|
||||
|
||||
|
@ -45,7 +45,6 @@ const char* StringsStorage::GetFunctionName(const char* name) {
|
||||
|
||||
CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
|
||||
const char* name,
|
||||
int security_token_id,
|
||||
const char* name_prefix,
|
||||
const char* resource_name,
|
||||
int line_number)
|
||||
@ -57,7 +56,6 @@ CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
|
||||
line_number_(line_number),
|
||||
shared_id_(0),
|
||||
script_id_(v8::Script::kNoScriptId),
|
||||
security_token_id_(security_token_id),
|
||||
no_frame_ranges_(NULL) {
|
||||
}
|
||||
|
||||
|
@ -41,60 +41,6 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
|
||||
TokenEnumerator::TokenEnumerator()
|
||||
: token_locations_(4),
|
||||
token_removed_(4) {
|
||||
}
|
||||
|
||||
|
||||
TokenEnumerator::~TokenEnumerator() {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
for (int i = 0; i < token_locations_.length(); ++i) {
|
||||
if (!token_removed_[i]) {
|
||||
isolate->global_handles()->ClearWeakness(token_locations_[i]);
|
||||
isolate->global_handles()->Destroy(token_locations_[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int TokenEnumerator::GetTokenId(Object* token) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
if (token == NULL) return TokenEnumerator::kNoSecurityToken;
|
||||
for (int i = 0; i < token_locations_.length(); ++i) {
|
||||
if (*token_locations_[i] == token && !token_removed_[i]) return i;
|
||||
}
|
||||
Handle<Object> handle = isolate->global_handles()->Create(token);
|
||||
// handle.location() points to a memory cell holding a pointer
|
||||
// to a token object in the V8's heap.
|
||||
isolate->global_handles()->MakeWeak(handle.location(),
|
||||
this,
|
||||
TokenRemovedCallback);
|
||||
token_locations_.Add(handle.location());
|
||||
token_removed_.Add(false);
|
||||
return token_locations_.length() - 1;
|
||||
}
|
||||
|
||||
|
||||
void TokenEnumerator::TokenRemovedCallback(v8::Isolate* isolate,
|
||||
v8::Persistent<v8::Value>* handle,
|
||||
void* parameter) {
|
||||
reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved(
|
||||
Utils::OpenPersistent(handle).location());
|
||||
handle->Dispose(isolate);
|
||||
}
|
||||
|
||||
|
||||
void TokenEnumerator::TokenRemoved(Object** token_location) {
|
||||
for (int i = 0; i < token_locations_.length(); ++i) {
|
||||
if (token_locations_[i] == token_location && !token_removed_[i]) {
|
||||
token_removed_[i] = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StringsStorage::StringsStorage()
|
||||
: names_(StringsMatch) {
|
||||
}
|
||||
@ -274,12 +220,11 @@ double ProfileNode::GetTotalMillis() const {
|
||||
|
||||
|
||||
void ProfileNode::Print(int indent) {
|
||||
OS::Print("%5u %5u %*c %s%s [%d] #%d %d",
|
||||
OS::Print("%5u %5u %*c %s%s #%d %d",
|
||||
total_ticks_, self_ticks_,
|
||||
indent, ' ',
|
||||
entry_->name_prefix(),
|
||||
entry_->name(),
|
||||
entry_->security_token_id(),
|
||||
entry_->script_id(),
|
||||
id());
|
||||
if (entry_->resource_name()[0] != '\0')
|
||||
@ -353,59 +298,6 @@ struct NodesPair {
|
||||
};
|
||||
|
||||
|
||||
class FilteredCloneCallback {
|
||||
public:
|
||||
FilteredCloneCallback(ProfileNode* dst_root, int security_token_id)
|
||||
: stack_(10),
|
||||
security_token_id_(security_token_id) {
|
||||
stack_.Add(NodesPair(NULL, dst_root));
|
||||
}
|
||||
|
||||
void BeforeTraversingChild(ProfileNode* parent, ProfileNode* child) {
|
||||
if (IsTokenAcceptable(child->entry()->security_token_id(),
|
||||
parent->entry()->security_token_id())) {
|
||||
ProfileNode* clone = stack_.last().dst->FindOrAddChild(child->entry());
|
||||
clone->IncreaseSelfTicks(child->self_ticks());
|
||||
stack_.Add(NodesPair(child, clone));
|
||||
} else {
|
||||
// Attribute ticks to parent node.
|
||||
stack_.last().dst->IncreaseSelfTicks(child->self_ticks());
|
||||
}
|
||||
}
|
||||
|
||||
void AfterAllChildrenTraversed(ProfileNode* parent) { }
|
||||
|
||||
void AfterChildTraversed(ProfileNode*, ProfileNode* child) {
|
||||
if (stack_.last().src == child) {
|
||||
stack_.RemoveLast();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
bool IsTokenAcceptable(int token, int parent_token) {
|
||||
if (token == TokenEnumerator::kNoSecurityToken
|
||||
|| token == security_token_id_) return true;
|
||||
if (token == TokenEnumerator::kInheritsSecurityToken) {
|
||||
ASSERT(parent_token != TokenEnumerator::kInheritsSecurityToken);
|
||||
return parent_token == TokenEnumerator::kNoSecurityToken
|
||||
|| parent_token == security_token_id_;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
List<NodesPair> stack_;
|
||||
int security_token_id_;
|
||||
};
|
||||
|
||||
|
||||
void ProfileTree::FilteredClone(ProfileTree* src, int security_token_id) {
|
||||
ms_to_ticks_scale_ = src->ms_to_ticks_scale_;
|
||||
FilteredCloneCallback cb(root_, security_token_id);
|
||||
src->TraverseDepthFirst(&cb);
|
||||
CalculateTotalTicks();
|
||||
}
|
||||
|
||||
|
||||
void ProfileTree::SetTickRatePerMs(double ticks_per_ms) {
|
||||
ms_to_ticks_scale_ = ticks_per_ms > 0 ? 1.0 / ticks_per_ms : 1.0;
|
||||
}
|
||||
@ -496,14 +388,6 @@ void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
|
||||
}
|
||||
|
||||
|
||||
CpuProfile* CpuProfile::FilteredClone(int security_token_id) {
|
||||
ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
|
||||
CpuProfile* clone = new CpuProfile(title_, uid_, false);
|
||||
clone->top_down_.FilteredClone(&top_down_, security_token_id);
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
void CpuProfile::ShortPrint() {
|
||||
OS::Print("top down ");
|
||||
top_down_.ShortPrint();
|
||||
@ -602,10 +486,7 @@ void CodeMap::Print() {
|
||||
|
||||
|
||||
CpuProfilesCollection::CpuProfilesCollection()
|
||||
: profiles_uids_(UidsMatch),
|
||||
current_profiles_semaphore_(OS::CreateSemaphore(1)) {
|
||||
// Create list of unabridged profiles.
|
||||
profiles_by_token_.Add(new List<CpuProfile*>());
|
||||
: current_profiles_semaphore_(OS::CreateSemaphore(1)) {
|
||||
}
|
||||
|
||||
|
||||
@ -619,19 +500,10 @@ static void DeleteCpuProfile(CpuProfile** profile_ptr) {
|
||||
}
|
||||
|
||||
|
||||
static void DeleteProfilesList(List<CpuProfile*>** list_ptr) {
|
||||
if (*list_ptr != NULL) {
|
||||
(*list_ptr)->Iterate(DeleteCpuProfile);
|
||||
delete *list_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CpuProfilesCollection::~CpuProfilesCollection() {
|
||||
delete current_profiles_semaphore_;
|
||||
finished_profiles_.Iterate(DeleteCpuProfile);
|
||||
current_profiles_.Iterate(DeleteCpuProfile);
|
||||
detached_profiles_.Iterate(DeleteCpuProfile);
|
||||
profiles_by_token_.Iterate(DeleteProfilesList);
|
||||
code_entries_.Iterate(DeleteCodeEntry);
|
||||
}
|
||||
|
||||
@ -657,8 +529,7 @@ bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid,
|
||||
}
|
||||
|
||||
|
||||
CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
|
||||
const char* title,
|
||||
CpuProfile* CpuProfilesCollection::StopProfiling(const char* title,
|
||||
double actual_sampling_rate) {
|
||||
const int title_len = StrLength(title);
|
||||
CpuProfile* profile = NULL;
|
||||
@ -671,48 +542,11 @@ CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
|
||||
}
|
||||
current_profiles_semaphore_->Signal();
|
||||
|
||||
if (profile != NULL) {
|
||||
profile->CalculateTotalTicks();
|
||||
profile->SetActualSamplingRate(actual_sampling_rate);
|
||||
List<CpuProfile*>* unabridged_list =
|
||||
profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
|
||||
unabridged_list->Add(profile);
|
||||
HashMap::Entry* entry =
|
||||
profiles_uids_.Lookup(reinterpret_cast<void*>(profile->uid()),
|
||||
static_cast<uint32_t>(profile->uid()),
|
||||
true);
|
||||
ASSERT(entry->value == NULL);
|
||||
entry->value = reinterpret_cast<void*>(unabridged_list->length() - 1);
|
||||
return GetProfile(security_token_id, profile->uid());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CpuProfile* CpuProfilesCollection::GetProfile(int security_token_id,
|
||||
unsigned uid) {
|
||||
int index = GetProfileIndex(uid);
|
||||
if (index < 0) return NULL;
|
||||
List<CpuProfile*>* unabridged_list =
|
||||
profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
|
||||
if (security_token_id == TokenEnumerator::kNoSecurityToken) {
|
||||
return unabridged_list->at(index);
|
||||
}
|
||||
List<CpuProfile*>* list = GetProfilesList(security_token_id);
|
||||
if (list->at(index) == NULL) {
|
||||
(*list)[index] =
|
||||
unabridged_list->at(index)->FilteredClone(security_token_id);
|
||||
}
|
||||
return list->at(index);
|
||||
}
|
||||
|
||||
|
||||
int CpuProfilesCollection::GetProfileIndex(unsigned uid) {
|
||||
HashMap::Entry* entry = profiles_uids_.Lookup(reinterpret_cast<void*>(uid),
|
||||
static_cast<uint32_t>(uid),
|
||||
false);
|
||||
return entry != NULL ?
|
||||
static_cast<int>(reinterpret_cast<intptr_t>(entry->value)) : -1;
|
||||
if (profile == NULL) return NULL;
|
||||
profile->CalculateTotalTicks();
|
||||
profile->SetActualSamplingRate(actual_sampling_rate);
|
||||
finished_profiles_.Add(profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
||||
@ -728,74 +562,13 @@ bool CpuProfilesCollection::IsLastProfile(const char* title) {
|
||||
void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) {
|
||||
// Called from VM thread for a completed profile.
|
||||
unsigned uid = profile->uid();
|
||||
int index = GetProfileIndex(uid);
|
||||
if (index < 0) {
|
||||
detached_profiles_.RemoveElement(profile);
|
||||
return;
|
||||
}
|
||||
profiles_uids_.Remove(reinterpret_cast<void*>(uid),
|
||||
static_cast<uint32_t>(uid));
|
||||
// Decrement all indexes above the deleted one.
|
||||
for (HashMap::Entry* p = profiles_uids_.Start();
|
||||
p != NULL;
|
||||
p = profiles_uids_.Next(p)) {
|
||||
intptr_t p_index = reinterpret_cast<intptr_t>(p->value);
|
||||
if (p_index > index) {
|
||||
p->value = reinterpret_cast<void*>(p_index - 1);
|
||||
for (int i = 0; i < finished_profiles_.length(); i++) {
|
||||
if (uid == finished_profiles_[i]->uid()) {
|
||||
finished_profiles_.Remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < profiles_by_token_.length(); ++i) {
|
||||
List<CpuProfile*>* list = profiles_by_token_[i];
|
||||
if (list != NULL && index < list->length()) {
|
||||
// Move all filtered clones into detached_profiles_,
|
||||
// so we can know that they are still in use.
|
||||
CpuProfile* cloned_profile = list->Remove(index);
|
||||
if (cloned_profile != NULL && cloned_profile != profile) {
|
||||
detached_profiles_.Add(cloned_profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CpuProfilesCollection::TokenToIndex(int security_token_id) {
|
||||
ASSERT(TokenEnumerator::kNoSecurityToken == -1);
|
||||
return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ...
|
||||
}
|
||||
|
||||
|
||||
List<CpuProfile*>* CpuProfilesCollection::GetProfilesList(
|
||||
int security_token_id) {
|
||||
const int index = TokenToIndex(security_token_id);
|
||||
const int lists_to_add = index - profiles_by_token_.length() + 1;
|
||||
if (lists_to_add > 0) profiles_by_token_.AddBlock(NULL, lists_to_add);
|
||||
List<CpuProfile*>* unabridged_list =
|
||||
profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
|
||||
const int current_count = unabridged_list->length();
|
||||
if (profiles_by_token_[index] == NULL) {
|
||||
profiles_by_token_[index] = new List<CpuProfile*>(current_count);
|
||||
}
|
||||
List<CpuProfile*>* list = profiles_by_token_[index];
|
||||
const int profiles_to_add = current_count - list->length();
|
||||
if (profiles_to_add > 0) list->AddBlock(NULL, profiles_to_add);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
List<CpuProfile*>* CpuProfilesCollection::Profiles(int security_token_id) {
|
||||
List<CpuProfile*>* unabridged_list =
|
||||
profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
|
||||
if (security_token_id == TokenEnumerator::kNoSecurityToken) {
|
||||
return unabridged_list;
|
||||
}
|
||||
List<CpuProfile*>* list = GetProfilesList(security_token_id);
|
||||
const int current_count = unabridged_list->length();
|
||||
for (int i = 0; i < current_count; ++i) {
|
||||
if (list->at(i) == NULL) {
|
||||
(*list)[i] = unabridged_list->at(i)->FilteredClone(security_token_id);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
@ -815,13 +588,11 @@ void CpuProfilesCollection::AddPathToCurrentProfiles(
|
||||
CodeEntry* CpuProfilesCollection::NewCodeEntry(
|
||||
Logger::LogEventsAndTags tag,
|
||||
const char* name,
|
||||
int security_token_id,
|
||||
const char* name_prefix,
|
||||
const char* resource_name,
|
||||
int line_number) {
|
||||
CodeEntry* code_entry = new CodeEntry(tag,
|
||||
name,
|
||||
security_token_id,
|
||||
name_prefix,
|
||||
resource_name,
|
||||
line_number);
|
||||
|
@ -37,30 +37,6 @@ namespace internal {
|
||||
|
||||
struct OffsetRange;
|
||||
|
||||
class TokenEnumerator {
|
||||
public:
|
||||
TokenEnumerator();
|
||||
~TokenEnumerator();
|
||||
int GetTokenId(Object* token);
|
||||
|
||||
static const int kNoSecurityToken = -1;
|
||||
static const int kInheritsSecurityToken = -2;
|
||||
|
||||
private:
|
||||
static void TokenRemovedCallback(v8::Isolate* isolate,
|
||||
v8::Persistent<v8::Value>* handle,
|
||||
void* parameter);
|
||||
void TokenRemoved(Object** token_location);
|
||||
|
||||
List<Object**> token_locations_;
|
||||
List<bool> token_removed_;
|
||||
|
||||
friend class TokenEnumeratorTester;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(TokenEnumerator);
|
||||
};
|
||||
|
||||
|
||||
// Provides a storage of strings allocated in C++ heap, to hold them
|
||||
// forever, even if they disappear from JS heap or external storage.
|
||||
class StringsStorage {
|
||||
@ -98,7 +74,6 @@ class CodeEntry {
|
||||
// CodeEntry doesn't own name strings, just references them.
|
||||
INLINE(CodeEntry(Logger::LogEventsAndTags tag,
|
||||
const char* name,
|
||||
int security_token_id = TokenEnumerator::kNoSecurityToken,
|
||||
const char* name_prefix = CodeEntry::kEmptyNamePrefix,
|
||||
const char* resource_name = CodeEntry::kEmptyResourceName,
|
||||
int line_number = v8::CpuProfileNode::kNoLineNumberInfo));
|
||||
@ -113,7 +88,6 @@ class CodeEntry {
|
||||
INLINE(void set_shared_id(int shared_id)) { shared_id_ = shared_id; }
|
||||
INLINE(int script_id() const) { return script_id_; }
|
||||
INLINE(void set_script_id(int script_id)) { script_id_ = script_id; }
|
||||
INLINE(int security_token_id() const) { return security_token_id_; }
|
||||
|
||||
INLINE(static bool is_js_function_tag(Logger::LogEventsAndTags tag));
|
||||
|
||||
@ -141,7 +115,6 @@ class CodeEntry {
|
||||
int line_number_;
|
||||
int shared_id_;
|
||||
int script_id_;
|
||||
int security_token_id_;
|
||||
List<OffsetRange>* no_frame_ranges_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CodeEntry);
|
||||
@ -201,7 +174,6 @@ class ProfileTree {
|
||||
ProfileNode* AddPathFromEnd(const Vector<CodeEntry*>& path);
|
||||
void AddPathFromStart(const Vector<CodeEntry*>& path);
|
||||
void CalculateTotalTicks();
|
||||
void FilteredClone(ProfileTree* src, int security_token_id);
|
||||
|
||||
double TicksToMillis(unsigned ticks) const {
|
||||
return ticks * ms_to_ticks_scale_;
|
||||
@ -238,7 +210,6 @@ class CpuProfile {
|
||||
void AddPath(const Vector<CodeEntry*>& path);
|
||||
void CalculateTotalTicks();
|
||||
void SetActualSamplingRate(double actual_sampling_rate);
|
||||
CpuProfile* FilteredClone(int security_token_id);
|
||||
|
||||
INLINE(const char* title() const) { return title_; }
|
||||
INLINE(unsigned uid() const) { return uid_; }
|
||||
@ -315,10 +286,8 @@ class CpuProfilesCollection {
|
||||
~CpuProfilesCollection();
|
||||
|
||||
bool StartProfiling(const char* title, unsigned uid, bool record_samples);
|
||||
CpuProfile* StopProfiling(int security_token_id,
|
||||
const char* title,
|
||||
double actual_sampling_rate);
|
||||
List<CpuProfile*>* Profiles(int security_token_id);
|
||||
CpuProfile* StopProfiling(const char* title, double actual_sampling_rate);
|
||||
List<CpuProfile*>* profiles() { return &finished_profiles_; }
|
||||
const char* GetName(Name* name) {
|
||||
return function_and_resource_names_.GetName(name);
|
||||
}
|
||||
@ -331,15 +300,12 @@ class CpuProfilesCollection {
|
||||
const char* GetFunctionName(const char* name) {
|
||||
return function_and_resource_names_.GetFunctionName(name);
|
||||
}
|
||||
CpuProfile* GetProfile(int security_token_id, unsigned uid);
|
||||
bool IsLastProfile(const char* title);
|
||||
void RemoveProfile(CpuProfile* profile);
|
||||
bool HasDetachedProfiles() { return detached_profiles_.length() > 0; }
|
||||
|
||||
CodeEntry* NewCodeEntry(
|
||||
Logger::LogEventsAndTags tag,
|
||||
const char* name,
|
||||
int security_token_id = TokenEnumerator::kNoSecurityToken,
|
||||
const char* name_prefix = CodeEntry::kEmptyNamePrefix,
|
||||
const char* resource_name = CodeEntry::kEmptyResourceName,
|
||||
int line_number = v8::CpuProfileNode::kNoLineNumberInfo);
|
||||
@ -351,21 +317,9 @@ class CpuProfilesCollection {
|
||||
static const int kMaxSimultaneousProfiles = 100;
|
||||
|
||||
private:
|
||||
int GetProfileIndex(unsigned uid);
|
||||
List<CpuProfile*>* GetProfilesList(int security_token_id);
|
||||
int TokenToIndex(int security_token_id);
|
||||
|
||||
INLINE(static bool UidsMatch(void* key1, void* key2)) {
|
||||
return key1 == key2;
|
||||
}
|
||||
|
||||
StringsStorage function_and_resource_names_;
|
||||
List<CodeEntry*> code_entries_;
|
||||
List<List<CpuProfile*>* > profiles_by_token_;
|
||||
// Mapping from profiles' uids to indexes in the second nested list
|
||||
// of profiles_by_token_.
|
||||
HashMap profiles_uids_;
|
||||
List<CpuProfile*> detached_profiles_;
|
||||
List<CpuProfile*> finished_profiles_;
|
||||
|
||||
// Accessed by VM thread and profile generator thread.
|
||||
List<CpuProfile*> current_profiles_;
|
||||
|
@ -44,7 +44,6 @@ using i::ProfileGenerator;
|
||||
using i::ProfileNode;
|
||||
using i::ProfilerEventsProcessor;
|
||||
using i::ScopedVector;
|
||||
using i::TokenEnumerator;
|
||||
using i::Vector;
|
||||
|
||||
|
||||
@ -225,8 +224,7 @@ TEST(TickEvents) {
|
||||
|
||||
processor.Stop();
|
||||
processor.Join();
|
||||
CpuProfile* profile =
|
||||
profiles->StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
|
||||
CpuProfile* profile = profiles->StopProfiling("", 1);
|
||||
CHECK_NE(NULL, profile);
|
||||
|
||||
// Check call trees.
|
||||
@ -290,8 +288,7 @@ TEST(Issue1398) {
|
||||
|
||||
processor.Stop();
|
||||
processor.Join();
|
||||
CpuProfile* profile =
|
||||
profiles->StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
|
||||
CpuProfile* profile = profiles->StopProfiling("", 1);
|
||||
CHECK_NE(NULL, profile);
|
||||
|
||||
int actual_depth = 0;
|
||||
@ -395,63 +392,6 @@ TEST(DeleteCpuProfile) {
|
||||
}
|
||||
|
||||
|
||||
TEST(DeleteCpuProfileDifferentTokens) {
|
||||
LocalContext env;
|
||||
v8::HandleScope scope(env->GetIsolate());
|
||||
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
|
||||
|
||||
CHECK_EQ(0, cpu_profiler->GetProfileCount());
|
||||
v8::Local<v8::String> name1 = v8::String::New("1");
|
||||
cpu_profiler->StartCpuProfiling(name1);
|
||||
const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1);
|
||||
CHECK_NE(NULL, p1);
|
||||
CHECK_EQ(1, cpu_profiler->GetProfileCount());
|
||||
unsigned uid1 = p1->GetUid();
|
||||
CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1));
|
||||
v8::Local<v8::String> token1 = v8::String::New("token1");
|
||||
const v8::CpuProfile* p1_t1 = cpu_profiler->FindCpuProfile(uid1, token1);
|
||||
CHECK_NE(NULL, p1_t1);
|
||||
CHECK_NE(p1, p1_t1);
|
||||
CHECK_EQ(1, cpu_profiler->GetProfileCount());
|
||||
const_cast<v8::CpuProfile*>(p1)->Delete();
|
||||
CHECK_EQ(0, cpu_profiler->GetProfileCount());
|
||||
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1));
|
||||
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1, token1));
|
||||
const_cast<v8::CpuProfile*>(p1_t1)->Delete();
|
||||
CHECK_EQ(0, cpu_profiler->GetProfileCount());
|
||||
|
||||
v8::Local<v8::String> name2 = v8::String::New("2");
|
||||
cpu_profiler->StartCpuProfiling(name2);
|
||||
v8::Local<v8::String> token2 = v8::String::New("token2");
|
||||
const v8::CpuProfile* p2_t2 = cpu_profiler->StopCpuProfiling(name2, token2);
|
||||
CHECK_NE(NULL, p2_t2);
|
||||
CHECK_EQ(1, cpu_profiler->GetProfileCount());
|
||||
unsigned uid2 = p2_t2->GetUid();
|
||||
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
|
||||
const v8::CpuProfile* p2 = cpu_profiler->FindCpuProfile(uid2);
|
||||
CHECK_NE(p2_t2, p2);
|
||||
v8::Local<v8::String> name3 = v8::String::New("3");
|
||||
cpu_profiler->StartCpuProfiling(name3);
|
||||
const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3);
|
||||
CHECK_NE(NULL, p3);
|
||||
CHECK_EQ(2, cpu_profiler->GetProfileCount());
|
||||
unsigned uid3 = p3->GetUid();
|
||||
CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
|
||||
CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
|
||||
const_cast<v8::CpuProfile*>(p2_t2)->Delete();
|
||||
CHECK_EQ(1, cpu_profiler->GetProfileCount());
|
||||
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
|
||||
CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
|
||||
const_cast<v8::CpuProfile*>(p2)->Delete();
|
||||
CHECK_EQ(1, cpu_profiler->GetProfileCount());
|
||||
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2));
|
||||
CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3));
|
||||
const_cast<v8::CpuProfile*>(p3)->Delete();
|
||||
CHECK_EQ(0, cpu_profiler->GetProfileCount());
|
||||
CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3));
|
||||
}
|
||||
|
||||
|
||||
TEST(GetProfilerWhenIsolateIsNotInitialized) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
CHECK(i::Isolate::Current()->IsDefaultIsolate());
|
||||
|
@ -43,48 +43,9 @@ using i::ProfileTree;
|
||||
using i::ProfileGenerator;
|
||||
using i::SampleRateCalculator;
|
||||
using i::TickSample;
|
||||
using i::TokenEnumerator;
|
||||
using i::Vector;
|
||||
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class TokenEnumeratorTester {
|
||||
public:
|
||||
static i::List<bool>* token_removed(TokenEnumerator* te) {
|
||||
return &te->token_removed_;
|
||||
}
|
||||
};
|
||||
|
||||
} } // namespace v8::internal
|
||||
|
||||
TEST(TokenEnumerator) {
|
||||
TokenEnumerator te;
|
||||
CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL));
|
||||
v8::HandleScope hs(v8::Isolate::GetCurrent());
|
||||
v8::Local<v8::String> token1(v8::String::New("1x"));
|
||||
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
|
||||
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
|
||||
v8::Local<v8::String> token2(v8::String::New("2x"));
|
||||
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
|
||||
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
|
||||
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
|
||||
{
|
||||
v8::HandleScope hs(v8::Isolate::GetCurrent());
|
||||
v8::Local<v8::String> token3(v8::String::New("3x"));
|
||||
CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3)));
|
||||
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
|
||||
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
|
||||
}
|
||||
CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2));
|
||||
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
||||
CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2));
|
||||
CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
|
||||
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
|
||||
}
|
||||
|
||||
|
||||
TEST(ProfileNodeFindOrAddChild) {
|
||||
ProfileTree tree;
|
||||
ProfileNode node(&tree, NULL);
|
||||
@ -121,8 +82,7 @@ TEST(ProfileNodeFindOrAddChildForSameFunction) {
|
||||
CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa);
|
||||
CHECK_EQ(childNode1, node.FindOrAddChild(&entry2));
|
||||
// Now with a different security token.
|
||||
CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa,
|
||||
TokenEnumerator::kNoSecurityToken + 1);
|
||||
CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa);
|
||||
CHECK_EQ(childNode1, node.FindOrAddChild(&entry3));
|
||||
}
|
||||
|
||||
@ -415,104 +375,6 @@ TEST(ProfileTreeCalculateTotalTicks) {
|
||||
}
|
||||
|
||||
|
||||
TEST(ProfileTreeFilteredClone) {
|
||||
ProfileTree source_tree;
|
||||
const int token0 = 0, token1 = 1, token2 = 2;
|
||||
CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa", token0);
|
||||
CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb", token1);
|
||||
CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc", token0);
|
||||
CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd",
|
||||
TokenEnumerator::kInheritsSecurityToken);
|
||||
|
||||
{
|
||||
CodeEntry* e1_e2_path[] = {&entry1, &entry2};
|
||||
Vector<CodeEntry*> e1_e2_path_vec(
|
||||
e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0]));
|
||||
source_tree.AddPathFromStart(e1_e2_path_vec);
|
||||
CodeEntry* e2_e4_path[] = {&entry2, &entry4};
|
||||
Vector<CodeEntry*> e2_e4_path_vec(
|
||||
e2_e4_path, sizeof(e2_e4_path) / sizeof(e2_e4_path[0]));
|
||||
source_tree.AddPathFromStart(e2_e4_path_vec);
|
||||
CodeEntry* e3_e1_path[] = {&entry3, &entry1};
|
||||
Vector<CodeEntry*> e3_e1_path_vec(
|
||||
e3_e1_path, sizeof(e3_e1_path) / sizeof(e3_e1_path[0]));
|
||||
source_tree.AddPathFromStart(e3_e1_path_vec);
|
||||
CodeEntry* e3_e2_path[] = {&entry3, &entry2};
|
||||
Vector<CodeEntry*> e3_e2_path_vec(
|
||||
e3_e2_path, sizeof(e3_e2_path) / sizeof(e3_e2_path[0]));
|
||||
source_tree.AddPathFromStart(e3_e2_path_vec);
|
||||
source_tree.CalculateTotalTicks();
|
||||
// Results in -> {entry1,0,1,0} -> {entry2,1,1,1}
|
||||
// {root,0,4,-1} -> {entry2,0,1,1} -> {entry4,1,1,inherits}
|
||||
// -> {entry3,0,2,0} -> {entry1,1,1,0}
|
||||
// -> {entry2,1,1,1}
|
||||
CHECK_EQ(4, source_tree.root()->total_ticks());
|
||||
CHECK_EQ(0, source_tree.root()->self_ticks());
|
||||
}
|
||||
|
||||
{
|
||||
ProfileTree token0_tree;
|
||||
token0_tree.FilteredClone(&source_tree, token0);
|
||||
// Should be -> {entry1,1,1,0}
|
||||
// {root,1,4,-1} -> {entry3,1,2,0} -> {entry1,1,1,0}
|
||||
// [self ticks from filtered nodes are attributed to their parents]
|
||||
CHECK_EQ(4, token0_tree.root()->total_ticks());
|
||||
CHECK_EQ(1, token0_tree.root()->self_ticks());
|
||||
ProfileTreeTestHelper token0_helper(&token0_tree);
|
||||
ProfileNode* node1 = token0_helper.Walk(&entry1);
|
||||
CHECK_NE(NULL, node1);
|
||||
CHECK_EQ(1, node1->total_ticks());
|
||||
CHECK_EQ(1, node1->self_ticks());
|
||||
CHECK_EQ(NULL, token0_helper.Walk(&entry2));
|
||||
ProfileNode* node3 = token0_helper.Walk(&entry3);
|
||||
CHECK_NE(NULL, node3);
|
||||
CHECK_EQ(2, node3->total_ticks());
|
||||
CHECK_EQ(1, node3->self_ticks());
|
||||
ProfileNode* node3_1 = token0_helper.Walk(&entry3, &entry1);
|
||||
CHECK_NE(NULL, node3_1);
|
||||
CHECK_EQ(1, node3_1->total_ticks());
|
||||
CHECK_EQ(1, node3_1->self_ticks());
|
||||
CHECK_EQ(NULL, token0_helper.Walk(&entry3, &entry2));
|
||||
}
|
||||
|
||||
{
|
||||
ProfileTree token1_tree;
|
||||
token1_tree.FilteredClone(&source_tree, token1);
|
||||
// Should be
|
||||
// {root,1,4,-1} -> {entry2,2,3,1} -> {entry4,1,1,inherits}
|
||||
// [child nodes referring to the same entry get merged and
|
||||
// their self times summed up]
|
||||
CHECK_EQ(4, token1_tree.root()->total_ticks());
|
||||
CHECK_EQ(1, token1_tree.root()->self_ticks());
|
||||
ProfileTreeTestHelper token1_helper(&token1_tree);
|
||||
CHECK_EQ(NULL, token1_helper.Walk(&entry1));
|
||||
CHECK_EQ(NULL, token1_helper.Walk(&entry3));
|
||||
ProfileNode* node2 = token1_helper.Walk(&entry2);
|
||||
CHECK_NE(NULL, node2);
|
||||
CHECK_EQ(3, node2->total_ticks());
|
||||
CHECK_EQ(2, node2->self_ticks());
|
||||
ProfileNode* node2_4 = token1_helper.Walk(&entry2, &entry4);
|
||||
CHECK_NE(NULL, node2_4);
|
||||
CHECK_EQ(1, node2_4->total_ticks());
|
||||
CHECK_EQ(1, node2_4->self_ticks());
|
||||
}
|
||||
|
||||
{
|
||||
ProfileTree token2_tree;
|
||||
token2_tree.FilteredClone(&source_tree, token2);
|
||||
// Should be
|
||||
// {root,4,4,-1}
|
||||
// [no nodes, all ticks get migrated into root node]
|
||||
CHECK_EQ(4, token2_tree.root()->total_ticks());
|
||||
CHECK_EQ(4, token2_tree.root()->self_ticks());
|
||||
ProfileTreeTestHelper token2_helper(&token2_tree);
|
||||
CHECK_EQ(NULL, token2_helper.Walk(&entry1));
|
||||
CHECK_EQ(NULL, token2_helper.Walk(&entry2));
|
||||
CHECK_EQ(NULL, token2_helper.Walk(&entry3));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline i::Address ToAddress(int n) {
|
||||
return reinterpret_cast<i::Address>(n);
|
||||
}
|
||||
@ -623,8 +485,7 @@ TEST(RecordTickSample) {
|
||||
sample3.frames_count = 2;
|
||||
generator.RecordTickSample(sample3);
|
||||
|
||||
CpuProfile* profile =
|
||||
profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
|
||||
CpuProfile* profile = profiles.StopProfiling("", 1);
|
||||
CHECK_NE(NULL, profile);
|
||||
ProfileTreeTestHelper top_down_test_helper(profile->top_down());
|
||||
CHECK_EQ(NULL, top_down_test_helper.Walk(entry2));
|
||||
@ -737,8 +598,7 @@ TEST(SampleIds) {
|
||||
sample3.frames_count = 2;
|
||||
generator.RecordTickSample(sample3);
|
||||
|
||||
CpuProfile* profile =
|
||||
profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
|
||||
CpuProfile* profile = profiles.StopProfiling("", 1);
|
||||
int nodeId = 1;
|
||||
CheckNodeIds(profile->top_down()->root(), &nodeId);
|
||||
CHECK_EQ(7, nodeId - 1);
|
||||
@ -767,8 +627,7 @@ TEST(NoSamples) {
|
||||
sample1.frames_count = 1;
|
||||
generator.RecordTickSample(sample1);
|
||||
|
||||
CpuProfile* profile =
|
||||
profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
|
||||
CpuProfile* profile = profiles.StopProfiling("", 1);
|
||||
int nodeId = 1;
|
||||
CheckNodeIds(profile->top_down()->root(), &nodeId);
|
||||
CHECK_EQ(3, nodeId - 1);
|
||||
@ -862,7 +721,7 @@ TEST(RecordStackTraceAtStartProfiling) {
|
||||
"a();\n"
|
||||
"stopProfiling();");
|
||||
CHECK_EQ(1, profiler->GetProfilesCount());
|
||||
CpuProfile* profile = profiler->GetProfile(NULL, 0);
|
||||
CpuProfile* profile = profiler->GetProfile(0);
|
||||
const ProfileTree* topDown = profile->top_down();
|
||||
const ProfileNode* current = topDown->root();
|
||||
const_cast<ProfileNode*>(current)->Print(0);
|
||||
|
Loading…
Reference in New Issue
Block a user