| Index: test/cctest/test-cpu-profiler.cc
|
| diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
|
| index a69dd4cad4c4f23be5d36bbfe35f61d962c70df2..f286b9d0502d29cd651043cdff926da251ef1c2e 100644
|
| --- a/test/cctest/test-cpu-profiler.cc
|
| +++ b/test/cctest/test-cpu-profiler.cc
|
| @@ -64,11 +64,6 @@
|
| const char* it = strstr(src, substring);
|
| CHECK(it);
|
| return static_cast<size_t>(it - src);
|
| -}
|
| -
|
| -template <typename A, typename B>
|
| -static int dist(A a, B b) {
|
| - return abs(static_cast<int>(a) - static_cast<int>(b));
|
| }
|
|
|
| static const char* reason(const i::DeoptimizeReason reason) {
|
| @@ -1911,8 +1906,7 @@
|
| }
|
|
|
| static const char* inlined_source =
|
| - "function opt_function(left, right) { var k = left*right; return k + 1; "
|
| - "}\n";
|
| + "function opt_function(f) { return f()*f(); }\n";
|
| // 0.........1.........2.........3.........4....*....5.........6......*..7
|
|
|
|
|
| @@ -1929,17 +1923,16 @@
|
|
|
| // 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"
|
| - "\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, 1e9);\n"
|
| + "test(function(){return 100000000000});\n"
|
| "\n"
|
| "stopProfiling();\n"
|
| "\n";
|
| @@ -1974,13 +1967,13 @@
|
| CHECK_EQ(1U, deopt_infos.size());
|
|
|
| const v8::CpuProfileDeoptInfo& info = deopt_infos[0];
|
| - CHECK(reason(i::DeoptimizeReason::kNotASmi) == info.deopt_reason ||
|
| - 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_LE(dist(offset(inlined_source, "*right"), info.stack[0].position), 1);
|
| + 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);
|
| }
|
| @@ -1999,18 +1992,21 @@
|
|
|
| // 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"
|
| - "\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"
|
| - "\n"
|
| - "test1(undefined, 1e9);\n"
|
| + "test1(function(){return 12});\n"
|
| + "\n"
|
| + "test1(function(){return 100000000000});\n"
|
| "\n"
|
| "stopProfiling();\n"
|
| "\n";
|
| @@ -2048,14 +2044,14 @@
|
| CHECK_EQ(1U, deopt_infos.size());
|
|
|
| const v8::CpuProfileDeoptInfo info = deopt_infos[0];
|
| - CHECK(reason(i::DeoptimizeReason::kNotASmi) == info.deopt_reason ||
|
| - 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_LE(dist(offset(inlined_source, "*right"), info.stack[0].position), 1);
|
| + 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);
|
| }
|
| @@ -2076,15 +2072,17 @@
|
| const char* source =
|
| "function test(left, right) { return opt_function(left, right); }\n"
|
| "\n"
|
| - "test(10, 10);\n"
|
| - "\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";
|
|
|