Chromium Code Reviews

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

Issue 1796893002: [Interpreter] Pops the context to the correct level on return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added a test for try-finally with return in test-interpreter. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | test/cctest/interpreter/bytecode_expectations/BasicLoops.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 412c0d34356c56e3988c29f9da2418c6d2a00721..8f709da2a1e14c7a4b82f1e07e7a502f9c4d42cb 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -72,6 +72,7 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED {
Scope* scope() const { return scope_; }
Register reg() const { return register_; }
+ bool ShouldPopContext() { return should_pop_context_; }
private:
const BytecodeArrayBuilder* builder() const { return generator_->builder(); }
@@ -363,21 +364,20 @@ void BytecodeGenerator::ControlScope::PerformCommand(Command command,
Statement* statement) {
ControlScope* current = this;
ContextScope* context = generator()->execution_context();
+ // Do not pop if it is the outermost context.
+ if (context != current->context() && context->ShouldPopContext()) {
mythria 2016/03/15 09:49:11 I am still not very sure about the check for conte
+ generator()->builder()->PopContext(current->context()->reg());
+ }
do {
- if (current->context() != context) {
- // 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.
- 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();
+ if (current->context() != context) {
+ // Pop context to the expected depth.
+ // TODO(rmcilroy): Only emit a single context pop.
+ generator()->builder()->PopContext(current->context()->reg());
+ }
} while (current != nullptr);
UNREACHABLE();
}
« no previous file with comments | « no previous file | test/cctest/interpreter/bytecode_expectations/BasicLoops.golden » ('j') | no next file with comments »

Powered by Google App Engine