OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 30 matching lines...) Expand all Loading... |
41 using i::CpuProfilesCollection; | 41 using i::CpuProfilesCollection; |
42 using i::ProfileNode; | 42 using i::ProfileNode; |
43 using i::ProfileTree; | 43 using i::ProfileTree; |
44 using i::ProfileGenerator; | 44 using i::ProfileGenerator; |
45 using i::TickSample; | 45 using i::TickSample; |
46 using i::Vector; | 46 using i::Vector; |
47 | 47 |
48 | 48 |
49 TEST(ProfileNodeFindOrAddChild) { | 49 TEST(ProfileNodeFindOrAddChild) { |
50 ProfileTree tree; | 50 ProfileTree tree; |
51 ProfileNode node(&tree, NULL); | 51 ProfileNode* node = tree.root(); |
52 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 52 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
53 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 53 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); |
54 CHECK_NE(NULL, childNode1); | 54 CHECK_NE(NULL, childNode1); |
55 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 55 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
56 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 56 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
57 ProfileNode* childNode2 = node.FindOrAddChild(&entry2); | 57 ProfileNode* childNode2 = node->FindOrAddChild(&entry2); |
58 CHECK_NE(NULL, childNode2); | 58 CHECK_NE(NULL, childNode2); |
59 CHECK_NE(childNode1, childNode2); | 59 CHECK_NE(childNode1, childNode2); |
60 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 60 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
61 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 61 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); |
62 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 62 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
63 ProfileNode* childNode3 = node.FindOrAddChild(&entry3); | 63 ProfileNode* childNode3 = node->FindOrAddChild(&entry3); |
64 CHECK_NE(NULL, childNode3); | 64 CHECK_NE(NULL, childNode3); |
65 CHECK_NE(childNode1, childNode3); | 65 CHECK_NE(childNode1, childNode3); |
66 CHECK_NE(childNode2, childNode3); | 66 CHECK_NE(childNode2, childNode3); |
67 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 67 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
68 CHECK_EQ(childNode2, node.FindOrAddChild(&entry2)); | 68 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); |
69 CHECK_EQ(childNode3, node.FindOrAddChild(&entry3)); | 69 CHECK_EQ(childNode3, node->FindOrAddChild(&entry3)); |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 TEST(ProfileNodeFindOrAddChildForSameFunction) { | 73 TEST(ProfileNodeFindOrAddChildForSameFunction) { |
74 const char* aaa = "aaa"; | 74 const char* aaa = "aaa"; |
75 ProfileTree tree; | 75 ProfileTree tree; |
76 ProfileNode node(&tree, NULL); | 76 ProfileNode* node = tree.root(); |
77 CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); | 77 CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); |
78 ProfileNode* childNode1 = node.FindOrAddChild(&entry1); | 78 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); |
79 CHECK_NE(NULL, childNode1); | 79 CHECK_NE(NULL, childNode1); |
80 CHECK_EQ(childNode1, node.FindOrAddChild(&entry1)); | 80 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
81 // The same function again. | 81 // The same function again. |
82 CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); | 82 CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); |
83 CHECK_EQ(childNode1, node.FindOrAddChild(&entry2)); | 83 CHECK_EQ(childNode1, node->FindOrAddChild(&entry2)); |
84 // Now with a different security token. | 84 // Now with a different security token. |
85 CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa); | 85 CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa); |
86 CHECK_EQ(childNode1, node.FindOrAddChild(&entry3)); | 86 CHECK_EQ(childNode1, node->FindOrAddChild(&entry3)); |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 namespace { | 90 namespace { |
91 | 91 |
92 class ProfileTreeTestHelper { | 92 class ProfileTreeTestHelper { |
93 public: | 93 public: |
94 explicit ProfileTreeTestHelper(const ProfileTree* tree) | 94 explicit ProfileTreeTestHelper(const ProfileTree* tree) |
95 : tree_(tree) { } | 95 : tree_(tree) { } |
96 | 96 |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 766 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
767 | 767 |
768 current = PickChild(current, "TryFinally"); | 768 current = PickChild(current, "TryFinally"); |
769 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 769 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
770 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); | 770 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); |
771 | 771 |
772 current = PickChild(current, "TryCatch"); | 772 current = PickChild(current, "TryCatch"); |
773 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 773 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); |
774 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); | 774 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); |
775 } | 775 } |
OLD | NEW |