Skip to content

Commit 479fdc1

Browse files
verwaestV8 LUCI CQ
authored andcommitted
[parsing] better disambiguate with scopes
drive-by: enable reuse-scope-infos behind --fuzzing Bug: 352402518 Change-Id: I993a81421c399c353927771cf371cc265941a1e4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5707148 Reviewed-by: Leszek Swirski <[email protected]> Auto-Submit: Toon Verwaest <[email protected]> Commit-Queue: Toon Verwaest <[email protected]> Cr-Commit-Position: refs/heads/main@{#95015}
1 parent fc0922e commit 479fdc1

5 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/flags/flag-definitions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,8 @@ DEFINE_BOOL(trace_generalization, false, "trace map generalization")
995995
DEFINE_BOOL(reuse_scope_infos, false,
996996
"reuse scope infos from previous compiles")
997997

998+
DEFINE_IMPLICATION(fuzzing, reuse_scope_infos)
999+
9981000
// Flags for Sparkplug
9991001
#undef FLAG
10001002
#if V8_ENABLE_SPARKPLUG

src/parsing/parser-base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6097,7 +6097,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWithStatement(
60976097
StatementT body = impl()->NullStatement();
60986098
{
60996099
BlockState block_state(&scope_, with_scope);
6100-
with_scope->set_start_position(end_position());
6100+
with_scope->set_start_position(position());
61016101
body = ParseStatement(labels, nullptr);
61026102
with_scope->set_end_position(end_position());
61036103
}

test/cctest/test-debug.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,7 @@ class DebugScopingListener : public v8::debug::DebugDelegate {
31503150

31513151
auto scopes = stack_traces->GetScopeIterator();
31523152
CHECK_EQ(v8::debug::ScopeIterator::ScopeTypeWith, scopes->GetType());
3153-
CHECK_EQ(20, scopes->GetStartLocation().GetColumnNumber());
3153+
CHECK_EQ(19, scopes->GetStartLocation().GetColumnNumber());
31543154
CHECK_EQ(31, scopes->GetEndLocation().GetColumnNumber());
31553155

31563156
scopes->Advance();

test/mjsunit/regress-352402518.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --reuse-scope-infos
6+
7+
with({}){function h(){}}

test/unittests/parser/parsing-unittest.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,24 +1507,24 @@ TEST_F(ParsingTest, ScopePositions) {
15071507
};
15081508

15091509
const SourceData source_data[] = {
1510-
{" with ({})", "{ block; }", " more;", i::WITH_SCOPE,
1510+
{" with ({}", "){ block; }", " more;", i::WITH_SCOPE,
15111511
i::LanguageMode::kSloppy},
1512-
{" with ({})", "{ block; }", "; more;", i::WITH_SCOPE,
1512+
{" with ({}", "){ block; }", "; more;", i::WITH_SCOPE,
15131513
i::LanguageMode::kSloppy},
1514-
{" with ({})",
1515-
"{\n"
1514+
{" with ({}",
1515+
"){\n"
15161516
" block;\n"
15171517
" }",
15181518
"\n"
15191519
" more;",
15201520
i::WITH_SCOPE, i::LanguageMode::kSloppy},
1521-
{" with ({})", "statement;", " more;", i::WITH_SCOPE,
1521+
{" with ({}", ")statement;", " more;", i::WITH_SCOPE,
15221522
i::LanguageMode::kSloppy},
1523-
{" with ({})", "statement",
1523+
{" with ({}", ")statement",
15241524
"\n"
15251525
" more;",
15261526
i::WITH_SCOPE, i::LanguageMode::kSloppy},
1527-
{" with ({})", "statement;",
1527+
{" with ({}", ")statement;",
15281528
"\n"
15291529
" more;",
15301530
i::WITH_SCOPE, i::LanguageMode::kSloppy},

0 commit comments

Comments
 (0)