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

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

Issue 1737043002: [Interpreter] Log source positions for bytecode arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_cpu_profiler
Patch Set: TickLinesBaseline now works with more source positions Created 4 years, 9 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 | « test/cctest/cctest.status ('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 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0); 976 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0);
977 977
978 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 978 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
979 979
980 const v8::CpuProfileNode* start_node = GetChild(env, root, "start"); 980 const v8::CpuProfileNode* start_node = GetChild(env, root, "start");
981 GetChild(env, start_node, "foo"); 981 GetChild(env, start_node, "foo");
982 982
983 profile->Delete(); 983 profile->Delete();
984 } 984 }
985 985
986
987 // This tests checks distribution of the samples through the source lines. 986 // This tests checks distribution of the samples through the source lines.
988 TEST(TickLines) { 987 static void TickLines(bool optimize) {
989 CcTest::InitializeVM(); 988 CcTest::InitializeVM();
990 LocalContext env; 989 LocalContext env;
990 i::FLAG_allow_natives_syntax = true;
991 i::FLAG_turbo_source_positions = true; 991 i::FLAG_turbo_source_positions = true;
992 i::Isolate* isolate = CcTest::i_isolate(); 992 i::Isolate* isolate = CcTest::i_isolate();
993 i::Factory* factory = isolate->factory(); 993 i::Factory* factory = isolate->factory();
994 i::HandleScope scope(isolate); 994 i::HandleScope scope(isolate);
995 995
996 i::EmbeddedVector<char, 512> script; 996 i::EmbeddedVector<char, 512> script;
997 997
998 const char* func_name = "func"; 998 const char* func_name = "func";
999 const char* opt_func =
1000 optimize ? "%OptimizeFunctionOnNextCall" : "%NeverOptimizeFunction";
999 i::SNPrintF(script, 1001 i::SNPrintF(script,
1000 "function %s() {\n" 1002 "function %s() {\n"
1001 " var n = 0;\n" 1003 " var n = 0;\n"
1002 " var m = 100*100;\n" 1004 " var m = 100*100;\n"
1003 " while (m > 1) {\n" 1005 " while (m > 1) {\n"
1004 " m--;\n" 1006 " m--;\n"
1005 " n += m * m * m;\n" 1007 " n += m * m * m;\n"
1006 " }\n" 1008 " }\n"
1007 "}\n" 1009 "}\n"
1010 "%s(%s);\n"
1008 "%s();\n", 1011 "%s();\n",
1009 func_name, func_name); 1012 func_name, opt_func, func_name, func_name);
1010 1013
1011 CompileRun(script.start()); 1014 CompileRun(script.start());
1012 1015
1013 i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast( 1016 i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(
1014 v8::Utils::OpenHandle(*GetFunction(env.local(), func_name))); 1017 v8::Utils::OpenHandle(*GetFunction(env.local(), func_name)));
1015 CHECK(func->shared()); 1018 CHECK(func->shared());
1016 CHECK(func->shared()->abstract_code()); 1019 CHECK(func->shared()->abstract_code());
1017 i::AbstractCode* code = NULL; 1020 i::AbstractCode* code = func->abstract_code();
1018 if (func->abstract_code()->kind() == i::AbstractCode::OPTIMIZED_FUNCTION) {
1019 code = func->abstract_code();
1020 } else {
1021 CHECK(func->shared()->abstract_code() == func->abstract_code() ||
1022 !i::FLAG_crankshaft);
1023 code = func->shared()->abstract_code();
1024 }
1025 CHECK(code); 1021 CHECK(code);
1026 i::Address code_address = code->instruction_start(); 1022 i::Address code_address = code->instruction_start();
1027 CHECK(code_address); 1023 CHECK(code_address);
1028 1024
1029 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 1025 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
1030 profiles->StartProfiling("", false); 1026 profiles->StartProfiling("", false);
1031 ProfileGenerator generator(profiles); 1027 ProfileGenerator generator(profiles);
1032 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 1028 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
1033 &generator, NULL, v8::base::TimeDelta::FromMicroseconds(100))); 1029 &generator, NULL, v8::base::TimeDelta::FromMicroseconds(100)));
1034 processor->Start(); 1030 processor->Start();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 CHECK(func_node->GetLineTicks(&entries[0], line_count)); 1071 CHECK(func_node->GetLineTicks(&entries[0], line_count));
1076 int value = 0; 1072 int value = 0;
1077 for (int i = 0; i < entries.length(); i++) 1073 for (int i = 0; i < entries.length(); i++)
1078 if (entries[i].line == hit_line) { 1074 if (entries[i].line == hit_line) {
1079 value = entries[i].hit_count; 1075 value = entries[i].hit_count;
1080 break; 1076 break;
1081 } 1077 }
1082 CHECK_EQ(hit_count, value); 1078 CHECK_EQ(hit_count, value);
1083 } 1079 }
1084 1080
1081 TEST(TickLinesBaseline) { TickLines(false); }
1082
1083 TEST(TickLinesOptimized) { TickLines(true); }
1084
1085 static const char* call_function_test_source = 1085 static const char* call_function_test_source =
1086 "%NeverOptimizeFunction(bar);\n" 1086 "%NeverOptimizeFunction(bar);\n"
1087 "%NeverOptimizeFunction(start);\n" 1087 "%NeverOptimizeFunction(start);\n"
1088 "function bar(n) {\n" 1088 "function bar(n) {\n"
1089 " var s = 0;\n" 1089 " var s = 0;\n"
1090 " for (var i = 0; i < n; i++) s += i * i * i;\n" 1090 " for (var i = 0; i < n; i++) s += i * i * i;\n"
1091 " return s;\n" 1091 " return s;\n"
1092 "}\n" 1092 "}\n"
1093 "function start(duration) {\n" 1093 "function start(duration) {\n"
1094 " var start = Date.now();\n" 1094 " var start = Date.now();\n"
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 iprofile->Print(); 2024 iprofile->Print();
2025 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); 2025 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
2026 2026
2027 const char* branch[] = {"", "test"}; 2027 const char* branch[] = {"", "test"};
2028 const ProfileNode* itest_node = 2028 const ProfileNode* itest_node =
2029 GetSimpleBranch(env, profile, branch, arraysize(branch)); 2029 GetSimpleBranch(env, profile, branch, arraysize(branch));
2030 CHECK_EQ(0U, itest_node->deopt_infos().size()); 2030 CHECK_EQ(0U, itest_node->deopt_infos().size());
2031 2031
2032 iprofiler->DeleteProfile(iprofile); 2032 iprofiler->DeleteProfile(iprofile);
2033 } 2033 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698