Chromium Code Reviews| 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(); |
| } |