From fdad5b6f38fc23da29aadbee25c560421ce3aa59 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Sun, 31 Mar 2019 11:53:24 -0400 Subject: [PATCH] deps: V8: fix filename manipulation for Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport-PR-URL: https://github.com/nodejs/node/pull/30109 PR-URL: https://github.com/nodejs/node/pull/28016 Reviewed-By: Colin Ihrig Reviewed-By: Refael Ackermann (רפאל פלחי) Reviewed-By: Rich Trott Reviewed-By: Michael Dawson Reviewed-By: Jiawen Geng --- common.gypi | 2 +- .../snapshot/embedded/platform-embedded-file-writer-win.cc | 6 +++++- deps/v8/src/torque/csa-generator.cc | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common.gypi b/common.gypi index e3b0bde754a185..8411b7d7801003 100644 --- a/common.gypi +++ b/common.gypi @@ -38,7 +38,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.0', + 'v8_embedder_string': '-node.1', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-win.cc b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-win.cc index 9a9a26fbd0abef..887cbf0dbe5f96 100644 --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-win.cc +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-win.cc @@ -669,7 +669,11 @@ void PlatformEmbeddedFileWriterWin::DeclareExternalFilename( // Replace any Windows style paths (backslashes) with forward // slashes. std::string fixed_filename(filename); - std::replace(fixed_filename.begin(), fixed_filename.end(), '\\', '/'); + for (auto& c : fixed_filename) { + if (c == '\\') { + c = '/'; + } + } fprintf(fp_, ".file %d \"%s\"\n", fileid, fixed_filename.c_str()); } diff --git a/deps/v8/src/torque/csa-generator.cc b/deps/v8/src/torque/csa-generator.cc index 0c49033955b68a..7925783914ab14 100644 --- a/deps/v8/src/torque/csa-generator.cc +++ b/deps/v8/src/torque/csa-generator.cc @@ -56,10 +56,14 @@ Stack CSAGenerator::EmitBlock(const Block* block) { } void CSAGenerator::EmitSourcePosition(SourcePosition pos, bool always_emit) { - const std::string& file = SourceFileMap::AbsolutePath(pos.source); + std::string file = SourceFileMap::AbsolutePath(pos.source); if (always_emit || !previous_position_.CompareStartIgnoreColumn(pos)) { // Lines in Torque SourcePositions are zero-based, while the // CodeStubAssembler and downwind systems are one-based. + for (auto& c : file) { + if (c == '\\') + c = '/'; + } out_ << " ca_.SetSourcePosition(\"" << file << "\", " << (pos.start.line + 1) << ");\n"; previous_position_ = pos;