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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 using i::ProfileGenerator; | 45 using i::ProfileGenerator; |
46 using i::TickSample; | 46 using i::TickSample; |
47 using i::Vector; | 47 using i::Vector; |
48 | 48 |
49 | 49 |
50 TEST(ProfileNodeFindOrAddChild) { | 50 TEST(ProfileNodeFindOrAddChild) { |
51 ProfileTree tree; | 51 ProfileTree tree; |
52 ProfileNode* node = tree.root(); | 52 ProfileNode* node = tree.root(); |
53 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 53 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
54 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); | 54 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); |
55 CHECK_NE(NULL, childNode1); | 55 CHECK(childNode1); |
56 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 56 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
57 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 57 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
58 ProfileNode* childNode2 = node->FindOrAddChild(&entry2); | 58 ProfileNode* childNode2 = node->FindOrAddChild(&entry2); |
59 CHECK_NE(NULL, childNode2); | 59 CHECK(childNode2); |
60 CHECK_NE(childNode1, childNode2); | 60 CHECK_NE(childNode1, childNode2); |
61 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 61 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
62 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); | 62 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); |
63 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 63 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
64 ProfileNode* childNode3 = node->FindOrAddChild(&entry3); | 64 ProfileNode* childNode3 = node->FindOrAddChild(&entry3); |
65 CHECK_NE(NULL, childNode3); | 65 CHECK(childNode3); |
66 CHECK_NE(childNode1, childNode3); | 66 CHECK_NE(childNode1, childNode3); |
67 CHECK_NE(childNode2, childNode3); | 67 CHECK_NE(childNode2, childNode3); |
68 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 68 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
69 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); | 69 CHECK_EQ(childNode2, node->FindOrAddChild(&entry2)); |
70 CHECK_EQ(childNode3, node->FindOrAddChild(&entry3)); | 70 CHECK_EQ(childNode3, node->FindOrAddChild(&entry3)); |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 TEST(ProfileNodeFindOrAddChildForSameFunction) { | 74 TEST(ProfileNodeFindOrAddChildForSameFunction) { |
75 const char* aaa = "aaa"; | 75 const char* aaa = "aaa"; |
76 ProfileTree tree; | 76 ProfileTree tree; |
77 ProfileNode* node = tree.root(); | 77 ProfileNode* node = tree.root(); |
78 CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); | 78 CodeEntry entry1(i::Logger::FUNCTION_TAG, aaa); |
79 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); | 79 ProfileNode* childNode1 = node->FindOrAddChild(&entry1); |
80 CHECK_NE(NULL, childNode1); | 80 CHECK(childNode1); |
81 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); | 81 CHECK_EQ(childNode1, node->FindOrAddChild(&entry1)); |
82 // The same function again. | 82 // The same function again. |
83 CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); | 83 CodeEntry entry2(i::Logger::FUNCTION_TAG, aaa); |
84 CHECK_EQ(childNode1, node->FindOrAddChild(&entry2)); | 84 CHECK_EQ(childNode1, node->FindOrAddChild(&entry2)); |
85 // Now with a different security token. | 85 // Now with a different security token. |
86 CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa); | 86 CodeEntry entry3(i::Logger::FUNCTION_TAG, aaa); |
87 CHECK_EQ(childNode1, node->FindOrAddChild(&entry3)); | 87 CHECK_EQ(childNode1, node->FindOrAddChild(&entry3)); |
88 } | 88 } |
89 | 89 |
90 | 90 |
(...skipping 25 matching lines...) Expand all Loading... |
116 }; | 116 }; |
117 | 117 |
118 } // namespace | 118 } // namespace |
119 | 119 |
120 TEST(ProfileTreeAddPathFromStart) { | 120 TEST(ProfileTreeAddPathFromStart) { |
121 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 121 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
122 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 122 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
123 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 123 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
124 ProfileTree tree; | 124 ProfileTree tree; |
125 ProfileTreeTestHelper helper(&tree); | 125 ProfileTreeTestHelper helper(&tree); |
126 CHECK_EQ(NULL, helper.Walk(&entry1)); | 126 CHECK(!helper.Walk(&entry1)); |
127 CHECK_EQ(NULL, helper.Walk(&entry2)); | 127 CHECK(!helper.Walk(&entry2)); |
128 CHECK_EQ(NULL, helper.Walk(&entry3)); | 128 CHECK(!helper.Walk(&entry3)); |
129 | 129 |
130 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; | 130 CodeEntry* path[] = {NULL, &entry1, NULL, &entry2, NULL, NULL, &entry3, NULL}; |
131 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 131 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
132 tree.AddPathFromStart(path_vec); | 132 tree.AddPathFromStart(path_vec); |
133 CHECK_EQ(NULL, helper.Walk(&entry2)); | 133 CHECK(!helper.Walk(&entry2)); |
134 CHECK_EQ(NULL, helper.Walk(&entry3)); | 134 CHECK(!helper.Walk(&entry3)); |
135 ProfileNode* node1 = helper.Walk(&entry1); | 135 ProfileNode* node1 = helper.Walk(&entry1); |
136 CHECK_NE(NULL, node1); | 136 CHECK(node1); |
137 CHECK_EQ(0, node1->self_ticks()); | 137 CHECK_EQ(0u, node1->self_ticks()); |
138 CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); | 138 CHECK(!helper.Walk(&entry1, &entry1)); |
139 CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); | 139 CHECK(!helper.Walk(&entry1, &entry3)); |
140 ProfileNode* node2 = helper.Walk(&entry1, &entry2); | 140 ProfileNode* node2 = helper.Walk(&entry1, &entry2); |
141 CHECK_NE(NULL, node2); | 141 CHECK(node2); |
142 CHECK_NE(node1, node2); | 142 CHECK_NE(node1, node2); |
143 CHECK_EQ(0, node2->self_ticks()); | 143 CHECK_EQ(0u, node2->self_ticks()); |
144 CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); | 144 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); |
145 CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry2)); | 145 CHECK(!helper.Walk(&entry1, &entry2, &entry2)); |
146 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); | 146 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); |
147 CHECK_NE(NULL, node3); | 147 CHECK(node3); |
148 CHECK_NE(node1, node3); | 148 CHECK_NE(node1, node3); |
149 CHECK_NE(node2, node3); | 149 CHECK_NE(node2, node3); |
150 CHECK_EQ(1, node3->self_ticks()); | 150 CHECK_EQ(1u, node3->self_ticks()); |
151 | 151 |
152 tree.AddPathFromStart(path_vec); | 152 tree.AddPathFromStart(path_vec); |
153 CHECK_EQ(node1, helper.Walk(&entry1)); | 153 CHECK_EQ(node1, helper.Walk(&entry1)); |
154 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); | 154 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
155 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); | 155 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
156 CHECK_EQ(0, node1->self_ticks()); | 156 CHECK_EQ(0u, node1->self_ticks()); |
157 CHECK_EQ(0, node2->self_ticks()); | 157 CHECK_EQ(0u, node2->self_ticks()); |
158 CHECK_EQ(2, node3->self_ticks()); | 158 CHECK_EQ(2u, node3->self_ticks()); |
159 | 159 |
160 CodeEntry* path2[] = {&entry1, &entry2, &entry2}; | 160 CodeEntry* path2[] = {&entry1, &entry2, &entry2}; |
161 Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); | 161 Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); |
162 tree.AddPathFromStart(path2_vec); | 162 tree.AddPathFromStart(path2_vec); |
163 CHECK_EQ(NULL, helper.Walk(&entry2)); | 163 CHECK(!helper.Walk(&entry2)); |
164 CHECK_EQ(NULL, helper.Walk(&entry3)); | 164 CHECK(!helper.Walk(&entry3)); |
165 CHECK_EQ(node1, helper.Walk(&entry1)); | 165 CHECK_EQ(node1, helper.Walk(&entry1)); |
166 CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); | 166 CHECK(!helper.Walk(&entry1, &entry1)); |
167 CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); | 167 CHECK(!helper.Walk(&entry1, &entry3)); |
168 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); | 168 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
169 CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); | 169 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); |
170 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); | 170 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
171 CHECK_EQ(2, node3->self_ticks()); | 171 CHECK_EQ(2u, node3->self_ticks()); |
172 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); | 172 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
173 CHECK_NE(NULL, node4); | 173 CHECK(node4); |
174 CHECK_NE(node3, node4); | 174 CHECK_NE(node3, node4); |
175 CHECK_EQ(1, node4->self_ticks()); | 175 CHECK_EQ(1u, node4->self_ticks()); |
176 } | 176 } |
177 | 177 |
178 | 178 |
179 TEST(ProfileTreeAddPathFromEnd) { | 179 TEST(ProfileTreeAddPathFromEnd) { |
180 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 180 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
181 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 181 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
182 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 182 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
183 ProfileTree tree; | 183 ProfileTree tree; |
184 ProfileTreeTestHelper helper(&tree); | 184 ProfileTreeTestHelper helper(&tree); |
185 CHECK_EQ(NULL, helper.Walk(&entry1)); | 185 CHECK(!helper.Walk(&entry1)); |
186 CHECK_EQ(NULL, helper.Walk(&entry2)); | 186 CHECK(!helper.Walk(&entry2)); |
187 CHECK_EQ(NULL, helper.Walk(&entry3)); | 187 CHECK(!helper.Walk(&entry3)); |
188 | 188 |
189 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; | 189 CodeEntry* path[] = {NULL, &entry3, NULL, &entry2, NULL, NULL, &entry1, NULL}; |
190 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); | 190 Vector<CodeEntry*> path_vec(path, sizeof(path) / sizeof(path[0])); |
191 tree.AddPathFromEnd(path_vec); | 191 tree.AddPathFromEnd(path_vec); |
192 CHECK_EQ(NULL, helper.Walk(&entry2)); | 192 CHECK(!helper.Walk(&entry2)); |
193 CHECK_EQ(NULL, helper.Walk(&entry3)); | 193 CHECK(!helper.Walk(&entry3)); |
194 ProfileNode* node1 = helper.Walk(&entry1); | 194 ProfileNode* node1 = helper.Walk(&entry1); |
195 CHECK_NE(NULL, node1); | 195 CHECK(node1); |
196 CHECK_EQ(0, node1->self_ticks()); | 196 CHECK_EQ(0u, node1->self_ticks()); |
197 CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); | 197 CHECK(!helper.Walk(&entry1, &entry1)); |
198 CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); | 198 CHECK(!helper.Walk(&entry1, &entry3)); |
199 ProfileNode* node2 = helper.Walk(&entry1, &entry2); | 199 ProfileNode* node2 = helper.Walk(&entry1, &entry2); |
200 CHECK_NE(NULL, node2); | 200 CHECK(node2); |
201 CHECK_NE(node1, node2); | 201 CHECK_NE(node1, node2); |
202 CHECK_EQ(0, node2->self_ticks()); | 202 CHECK_EQ(0u, node2->self_ticks()); |
203 CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); | 203 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); |
204 CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry2)); | 204 CHECK(!helper.Walk(&entry1, &entry2, &entry2)); |
205 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); | 205 ProfileNode* node3 = helper.Walk(&entry1, &entry2, &entry3); |
206 CHECK_NE(NULL, node3); | 206 CHECK(node3); |
207 CHECK_NE(node1, node3); | 207 CHECK_NE(node1, node3); |
208 CHECK_NE(node2, node3); | 208 CHECK_NE(node2, node3); |
209 CHECK_EQ(1, node3->self_ticks()); | 209 CHECK_EQ(1u, node3->self_ticks()); |
210 | 210 |
211 tree.AddPathFromEnd(path_vec); | 211 tree.AddPathFromEnd(path_vec); |
212 CHECK_EQ(node1, helper.Walk(&entry1)); | 212 CHECK_EQ(node1, helper.Walk(&entry1)); |
213 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); | 213 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
214 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); | 214 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
215 CHECK_EQ(0, node1->self_ticks()); | 215 CHECK_EQ(0u, node1->self_ticks()); |
216 CHECK_EQ(0, node2->self_ticks()); | 216 CHECK_EQ(0u, node2->self_ticks()); |
217 CHECK_EQ(2, node3->self_ticks()); | 217 CHECK_EQ(2u, node3->self_ticks()); |
218 | 218 |
219 CodeEntry* path2[] = {&entry2, &entry2, &entry1}; | 219 CodeEntry* path2[] = {&entry2, &entry2, &entry1}; |
220 Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); | 220 Vector<CodeEntry*> path2_vec(path2, sizeof(path2) / sizeof(path2[0])); |
221 tree.AddPathFromEnd(path2_vec); | 221 tree.AddPathFromEnd(path2_vec); |
222 CHECK_EQ(NULL, helper.Walk(&entry2)); | 222 CHECK(!helper.Walk(&entry2)); |
223 CHECK_EQ(NULL, helper.Walk(&entry3)); | 223 CHECK(!helper.Walk(&entry3)); |
224 CHECK_EQ(node1, helper.Walk(&entry1)); | 224 CHECK_EQ(node1, helper.Walk(&entry1)); |
225 CHECK_EQ(NULL, helper.Walk(&entry1, &entry1)); | 225 CHECK(!helper.Walk(&entry1, &entry1)); |
226 CHECK_EQ(NULL, helper.Walk(&entry1, &entry3)); | 226 CHECK(!helper.Walk(&entry1, &entry3)); |
227 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); | 227 CHECK_EQ(node2, helper.Walk(&entry1, &entry2)); |
228 CHECK_EQ(NULL, helper.Walk(&entry1, &entry2, &entry1)); | 228 CHECK(!helper.Walk(&entry1, &entry2, &entry1)); |
229 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); | 229 CHECK_EQ(node3, helper.Walk(&entry1, &entry2, &entry3)); |
230 CHECK_EQ(2, node3->self_ticks()); | 230 CHECK_EQ(2u, node3->self_ticks()); |
231 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); | 231 ProfileNode* node4 = helper.Walk(&entry1, &entry2, &entry2); |
232 CHECK_NE(NULL, node4); | 232 CHECK(node4); |
233 CHECK_NE(node3, node4); | 233 CHECK_NE(node3, node4); |
234 CHECK_EQ(1, node4->self_ticks()); | 234 CHECK_EQ(1u, node4->self_ticks()); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 TEST(ProfileTreeCalculateTotalTicks) { | 238 TEST(ProfileTreeCalculateTotalTicks) { |
239 ProfileTree empty_tree; | 239 ProfileTree empty_tree; |
240 CHECK_EQ(0, empty_tree.root()->self_ticks()); | 240 CHECK_EQ(0u, empty_tree.root()->self_ticks()); |
241 empty_tree.root()->IncrementSelfTicks(); | 241 empty_tree.root()->IncrementSelfTicks(); |
242 CHECK_EQ(1, empty_tree.root()->self_ticks()); | 242 CHECK_EQ(1u, empty_tree.root()->self_ticks()); |
243 | 243 |
244 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 244 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
245 CodeEntry* e1_path[] = {&entry1}; | 245 CodeEntry* e1_path[] = {&entry1}; |
246 Vector<CodeEntry*> e1_path_vec( | 246 Vector<CodeEntry*> e1_path_vec( |
247 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); | 247 e1_path, sizeof(e1_path) / sizeof(e1_path[0])); |
248 | 248 |
249 ProfileTree single_child_tree; | 249 ProfileTree single_child_tree; |
250 single_child_tree.AddPathFromStart(e1_path_vec); | 250 single_child_tree.AddPathFromStart(e1_path_vec); |
251 single_child_tree.root()->IncrementSelfTicks(); | 251 single_child_tree.root()->IncrementSelfTicks(); |
252 CHECK_EQ(1, single_child_tree.root()->self_ticks()); | 252 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); |
253 ProfileTreeTestHelper single_child_helper(&single_child_tree); | 253 ProfileTreeTestHelper single_child_helper(&single_child_tree); |
254 ProfileNode* node1 = single_child_helper.Walk(&entry1); | 254 ProfileNode* node1 = single_child_helper.Walk(&entry1); |
255 CHECK_NE(NULL, node1); | 255 CHECK(node1); |
256 CHECK_EQ(1, single_child_tree.root()->self_ticks()); | 256 CHECK_EQ(1u, single_child_tree.root()->self_ticks()); |
257 CHECK_EQ(1, node1->self_ticks()); | 257 CHECK_EQ(1u, node1->self_ticks()); |
258 | 258 |
259 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 259 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
260 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; | 260 CodeEntry* e1_e2_path[] = {&entry1, &entry2}; |
261 Vector<CodeEntry*> e1_e2_path_vec( | 261 Vector<CodeEntry*> e1_e2_path_vec( |
262 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); | 262 e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0])); |
263 | 263 |
264 ProfileTree flat_tree; | 264 ProfileTree flat_tree; |
265 ProfileTreeTestHelper flat_helper(&flat_tree); | 265 ProfileTreeTestHelper flat_helper(&flat_tree); |
266 flat_tree.AddPathFromStart(e1_path_vec); | 266 flat_tree.AddPathFromStart(e1_path_vec); |
267 flat_tree.AddPathFromStart(e1_path_vec); | 267 flat_tree.AddPathFromStart(e1_path_vec); |
268 flat_tree.AddPathFromStart(e1_e2_path_vec); | 268 flat_tree.AddPathFromStart(e1_e2_path_vec); |
269 flat_tree.AddPathFromStart(e1_e2_path_vec); | 269 flat_tree.AddPathFromStart(e1_e2_path_vec); |
270 flat_tree.AddPathFromStart(e1_e2_path_vec); | 270 flat_tree.AddPathFromStart(e1_e2_path_vec); |
271 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} | 271 // Results in {root,0,0} -> {entry1,0,2} -> {entry2,0,3} |
272 CHECK_EQ(0, flat_tree.root()->self_ticks()); | 272 CHECK_EQ(0u, flat_tree.root()->self_ticks()); |
273 node1 = flat_helper.Walk(&entry1); | 273 node1 = flat_helper.Walk(&entry1); |
274 CHECK_NE(NULL, node1); | 274 CHECK(node1); |
275 CHECK_EQ(2, node1->self_ticks()); | 275 CHECK_EQ(2u, node1->self_ticks()); |
276 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); | 276 ProfileNode* node2 = flat_helper.Walk(&entry1, &entry2); |
277 CHECK_NE(NULL, node2); | 277 CHECK(node2); |
278 CHECK_EQ(3, node2->self_ticks()); | 278 CHECK_EQ(3u, node2->self_ticks()); |
279 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} | 279 // Must calculate {root,5,0} -> {entry1,5,2} -> {entry2,3,3} |
280 CHECK_EQ(0, flat_tree.root()->self_ticks()); | 280 CHECK_EQ(0u, flat_tree.root()->self_ticks()); |
281 CHECK_EQ(2, node1->self_ticks()); | 281 CHECK_EQ(2u, node1->self_ticks()); |
282 | 282 |
283 CodeEntry* e2_path[] = {&entry2}; | 283 CodeEntry* e2_path[] = {&entry2}; |
284 Vector<CodeEntry*> e2_path_vec( | 284 Vector<CodeEntry*> e2_path_vec( |
285 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); | 285 e2_path, sizeof(e2_path) / sizeof(e2_path[0])); |
286 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 286 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
287 CodeEntry* e3_path[] = {&entry3}; | 287 CodeEntry* e3_path[] = {&entry3}; |
288 Vector<CodeEntry*> e3_path_vec( | 288 Vector<CodeEntry*> e3_path_vec( |
289 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); | 289 e3_path, sizeof(e3_path) / sizeof(e3_path[0])); |
290 | 290 |
291 ProfileTree wide_tree; | 291 ProfileTree wide_tree; |
292 ProfileTreeTestHelper wide_helper(&wide_tree); | 292 ProfileTreeTestHelper wide_helper(&wide_tree); |
293 wide_tree.AddPathFromStart(e1_path_vec); | 293 wide_tree.AddPathFromStart(e1_path_vec); |
294 wide_tree.AddPathFromStart(e1_path_vec); | 294 wide_tree.AddPathFromStart(e1_path_vec); |
295 wide_tree.AddPathFromStart(e1_e2_path_vec); | 295 wide_tree.AddPathFromStart(e1_e2_path_vec); |
296 wide_tree.AddPathFromStart(e2_path_vec); | 296 wide_tree.AddPathFromStart(e2_path_vec); |
297 wide_tree.AddPathFromStart(e2_path_vec); | 297 wide_tree.AddPathFromStart(e2_path_vec); |
298 wide_tree.AddPathFromStart(e2_path_vec); | 298 wide_tree.AddPathFromStart(e2_path_vec); |
299 wide_tree.AddPathFromStart(e3_path_vec); | 299 wide_tree.AddPathFromStart(e3_path_vec); |
300 wide_tree.AddPathFromStart(e3_path_vec); | 300 wide_tree.AddPathFromStart(e3_path_vec); |
301 wide_tree.AddPathFromStart(e3_path_vec); | 301 wide_tree.AddPathFromStart(e3_path_vec); |
302 wide_tree.AddPathFromStart(e3_path_vec); | 302 wide_tree.AddPathFromStart(e3_path_vec); |
303 // Results in -> {entry1,0,2} -> {entry2,0,1} | 303 // Results in -> {entry1,0,2} -> {entry2,0,1} |
304 // {root,0,0} -> {entry2,0,3} | 304 // {root,0,0} -> {entry2,0,3} |
305 // -> {entry3,0,4} | 305 // -> {entry3,0,4} |
306 CHECK_EQ(0, wide_tree.root()->self_ticks()); | 306 CHECK_EQ(0u, wide_tree.root()->self_ticks()); |
307 node1 = wide_helper.Walk(&entry1); | 307 node1 = wide_helper.Walk(&entry1); |
308 CHECK_NE(NULL, node1); | 308 CHECK(node1); |
309 CHECK_EQ(2, node1->self_ticks()); | 309 CHECK_EQ(2u, node1->self_ticks()); |
310 ProfileNode* node1_2 = wide_helper.Walk(&entry1, &entry2); | 310 ProfileNode* node1_2 = wide_helper.Walk(&entry1, &entry2); |
311 CHECK_NE(NULL, node1_2); | 311 CHECK(node1_2); |
312 CHECK_EQ(1, node1_2->self_ticks()); | 312 CHECK_EQ(1u, node1_2->self_ticks()); |
313 node2 = wide_helper.Walk(&entry2); | 313 node2 = wide_helper.Walk(&entry2); |
314 CHECK_NE(NULL, node2); | 314 CHECK(node2); |
315 CHECK_EQ(3, node2->self_ticks()); | 315 CHECK_EQ(3u, node2->self_ticks()); |
316 ProfileNode* node3 = wide_helper.Walk(&entry3); | 316 ProfileNode* node3 = wide_helper.Walk(&entry3); |
317 CHECK_NE(NULL, node3); | 317 CHECK(node3); |
318 CHECK_EQ(4, node3->self_ticks()); | 318 CHECK_EQ(4u, node3->self_ticks()); |
319 // Calculates -> {entry1,3,2} -> {entry2,1,1} | 319 // Calculates -> {entry1,3,2} -> {entry2,1,1} |
320 // {root,10,0} -> {entry2,3,3} | 320 // {root,10,0} -> {entry2,3,3} |
321 // -> {entry3,4,4} | 321 // -> {entry3,4,4} |
322 CHECK_EQ(0, wide_tree.root()->self_ticks()); | 322 CHECK_EQ(0u, wide_tree.root()->self_ticks()); |
323 CHECK_EQ(2, node1->self_ticks()); | 323 CHECK_EQ(2u, node1->self_ticks()); |
324 CHECK_EQ(1, node1_2->self_ticks()); | 324 CHECK_EQ(1u, node1_2->self_ticks()); |
325 CHECK_EQ(3, node2->self_ticks()); | 325 CHECK_EQ(3u, node2->self_ticks()); |
326 CHECK_EQ(4, node3->self_ticks()); | 326 CHECK_EQ(4u, node3->self_ticks()); |
327 } | 327 } |
328 | 328 |
329 | 329 |
330 static inline i::Address ToAddress(int n) { | 330 static inline i::Address ToAddress(int n) { |
331 return reinterpret_cast<i::Address>(n); | 331 return reinterpret_cast<i::Address>(n); |
332 } | 332 } |
333 | 333 |
334 | 334 |
335 TEST(CodeMapAddCode) { | 335 TEST(CodeMapAddCode) { |
336 CodeMap code_map; | 336 CodeMap code_map; |
337 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 337 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
338 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 338 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
339 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 339 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
340 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); | 340 CodeEntry entry4(i::Logger::FUNCTION_TAG, "ddd"); |
341 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 341 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
342 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 342 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
343 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); | 343 code_map.AddCode(ToAddress(0x1900), &entry3, 0x50); |
344 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); | 344 code_map.AddCode(ToAddress(0x1950), &entry4, 0x10); |
345 CHECK_EQ(NULL, code_map.FindEntry(0)); | 345 CHECK(!code_map.FindEntry(0)); |
346 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500 - 1))); | 346 CHECK(!code_map.FindEntry(ToAddress(0x1500 - 1))); |
347 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 347 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
348 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); | 348 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x100))); |
349 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); | 349 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500 + 0x200 - 1))); |
350 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 350 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
351 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); | 351 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x50))); |
352 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); | 352 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700 + 0x100 - 1))); |
353 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700 + 0x100))); | 353 CHECK(!code_map.FindEntry(ToAddress(0x1700 + 0x100))); |
354 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1900 - 1))); | 354 CHECK(!code_map.FindEntry(ToAddress(0x1900 - 1))); |
355 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); | 355 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900))); |
356 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); | 356 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1900 + 0x28))); |
357 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); | 357 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950))); |
358 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); | 358 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x7))); |
359 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); | 359 CHECK_EQ(&entry4, code_map.FindEntry(ToAddress(0x1950 + 0x10 - 1))); |
360 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1950 + 0x10))); | 360 CHECK(!code_map.FindEntry(ToAddress(0x1950 + 0x10))); |
361 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0xFFFFFFFF))); | 361 CHECK(!code_map.FindEntry(ToAddress(0xFFFFFFFF))); |
362 } | 362 } |
363 | 363 |
364 | 364 |
365 TEST(CodeMapMoveAndDeleteCode) { | 365 TEST(CodeMapMoveAndDeleteCode) { |
366 CodeMap code_map; | 366 CodeMap code_map; |
367 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); | 367 CodeEntry entry1(i::Logger::FUNCTION_TAG, "aaa"); |
368 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); | 368 CodeEntry entry2(i::Logger::FUNCTION_TAG, "bbb"); |
369 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); | 369 code_map.AddCode(ToAddress(0x1500), &entry1, 0x200); |
370 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); | 370 code_map.AddCode(ToAddress(0x1700), &entry2, 0x100); |
371 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); | 371 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500))); |
372 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); | 372 CHECK_EQ(&entry2, code_map.FindEntry(ToAddress(0x1700))); |
373 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. | 373 code_map.MoveCode(ToAddress(0x1500), ToAddress(0x1700)); // Deprecate bbb. |
374 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1500))); | 374 CHECK(!code_map.FindEntry(ToAddress(0x1500))); |
375 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); | 375 CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1700))); |
376 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); | 376 CodeEntry entry3(i::Logger::FUNCTION_TAG, "ccc"); |
377 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); | 377 code_map.AddCode(ToAddress(0x1750), &entry3, 0x100); |
378 CHECK_EQ(NULL, code_map.FindEntry(ToAddress(0x1700))); | 378 CHECK(!code_map.FindEntry(ToAddress(0x1700))); |
379 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); | 379 CHECK_EQ(&entry3, code_map.FindEntry(ToAddress(0x1750))); |
380 } | 380 } |
381 | 381 |
382 | 382 |
383 namespace { | 383 namespace { |
384 | 384 |
385 class TestSetup { | 385 class TestSetup { |
386 public: | 386 public: |
387 TestSetup() | 387 TestSetup() |
388 : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) { | 388 : old_flag_prof_browser_mode_(i::FLAG_prof_browser_mode) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 generator.RecordTickSample(sample2); | 431 generator.RecordTickSample(sample2); |
432 TickSample sample3; | 432 TickSample sample3; |
433 sample3.pc = ToAddress(0x1510); | 433 sample3.pc = ToAddress(0x1510); |
434 sample3.tos = ToAddress(0x1500); | 434 sample3.tos = ToAddress(0x1500); |
435 sample3.stack[0] = ToAddress(0x1910); | 435 sample3.stack[0] = ToAddress(0x1910); |
436 sample3.stack[1] = ToAddress(0x1610); | 436 sample3.stack[1] = ToAddress(0x1610); |
437 sample3.frames_count = 2; | 437 sample3.frames_count = 2; |
438 generator.RecordTickSample(sample3); | 438 generator.RecordTickSample(sample3); |
439 | 439 |
440 CpuProfile* profile = profiles.StopProfiling(""); | 440 CpuProfile* profile = profiles.StopProfiling(""); |
441 CHECK_NE(NULL, profile); | 441 CHECK(profile); |
442 ProfileTreeTestHelper top_down_test_helper(profile->top_down()); | 442 ProfileTreeTestHelper top_down_test_helper(profile->top_down()); |
443 CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); | 443 CHECK(!top_down_test_helper.Walk(entry2)); |
444 CHECK_EQ(NULL, top_down_test_helper.Walk(entry3)); | 444 CHECK(!top_down_test_helper.Walk(entry3)); |
445 ProfileNode* node1 = top_down_test_helper.Walk(entry1); | 445 ProfileNode* node1 = top_down_test_helper.Walk(entry1); |
446 CHECK_NE(NULL, node1); | 446 CHECK(node1); |
447 CHECK_EQ(entry1, node1->entry()); | 447 CHECK_EQ(entry1, node1->entry()); |
448 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); | 448 ProfileNode* node2 = top_down_test_helper.Walk(entry1, entry1); |
449 CHECK_NE(NULL, node2); | 449 CHECK(node2); |
450 CHECK_EQ(entry1, node2->entry()); | 450 CHECK_EQ(entry1, node2->entry()); |
451 ProfileNode* node3 = top_down_test_helper.Walk(entry1, entry2, entry3); | 451 ProfileNode* node3 = top_down_test_helper.Walk(entry1, entry2, entry3); |
452 CHECK_NE(NULL, node3); | 452 CHECK(node3); |
453 CHECK_EQ(entry3, node3->entry()); | 453 CHECK_EQ(entry3, node3->entry()); |
454 ProfileNode* node4 = top_down_test_helper.Walk(entry1, entry3, entry1); | 454 ProfileNode* node4 = top_down_test_helper.Walk(entry1, entry3, entry1); |
455 CHECK_NE(NULL, node4); | 455 CHECK(node4); |
456 CHECK_EQ(entry1, node4->entry()); | 456 CHECK_EQ(entry1, node4->entry()); |
457 } | 457 } |
458 | 458 |
459 | 459 |
460 static void CheckNodeIds(ProfileNode* node, int* expectedId) { | 460 static void CheckNodeIds(ProfileNode* node, unsigned* expectedId) { |
461 CHECK_EQ((*expectedId)++, node->id()); | 461 CHECK_EQ((*expectedId)++, node->id()); |
462 for (int i = 0; i < node->children()->length(); i++) { | 462 for (int i = 0; i < node->children()->length(); i++) { |
463 CheckNodeIds(node->children()->at(i), expectedId); | 463 CheckNodeIds(node->children()->at(i), expectedId); |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 | 467 |
468 TEST(SampleIds) { | 468 TEST(SampleIds) { |
469 TestSetup test_setup; | 469 TestSetup test_setup; |
470 CpuProfilesCollection profiles(CcTest::heap()); | 470 CpuProfilesCollection profiles(CcTest::heap()); |
(...skipping 23 matching lines...) Expand all Loading... |
494 sample2.frames_count = 3; | 494 sample2.frames_count = 3; |
495 generator.RecordTickSample(sample2); | 495 generator.RecordTickSample(sample2); |
496 TickSample sample3; | 496 TickSample sample3; |
497 sample3.pc = ToAddress(0x1510); | 497 sample3.pc = ToAddress(0x1510); |
498 sample3.stack[0] = ToAddress(0x1910); | 498 sample3.stack[0] = ToAddress(0x1910); |
499 sample3.stack[1] = ToAddress(0x1610); | 499 sample3.stack[1] = ToAddress(0x1610); |
500 sample3.frames_count = 2; | 500 sample3.frames_count = 2; |
501 generator.RecordTickSample(sample3); | 501 generator.RecordTickSample(sample3); |
502 | 502 |
503 CpuProfile* profile = profiles.StopProfiling(""); | 503 CpuProfile* profile = profiles.StopProfiling(""); |
504 int nodeId = 1; | 504 unsigned nodeId = 1; |
505 CheckNodeIds(profile->top_down()->root(), &nodeId); | 505 CheckNodeIds(profile->top_down()->root(), &nodeId); |
506 CHECK_EQ(7, nodeId - 1); | 506 CHECK_EQ(7u, nodeId - 1); |
507 | 507 |
508 CHECK_EQ(3, profile->samples_count()); | 508 CHECK_EQ(3, profile->samples_count()); |
509 int expected_id[] = {3, 5, 7}; | 509 unsigned expected_id[] = {3, 5, 7}; |
510 for (int i = 0; i < 3; i++) { | 510 for (int i = 0; i < 3; i++) { |
511 CHECK_EQ(expected_id[i], profile->sample(i)->id()); | 511 CHECK_EQ(expected_id[i], profile->sample(i)->id()); |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 TEST(NoSamples) { | 516 TEST(NoSamples) { |
517 TestSetup test_setup; | 517 TestSetup test_setup; |
518 CpuProfilesCollection profiles(CcTest::heap()); | 518 CpuProfilesCollection profiles(CcTest::heap()); |
519 profiles.StartProfiling("", false); | 519 profiles.StartProfiling("", false); |
520 ProfileGenerator generator(&profiles); | 520 ProfileGenerator generator(&profiles); |
521 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); | 521 CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); |
522 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); | 522 generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); |
523 | 523 |
524 // We are building the following calls tree: | 524 // We are building the following calls tree: |
525 // (root)#1 -> aaa #2 -> aaa #3 - sample1 | 525 // (root)#1 -> aaa #2 -> aaa #3 - sample1 |
526 TickSample sample1; | 526 TickSample sample1; |
527 sample1.pc = ToAddress(0x1600); | 527 sample1.pc = ToAddress(0x1600); |
528 sample1.stack[0] = ToAddress(0x1510); | 528 sample1.stack[0] = ToAddress(0x1510); |
529 sample1.frames_count = 1; | 529 sample1.frames_count = 1; |
530 generator.RecordTickSample(sample1); | 530 generator.RecordTickSample(sample1); |
531 | 531 |
532 CpuProfile* profile = profiles.StopProfiling(""); | 532 CpuProfile* profile = profiles.StopProfiling(""); |
533 int nodeId = 1; | 533 unsigned nodeId = 1; |
534 CheckNodeIds(profile->top_down()->root(), &nodeId); | 534 CheckNodeIds(profile->top_down()->root(), &nodeId); |
535 CHECK_EQ(3, nodeId - 1); | 535 CHECK_EQ(3u, nodeId - 1); |
536 | 536 |
537 CHECK_EQ(0, profile->samples_count()); | 537 CHECK_EQ(0, profile->samples_count()); |
538 } | 538 } |
539 | 539 |
540 | 540 |
541 static const ProfileNode* PickChild(const ProfileNode* parent, | 541 static const ProfileNode* PickChild(const ProfileNode* parent, |
542 const char* name) { | 542 const char* name) { |
543 for (int i = 0; i < parent->children()->length(); ++i) { | 543 for (int i = 0; i < parent->children()->length(); ++i) { |
544 const ProfileNode* child = parent->children()->at(i); | 544 const ProfileNode* child = parent->children()->at(i); |
545 if (strcmp(child->entry()->name(), name) == 0) return child; | 545 if (strcmp(child->entry()->name(), name) == 0) return child; |
(...skipping 27 matching lines...) Expand all Loading... |
573 // The tree should look like this: | 573 // The tree should look like this: |
574 // (root) | 574 // (root) |
575 // "" | 575 // "" |
576 // a | 576 // a |
577 // b | 577 // b |
578 // c | 578 // c |
579 // There can also be: | 579 // There can also be: |
580 // startProfiling | 580 // startProfiling |
581 // if the sampler managed to get a tick. | 581 // if the sampler managed to get a tick. |
582 current = PickChild(current, ""); | 582 current = PickChild(current, ""); |
583 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 583 CHECK(const_cast<ProfileNode*>(current)); |
584 current = PickChild(current, "a"); | 584 current = PickChild(current, "a"); |
585 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 585 CHECK(const_cast<ProfileNode*>(current)); |
586 current = PickChild(current, "b"); | 586 current = PickChild(current, "b"); |
587 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 587 CHECK(const_cast<ProfileNode*>(current)); |
588 current = PickChild(current, "c"); | 588 current = PickChild(current, "c"); |
589 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 589 CHECK(const_cast<ProfileNode*>(current)); |
590 CHECK(current->children()->length() == 0 || | 590 CHECK(current->children()->length() == 0 || |
591 current->children()->length() == 1); | 591 current->children()->length() == 1); |
592 if (current->children()->length() == 1) { | 592 if (current->children()->length() == 1) { |
593 current = PickChild(current, "startProfiling"); | 593 current = PickChild(current, "startProfiling"); |
594 CHECK_EQ(0, current->children()->length()); | 594 CHECK_EQ(0, current->children()->length()); |
595 } | 595 } |
596 } | 596 } |
597 | 597 |
598 | 598 |
599 TEST(Issue51919) { | 599 TEST(Issue51919) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 const_cast<v8::CpuProfileNode*>(current))->Print(0); | 651 const_cast<v8::CpuProfileNode*>(current))->Print(0); |
652 // The tree should look like this: | 652 // The tree should look like this: |
653 // (root) | 653 // (root) |
654 // "" | 654 // "" |
655 // b | 655 // b |
656 // a | 656 // a |
657 // There can also be: | 657 // There can also be: |
658 // startProfiling | 658 // startProfiling |
659 // if the sampler managed to get a tick. | 659 // if the sampler managed to get a tick. |
660 current = PickChild(current, ""); | 660 current = PickChild(current, ""); |
661 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 661 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
662 | 662 |
663 current = PickChild(current, "b"); | 663 current = PickChild(current, "b"); |
664 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 664 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
665 CHECK_EQ(script_b->GetUnboundScript()->GetId(), current->GetScriptId()); | 665 CHECK_EQ(script_b->GetUnboundScript()->GetId(), current->GetScriptId()); |
666 | 666 |
667 current = PickChild(current, "a"); | 667 current = PickChild(current, "a"); |
668 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 668 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
669 CHECK_EQ(script_a->GetUnboundScript()->GetId(), current->GetScriptId()); | 669 CHECK_EQ(script_a->GetUnboundScript()->GetId(), current->GetScriptId()); |
670 } | 670 } |
671 | 671 |
672 | 672 |
673 | 673 |
674 | 674 |
675 static const char* line_number_test_source_existing_functions = | 675 static const char* line_number_test_source_existing_functions = |
676 "function foo_at_the_first_line() {\n" | 676 "function foo_at_the_first_line() {\n" |
677 "}\n" | 677 "}\n" |
678 "foo_at_the_first_line();\n" | 678 "foo_at_the_first_line();\n" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 CHECK(profile); | 757 CHECK(profile); |
758 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); | 758 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); |
759 reinterpret_cast<ProfileNode*>( | 759 reinterpret_cast<ProfileNode*>( |
760 const_cast<v8::CpuProfileNode*>(current))->Print(0); | 760 const_cast<v8::CpuProfileNode*>(current))->Print(0); |
761 // The tree should look like this: | 761 // The tree should look like this: |
762 // (root) | 762 // (root) |
763 // "" | 763 // "" |
764 // kTryFinally | 764 // kTryFinally |
765 // kTryCatch | 765 // kTryCatch |
766 current = PickChild(current, ""); | 766 current = PickChild(current, ""); |
767 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 767 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
768 | 768 |
769 current = PickChild(current, "TryFinally"); | 769 current = PickChild(current, "TryFinally"); |
770 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 770 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
771 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); | 771 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); |
772 | 772 |
773 current = PickChild(current, "TryCatch"); | 773 current = PickChild(current, "TryCatch"); |
774 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 774 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
775 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); | 775 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); |
776 } | 776 } |
OLD | NEW |