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

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 18058008: CPUProfiler: Improve line numbers support in profiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cosmetic changes Created 7 years, 5 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
« src/compiler.cc ('K') | « test/cctest/test-cpu-profiler.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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 current = PickChild(current, "b"); 960 current = PickChild(current, "b");
961 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); 961 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
962 CHECK_EQ(script_b->GetId(), current->GetScriptId()); 962 CHECK_EQ(script_b->GetId(), current->GetScriptId());
963 963
964 current = PickChild(current, "a"); 964 current = PickChild(current, "a");
965 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); 965 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
966 CHECK_EQ(script_a->GetId(), current->GetScriptId()); 966 CHECK_EQ(script_a->GetId(), current->GetScriptId());
967 } 967 }
968 968
969 969
970
971
972 static const char* line_number_test_source_existing_functions =
973 "function foo_at_the_first_line() {\n"
974 "}\n"
975 "foo_at_the_first_line();\n"
976 "function lazy_func_at_forth_line() {}\n";
977
978
979 static const char* line_number_test_source_profile_time_functions =
980 "// Empty first line\n"
981 "function bar_at_the_second_line() {\n"
982 " foo_at_the_first_line();\n"
983 "}\n"
984 "bar_at_the_second_line();\n"
985 "function lazy_func_at_6th_line() {}";
986
987 int GetFunctionLineNumber(LocalContext* env, const char* name) {
988 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
989 CodeMap* code_map = profiler->generator()->code_map();
990 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle(
991 *v8::Local<v8::Function>::Cast(
992 (*(*env))->Global()->Get(v8_str(name))));
993 CodeEntry* func_entry = code_map->FindEntry(func->code()->address());
994 if (!func_entry)
995 FATAL(name);
996 return func_entry->line_number();
997 }
998
999
1000 TEST(LineNumber) {
1001 i::FLAG_use_inlining = false;
1002
1003 CcTest::InitializeVM();
1004 LocalContext env;
1005 i::Isolate* isolate = i::Isolate::Current();
1006 TestSetup test_setup;
1007
1008 i::HandleScope scope(isolate);
1009
1010 CompileRun(line_number_test_source_existing_functions);
1011
1012 CpuProfiler* profiler = isolate->cpu_profiler();
1013 profiler->StartProfiling("LineNumber");
1014
1015 CompileRun(line_number_test_source_profile_time_functions);
1016
1017 profiler->processor()->StopSynchronously();
1018
1019 CHECK_EQ(1, GetFunctionLineNumber(&env, "foo_at_the_first_line"));
1020 CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_forth_line"));
1021 CHECK_EQ(2, GetFunctionLineNumber(&env, "bar_at_the_second_line"));
1022 CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_6th_line"));
1023
1024 profiler->StopProfiling("LineNumber");
1025 }
OLDNEW
« src/compiler.cc ('K') | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698