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

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

Issue 910773002: Propagate Deopt reason to cpu-profiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed 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 | « src/x87/lithium-codegen-x87.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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 const char* names[], int length) { 486 const char* names[], int length) {
487 for (int i = 0; i < length; i++) { 487 for (int i = 0; i < length; i++) {
488 const char* name = names[i]; 488 const char* name = names[i];
489 node = GetChild(isolate, node, name); 489 node = GetChild(isolate, node, name);
490 int expectedChildrenCount = (i == length - 1) ? 0 : 1; 490 int expectedChildrenCount = (i == length - 1) ? 0 : 1;
491 CHECK_EQ(expectedChildrenCount, node->GetChildrenCount()); 491 CHECK_EQ(expectedChildrenCount, node->GetChildrenCount());
492 } 492 }
493 } 493 }
494 494
495 495
496 static const v8::CpuProfileNode* GetSimpleBranch(v8::Isolate* isolate,
497 const v8::CpuProfileNode* node,
498 const char* names[],
499 int length) {
500 for (int i = 0; i < length; i++) {
501 node = GetChild(isolate, node, names[i]);
502 }
503 return node;
504 }
505
506
496 static const char* cpu_profiler_test_source = "function loop(timeout) {\n" 507 static const char* cpu_profiler_test_source = "function loop(timeout) {\n"
497 " this.mmm = 0;\n" 508 " this.mmm = 0;\n"
498 " var start = Date.now();\n" 509 " var start = Date.now();\n"
499 " while (Date.now() - start < timeout) {\n" 510 " while (Date.now() - start < timeout) {\n"
500 " var n = 100*1000;\n" 511 " var n = 100*1000;\n"
501 " while(n > 1) {\n" 512 " while(n > 1) {\n"
502 " n--;\n" 513 " n--;\n"
503 " this.mmm += n * n * n;\n" 514 " this.mmm += n * n * n;\n"
504 " }\n" 515 " }\n"
505 " }\n" 516 " }\n"
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 inner_profile = NULL; 1710 inner_profile = NULL;
1700 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1711 CHECK_EQ(0, iprofiler->GetProfilesCount());
1701 1712
1702 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); 1713 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer);
1703 CHECK(outer_profile); 1714 CHECK(outer_profile);
1704 CHECK_EQ(1, iprofiler->GetProfilesCount()); 1715 CHECK_EQ(1, iprofiler->GetProfilesCount());
1705 outer_profile->Delete(); 1716 outer_profile->Delete();
1706 outer_profile = NULL; 1717 outer_profile = NULL;
1707 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1718 CHECK_EQ(0, iprofiler->GetProfilesCount());
1708 } 1719 }
1720
1721
1722 static const char* collect_deopt_events_test_source =
1723 "function opt_function(value) {\n"
1724 " return value / 10;\n"
1725 "}\n"
1726 "\n"
1727 "function test(value) {\n"
1728 " return opt_function(value);\n"
1729 "}\n"
1730 "\n"
1731 "startProfiling();\n"
1732 "\n"
1733 "for (var i = 0; i < 10; ++i) test(10);\n"
1734 "\n"
1735 "%OptimizeFunctionOnNextCall(opt_function)\n"
1736 "\n"
1737 "for (var i = 0; i < 10; ++i) test(10);\n"
1738 "\n"
1739 "for (var i = 0; i < 10; ++i) test(undefined);\n"
1740 "\n"
1741 "stopProfiling();\n"
1742 "\n";
1743
1744
1745 TEST(CollectDeoptEvents) {
1746 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
1747 i::FLAG_allow_natives_syntax = true;
1748 v8::HandleScope scope(CcTest::isolate());
1749 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
1750 v8::Context::Scope context_scope(env);
1751 v8::Isolate* isolate = env->GetIsolate();
1752 v8::CpuProfiler* profiler = isolate->GetCpuProfiler();
1753 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
1754
1755 v8::Script::Compile(v8_str(collect_deopt_events_test_source))->Run();
1756 i::CpuProfile* iprofile = iprofiler->GetProfile(0);
1757 iprofile->Print();
1758 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
1759 const char* branch[] = {"", "test", "opt_function"};
1760 const v8::CpuProfileNode* opt_function = GetSimpleBranch(
1761 env->GetIsolate(), profile->GetTopDownRoot(), branch, arraysize(branch));
1762 CHECK(opt_function);
1763 iprofiler->DeleteProfile(iprofile);
1764 }
OLDNEW
« no previous file with comments | « src/x87/lithium-codegen-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698