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

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

Issue 1740073002: Make CPU profiler unwind the inlined functions stack. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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') | test/cctest/test-profile-generator.cc » ('j') | 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 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 const v8::CpuProfileNode* root = profile->GetTopDownRoot(); 1503 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1504 const v8::CpuProfileNode* start_node = GetChild(env, root, "start"); 1504 const v8::CpuProfileNode* start_node = GetChild(env, root, "start");
1505 const v8::CpuProfileNode* native_node = 1505 const v8::CpuProfileNode* native_node =
1506 GetChild(env, start_node, "CallJsFunction"); 1506 GetChild(env, start_node, "CallJsFunction");
1507 const v8::CpuProfileNode* bar_node = GetChild(env, native_node, "bar"); 1507 const v8::CpuProfileNode* bar_node = GetChild(env, native_node, "bar");
1508 GetChild(env, bar_node, "foo"); 1508 GetChild(env, bar_node, "foo");
1509 1509
1510 profile->Delete(); 1510 profile->Delete();
1511 } 1511 }
1512 1512
1513 void CheckChildIsRare(const v8::Local<v8::Context>& context,
1514 const v8::CpuProfileNode* node, const char* name) {
1515 const v8::CpuProfileNode* child = FindChild(context, node, name);
1516 CHECK(!child || child->GetHitCount() < 10u);
1517 }
1518
1519 static const char* inlining_test_source =
1520 "%NeverOptimizeFunction(action);\n"
1521 "%NeverOptimizeFunction(start);\n"
1522 "%OptimizeFunctionOnNextCall(level1);\n"
1523 "%OptimizeFunctionOnNextCall(level2);\n"
1524 "%OptimizeFunctionOnNextCall(level3);\n"
1525 "function action(n) {\n"
1526 " var s = 0;\n"
1527 " for (var i = 0; i < n; ++i) s += i*i*i;\n"
1528 " return s;\n"
1529 "}\n"
1530 "function level3() { return action(1000); }\n"
1531 "function level2() { return level3() * 2; }\n"
1532 "function level1() { return level2(); }\n"
1533 "function start() {\n"
1534 " startProfiling('my_profile');\n"
1535 " var startTime = Date.now();\n"
1536 " do {\n"
1537 " level1();\n"
1538 " } while (Date.now() - startTime < 200);\n"
1539 "}";
1540
1541 // The test check multiple entrances/exits between JS and native code.
1542 //
1543 // [Top down]:
1544 // (root) #0 1
1545 // start #16 3
1546 // level1 #0 4
1547 // level2 #16 5
1548 // level3 #16 6
1549 // action #16 7
1550 // (program) #0 2
1551 TEST(Inlining) {
titzer 2016/02/26 21:24:01 Is there a way to make this test non-flaky? It cur
alph 2016/02/26 22:12:10 It does not. It was supposed to check that there's
titzer 2016/02/26 23:46:52 It's still inherently flaky. Why can't you test th
alph 2016/02/27 08:24:02 looks like I managed to make the test deterministi
1552 i::FLAG_allow_natives_syntax = true;
1553 v8::HandleScope scope(CcTest::isolate());
1554 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
1555 v8::Context::Scope context_scope(env);
1556
1557 CompileRun(inlining_test_source);
1558 v8::Local<v8::Function> function = GetFunction(env, "start");
1559 v8::CpuProfile* profile = RunProfiler(env, function, NULL, 0, 1000);
1560
1561 const v8::CpuProfileNode* root = profile->GetTopDownRoot();
1562 const v8::CpuProfileNode* start_node = GetChild(env, root, "start");
1563 const v8::CpuProfileNode* level1_node = GetChild(env, start_node, "level1");
1564 const v8::CpuProfileNode* level2_node = GetChild(env, level1_node, "level2");
1565 const v8::CpuProfileNode* level3_node = GetChild(env, level2_node, "level3");
1566 GetChild(env, level3_node, "action");
1567 CheckChildIsRare(env, start_node, "level2");
1568 CheckChildIsRare(env, start_node, "level3");
1569 CheckChildIsRare(env, start_node, "action");
1570 CheckChildIsRare(env, level1_node, "level3");
1571 CheckChildIsRare(env, level1_node, "action");
1572 CheckChildIsRare(env, level2_node, "action");
1573
1574 profile->Delete();
1575 }
1576
1513 // [Top down]: 1577 // [Top down]:
1514 // 0 (root) #0 1 1578 // 0 (root) #0 1
1515 // 2 (program) #0 2 1579 // 2 (program) #0 2
1516 // 3 (idle) #0 3 1580 // 3 (idle) #0 3
1517 TEST(IdleTime) { 1581 TEST(IdleTime) {
1518 LocalContext env; 1582 LocalContext env;
1519 v8::HandleScope scope(env->GetIsolate()); 1583 v8::HandleScope scope(env->GetIsolate());
1520 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); 1584 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
1521 1585
1522 v8::Local<v8::String> profile_name = v8_str("my_profile"); 1586 v8::Local<v8::String> profile_name = v8_str("my_profile");
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 iprofile->Print(); 2032 iprofile->Print();
1969 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile); 2033 v8::CpuProfile* profile = reinterpret_cast<v8::CpuProfile*>(iprofile);
1970 2034
1971 const char* branch[] = {"", "test"}; 2035 const char* branch[] = {"", "test"};
1972 const ProfileNode* itest_node = 2036 const ProfileNode* itest_node =
1973 GetSimpleBranch(env, profile, branch, arraysize(branch)); 2037 GetSimpleBranch(env, profile, branch, arraysize(branch));
1974 CHECK_EQ(0U, itest_node->deopt_infos().size()); 2038 CHECK_EQ(0U, itest_node->deopt_infos().size());
1975 2039
1976 iprofiler->DeleteProfile(iprofile); 2040 iprofiler->DeleteProfile(iprofile);
1977 } 2041 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | test/cctest/test-profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698