OLD | NEW |
---|---|
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 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1713 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); | 1713 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); |
1714 CHECK(outer_profile); | 1714 CHECK(outer_profile); |
1715 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1715 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
1716 outer_profile->Delete(); | 1716 outer_profile->Delete(); |
1717 outer_profile = NULL; | 1717 outer_profile = NULL; |
1718 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1718 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
1719 } | 1719 } |
1720 | 1720 |
1721 | 1721 |
1722 static const char* collect_deopt_events_test_source = | 1722 static const char* collect_deopt_events_test_source = |
1723 "function opt_function(value) {\n" | 1723 "function opt_function(left, right) {\n" |
1724 " return value / 10;\n" | 1724 " var k = left / 10;\n" |
1725 " var r = 10 / right;\n" | |
1726 " return k + r;" | |
1725 "}\n" | 1727 "}\n" |
1726 "\n" | 1728 "\n" |
1727 "function test(value) {\n" | 1729 "function test(left, right) {\n" |
1728 " return opt_function(value);\n" | 1730 " return opt_function(left, right);\n" |
1729 "}\n" | 1731 "}\n" |
1730 "\n" | 1732 "\n" |
1731 "startProfiling();\n" | 1733 "startProfiling();\n" |
1732 "\n" | 1734 "\n" |
1733 "for (var i = 0; i < 10; ++i) test(10);\n" | 1735 "test(10, 10);\n" |
1734 "\n" | 1736 "\n" |
1735 "%OptimizeFunctionOnNextCall(opt_function)\n" | 1737 "%OptimizeFunctionOnNextCall(opt_function)\n" |
1736 "\n" | 1738 "\n" |
1737 "for (var i = 0; i < 10; ++i) test(10);\n" | 1739 "test(10, 10);\n" |
1738 "\n" | 1740 "\n" |
1739 "for (var i = 0; i < 10; ++i) test(undefined);\n" | 1741 "test(undefined, 10);\n" |
1742 "\n" | |
1743 "%OptimizeFunctionOnNextCall(opt_function)\n" | |
1744 "\n" | |
1745 "test(10, 10);\n" | |
1746 "\n" | |
1747 "test(10, 0);\n" | |
1740 "\n" | 1748 "\n" |
1741 "stopProfiling();\n" | 1749 "stopProfiling();\n" |
1742 "\n"; | 1750 "\n"; |
1743 | 1751 |
1744 | 1752 |
1745 TEST(CollectDeoptEvents) { | 1753 TEST(CollectDeoptEvents) { |
1746 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; | 1754 if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; |
1747 i::FLAG_allow_natives_syntax = true; | 1755 i::FLAG_allow_natives_syntax = true; |
1748 v8::HandleScope scope(CcTest::isolate()); | 1756 v8::HandleScope scope(CcTest::isolate()); |
1749 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1757 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
1750 v8::Context::Scope context_scope(env); | 1758 v8::Context::Scope context_scope(env); |
1751 v8::Isolate* isolate = env->GetIsolate(); | 1759 v8::Isolate* isolate = env->GetIsolate(); |
1752 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); | 1760 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); |
1753 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); | 1761 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); |
1754 | 1762 |
1755 v8::Script::Compile(v8_str(collect_deopt_events_test_source))->Run(); | 1763 v8::Script::Compile(v8_str(collect_deopt_events_test_source))->Run(); |
1756 i::CpuProfile* iprofile = iprofiler->GetProfile(0); | 1764 i::CpuProfile* iprofile = iprofiler->GetProfile(0); |
1757 iprofile->Print(); | 1765 iprofile->Print(); |
1758 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); | 1766 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); |
1759 const char* branch[] = {"", "test", "opt_function"}; | 1767 const char* branch[] = {"", "test", "opt_function"}; |
1760 const v8::CpuProfileNode* opt_function = GetSimpleBranch( | 1768 const v8::CpuProfileNode* opt_function = GetSimpleBranch( |
1761 env->GetIsolate(), profile->GetTopDownRoot(), branch, arraysize(branch)); | 1769 env->GetIsolate(), profile->GetTopDownRoot(), branch, arraysize(branch)); |
1762 CHECK(opt_function); | 1770 CHECK(opt_function); |
1771 const i::ProfileNode* iopt_function = | |
1772 reinterpret_cast<const i::ProfileNode*>(opt_function); | |
1773 CHECK_EQ(2, iopt_function->deopt_infos().length()); | |
alph
2015/02/12 13:19:46
can you also check the reasons and positions pleas
loislo
2015/02/12 15:20:01
Done.
| |
1763 iprofiler->DeleteProfile(iprofile); | 1774 iprofiler->DeleteProfile(iprofile); |
1764 } | 1775 } |
OLD | NEW |