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

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

Issue 1768123002: [Interpreter] Fixes a bug when popping context to correct level on break/continue. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes comments Created 4 years, 9 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 | « no previous file | test/cctest/interpreter/bytecode_expectations/ContextVariables.golden » ('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 c4026b59ec1659c024f231fca7d6a561b6c39a72..839b2f884e8baafe979e7a902802449a566b095c 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -362,16 +362,22 @@ class BytecodeGenerator::ControlScopeForTryFinally final
void BytecodeGenerator::ControlScope::PerformCommand(Command command,
Statement* statement) {
ControlScope* current = this;
- ContextScope* context = this->context();
+ ContextScope* context = generator()->execution_context();
do {
- if (current->Execute(command, statement)) { return; }
- current = current->outer();
if (current->context() != context) {
- // Pop context to the expected depth.
+ // Pop context to the expected depth for break and continue. For return
+ // and throw it is not required to pop. Debugger expects that the
+ // context is not popped on return. So do not pop on return.
// TODO(rmcilroy): Only emit a single context pop.
- generator()->builder()->PopContext(current->context()->reg());
+ if (command == CMD_BREAK || command == CMD_CONTINUE) {
+ generator()->builder()->PopContext(current->context()->reg());
+ }
context = current->context();
}
+ if (current->Execute(command, statement)) {
+ return;
+ }
+ current = current->outer();
} while (current != nullptr);
UNREACHABLE();
}
« no previous file with comments | « no previous file | test/cctest/interpreter/bytecode_expectations/ContextVariables.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698