Commit 69609019 authored by yurys@chromium.org's avatar yurys@chromium.org

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
parent a925b6b8
......@@ -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.
......
......@@ -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) {
}
......
This diff is collapsed.
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment