From 566075967d2ebd91a0386dc2ac6840e178a8d135 Mon Sep 17 00:00:00 2001 From: Daniel Beckert Date: Mon, 17 Sep 2018 16:26:31 -0300 Subject: [PATCH] deps: cherry-pick 9a23bdd from upstream V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [Isolate] Fix Isolate::PrintCurrentStackTrace for interpreted frames Previously we were getting the code object from the stack, so printed incorrect position details for interpreted frames. BUG=v8:7916 Change-Id: I2f87584117d88b7db3f3b9bdbfe793c4d3e33fe9 Reviewed-on: https://chromium-review.googlesource.com/1126313 Reviewed-by: Toon Verwaest Commit-Queue: Ross McIlroy Cr-Commit-Position: refs/heads/master@{#54253} Refs: https://github.com/v8/v8/commit/9a23bdd7ea2eba9a7a4439a7844e72fbf42bb3c4 Refs: https://github.com/nodejs/node/issues/21988 PR-URL: https://github.com/nodejs/node/pull/22910 Reviewed-By: Matheus Marchini Reviewed-By: Michaƫl Zasso --- common.gypi | 2 +- deps/v8/src/isolate.cc | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common.gypi b/common.gypi index 0279c577a14b57..e9e05049dbb265 100644 --- a/common.gypi +++ b/common.gypi @@ -29,7 +29,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.27', + 'v8_embedder_string': '-node.28', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/isolate.cc b/deps/v8/src/isolate.cc index bb50ae493d5eea..0bdfef5e81b319 100644 --- a/deps/v8/src/isolate.cc +++ b/deps/v8/src/isolate.cc @@ -1661,8 +1661,17 @@ void Isolate::PrintCurrentStackTrace(FILE* out) { Handle receiver(frame->receiver(), this); Handle function(frame->function(), this); - Handle code(AbstractCode::cast(frame->LookupCode()), this); - const int offset = static_cast(frame->pc() - code->InstructionStart()); + Handle code; + int offset; + if (frame->is_interpreted()) { + InterpretedFrame* interpreted_frame = InterpretedFrame::cast(frame); + code = handle(AbstractCode::cast(interpreted_frame->GetBytecodeArray()), + this); + offset = interpreted_frame->GetBytecodeOffset(); + } else { + code = handle(AbstractCode::cast(frame->LookupCode()), this); + offset = static_cast(frame->pc() - code->InstructionStart()); + } JSStackFrame site(this, receiver, function, code, offset); Handle line = site.ToString().ToHandleChecked();