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

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

Issue 919953002: CPUProfiler: Push deopt reason further to ProfileNode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: unnecessary changes were removed 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // 27 //
28 // Tests of profiles generator and utilities. 28 // Tests of profiles generator and utilities.
29 29
30 #include "src/v8.h" 30 #include "src/v8.h"
31 31
32 #include "include/v8-profiler.h" 32 #include "include/v8-profiler.h"
33 #include "src/base/platform/platform.h" 33 #include "src/base/platform/platform.h"
34 #include "src/cpu-profiler-inl.h" 34 #include "src/cpu-profiler-inl.h"
35 #include "src/deoptimizer.h"
35 #include "src/smart-pointers.h" 36 #include "src/smart-pointers.h"
36 #include "src/utils.h" 37 #include "src/utils.h"
37 #include "test/cctest/cctest.h" 38 #include "test/cctest/cctest.h"
38 #include "test/cctest/profiler-extension.h" 39 #include "test/cctest/profiler-extension.h"
39 using i::CodeEntry; 40 using i::CodeEntry;
40 using i::CpuProfile; 41 using i::CpuProfile;
41 using i::CpuProfiler; 42 using i::CpuProfiler;
42 using i::CpuProfilesCollection; 43 using i::CpuProfilesCollection;
43 using i::Heap; 44 using i::Heap;
44 using i::ProfileGenerator; 45 using i::ProfileGenerator;
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); 1714 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer);
1714 CHECK(outer_profile); 1715 CHECK(outer_profile);
1715 CHECK_EQ(1, iprofiler->GetProfilesCount()); 1716 CHECK_EQ(1, iprofiler->GetProfilesCount());
1716 outer_profile->Delete(); 1717 outer_profile->Delete();
1717 outer_profile = NULL; 1718 outer_profile = NULL;
1718 CHECK_EQ(0, iprofiler->GetProfilesCount()); 1719 CHECK_EQ(0, iprofiler->GetProfilesCount());
1719 } 1720 }
1720 1721
1721 1722
1722 static const char* collect_deopt_events_test_source = 1723 static const char* collect_deopt_events_test_source =
1723 "function opt_function(value) {\n" 1724 "function opt_function(left, right, depth) {\n"
1724 " return value / 10;\n" 1725 " if (depth) return opt_function(left, right, depth - 1);\n"
1726 "\n"
1727 " var k = left / 10;\n"
1728 " var r = 10 / right;\n"
1729 " return k + r;"
1725 "}\n" 1730 "}\n"
1726 "\n" 1731 "\n"
1727 "function test(value) {\n" 1732 "function test(left, right) {\n"
1728 " return opt_function(value);\n" 1733 " return opt_function(left, right, 1);\n"
1729 "}\n" 1734 "}\n"
1730 "\n" 1735 "\n"
1731 "startProfiling();\n" 1736 "startProfiling();\n"
1732 "\n" 1737 "\n"
1733 "for (var i = 0; i < 10; ++i) test(10);\n" 1738 "test(10, 10);\n"
1734 "\n" 1739 "\n"
1735 "%OptimizeFunctionOnNextCall(opt_function)\n" 1740 "%OptimizeFunctionOnNextCall(opt_function)\n"
1736 "\n" 1741 "\n"
1737 "for (var i = 0; i < 10; ++i) test(10);\n" 1742 "test(10, 10);\n"
1738 "\n" 1743 "\n"
1739 "for (var i = 0; i < 10; ++i) test(undefined);\n" 1744 "test(undefined, 10);\n"
1745 "\n"
1746 "%OptimizeFunctionOnNextCall(opt_function)\n"
1747 "\n"
1748 "test(10, 10);\n"
1749 "\n"
1750 "test(10, 0);\n"
1740 "\n" 1751 "\n"
1741 "stopProfiling();\n" 1752 "stopProfiling();\n"
1742 "\n"; 1753 "\n";
1743 1754
1744 1755
1745 TEST(CollectDeoptEvents) { 1756 TEST(CollectDeoptEvents) {
1746 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; 1757 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
1747 i::FLAG_allow_natives_syntax = true; 1758 i::FLAG_allow_natives_syntax = true;
1748 v8::HandleScope scope(CcTest::isolate()); 1759 v8::HandleScope scope(CcTest::isolate());
1749 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); 1760 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
1750 v8::Context::Scope context_scope(env); 1761 v8::Context::Scope context_scope(env);
1751 v8::Isolate* isolate = env->GetIsolate(); 1762 v8::Isolate* isolate = env->GetIsolate();
1752 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); 1763 v8::CpuProfiler* profiler = isolate->GetCpuProfiler();
1753 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); 1764 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
1754 1765
1755 v8::Script::Compile(v8_str(collect_deopt_events_test_source))->Run(); 1766 v8::Script::Compile(v8_str(collect_deopt_events_test_source))->Run();
1756 i::CpuProfile* iprofile = iprofiler->GetProfile(0); 1767 i::CpuProfile* iprofile = iprofiler->GetProfile(0);
1757 iprofile->Print(); 1768 iprofile->Print();
1758 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); 1769 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
1759 const char* branch[] = {"", "test", "opt_function"}; 1770 const char* branch[] = {"", "test", "opt_function", "opt_function"};
1760 const v8::CpuProfileNode* opt_function = GetSimpleBranch( 1771 const v8::CpuProfileNode* opt_function = GetSimpleBranch(
1761 env->GetIsolate(), profile->GetTopDownRoot(), branch, arraysize(branch)); 1772 env->GetIsolate(), profile->GetTopDownRoot(), branch, arraysize(branch));
1762 CHECK(opt_function); 1773 CHECK(opt_function);
1774 const i::ProfileNode* iopt_function =
1775 reinterpret_cast<const i::ProfileNode*>(opt_function);
1776 CHECK_EQ(2, iopt_function->deopt_infos().length());
1777 CHECK_EQ(i::Deoptimizer::GetDeoptReason(i::Deoptimizer::kNotAHeapNumber),
1778 iopt_function->deopt_infos()[0].deopt_reason);
1779 CHECK_EQ(i::Deoptimizer::GetDeoptReason(i::Deoptimizer::kDivisionByZero),
1780 iopt_function->deopt_infos()[1].deopt_reason);
1763 iprofiler->DeleteProfile(iprofile); 1781 iprofiler->DeleteProfile(iprofile);
1764 } 1782 }
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