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

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

Issue 14253015: Skip samples where top function's stack frame is not setup properly (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed printf Created 7 years, 7 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 | Annotate | Revision Log
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 i::HandleScope scope(isolate); 111 i::HandleScope scope(isolate);
112 const char* aaa_str = "aaa"; 112 const char* aaa_str = "aaa";
113 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( 113 i::Handle<i::String> aaa_name = factory->NewStringFromAscii(
114 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 114 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
115 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, 115 processor.CodeCreateEvent(i::Logger::FUNCTION_TAG,
116 *aaa_name, 116 *aaa_name,
117 heap->empty_string(), 117 heap->empty_string(),
118 0, 118 0,
119 ToAddress(0x1000), 119 ToAddress(0x1000),
120 0x100, 120 0x100,
121 ToAddress(0x10000)); 121 ToAddress(0x10000),
122 NULL);
122 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 123 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
123 "bbb", 124 "bbb",
124 ToAddress(0x1200), 125 ToAddress(0x1200),
125 0x80); 126 0x80);
126 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10); 127 processor.CodeCreateEvent(i::Logger::STUB_TAG, 5, ToAddress(0x1300), 0x10);
127 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG, 128 processor.CodeCreateEvent(i::Logger::BUILTIN_TAG,
128 "ddd", 129 "ddd",
129 ToAddress(0x1400), 130 ToAddress(0x1400),
130 0x80); 131 0x80);
131 processor.CodeMoveEvent(ToAddress(0x1400), ToAddress(0x1500)); 132 processor.CodeMoveEvent(ToAddress(0x1400), ToAddress(0x1500));
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 539
539 const char* barBranch[] = { "bar", "delay", "loop" }; 540 const char* barBranch[] = { "bar", "delay", "loop" };
540 CheckSimpleBranch(fooNode, barBranch, ARRAY_SIZE(barBranch)); 541 CheckSimpleBranch(fooNode, barBranch, ARRAY_SIZE(barBranch));
541 const char* bazBranch[] = { "baz", "delay", "loop" }; 542 const char* bazBranch[] = { "baz", "delay", "loop" };
542 CheckSimpleBranch(fooNode, bazBranch, ARRAY_SIZE(bazBranch)); 543 CheckSimpleBranch(fooNode, bazBranch, ARRAY_SIZE(bazBranch));
543 const char* delayBranch[] = { "delay", "loop" }; 544 const char* delayBranch[] = { "delay", "loop" };
544 CheckSimpleBranch(fooNode, delayBranch, ARRAY_SIZE(delayBranch)); 545 CheckSimpleBranch(fooNode, delayBranch, ARRAY_SIZE(delayBranch));
545 546
546 cpu_profiler->DeleteAllCpuProfiles(); 547 cpu_profiler->DeleteAllCpuProfiles();
547 } 548 }
549
550
551
552 static const char* cpu_profiler_test_source2 = "function loop() {}\n"
553 "function delay() { loop(); }\n"
554 "function start(count) {\n"
555 " var k = 0;\n"
556 " do {\n"
557 " delay();\n"
558 " } while (++k < count*1000*1000);\n"
559 "}\n";
560
561 // Check that the profile tree doesn't contain unexpecte traces:
562 // - 'loop' can be called only by 'delay'
563 // - 'delay' may be called only by 'start'
564 // The profile will look like the following:
565 //
566 // [Top down]:
567 // 135 0 (root) [-1] #1
568 // 121 72 start [-1] #3
569 // 49 33 delay [-1] #4
570 // 16 16 loop [-1] #5
571 // 14 14 (program) [-1] #2
572 TEST(SampleWhenFrameIsNotSetup) {
573 LocalContext env;
574 v8::HandleScope scope(env->GetIsolate());
575
576 v8::Script::Compile(v8::String::New(cpu_profiler_test_source2))->Run();
577 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
578 env->Global()->Get(v8::String::New("start")));
579
580 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
581 v8::Local<v8::String> profile_name = v8::String::New("my_profile");
582
583 cpu_profiler->StartCpuProfiling(profile_name);
584 int32_t repeat_count = 10;
585 v8::Handle<v8::Value> args[] = { v8::Integer::New(repeat_count) };
586 function->Call(env->Global(), ARRAY_SIZE(args), args);
587 const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
588
589 CHECK_NE(NULL, profile);
590 // Dump collected profile to have a better diagnostic in case of failure.
591 reinterpret_cast<i::CpuProfile*>(
592 const_cast<v8::CpuProfile*>(profile))->Print();
593
594 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
595
596 ScopedVector<v8::Handle<v8::String> > names(3);
597 names[0] = v8::String::New(ProfileGenerator::kGarbageCollectorEntryName);
598 names[1] = v8::String::New(ProfileGenerator::kProgramEntryName);
599 names[2] = v8::String::New("start");
600 CheckChildrenNames(root, names);
601
602 const v8::CpuProfileNode* startNode = FindChild(root, "start");
603 if (startNode->GetChildrenCount() > 0) {
604 CHECK_EQ(1, startNode->GetChildrenCount());
605 const v8::CpuProfileNode* delayNode = FindChild(startNode, "delay");
606 if (delayNode->GetChildrenCount() > 0) {
607 CHECK_EQ(1, delayNode->GetChildrenCount());
608 FindChild(delayNode, "loop");
609 }
610 }
611
612 cpu_profiler->DeleteAllCpuProfiles();
613 }
OLDNEW
« src/x64/lithium-codegen-x64.cc ('K') | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698