Commit 5f8cd45b authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[asm.js] Fix semicolon insertion in presence of comments.

This makes sure we properly recognize a newline character as part of
semicolon insertion, even if the newline appears after a CPP-style
single line comment. The same applies for newlines within C-style multi
line comments.

R=clemensh@chromium.org
TEST=mjsunit/asm/regress-913822
BUG=chromium:913822

Change-Id: I64f098d7e386dea7b7fb6c233c1625425e36bde0
Reviewed-on: https://chromium-review.googlesource.com/c/1373551Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58189}
parent 663a2ac4
......@@ -349,6 +349,9 @@ bool AsmJsScanner::ConsumeCComment() {
return true;
}
}
if (ch == '\n') {
preceded_by_newline_ = true;
}
if (ch == kEndOfInput) {
return false;
}
......@@ -358,7 +361,11 @@ bool AsmJsScanner::ConsumeCComment() {
void AsmJsScanner::ConsumeCPPComment() {
for (;;) {
uc32 ch = stream_->Advance();
if (ch == '\n' || ch == kEndOfInput) {
if (ch == '\n') {
preceded_by_newline_ = true;
return;
}
if (ch == kEndOfInput) {
return;
}
}
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
(function TestNewlineInCPPComment() {
function Module() {
"use asm" // Crash by comment!
function f() {}
return f
}
Module();
assertTrue(%IsAsmWasmCode(Module));
})();
(function TestNewlineInCComment() {
function Module() {
"use asm" /* Crash by
comment! */ function f() {}
return f
}
Module();
assertTrue(%IsAsmWasmCode(Module));
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment