Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1601153002: [Interpreter] Ensure that block breaks are within the correct context scope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 9698773dda5693dc1b7c36b50d0388e15a05373e..8b22f1d3647b8405420912e97afdc35cd9924765 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -422,24 +422,24 @@ void BytecodeGenerator::MakeBytecodeBody() {
void BytecodeGenerator::VisitBlock(Block* stmt) {
- BlockBuilder block_builder(this->builder());
- ControlScopeForBreakable execution_control(this, stmt, &block_builder);
-
- if (stmt->scope() == NULL) {
- // Visit statements in the same scope, no declarations.
- VisitStatements(stmt->statements());
+ // Visit declarations and statements.
+ if (stmt->scope() != nullptr && stmt->scope()->NeedsContext()) {
+ VisitNewLocalBlockContext(stmt->scope());
+ ContextScope scope(this, stmt->scope());
+ VisitBlockDeclarationsAndStatements(stmt);
} else {
- // Visit declarations and statements in a block scope.
- if (stmt->scope()->NeedsContext()) {
- VisitNewLocalBlockContext(stmt->scope());
- ContextScope scope(this, stmt->scope());
- VisitDeclarations(stmt->scope()->declarations());
- VisitStatements(stmt->statements());
- } else {
- VisitDeclarations(stmt->scope()->declarations());
- VisitStatements(stmt->statements());
- }
+ VisitBlockDeclarationsAndStatements(stmt);
+ }
+}
+
+
+void BytecodeGenerator::VisitBlockDeclarationsAndStatements(Block* stmt) {
+ BlockBuilder block_builder(builder());
+ ControlScopeForBreakable execution_control(this, stmt, &block_builder);
+ if (stmt->scope() != nullptr) {
+ VisitDeclarations(stmt->scope()->declarations());
}
+ VisitStatements(stmt->statements());
if (stmt->labels() != nullptr) block_builder.EndBlock();
}
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698