From a26081264dd8102cc67db4a53cf3485d49f0a3f9 Mon Sep 17 00:00:00 2001 From: Benjamin Coe Date: Tue, 24 Nov 2020 18:01:16 -0800 Subject: [PATCH] deps: V8: cherry-pick 86991d0587a1 Adds methods for fetching stack trace information about enclosing function. Refs #36042 Original commit message: Reland "stack-trace-api: implement getEnclosingLine/Column" This reverts commit 5557a63beb5a53c93e9b590eaf2933e21bcb3768. Reason for revert: Sheriff's mistake, failing test was previously flaking. Original change's description: > Revert "stack-trace-api: implement getEnclosingLine/Column" > > This reverts commit c48ae2d96cbfdc2216706a5e9a79ae1dce5a638b. > > Reason for revert: Breaks a profiling test: > https://ci.chromium.org/p/v8/builders/ci/V8%20Win32/30010 > > Original change's description: > > stack-trace-api: implement getEnclosingLine/Column > > > > Introduces getEnclosingColumn and getEnclosingLine on CallSite > > so that the position can be used to lookup the original symbol > > for function when source maps are used. > > > > BUG=v8:11157 > > > > Change-Id: I06c4c374d172d206579abb170c7b7a2bd3bb159f > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2547218 > > Reviewed-by: Jakob Kummerow > > Commit-Queue: Benjamin Coe > > Cr-Commit-Position: refs/heads/master@{#71343} > > TBR=jkummerow@chromium.org,yangguo@chromium.org,bencoe@google.com > > Change-Id: Iab5c250c1c4fbdab86971f4a7e40abc8f87cf79c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: v8:11157 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2555384 > Reviewed-by: Bill Budge > Commit-Queue: Bill Budge > Cr-Commit-Position: refs/heads/master@{#71345} TBR=bbudge@chromium.org,jkummerow@chromium.org,yangguo@chromium.org,bencoe@google.com # Not skipping CQ checks because this is a reland. Bug: v8:11157 Change-Id: I8dba19ceb29a24594469d2cf79626f741dc4cad3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2555499 Reviewed-by: Bill Budge Commit-Queue: Bill Budge Cr-Commit-Position: refs/heads/master@{#71348} Refs: https://github.com/v8/v8/commit/86991d0587a1f05b973eef8420c0cf48fdaaf915 PR-URL: https://github.com/nodejs/node/pull/36254 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel --- common.gypi | 2 +- deps/v8/src/builtins/builtins-callsite.cc | 16 +++++++ deps/v8/src/builtins/builtins-definitions.h | 2 + deps/v8/src/execution/messages.cc | 46 +++++++++++++++++++++ deps/v8/src/execution/messages.h | 11 +++++ deps/v8/src/init/bootstrapper.cc | 4 ++ deps/v8/test/mjsunit/stack-traces.js | 20 +++++++++ deps/v8/test/mjsunit/wasm/asm-wasm-stack.js | 15 +++++++ 8 files changed, 115 insertions(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index b8bf5ff7137c67..492ca97825df3b 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.12', + 'v8_embedder_string': '-node.13', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/builtins/builtins-callsite.cc b/deps/v8/src/builtins/builtins-callsite.cc index 5b7807ed4a9e50..63e4d7a572e53b 100644 --- a/deps/v8/src/builtins/builtins-callsite.cc +++ b/deps/v8/src/builtins/builtins-callsite.cc @@ -53,6 +53,22 @@ BUILTIN(CallSitePrototypeGetColumnNumber) { return PositiveNumberOrNull(it.Frame()->GetColumnNumber(), isolate); } +BUILTIN(CallSitePrototypeGetEnclosingColumnNumber) { + HandleScope scope(isolate); + CHECK_CALLSITE(recv, "getEnclosingColumnNumber"); + FrameArrayIterator it(isolate, GetFrameArray(isolate, recv), + GetFrameIndex(isolate, recv)); + return PositiveNumberOrNull(it.Frame()->GetEnclosingColumnNumber(), isolate); +} + +BUILTIN(CallSitePrototypeGetEnclosingLineNumber) { + HandleScope scope(isolate); + CHECK_CALLSITE(recv, "getEnclosingLineNumber"); + FrameArrayIterator it(isolate, GetFrameArray(isolate, recv), + GetFrameIndex(isolate, recv)); + return PositiveNumberOrNull(it.Frame()->GetEnclosingLineNumber(), isolate); +} + BUILTIN(CallSitePrototypeGetEvalOrigin) { HandleScope scope(isolate); CHECK_CALLSITE(recv, "getEvalOrigin"); diff --git a/deps/v8/src/builtins/builtins-definitions.h b/deps/v8/src/builtins/builtins-definitions.h index a30520d1507ace..30fd5a3944baeb 100644 --- a/deps/v8/src/builtins/builtins-definitions.h +++ b/deps/v8/src/builtins/builtins-definitions.h @@ -367,6 +367,8 @@ namespace internal { \ /* CallSite */ \ CPP(CallSitePrototypeGetColumnNumber) \ + CPP(CallSitePrototypeGetEnclosingColumnNumber) \ + CPP(CallSitePrototypeGetEnclosingLineNumber) \ CPP(CallSitePrototypeGetEvalOrigin) \ CPP(CallSitePrototypeGetFileName) \ CPP(CallSitePrototypeGetFunction) \ diff --git a/deps/v8/src/execution/messages.cc b/deps/v8/src/execution/messages.cc index ea31dc3374fac5..343711b7651eb6 100644 --- a/deps/v8/src/execution/messages.cc +++ b/deps/v8/src/execution/messages.cc @@ -514,6 +514,26 @@ int JSStackFrame::GetColumnNumber() { return kNone; } +int JSStackFrame::GetEnclosingLineNumber() { + if (HasScript()) { + Handle shared = handle(function_->shared(), isolate_); + return Script::GetLineNumber(GetScript(), + shared->function_token_position()) + 1; + } else { + return kNone; + } +} + +int JSStackFrame::GetEnclosingColumnNumber() { + if (HasScript()) { + Handle shared = handle(function_->shared(), isolate_); + return Script::GetColumnNumber(GetScript(), + shared->function_token_position()) + 1; + } else { + return kNone; + } +} + int JSStackFrame::GetPromiseIndex() const { return (is_promise_all_ || is_promise_any_) ? offset_ : kNone; } @@ -602,6 +622,12 @@ int WasmStackFrame::GetPosition() const { int WasmStackFrame::GetColumnNumber() { return GetModuleOffset(); } +int WasmStackFrame::GetEnclosingColumnNumber() { + const int function_offset = + GetWasmFunctionOffset(wasm_instance_->module(), wasm_func_index_); + return function_offset; +} + int WasmStackFrame::GetModuleOffset() const { const int function_offset = GetWasmFunctionOffset(wasm_instance_->module(), wasm_func_index_); @@ -672,6 +698,26 @@ int AsmJsWasmStackFrame::GetColumnNumber() { return Script::GetColumnNumber(script, GetPosition()) + 1; } +int AsmJsWasmStackFrame::GetEnclosingLineNumber() { + DCHECK_LE(0, GetPosition()); + Handle