| Index: test/cctest/test-cpu-profiler.cc
|
| diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
|
| index a45ca6b759b78190a3d6d75dc97a6fb65cdefc6e..08401edc47af870e6c76fd4ea581824de189671b 100644
|
| --- a/test/cctest/test-cpu-profiler.cc
|
| +++ b/test/cctest/test-cpu-profiler.cc
|
| @@ -1906,10 +1906,8 @@ TEST(SourceLocation) {
|
| .ToLocalChecked();
|
| }
|
|
|
| -
|
| static const char* inlined_source =
|
| - "function opt_function(left, right) { var k = left / 10; var r = 10 / "
|
| - "right; return k + r; }\n";
|
| + "function opt_function(f) { return f()*f(); }\n";
|
| // 0.........1.........2.........3.........4....*....5.........6......*..7
|
|
|
|
|
| @@ -1917,6 +1915,7 @@ static const char* inlined_source =
|
| TEST(DeoptAtFirstLevelInlinedSource) {
|
| if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
|
| i::FLAG_allow_natives_syntax = true;
|
| + i::FLAG_turbo_source_positions = true;
|
| v8::HandleScope scope(CcTest::isolate());
|
| v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
|
| v8::Context::Scope context_scope(env);
|
| @@ -1926,17 +1925,16 @@ TEST(DeoptAtFirstLevelInlinedSource) {
|
|
|
| // 0.........1.........2.........3.........4.........5.........6.........7
|
| const char* source =
|
| - "function test(left, right) { return opt_function(left, right); }\n"
|
| + "function test(f) { return opt_function(f); }\n"
|
| "\n"
|
| "startProfiling();\n"
|
| "\n"
|
| - "test(10, 10);\n"
|
| + "test(function(){return 10});test(function(){return 12});\n"
|
| "\n"
|
| + "%SetForceInlineFlag(opt_function);\n"
|
| "%OptimizeFunctionOnNextCall(test)\n"
|
| "\n"
|
| - "test(10, 10);\n"
|
| - "\n"
|
| - "test(undefined, 10);\n"
|
| + "test(function(){return 100000000000});\n"
|
| "\n"
|
| "stopProfiling();\n"
|
| "\n";
|
| @@ -1971,12 +1969,13 @@ TEST(DeoptAtFirstLevelInlinedSource) {
|
| CHECK_EQ(1U, deopt_infos.size());
|
|
|
| const v8::CpuProfileDeoptInfo& info = deopt_infos[0];
|
| - CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), info.deopt_reason);
|
| + CHECK_EQ(reason(i::DeoptimizeReason::kNotASmi), info.deopt_reason);
|
| CHECK_EQ(2U, info.stack.size());
|
| CHECK_EQ(inlined_script_id, info.stack[0].script_id);
|
| - CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position);
|
| + CHECK(abs(static_cast<int>(offset(inlined_source, "*f()")) -
|
| + static_cast<int>(info.stack[0].position)) <= 1);
|
| CHECK_EQ(script_id, info.stack[1].script_id);
|
| - CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position);
|
| + CHECK_EQ(offset(source, "opt_function(f)"), info.stack[1].position);
|
|
|
| iprofiler->DeleteProfile(iprofile);
|
| }
|
| @@ -1986,6 +1985,7 @@ TEST(DeoptAtFirstLevelInlinedSource) {
|
| TEST(DeoptAtSecondLevelInlinedSource) {
|
| if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
|
| i::FLAG_allow_natives_syntax = true;
|
| + i::FLAG_turbo_source_positions = true;
|
| v8::HandleScope scope(CcTest::isolate());
|
| v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
|
| v8::Context::Scope context_scope(env);
|
| @@ -1995,18 +1995,21 @@ TEST(DeoptAtSecondLevelInlinedSource) {
|
|
|
| // 0.........1.........2.........3.........4.........5.........6.........7
|
| const char* source =
|
| - "function test2(left, right) { return opt_function(left, right); }\n"
|
| - "function test1(left, right) { return test2(left, right); }\n"
|
| + "function test2(f) { return opt_function(f); }\n"
|
| + "function test1(f) { return test2(f); }\n"
|
| "\n"
|
| "startProfiling();\n"
|
| "\n"
|
| - "test1(10, 10);\n"
|
| + "test1(function(){return 10});\n"
|
| + "test1(function(){return 11});\n"
|
| "\n"
|
| + "%SetForceInlineFlag(test2);\n"
|
| + "%SetForceInlineFlag(opt_function);\n"
|
| "%OptimizeFunctionOnNextCall(test1)\n"
|
| "\n"
|
| - "test1(10, 10);\n"
|
| + "test1(function(){return 12});\n"
|
| "\n"
|
| - "test1(undefined, 10);\n"
|
| + "test1(function(){return 100000000000});\n"
|
| "\n"
|
| "stopProfiling();\n"
|
| "\n";
|
| @@ -2044,13 +2047,14 @@ TEST(DeoptAtSecondLevelInlinedSource) {
|
| CHECK_EQ(1U, deopt_infos.size());
|
|
|
| const v8::CpuProfileDeoptInfo info = deopt_infos[0];
|
| - CHECK_EQ(reason(i::DeoptimizeReason::kNotAHeapNumber), info.deopt_reason);
|
| + CHECK_EQ(reason(i::DeoptimizeReason::kNotASmi), info.deopt_reason);
|
| CHECK_EQ(3U, info.stack.size());
|
| CHECK_EQ(inlined_script_id, info.stack[0].script_id);
|
| - CHECK_EQ(offset(inlined_source, "left /"), info.stack[0].position);
|
| + CHECK(abs(static_cast<int>(offset(inlined_source, "*f()")) -
|
| + static_cast<int>(info.stack[0].position)) <= 1);
|
| CHECK_EQ(script_id, info.stack[1].script_id);
|
| - CHECK_EQ(offset(source, "opt_function(left,"), info.stack[1].position);
|
| - CHECK_EQ(offset(source, "test2(left, right);"), info.stack[2].position);
|
| + CHECK_EQ(offset(source, "opt_function(f)"), info.stack[1].position);
|
| + CHECK_EQ(offset(source, "test2(f);"), info.stack[2].position);
|
|
|
| iprofiler->DeleteProfile(iprofile);
|
| }
|
| @@ -2060,6 +2064,7 @@ TEST(DeoptAtSecondLevelInlinedSource) {
|
| TEST(DeoptUntrackedFunction) {
|
| if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
|
| i::FLAG_allow_natives_syntax = true;
|
| + i::FLAG_turbo_source_positions = true;
|
| v8::HandleScope scope(CcTest::isolate());
|
| v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
|
| v8::Context::Scope context_scope(env);
|
| @@ -2071,15 +2076,17 @@ TEST(DeoptUntrackedFunction) {
|
| const char* source =
|
| "function test(left, right) { return opt_function(left, right); }\n"
|
| "\n"
|
| - "test(10, 10);\n"
|
| + "test(function(){return 10});\n"
|
| + "test(function(){return 11});\n"
|
| "\n"
|
| + "%SetForceInlineFlag(opt_function);\n"
|
| "%OptimizeFunctionOnNextCall(test)\n"
|
| "\n"
|
| - "test(10, 10);\n"
|
| + "test(function(){return 10});\n"
|
| "\n"
|
| "startProfiling();\n" // profiler started after compilation.
|
| "\n"
|
| - "test(undefined, 10);\n"
|
| + "test(function(){return 100000000000});\n"
|
| "\n"
|
| "stopProfiling();\n"
|
| "\n";
|
|
|