| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 125 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
| 126 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 126 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
| 127 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 127 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
| 128 ProfileTree tree(CcTest::i_isolate()); | 128 ProfileTree tree(CcTest::i_isolate()); |
| 129 ProfileTreeTestHelper helper(&tree); | 129 ProfileTreeTestHelper helper(&tree); |
| 130 CHECK(!helper.Walk(&entry1)); | 130 CHECK(!helper.Walk(&entry1)); |
| 131 CHECK(!helper.Walk(&entry2)); | 131 CHECK(!helper.Walk(&entry2)); |
| 132 CHECK(!helper.Walk(&entry3)); | 132 CHECK(!helper.Walk(&entry3)); |
| 133 | 133 |
| 134 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; | 134 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
| 135 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 135 std::vector<CodeEntry*> path_vec(path, path + arraysize(path)); |
| 136 tree.AddPathFromEnd(path_vec); | 136 tree.AddPathFromEnd(path_vec); |
| 137 CHECK(!helper.Walk(&entry2)); | 137 CHECK(!helper.Walk(&entry2)); |
| 138 CHECK(!helper.Walk(&entry3)); | 138 CHECK(!helper.Walk(&entry3)); |
| 139 ProfileNode* node1 = helper.Walk(&entry1); | 139 ProfileNode* node1 = helper.Walk(&entry1); |
| 140 CHECK(node1); | 140 CHECK(node1); |
| 141 CHECK_EQ(0u, node1->self_ticks()); | 141 CHECK_EQ(0u, node1->self_ticks()); |
| 142 CHECK(!helper.Walk(&entry1, &entry1)); | 142 CHECK(!helper.Walk(&entry1, &entry1)); |
| 143 CHECK(!helper.Walk(&entry1, &entry3)); | 143 CHECK(!helper.Walk(&entry1, &entry3)); |
| 144 ProfileNode* node2 = helper.Walk(&entry1, &entry2); | 144 ProfileNode* node2 = helper.Walk(&entry1, &entry2); |
| 145 CHECK(node2); | 145 CHECK(node2); |
| 146 CHECK_NE(node1, node2); | 146 CHECK_NE(node1, node2); |
| 147 CHECK_EQ(0u, node2->self_ticks()); | 147 CHECK_EQ(0u, node2->self_ticks()); |
| 148 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); | 148 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); |
| 149 CHECK(!helper.Walk(&entry1, &entry2, &entry2)); | 149 CHECK(!helper.Walk(&entry1, &entry2, &entry2)); |
| 150 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); | 150 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); |
| 151 CHECK(node3); | 151 CHECK(node3); |
| 152 CHECK_NE(node1, node3); | 152 CHECK_NE(node1, node3); |
| 153 CHECK_NE(node2, node3); | 153 CHECK_NE(node2, node3); |
| 154 CHECK_EQ(1u, node3->self_ticks()); | 154 CHECK_EQ(1u, node3->self_ticks()); |
| 155 | 155 |
| 156 tree.AddPathFromEnd(path_vec); | 156 tree.AddPathFromEnd(path_vec); |
| 157 CHECK_EQ(node1, helper.Walk(&entry1)); | 157 CHECK_EQ(node1, helper.Walk(&entry1)); |
| 158 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); | 158 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
| 159 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); | 159 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
| 160 CHECK_EQ(0u, node1->self_ticks()); | 160 CHECK_EQ(0u, node1->self_ticks()); |
| 161 CHECK_EQ(0u, node2->self_ticks()); | 161 CHECK_EQ(0u, node2->self_ticks()); |
| 162 CHECK_EQ(2u, node3->self_ticks()); | 162 CHECK_EQ(2u, node3->self_ticks()); |
| 163 | 163 |
| 164 CodeEntry* path2[] = {&entry2, &entry2, &entry1}; | 164 CodeEntry* path2[] = {&entry2, &entry2, &entry1}; |
| 165 Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); | 165 std::vector<CodeEntry*> path2_vec(path2, path2 + arraysize(path2)); |
| 166 tree.AddPathFromEnd(path2_vec); | 166 tree.AddPathFromEnd(path2_vec); |
| 167 CHECK(!helper.Walk(&entry2)); | 167 CHECK(!helper.Walk(&entry2)); |
| 168 CHECK(!helper.Walk(&entry3)); | 168 CHECK(!helper.Walk(&entry3)); |
| 169 CHECK_EQ(node1, helper.Walk(&entry1)); | 169 CHECK_EQ(node1, helper.Walk(&entry1)); |
| 170 CHECK(!helper.Walk(&entry1, &entry1)); | 170 CHECK(!helper.Walk(&entry1, &entry1)); |
| 171 CHECK(!helper.Walk(&entry1, &entry3)); | 171 CHECK(!helper.Walk(&entry1, &entry3)); |
| 172 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); | 172 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
| 173 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); | 173 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); |
| 174 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); | 174 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
| 175 CHECK_EQ(2u, node3->self_ticks()); | 175 CHECK_EQ(2u, node3->self_ticks()); |
| 176 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); | 176 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
| 177 CHECK(node4); | 177 CHECK(node4); |
| 178 CHECK_NE(node3, node4); | 178 CHECK_NE(node3, node4); |
| 179 CHECK_EQ(1u, node4->self_ticks()); | 179 CHECK_EQ(1u, node4->self_ticks()); |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 TEST(ProfileTreeCalculateTotalTicks) { | 183 TEST(ProfileTreeCalculateTotalTicks) { |
| 184 CcTest::InitializeVM(); | 184 CcTest::InitializeVM(); |
| 185 ProfileTree empty_tree(CcTest::i_isolate()); | 185 ProfileTree empty_tree(CcTest::i_isolate()); |
| 186 CHECK_EQ(0u, empty_tree.root()->self_ticks()); | 186 CHECK_EQ(0u, empty_tree.root()->self_ticks()); |
| 187 empty_tree.root()->IncrementSelfTicks(); | 187 empty_tree.root()->IncrementSelfTicks(); |
| 188 CHECK_EQ(1u, empty_tree.root()->self_ticks()); | 188 CHECK_EQ(1u, empty_tree.root()->self_ticks()); |
| 189 | 189 |
| 190 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 190 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
| 191 CodeEntry* e1_path[] = {&entry1}; | 191 CodeEntry* e1_path[] = {&entry1}; |
| 192 Vector<CodeEntry*> e1_path_vec( | 192 std::vector<CodeEntry*> e1_path_vec(e1_path, e1_path + arraysize(e1_path)); |
| 193 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); | |
| 194 | 193 |
| 195 ProfileTree single_child_tree(CcTest::i_isolate()); | 194 ProfileTree single_child_tree(CcTest::i_isolate()); |
| 196 single_child_tree.AddPathFromEnd(e1_path_vec); | 195 single_child_tree.AddPathFromEnd(e1_path_vec); |
| 197 single_child_tree.root()->IncrementSelfTicks(); | 196 single_child_tree.root()->IncrementSelfTicks(); |
| 198 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); | 197 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); |
| 199 ProfileTreeTestHelper single_child_helper(&single_child_tree); | 198 ProfileTreeTestHelper single_child_helper(&single_child_tree); |
| 200 ProfileNode* node1 = single_child_helper.Walk(&entry1); | 199 ProfileNode* node1 = single_child_helper.Walk(&entry1); |
| 201 CHECK(node1); | 200 CHECK(node1); |
| 202 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); | 201 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); |
| 203 CHECK_EQ(1u, node1->self_ticks()); | 202 CHECK_EQ(1u, node1->self_ticks()); |
| 204 | 203 |
| 205 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 204 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
| 206 CodeEntry* e2_e1_path[] = {&entry2, &entry1}; | 205 CodeEntry* e2_e1_path[] = {&entry2, &entry1}; |
| 207 Vector<CodeEntry*> e2_e1_path_vec(e2_e1_path, | 206 std::vector<CodeEntry*> e2_e1_path_vec(e2_e1_path, |
| 208 sizeof(e2_e1_path) / sizeof(e2_e1_path[0])); | 207 e2_e1_path + arraysize(e2_e1_path)); |
| 209 | 208 |
| 210 ProfileTree flat_tree(CcTest::i_isolate()); | 209 ProfileTree flat_tree(CcTest::i_isolate()); |
| 211 ProfileTreeTestHelper flat_helper(&flat_tree); | 210 ProfileTreeTestHelper flat_helper(&flat_tree); |
| 212 flat_tree.AddPathFromEnd(e1_path_vec); | 211 flat_tree.AddPathFromEnd(e1_path_vec); |
| 213 flat_tree.AddPathFromEnd(e1_path_vec); | 212 flat_tree.AddPathFromEnd(e1_path_vec); |
| 214 flat_tree.AddPathFromEnd(e2_e1_path_vec); | 213 flat_tree.AddPathFromEnd(e2_e1_path_vec); |
| 215 flat_tree.AddPathFromEnd(e2_e1_path_vec); | 214 flat_tree.AddPathFromEnd(e2_e1_path_vec); |
| 216 flat_tree.AddPathFromEnd(e2_e1_path_vec); | 215 flat_tree.AddPathFromEnd(e2_e1_path_vec); |
| 217 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} | 216 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} |
| 218 CHECK_EQ(0u, flat_tree.root()->self_ticks()); | 217 CHECK_EQ(0u, flat_tree.root()->self_ticks()); |
| 219 node1 = flat_helper.Walk(&entry1); | 218 node1 = flat_helper.Walk(&entry1); |
| 220 CHECK(node1); | 219 CHECK(node1); |
| 221 CHECK_EQ(2u, node1->self_ticks()); | 220 CHECK_EQ(2u, node1->self_ticks()); |
| 222 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); | 221 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); |
| 223 CHECK(node2); | 222 CHECK(node2); |
| 224 CHECK_EQ(3u, node2->self_ticks()); | 223 CHECK_EQ(3u, node2->self_ticks()); |
| 225 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} | 224 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} |
| 226 CHECK_EQ(0u, flat_tree.root()->self_ticks()); | 225 CHECK_EQ(0u, flat_tree.root()->self_ticks()); |
| 227 CHECK_EQ(2u, node1->self_ticks()); | 226 CHECK_EQ(2u, node1->self_ticks()); |
| 228 | 227 |
| 229 CodeEntry* e2_path[] = {&entry2}; | 228 CodeEntry* e2_path[] = {&entry2}; |
| 230 Vector<CodeEntry*> e2_path_vec( | 229 std::vector<CodeEntry*> e2_path_vec(e2_path, e2_path + arraysize(e2_path)); |
| 231 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); | |
| 232 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 230 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
| 233 CodeEntry* e3_path[] = {&entry3}; | 231 CodeEntry* e3_path[] = {&entry3}; |
| 234 Vector<CodeEntry*> e3_path_vec( | 232 std::vector<CodeEntry*> e3_path_vec(e3_path, e3_path + arraysize(e3_path)); |
| 235 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); | |
| 236 | 233 |
| 237 ProfileTree wide_tree(CcTest::i_isolate()); | 234 ProfileTree wide_tree(CcTest::i_isolate()); |
| 238 ProfileTreeTestHelper wide_helper(&wide_tree); | 235 ProfileTreeTestHelper wide_helper(&wide_tree); |
| 239 wide_tree.AddPathFromEnd(e1_path_vec); | 236 wide_tree.AddPathFromEnd(e1_path_vec); |
| 240 wide_tree.AddPathFromEnd(e1_path_vec); | 237 wide_tree.AddPathFromEnd(e1_path_vec); |
| 241 wide_tree.AddPathFromEnd(e2_e1_path_vec); | 238 wide_tree.AddPathFromEnd(e2_e1_path_vec); |
| 242 wide_tree.AddPathFromEnd(e2_path_vec); | 239 wide_tree.AddPathFromEnd(e2_path_vec); |
| 243 wide_tree.AddPathFromEnd(e2_path_vec); | 240 wide_tree.AddPathFromEnd(e2_path_vec); |
| 244 wide_tree.AddPathFromEnd(e2_path_vec); | 241 wide_tree.AddPathFromEnd(e2_path_vec); |
| 245 wide_tree.AddPathFromEnd(e3_path_vec); | 242 wide_tree.AddPathFromEnd(e3_path_vec); |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 718 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 722 | 719 |
| 723 current = PickChild(current, "TryFinally"); | 720 current = PickChild(current, "TryFinally"); |
| 724 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 721 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 725 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); | 722 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); |
| 726 | 723 |
| 727 current = PickChild(current, "Debugger"); | 724 current = PickChild(current, "Debugger"); |
| 728 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 725 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 729 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); | 726 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); |
| 730 } | 727 } |
| OLD | NEW |