Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cherry-pick 1 changes from Release-0-M117 #39918

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions patches/v8/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ do_not_export_private_v8_symbols_on_windows.patch
fix_build_deprecated_attribute_for_older_msvc_versions.patch
fix_disable_implies_dcheck_for_node_stream_array_buffers.patch
chore_allow_customizing_microtask_policy_per_context.patch
cherry-pick-cf1d4d3c0b6e.patch
99 changes: 99 additions & 0 deletions patches/v8/cherry-pick-cf1d4d3c0b6e.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shu-yu Guo <syg@chromium.org>
Date: Thu, 31 Aug 2023 08:59:12 -0700
Subject: Merged: [interpreter] Fix TDZ elision in do-while tests

(cherry picked from commit 1626e229a8965f975db6e9da0e7ab85f8c74333f)

Change-Id: Ifb7461b6cfd62a10936470a760cb505cc5e1c60f
Fixed: chromium:1477588
Bug: v8:13723
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4862981
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/branch-heads/11.6@{#38}
Cr-Branched-From: e29c028f391389a7a60ee37097e3ca9e396d6fa4-refs/heads/11.6.189@{#3}
Cr-Branched-From: 95cbef20e2aa556a1ea75431a48b36c4de6b9934-refs/heads/main@{#88340}

diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index bd6c01047f9656c96f4fdc5fe6173d774219098d..751411a809c01329d59b3d310292ab0a997842cc 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -2435,8 +2435,16 @@ void BytecodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) {
VisitIterationBodyInHoleCheckElisionScope(stmt, &loop_builder);
builder()->SetExpressionAsStatementPosition(stmt->cond());
BytecodeLabels loop_backbranch(zone());
- VisitForTest(stmt->cond(), &loop_backbranch, loop_builder.break_labels(),
- TestFallthrough::kThen);
+ if (!loop_builder.break_labels()->empty()) {
+ // The test may be conditionally executed if there was a break statement
+ // inside the loop body, and therefore requires its own elision scope.
+ HoleCheckElisionScope elider(this);
+ VisitForTest(stmt->cond(), &loop_backbranch, loop_builder.break_labels(),
+ TestFallthrough::kThen);
+ } else {
+ VisitForTest(stmt->cond(), &loop_backbranch, loop_builder.break_labels(),
+ TestFallthrough::kThen);
+ }
loop_backbranch.Bind(builder());
}
}
diff --git a/test/unittests/interpreter/bytecode-generator-unittest.cc b/test/unittests/interpreter/bytecode-generator-unittest.cc
index add6f7711f564bbee177b8640d13db730723af6f..c6cd6d87ad9ab81278fda33c4d887bfc7865daa1 100644
--- a/test/unittests/interpreter/bytecode-generator-unittest.cc
+++ b/test/unittests/interpreter/bytecode-generator-unittest.cc
@@ -3231,6 +3231,10 @@ TEST_F(BytecodeGeneratorTest, ElideRedundantHoleChecks) {
"do { x; } while (y);\n"
"x; y;\n",

+ // do-while with break
+ "do { x; break; } while (y);\n"
+ "x; y;\n",
+
// C-style for
"for (x; y; z) { w; }\n"
"x; y; z; w;\n",
diff --git a/test/unittests/interpreter/bytecode_expectations/ElideRedundantHoleChecks.golden b/test/unittests/interpreter/bytecode_expectations/ElideRedundantHoleChecks.golden
index 21819d9247e810b1ca77a3d368c7f7af3a3a3a18..eaca674347108d365d37b26120334fb50debb46b 100644
--- a/test/unittests/interpreter/bytecode_expectations/ElideRedundantHoleChecks.golden
+++ b/test/unittests/interpreter/bytecode_expectations/ElideRedundantHoleChecks.golden
@@ -176,6 +176,38 @@ constant pool: [
handlers: [
]

+---
+snippet: "
+ {
+ f = function f(a) {
+ do { x; break; } while (y);
+ x; y;
+ }
+ let w, x, y, z;
+ f();
+ }
+"
+frame size: 0
+parameter count: 2
+bytecode array length: 16
+bytecodes: [
+ /* 29 S> */ B(LdaImmutableCurrentContextSlot), U8(2),
+ B(ThrowReferenceErrorIfHole), U8(0),
+ /* 32 S> */ B(Jump), U8(2),
+ /* 52 S> */ B(LdaImmutableCurrentContextSlot), U8(2),
+ B(ThrowReferenceErrorIfHole), U8(0),
+ /* 55 S> */ B(LdaImmutableCurrentContextSlot), U8(3),
+ B(ThrowReferenceErrorIfHole), U8(1),
+ B(LdaUndefined),
+ /* 60 S> */ B(Return),
+]
+constant pool: [
+ ONE_BYTE_INTERNALIZED_STRING_TYPE ["x"],
+ ONE_BYTE_INTERNALIZED_STRING_TYPE ["y"],
+]
+handlers: [
+]
+
---
snippet: "
{