From 4292ac5932da60e433bc38de6f72abb89cc3ca26 Mon Sep 17 00:00:00 2001 From: "loislo@chromium.org" Date: Wed, 26 Jun 2013 09:55:33 +0000 Subject: [PATCH] CPUProfiler: Simplify CodeEntry constructor calls. In almost all the places where we create CodeEntry we use default values. Lets move them into arguments default values. BUG=none TEST=no logic changes. R=yangguo@chromium.org, yurys@chromium.org Review URL: https://codereview.chromium.org/17836002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15333 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/profile-generator-inl.h | 4 +- src/profile-generator.cc | 20 ++----- src/profile-generator.h | 6 +-- test/cctest/test-profile-generator.cc | 76 ++++++++++----------------- 4 files changed, 36 insertions(+), 70 deletions(-) diff --git a/src/profile-generator-inl.h b/src/profile-generator-inl.h index d6e8a3775b..6f9a60171e 100644 --- a/src/profile-generator-inl.h +++ b/src/profile-generator-inl.h @@ -46,9 +46,9 @@ const char* StringsStorage::GetFunctionName(const char* name) { CodeEntry::CodeEntry(Logger::LogEventsAndTags tag, const char* name_prefix, const char* name, + int security_token_id, const char* resource_name, - int line_number, - int security_token_id) + int line_number) : tag_(tag), name_prefix_(name_prefix), name_(name), diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 7461462ccb..426d74ee96 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -296,12 +296,7 @@ class DeleteNodesCallback { ProfileTree::ProfileTree() - : root_entry_(Logger::FUNCTION_TAG, - "", - "(root)", - "", - 0, - TokenEnumerator::kNoSecurityToken), + : root_entry_(Logger::FUNCTION_TAG, "", "(root)"), next_node_id_(1), root_(new ProfileNode(this, &root_entry_)) { } @@ -797,9 +792,9 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, CodeEntry* entry = new CodeEntry(tag, CodeEntry::kEmptyNamePrefix, GetFunctionName(name), + TokenEnumerator::kNoSecurityToken, GetName(resource_name), - line_number, - TokenEnumerator::kNoSecurityToken); + line_number); code_entries_.Add(entry); return entry; } @@ -809,10 +804,7 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, const char* name) { CodeEntry* entry = new CodeEntry(tag, CodeEntry::kEmptyNamePrefix, - GetFunctionName(name), - "", - v8::CpuProfileNode::kNoLineNumberInfo, - TokenEnumerator::kNoSecurityToken); + GetFunctionName(name)); code_entries_.Add(entry); return entry; } @@ -824,8 +816,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, CodeEntry* entry = new CodeEntry(tag, name_prefix, GetName(name), - "", - v8::CpuProfileNode::kNoLineNumberInfo, TokenEnumerator::kInheritsSecurityToken); code_entries_.Add(entry); return entry; @@ -837,8 +827,6 @@ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag, CodeEntry* entry = new CodeEntry(tag, "args_count: ", GetName(args_count), - "", - v8::CpuProfileNode::kNoLineNumberInfo, TokenEnumerator::kInheritsSecurityToken); code_entries_.Add(entry); return entry; diff --git a/src/profile-generator.h b/src/profile-generator.h index 7a5e1f2fc5..d8016caff3 100644 --- a/src/profile-generator.h +++ b/src/profile-generator.h @@ -99,9 +99,9 @@ class CodeEntry { INLINE(CodeEntry(Logger::LogEventsAndTags tag, const char* name_prefix, const char* name, - const char* resource_name, - int line_number, - int security_token_id)); + int security_token_id = TokenEnumerator::kNoSecurityToken, + const char* resource_name = "", + int line_number = v8::CpuProfileNode::kNoLineNumberInfo)); ~CodeEntry(); INLINE(bool is_js_function() const) { return is_js_function_tag(tag_); } diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index b110ffa43e..17c9dd9f01 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -87,20 +87,17 @@ TEST(TokenEnumerator) { TEST(ProfileNodeFindOrAddChild) { ProfileTree tree; ProfileNode node(&tree, NULL); - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); ProfileNode* childNode1 = node.FindOrAddChild(&entry1); CHECK_NE(NULL, childNode1); CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); ProfileNode* childNode2 = node.FindOrAddChild(&entry2); CHECK_NE(NULL, childNode2); CHECK_NE(childNode1, childNode2); CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); ProfileNode* childNode3 = node.FindOrAddChild(&entry3); CHECK_NE(NULL, childNode3); CHECK_NE(childNode1, childNode3); @@ -116,17 +113,15 @@ TEST(ProfileNodeFindOrAddChildForSameFunction) { const char* aaa = "aaa"; ProfileTree tree; ProfileNode node(&tree, NULL); - CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, empty, aaa); ProfileNode* childNode1 = node.FindOrAddChild(&entry1); CHECK_NE(NULL, childNode1); CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); // The same function again. - CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry2(i::Logger::FUNCTION_TAG, empty, aaa); CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); // Now with a different security token. - CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, empty, 0, + CodeEntry entry3(i::Logger::FUNCTION_TAG, empty, aaa, TokenEnumerator::kNoSecurityToken + 1); CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); } @@ -162,12 +157,9 @@ class ProfileTreeTestHelper { } // namespace TEST(ProfileTreeAddPathFromStart) { - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); + CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); ProfileTree tree; ProfileTreeTestHelper helper(&tree); CHECK_EQ(NULL, helper.Walk(&entry1)); @@ -232,12 +224,9 @@ TEST(ProfileTreeAddPathFromStart) { TEST(ProfileTreeAddPathFromEnd) { - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); + CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); ProfileTree tree; ProfileTreeTestHelper helper(&tree); CHECK_EQ(NULL, helper.Walk(&entry1)); @@ -315,8 +304,7 @@ TEST(ProfileTreeCalculateTotalTicks) { CHECK_EQ(1, empty_tree.root()->total_ticks()); CHECK_EQ(1, empty_tree.root()->self_ticks()); - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); CodeEntry* e1_path[] = {&entry1}; Vector e1_path_vec( e1_path, sizeof(e1_path) / sizeof(e1_path[0])); @@ -337,8 +325,7 @@ TEST(ProfileTreeCalculateTotalTicks) { CHECK_EQ(1, node1->total_ticks()); CHECK_EQ(1, node1->self_ticks()); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); CodeEntry* e1_e2_path[] = {&entry1, &entry2}; Vector e1_e2_path_vec( e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); @@ -373,8 +360,7 @@ TEST(ProfileTreeCalculateTotalTicks) { CodeEntry* e2_path[] = {&entry2}; Vector e2_path_vec( e2_path, sizeof(e2_path) / sizeof(e2_path[0])); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); CodeEntry* e3_path[] = {&entry3}; Vector e3_path_vec( e3_path, sizeof(e3_path) / sizeof(e3_path[0])); @@ -432,12 +418,11 @@ TEST(ProfileTreeCalculateTotalTicks) { TEST(ProfileTreeFilteredClone) { ProfileTree source_tree; const int token0 = 0, token1 = 1, token2 = 2; - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, token0); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, token1); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0); - CodeEntry entry4( - i::Logger::FUNCTION_TAG, "", "ddd", "", 0, - TokenEnumerator::kInheritsSecurityToken); + 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}; @@ -534,14 +519,10 @@ static inline i::Address ToAddress(int n) { TEST(CodeMapAddCode) { CodeMap code_map; - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); + CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); + CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd"); code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); @@ -568,10 +549,8 @@ TEST(CodeMapAddCode) { TEST(CodeMapMoveAndDeleteCode) { CodeMap code_map; - CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0, - TokenEnumerator::kNoSecurityToken); - CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa"); + CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb"); code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); @@ -579,8 +558,7 @@ TEST(CodeMapMoveAndDeleteCode) { code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); - CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, - TokenEnumerator::kNoSecurityToken); + CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc"); code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750)));