Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 893533003: Revert "Make GCC happy again." and "Initial switch to Chromium-style CHECK_* and DCHECK_* macros.". (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-conversions.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); 157 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3);
158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); 158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4);
159 159
160 // Enqueue a tick event to enable code events processing. 160 // Enqueue a tick event to enable code events processing.
161 EnqueueTickSampleEvent(processor.get(), aaa_code->address()); 161 EnqueueTickSampleEvent(processor.get(), aaa_code->address());
162 162
163 processor->StopSynchronously(); 163 processor->StopSynchronously();
164 164
165 // Check the state of profile generator. 165 // Check the state of profile generator.
166 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); 166 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address());
167 CHECK(aaa); 167 CHECK_NE(NULL, aaa);
168 CHECK_EQ(aaa_str, aaa->name()); 168 CHECK_EQ(aaa_str, aaa->name());
169 169
170 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); 170 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address());
171 CHECK(comment); 171 CHECK_NE(NULL, comment);
172 CHECK_EQ("comment", comment->name()); 172 CHECK_EQ("comment", comment->name());
173 173
174 CodeEntry* args5 = generator.code_map()->FindEntry(args5_code->address()); 174 CodeEntry* args5 = generator.code_map()->FindEntry(args5_code->address());
175 CHECK(args5); 175 CHECK_NE(NULL, args5);
176 CHECK_EQ("5", args5->name()); 176 CHECK_EQ("5", args5->name());
177 177
178 CHECK(!generator.code_map()->FindEntry(comment2_code->address())); 178 CHECK_EQ(NULL, generator.code_map()->FindEntry(comment2_code->address()));
179 179
180 CodeEntry* comment2 = generator.code_map()->FindEntry(moved_code->address()); 180 CodeEntry* comment2 = generator.code_map()->FindEntry(moved_code->address());
181 CHECK(comment2); 181 CHECK_NE(NULL, comment2);
182 CHECK_EQ("comment2", comment2->name()); 182 CHECK_EQ("comment2", comment2->name());
183 } 183 }
184 184
185 185
186 template<typename T> 186 template<typename T>
187 static int CompareProfileNodes(const T* p1, const T* p2) { 187 static int CompareProfileNodes(const T* p1, const T* p2) {
188 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name()); 188 return strcmp((*p1)->entry()->name(), (*p2)->entry()->name());
189 } 189 }
190 190
191 191
(...skipping 25 matching lines...) Expand all
217 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, 217 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2,
218 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); 218 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2);
219 EnqueueTickSampleEvent( 219 EnqueueTickSampleEvent(
220 processor.get(), 220 processor.get(),
221 frame3_code->instruction_end() - 1, 221 frame3_code->instruction_end() - 1,
222 frame2_code->instruction_end() - 1, 222 frame2_code->instruction_end() - 1,
223 frame1_code->instruction_end() - 1); 223 frame1_code->instruction_end() - 1);
224 224
225 processor->StopSynchronously(); 225 processor->StopSynchronously();
226 CpuProfile* profile = profiles->StopProfiling(""); 226 CpuProfile* profile = profiles->StopProfiling("");
227 CHECK(profile); 227 CHECK_NE(NULL, profile);
228 228
229 // Check call trees. 229 // Check call trees.
230 const i::List<ProfileNode*>* top_down_root_children = 230 const i::List<ProfileNode*>* top_down_root_children =
231 profile->top_down()->root()->children(); 231 profile->top_down()->root()->children();
232 CHECK_EQ(1, top_down_root_children->length()); 232 CHECK_EQ(1, top_down_root_children->length());
233 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name()); 233 CHECK_EQ("bbb", top_down_root_children->last()->entry()->name());
234 const i::List<ProfileNode*>* top_down_bbb_children = 234 const i::List<ProfileNode*>* top_down_bbb_children =
235 top_down_root_children->last()->children(); 235 top_down_root_children->last()->children();
236 CHECK_EQ(1, top_down_bbb_children->length()); 236 CHECK_EQ(1, top_down_bbb_children->length());
237 CHECK_EQ("5", top_down_bbb_children->last()->entry()->name()); 237 CHECK_EQ("5", top_down_bbb_children->last()->entry()->name());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 sample->pc = code->address(); 282 sample->pc = code->address();
283 sample->tos = 0; 283 sample->tos = 0;
284 sample->frames_count = i::TickSample::kMaxFramesCount; 284 sample->frames_count = i::TickSample::kMaxFramesCount;
285 for (unsigned i = 0; i < sample->frames_count; ++i) { 285 for (unsigned i = 0; i < sample->frames_count; ++i) {
286 sample->stack[i] = code->address(); 286 sample->stack[i] = code->address();
287 } 287 }
288 processor->FinishTickSample(); 288 processor->FinishTickSample();
289 289
290 processor->StopSynchronously(); 290 processor->StopSynchronously();
291 CpuProfile* profile = profiles->StopProfiling(""); 291 CpuProfile* profile = profiles->StopProfiling("");
292 CHECK(profile); 292 CHECK_NE(NULL, profile);
293 293
294 unsigned actual_depth = 0; 294 int actual_depth = 0;
295 const ProfileNode* node = profile->top_down()->root(); 295 const ProfileNode* node = profile->top_down()->root();
296 while (node->children()->length() > 0) { 296 while (node->children()->length() > 0) {
297 node = node->children()->last(); 297 node = node->children()->last();
298 ++actual_depth; 298 ++actual_depth;
299 } 299 }
300 300
301 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC. 301 CHECK_EQ(1 + i::TickSample::kMaxFramesCount, actual_depth); // +1 for PC.
302 } 302 }
303 303
304 304
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 TEST(DeleteCpuProfile) { 349 TEST(DeleteCpuProfile) {
350 LocalContext env; 350 LocalContext env;
351 v8::HandleScope scope(env->GetIsolate()); 351 v8::HandleScope scope(env->GetIsolate());
352 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 352 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
353 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(cpu_profiler); 353 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(cpu_profiler);
354 354
355 CHECK_EQ(0, iprofiler->GetProfilesCount()); 355 CHECK_EQ(0, iprofiler->GetProfilesCount());
356 v8::Local<v8::String> name1 = v8::String::NewFromUtf8(env->GetIsolate(), "1"); 356 v8::Local<v8::String> name1 = v8::String::NewFromUtf8(env->GetIsolate(), "1");
357 cpu_profiler->StartProfiling(name1); 357 cpu_profiler->StartProfiling(name1);
358 v8::CpuProfile* p1 = cpu_profiler->StopProfiling(name1); 358 v8::CpuProfile* p1 = cpu_profiler->StopProfiling(name1);
359 CHECK(p1); 359 CHECK_NE(NULL, p1);
360 CHECK_EQ(1, iprofiler->GetProfilesCount()); 360 CHECK_EQ(1, iprofiler->GetProfilesCount());
361 CHECK(FindCpuProfile(cpu_profiler, p1)); 361 CHECK(FindCpuProfile(cpu_profiler, p1));
362 p1->Delete(); 362 p1->Delete();
363 CHECK_EQ(0, iprofiler->GetProfilesCount()); 363 CHECK_EQ(0, iprofiler->GetProfilesCount());
364 364
365 v8::Local<v8::String> name2 = v8::String::NewFromUtf8(env->GetIsolate(), "2"); 365 v8::Local<v8::String> name2 = v8::String::NewFromUtf8(env->GetIsolate(), "2");
366 cpu_profiler->StartProfiling(name2); 366 cpu_profiler->StartProfiling(name2);
367 v8::CpuProfile* p2 = cpu_profiler->StopProfiling(name2); 367 v8::CpuProfile* p2 = cpu_profiler->StopProfiling(name2);
368 CHECK(p2); 368 CHECK_NE(NULL, p2);
369 CHECK_EQ(1, iprofiler->GetProfilesCount()); 369 CHECK_EQ(1, iprofiler->GetProfilesCount());
370 CHECK(FindCpuProfile(cpu_profiler, p2)); 370 CHECK(FindCpuProfile(cpu_profiler, p2));
371 v8::Local<v8::String> name3 = v8::String::NewFromUtf8(env->GetIsolate(), "3"); 371 v8::Local<v8::String> name3 = v8::String::NewFromUtf8(env->GetIsolate(), "3");
372 cpu_profiler->StartProfiling(name3); 372 cpu_profiler->StartProfiling(name3);
373 v8::CpuProfile* p3 = cpu_profiler->StopProfiling(name3); 373 v8::CpuProfile* p3 = cpu_profiler->StopProfiling(name3);
374 CHECK(p3); 374 CHECK_NE(NULL, p3);
375 CHECK_EQ(2, iprofiler->GetProfilesCount()); 375 CHECK_EQ(2, iprofiler->GetProfilesCount());
376 CHECK_NE(p2, p3); 376 CHECK_NE(p2, p3);
377 CHECK(FindCpuProfile(cpu_profiler, p3)); 377 CHECK(FindCpuProfile(cpu_profiler, p3));
378 CHECK(FindCpuProfile(cpu_profiler, p2)); 378 CHECK(FindCpuProfile(cpu_profiler, p2));
379 p2->Delete(); 379 p2->Delete();
380 CHECK_EQ(1, iprofiler->GetProfilesCount()); 380 CHECK_EQ(1, iprofiler->GetProfilesCount());
381 CHECK(!FindCpuProfile(cpu_profiler, p2)); 381 CHECK(!FindCpuProfile(cpu_profiler, p2));
382 CHECK(FindCpuProfile(cpu_profiler, p3)); 382 CHECK(FindCpuProfile(cpu_profiler, p3));
383 p3->Delete(); 383 p3->Delete();
384 CHECK_EQ(0, iprofiler->GetProfilesCount()); 384 CHECK_EQ(0, iprofiler->GetProfilesCount());
(...skipping 25 matching lines...) Expand all
410 410
411 i::Sampler* sampler = 411 i::Sampler* sampler =
412 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler(); 412 reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
413 sampler->StartCountingSamples(); 413 sampler->StartCountingSamples();
414 do { 414 do {
415 function->Call(env->Global(), argc, argv); 415 function->Call(env->Global(), argc, argv);
416 } while (sampler->js_and_external_sample_count() < min_js_samples); 416 } while (sampler->js_and_external_sample_count() < min_js_samples);
417 417
418 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); 418 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name);
419 419
420 CHECK(profile); 420 CHECK_NE(NULL, profile);
421 // Dump collected profile to have a better diagnostic in case of failure. 421 // Dump collected profile to have a better diagnostic in case of failure.
422 reinterpret_cast<i::CpuProfile*>(profile)->Print(); 422 reinterpret_cast<i::CpuProfile*>(profile)->Print();
423 423
424 return profile; 424 return profile;
425 } 425 }
426 426
427 427
428 static bool ContainsString(v8::Handle<v8::String> string, 428 static bool ContainsString(v8::Handle<v8::String> string,
429 const Vector<v8::Handle<v8::String> >& vector) { 429 const Vector<v8::Handle<v8::String> >& vector) {
430 for (int i = 0; i < vector.length(); i++) { 430 for (int i = 0; i < vector.length(); i++) {
431 if (string->Equals(vector[i])) 431 if (string->Equals(vector[i]))
432 return true; 432 return true;
433 } 433 }
434 return false; 434 return false;
435 } 435 }
436 436
437 437
438 static void CheckChildrenNames(const v8::CpuProfileNode* node, 438 static void CheckChildrenNames(const v8::CpuProfileNode* node,
439 const Vector<v8::Handle<v8::String> >& names) { 439 const Vector<v8::Handle<v8::String> >& names) {
440 int count = node->GetChildrenCount(); 440 int count = node->GetChildrenCount();
441 for (int i = 0; i < count; i++) { 441 for (int i = 0; i < count; i++) {
442 v8::Handle<v8::String> name = node->GetChild(i)->GetFunctionName(); 442 v8::Handle<v8::String> name = node->GetChild(i)->GetFunctionName();
443 CHECK(ContainsString(name, names)); 443 CHECK(ContainsString(name, names));
444 // Check that there are no duplicates. 444 // Check that there are no duplicates.
445 for (int j = 0; j < count; j++) { 445 for (int j = 0; j < count; j++) {
446 if (j == i) continue; 446 if (j == i) continue;
447 CHECK(!name->Equals(node->GetChild(j)->GetFunctionName())); 447 CHECK_NE(name, node->GetChild(j)->GetFunctionName());
448 } 448 }
449 } 449 }
450 } 450 }
451 451
452 452
453 static const v8::CpuProfileNode* FindChild(v8::Isolate* isolate, 453 static const v8::CpuProfileNode* FindChild(v8::Isolate* isolate,
454 const v8::CpuProfileNode* node, 454 const v8::CpuProfileNode* node,
455 const char* name) { 455 const char* name) {
456 int count = node->GetChildrenCount(); 456 int count = node->GetChildrenCount();
457 v8::Handle<v8::String> nameHandle = v8::String::NewFromUtf8(isolate, name); 457 v8::Handle<v8::String> nameHandle = v8::String::NewFromUtf8(isolate, name);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 v8::Integer::New(env->GetIsolate(), profiling_interval_ms) 667 v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
668 }; 668 };
669 v8::CpuProfile* profile = 669 v8::CpuProfile* profile =
670 RunProfiler(env.local(), function, args, arraysize(args), 200, true); 670 RunProfiler(env.local(), function, args, arraysize(args), 200, true);
671 671
672 CHECK_LE(200, profile->GetSamplesCount()); 672 CHECK_LE(200, profile->GetSamplesCount());
673 uint64_t end_time = profile->GetEndTime(); 673 uint64_t end_time = profile->GetEndTime();
674 uint64_t current_time = profile->GetStartTime(); 674 uint64_t current_time = profile->GetStartTime();
675 CHECK_LE(current_time, end_time); 675 CHECK_LE(current_time, end_time);
676 for (int i = 0; i < profile->GetSamplesCount(); i++) { 676 for (int i = 0; i < profile->GetSamplesCount(); i++) {
677 CHECK(profile->GetSample(i)); 677 CHECK_NE(NULL, profile->GetSample(i));
678 uint64_t timestamp = profile->GetSampleTimestamp(i); 678 uint64_t timestamp = profile->GetSampleTimestamp(i);
679 CHECK_LE(current_time, timestamp); 679 CHECK_LE(current_time, timestamp);
680 CHECK_LE(timestamp, end_time); 680 CHECK_LE(timestamp, end_time);
681 current_time = timestamp; 681 current_time = timestamp;
682 } 682 }
683 683
684 profile->Delete(); 684 profile->Delete();
685 } 685 }
686 686
687 687
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 " n += m * m * m;\n" 1085 " n += m * m * m;\n"
1086 " }\n" 1086 " }\n"
1087 "}\n" 1087 "}\n"
1088 "%s();\n", 1088 "%s();\n",
1089 func_name, func_name); 1089 func_name, func_name);
1090 1090
1091 CompileRun(script.start()); 1091 CompileRun(script.start());
1092 1092
1093 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle( 1093 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle(
1094 *v8::Local<v8::Function>::Cast((*env)->Global()->Get(v8_str(func_name)))); 1094 *v8::Local<v8::Function>::Cast((*env)->Global()->Get(v8_str(func_name))));
1095 CHECK(func->shared()); 1095 CHECK_NE(NULL, func->shared());
1096 CHECK(func->shared()->code()); 1096 CHECK_NE(NULL, func->shared()->code());
1097 i::Code* code = NULL; 1097 i::Code* code = NULL;
1098 if (func->code()->is_optimized_code()) { 1098 if (func->code()->is_optimized_code()) {
1099 code = func->code(); 1099 code = func->code();
1100 } else { 1100 } else {
1101 CHECK(func->shared()->code() == func->code() || !i::FLAG_crankshaft); 1101 CHECK(func->shared()->code() == func->code() || !i::FLAG_crankshaft);
1102 code = func->shared()->code(); 1102 code = func->shared()->code();
1103 } 1103 }
1104 CHECK(code); 1104 CHECK_NE(NULL, code);
1105 i::Address code_address = code->instruction_start(); 1105 i::Address code_address = code->instruction_start();
1106 CHECK(code_address); 1106 CHECK_NE(NULL, code_address);
1107 1107
1108 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 1108 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
1109 profiles->StartProfiling("", false); 1109 profiles->StartProfiling("", false);
1110 ProfileGenerator generator(profiles); 1110 ProfileGenerator generator(profiles);
1111 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor( 1111 ProfilerEventsProcessor* processor = new ProfilerEventsProcessor(
1112 &generator, NULL, v8::base::TimeDelta::FromMicroseconds(100)); 1112 &generator, NULL, v8::base::TimeDelta::FromMicroseconds(100));
1113 processor->Start(); 1113 processor->Start();
1114 CpuProfiler profiler(isolate, profiles, &generator, processor); 1114 CpuProfiler profiler(isolate, profiles, &generator, processor);
1115 1115
1116 // Enqueue code creation events. 1116 // Enqueue code creation events.
1117 i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name); 1117 i::Handle<i::String> str = factory->NewStringFromAsciiChecked(func_name);
1118 int line = 1; 1118 int line = 1;
1119 int column = 1; 1119 int column = 1;
1120 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, code, func->shared(), NULL, 1120 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, code, func->shared(), NULL,
1121 *str, line, column); 1121 *str, line, column);
1122 1122
1123 // Enqueue a tick event to enable code events processing. 1123 // Enqueue a tick event to enable code events processing.
1124 EnqueueTickSampleEvent(processor, code_address); 1124 EnqueueTickSampleEvent(processor, code_address);
1125 1125
1126 processor->StopSynchronously(); 1126 processor->StopSynchronously();
1127 1127
1128 CpuProfile* profile = profiles->StopProfiling(""); 1128 CpuProfile* profile = profiles->StopProfiling("");
1129 CHECK(profile); 1129 CHECK_NE(NULL, profile);
1130 1130
1131 // Check the state of profile generator. 1131 // Check the state of profile generator.
1132 CodeEntry* func_entry = generator.code_map()->FindEntry(code_address); 1132 CodeEntry* func_entry = generator.code_map()->FindEntry(code_address);
1133 CHECK(func_entry); 1133 CHECK_NE(NULL, func_entry);
1134 CHECK_EQ(func_name, func_entry->name()); 1134 CHECK_EQ(func_name, func_entry->name());
1135 const i::JITLineInfoTable* line_info = func_entry->line_info(); 1135 const i::JITLineInfoTable* line_info = func_entry->line_info();
1136 CHECK(line_info); 1136 CHECK_NE(NULL, line_info);
1137 CHECK(!line_info->empty()); 1137 CHECK(!line_info->empty());
1138 1138
1139 // Check the hit source lines using V8 Public APIs. 1139 // Check the hit source lines using V8 Public APIs.
1140 const i::ProfileTree* tree = profile->top_down(); 1140 const i::ProfileTree* tree = profile->top_down();
1141 ProfileNode* root = tree->root(); 1141 ProfileNode* root = tree->root();
1142 CHECK(root); 1142 CHECK_NE(NULL, root);
1143 ProfileNode* func_node = root->FindChild(func_entry); 1143 ProfileNode* func_node = root->FindChild(func_entry);
1144 CHECK(func_node); 1144 CHECK_NE(NULL, func_node);
1145 1145
1146 // Add 10 faked ticks to source line #5. 1146 // Add 10 faked ticks to source line #5.
1147 int hit_line = 5; 1147 int hit_line = 5;
1148 int hit_count = 10; 1148 int hit_count = 10;
1149 for (int i = 0; i < hit_count; i++) func_node->IncrementLineTicks(hit_line); 1149 for (int i = 0; i < hit_count; i++) func_node->IncrementLineTicks(hit_line);
1150 1150
1151 unsigned int line_count = func_node->GetHitLineCount(); 1151 unsigned int line_count = func_node->GetHitLineCount();
1152 CHECK_EQ(2u, line_count); // Expect two hit source lines - #1 and #5. 1152 CHECK_EQ(2, line_count); // Expect two hit source lines - #1 and #5.
1153 ScopedVector<v8::CpuProfileNode::LineTick> entries(line_count); 1153 ScopedVector<v8::CpuProfileNode::LineTick> entries(line_count);
1154 CHECK(func_node->GetLineTicks(&entries[0], line_count)); 1154 CHECK(func_node->GetLineTicks(&entries[0], line_count));
1155 int value = 0; 1155 int value = 0;
1156 for (int i = 0; i < entries.length(); i++) 1156 for (int i = 0; i < entries.length(); i++)
1157 if (entries[i].line == hit_line) { 1157 if (entries[i].line == hit_line) {
1158 value = entries[i].hit_count; 1158 value = entries[i].hit_count;
1159 break; 1159 break;
1160 } 1160 }
1161 CHECK_EQ(hit_count, value); 1161 CHECK_EQ(hit_count, value);
1162 } 1162 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 v8::Script::Compile(v8::String::NewFromUtf8( 1368 v8::Script::Compile(v8::String::NewFromUtf8(
1369 env->GetIsolate(), cpu_profiler_deep_stack_test_source))->Run(); 1369 env->GetIsolate(), cpu_profiler_deep_stack_test_source))->Run();
1370 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 1370 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
1371 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 1371 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
1372 1372
1373 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1373 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1374 v8::Local<v8::String> profile_name = 1374 v8::Local<v8::String> profile_name =
1375 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile"); 1375 v8::String::NewFromUtf8(env->GetIsolate(), "my_profile");
1376 function->Call(env->Global(), 0, NULL); 1376 function->Call(env->Global(), 0, NULL);
1377 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); 1377 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name);
1378 CHECK(profile); 1378 CHECK_NE(NULL, profile);
1379 // Dump collected profile to have a better diagnostic in case of failure. 1379 // Dump collected profile to have a better diagnostic in case of failure.
1380 reinterpret_cast<i::CpuProfile*>(profile)->Print(); 1380 reinterpret_cast<i::CpuProfile*>(profile)->Print();
1381 1381
1382 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1382 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1383 { 1383 {
1384 ScopedVector<v8::Handle<v8::String> > names(3); 1384 ScopedVector<v8::Handle<v8::String> > names(3);
1385 names[0] = v8::String::NewFromUtf8( 1385 names[0] = v8::String::NewFromUtf8(
1386 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); 1386 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
1387 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), 1387 names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
1388 ProfileGenerator::kProgramEntryName); 1388 ProfileGenerator::kProgramEntryName);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 1656
1657 for (int i = 0; i < 3; i++) { 1657 for (int i = 0; i < 3; i++) {
1658 processor->AddCurrentStack(isolate); 1658 processor->AddCurrentStack(isolate);
1659 } 1659 }
1660 1660
1661 cpu_profiler->SetIdle(false); 1661 cpu_profiler->SetIdle(false);
1662 processor->AddCurrentStack(isolate); 1662 processor->AddCurrentStack(isolate);
1663 1663
1664 1664
1665 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name); 1665 v8::CpuProfile* profile = cpu_profiler->StopProfiling(profile_name);
1666 CHECK(profile); 1666 CHECK_NE(NULL, profile);
1667 // Dump collected profile to have a better diagnostic in case of failure. 1667 // Dump collected profile to have a better diagnostic in case of failure.
1668 reinterpret_cast<i::CpuProfile*>(profile)->Print(); 1668 reinterpret_cast<i::CpuProfile*>(profile)->Print();
1669 1669
1670 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1670 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1671 ScopedVector<v8::Handle<v8::String> > names(3); 1671 ScopedVector<v8::Handle<v8::String> > names(3);
1672 names[0] = v8::String::NewFromUtf8( 1672 names[0] = v8::String::NewFromUtf8(
1673 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName); 1673 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
1674 names[1] = v8::String::NewFromUtf8(env->GetIsolate(), 1674 names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
1675 ProfileGenerator::kProgramEntryName); 1675 ProfileGenerator::kProgramEntryName);
1676 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), 1676 names[2] = v8::String::NewFromUtf8(env->GetIsolate(),
1677 ProfileGenerator::kIdleEntryName); 1677 ProfileGenerator::kIdleEntryName);
1678 CheckChildrenNames(root, names); 1678 CheckChildrenNames(root, names);
1679 1679
1680 const v8::CpuProfileNode* programNode = 1680 const v8::CpuProfileNode* programNode =
1681 GetChild(env->GetIsolate(), root, ProfileGenerator::kProgramEntryName); 1681 GetChild(env->GetIsolate(), root, ProfileGenerator::kProgramEntryName);
1682 CHECK_EQ(0, programNode->GetChildrenCount()); 1682 CHECK_EQ(0, programNode->GetChildrenCount());
1683 CHECK_GE(programNode->GetHitCount(), 3u); 1683 CHECK_GE(programNode->GetHitCount(), 3);
1684 1684
1685 const v8::CpuProfileNode* idleNode = 1685 const v8::CpuProfileNode* idleNode =
1686 GetChild(env->GetIsolate(), root, ProfileGenerator::kIdleEntryName); 1686 GetChild(env->GetIsolate(), root, ProfileGenerator::kIdleEntryName);
1687 CHECK_EQ(0, idleNode->GetChildrenCount()); 1687 CHECK_EQ(0, idleNode->GetChildrenCount());
1688 CHECK_GE(idleNode->GetHitCount(), 3u); 1688 CHECK_GE(idleNode->GetHitCount(), 3);
1689 1689
1690 profile->Delete(); 1690 profile->Delete();
1691 } 1691 }
1692 1692
1693 1693
1694 static void CheckFunctionDetails(v8::Isolate* isolate, 1694 static void CheckFunctionDetails(v8::Isolate* isolate,
1695 const v8::CpuProfileNode* node, 1695 const v8::CpuProfileNode* node,
1696 const char* name, const char* script_name, 1696 const char* name, const char* script_name,
1697 int script_id, int line, int column) { 1697 int script_id, int line, int column) {
1698 CHECK( 1698 CHECK_EQ(v8::String::NewFromUtf8(isolate, name),
1699 v8::String::NewFromUtf8(isolate, name)->Equals(node->GetFunctionName())); 1699 node->GetFunctionName());
1700 CHECK(v8::String::NewFromUtf8(isolate, script_name) 1700 CHECK_EQ(v8::String::NewFromUtf8(isolate, script_name),
1701 ->Equals(node->GetScriptResourceName())); 1701 node->GetScriptResourceName());
1702 CHECK_EQ(script_id, node->GetScriptId()); 1702 CHECK_EQ(script_id, node->GetScriptId());
1703 CHECK_EQ(line, node->GetLineNumber()); 1703 CHECK_EQ(line, node->GetLineNumber());
1704 CHECK_EQ(column, node->GetColumnNumber()); 1704 CHECK_EQ(column, node->GetColumnNumber());
1705 } 1705 }
1706 1706
1707 1707
1708 TEST(FunctionDetails) { 1708 TEST(FunctionDetails) {
1709 v8::HandleScope scope(CcTest::isolate()); 1709 v8::HandleScope scope(CcTest::isolate());
1710 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); 1710 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
1711 v8::Context::Scope context_scope(env); 1711 v8::Context::Scope context_scope(env);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 inner_profile = NULL; 1772 inner_profile = NULL;
1773 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1773 CHECK_EQ(0, iprofiler->GetProfilesCount());
1774 1774
1775 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); 1775 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer);
1776 CHECK(outer_profile); 1776 CHECK(outer_profile);
1777 CHECK_EQ(1, iprofiler->GetProfilesCount()); 1777 CHECK_EQ(1, iprofiler->GetProfilesCount());
1778 outer_profile->Delete(); 1778 outer_profile->Delete();
1779 outer_profile = NULL; 1779 outer_profile = NULL;
1780 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1780 CHECK_EQ(0, iprofiler->GetProfilesCount());
1781 } 1781 }
OLDNEW
« no previous file with comments | « test/cctest/test-conversions.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698