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

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

Issue 290093005: Introduce a separate event for CodeDisableOpt (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: removed extra line Created 6 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
« no previous file with comments | « src/serialize.cc ('k') | no next file » | 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch, 580 CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch,
581 ARRAY_SIZE(bazBranch)); 581 ARRAY_SIZE(bazBranch));
582 const char* delayBranch[] = { "delay", "loop" }; 582 const char* delayBranch[] = { "delay", "loop" };
583 CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch, 583 CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch,
584 ARRAY_SIZE(delayBranch)); 584 ARRAY_SIZE(delayBranch));
585 585
586 profile->Delete(); 586 profile->Delete();
587 } 587 }
588 588
589 589
590 static const char* hot_deopt_no_frame_entry_test_source =
591 "function foo(a, b) {\n"
592 " try {\n"
593 " return a + b;\n"
594 " } catch (e) { }\n"
595 "}\n"
596 "function start(timeout) {\n"
597 " var start = Date.now();\n"
598 " do {\n"
599 " for (var i = 1; i < 1000; ++i) foo(1, i);\n"
600 " var duration = Date.now() - start;\n"
601 " } while (duration < timeout);\n"
602 " return duration;\n"
603 "}\n";
604
605 // Check that the profile tree for the script above will look like the
606 // following:
607 //
608 // [Top down]:
609 // 1062 0 (root) [-1]
610 // 1054 0 start [-1]
611 // 1054 1 foo [-1]
612 // 2 2 (program) [-1]
613 // 6 6 (garbage collector) [-1]
614 //
615 // The test checks no FP ranges are present in a deoptimized funcion.
616 // If 'foo' has no ranges the samples falling into the prologue will miss the
617 // 'start' function on the stack, so 'foo' will be attached to the (root).
618 TEST(HotDeoptNoFrameEntry) {
619 LocalContext env;
620 v8::HandleScope scope(env->GetIsolate());
621
622 v8::Script::Compile(v8::String::NewFromUtf8(
623 env->GetIsolate(),
624 hot_deopt_no_frame_entry_test_source))->Run();
625 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
626 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
627
628 int32_t profiling_interval_ms = 200;
629 v8::Handle<v8::Value> args[] = {
630 v8::Integer::New(env->GetIsolate(), profiling_interval_ms)
631 };
632 v8::CpuProfile* profile =
633 RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200);
634 function->Call(env->Global(), ARRAY_SIZE(args), args);
635
636 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
637
638 ScopedVector<v8::Handle<v8::String> > names(3);
639 names[0] = v8::String::NewFromUtf8(
640 env->GetIsolate(), ProfileGenerator::kGarbageCollectorEntryName);
641 names[1] = v8::String::NewFromUtf8(env->GetIsolate(),
642 ProfileGenerator::kProgramEntryName);
643 names[2] = v8::String::NewFromUtf8(env->GetIsolate(), "start");
644 CheckChildrenNames(root, names);
645
646 const v8::CpuProfileNode* startNode =
647 GetChild(env->GetIsolate(), root, "start");
648 CHECK_EQ(1, startNode->GetChildrenCount());
649
650 GetChild(env->GetIsolate(), startNode, "foo");
651
652 profile->Delete();
653 }
654
655
590 TEST(CollectCpuProfileSamples) { 656 TEST(CollectCpuProfileSamples) {
591 LocalContext env; 657 LocalContext env;
592 v8::HandleScope scope(env->GetIsolate()); 658 v8::HandleScope scope(env->GetIsolate());
593 659
594 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 660 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
595 cpu_profiler_test_source))->Run(); 661 cpu_profiler_test_source))->Run();
596 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast( 662 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
597 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start"))); 663 env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "start")));
598 664
599 int32_t profiling_interval_ms = 200; 665 int32_t profiling_interval_ms = 200;
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 inner_profile = NULL; 1660 inner_profile = NULL;
1595 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1661 CHECK_EQ(0, iprofiler->GetProfilesCount());
1596 1662
1597 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); 1663 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer);
1598 CHECK(outer_profile); 1664 CHECK(outer_profile);
1599 CHECK_EQ(1, iprofiler->GetProfilesCount()); 1665 CHECK_EQ(1, iprofiler->GetProfilesCount());
1600 outer_profile->Delete(); 1666 outer_profile->Delete();
1601 outer_profile = NULL; 1667 outer_profile = NULL;
1602 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1668 CHECK_EQ(0, iprofiler->GetProfilesCount());
1603 } 1669 }
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698