diff options
author | Yang Guo <yangguo@chromium.org> | 2018-11-09 15:12:33 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-11-13 22:25:34 -0800 |
commit | 715bbb9d04a320b4c1a234e1f9d878c116beb3f4 (patch) | |
tree | 970af036aa597d4d1fa83f0592546577aaae1fe9 /deps/v8/test | |
parent | c1d18a0728fc43036af47780414bb519b670a4d5 (diff) | |
download | android-node-v8-715bbb9d04a320b4c1a234e1f9d878c116beb3f4.tar.gz android-node-v8-715bbb9d04a320b4c1a234e1f9d878c116beb3f4.tar.bz2 android-node-v8-715bbb9d04a320b4c1a234e1f9d878c116beb3f4.zip |
deps: backport 073073b4f1 from upstream V8
Original commit message:
[profiler] introduce API to enable detailed source positions
This allows Node.js to enable detailed source positions for optimized code
early on, without having to pass a flag string.
R=petermarshall@chromium.org
Change-Id: Ie74ea41f600cf6e31acbe802116df4976ccf1c75
Reviewed-on: https://chromium-review.googlesource.com/c/1319757
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57380}
PR-URL: https://github.com/nodejs/node/pull/24274
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Peter Marshall <petermarshall@chromium.org>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'deps/v8/test')
-rw-r--r-- | deps/v8/test/cctest/test-cpu-profiler.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 75af3f6d98..8510996079 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -40,6 +40,7 @@ #include "src/objects-inl.h" #include "src/profiler/cpu-profiler-inl.h" #include "src/profiler/profiler-listener.h" +#include "src/source-position-table.h" #include "src/utils.h" #include "test/cctest/cctest.h" #include "test/cctest/profiler-extension.h" @@ -2544,6 +2545,46 @@ TEST(MultipleProfilers) { profiler2->StopProfiling("2"); } +UNINITIALIZED_TEST(DetailedSourcePositionAPI) { + i::FLAG_detailed_line_info = false; + i::FLAG_allow_natives_syntax = true; + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + + const char* source = + "function fib(i) {" + " if (i <= 1) return 1; " + " return fib(i - 1) +" + " fib(i - 2);" + "}" + "fib(5);" + "%OptimizeFunctionOnNextCall(fib);" + "fib(5);" + "fib"; + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + v8::Local<v8::Context> context = v8::Context::New(isolate); + v8::Context::Scope context_scope(context); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + + CHECK(!i_isolate->NeedsDetailedOptimizedCodeLineInfo()); + + int non_detailed_positions = GetSourcePositionEntryCount(i_isolate, source); + + v8::CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate); + CHECK(i_isolate->NeedsDetailedOptimizedCodeLineInfo()); + + int detailed_positions = GetSourcePositionEntryCount(i_isolate, source); + + CHECK((non_detailed_positions == -1 && detailed_positions == -1) || + non_detailed_positions < detailed_positions); + } + + isolate->Dispose(); +} + } // namespace test_cpu_profiler } // namespace internal } // namespace v8 |