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

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

Issue 1618693002: [Interpreter] Ensure context is popped when we break or continue (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase 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 | « no previous file | 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 5f640854f751764938498f4fe2b33a00fc4c9543..22b8e02a9d2b4449d099fecb71ff568404946123 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -81,7 +81,8 @@ class BytecodeGenerator::ContextScope BASE_EMBEDDED {
class BytecodeGenerator::ControlScope BASE_EMBEDDED {
public:
explicit ControlScope(BytecodeGenerator* generator)
- : generator_(generator), outer_(generator->execution_control()) {
+ : generator_(generator), outer_(generator->execution_control()),
+ context_(generator->execution_context()) {
generator_->set_execution_control(this);
}
virtual ~ControlScope() { generator_->set_execution_control(outer()); }
@@ -96,10 +97,12 @@ class BytecodeGenerator::ControlScope BASE_EMBEDDED {
BytecodeGenerator* generator() const { return generator_; }
ControlScope* outer() const { return outer_; }
+ ContextScope* context() const { return context_; }
private:
BytecodeGenerator* generator_;
ControlScope* outer_;
+ ContextScope* context_;
DISALLOW_COPY_AND_ASSIGN(ControlScope);
};
@@ -117,7 +120,7 @@ class BytecodeGenerator::ControlScopeForBreakable final
control_builder_(control_builder) {}
protected:
- virtual bool Execute(Command command, Statement* statement) {
+ bool Execute(Command command, Statement* statement) override {
if (statement != statement_) return false;
switch (command) {
case CMD_BREAK:
@@ -148,7 +151,7 @@ class BytecodeGenerator::ControlScopeForIteration final
loop_builder_(loop_builder) {}
protected:
- virtual bool Execute(Command command, Statement* statement) {
+ bool Execute(Command command, Statement* statement) override {
if (statement != statement_) return false;
switch (command) {
case CMD_BREAK:
@@ -170,9 +173,16 @@ class BytecodeGenerator::ControlScopeForIteration final
void BytecodeGenerator::ControlScope::PerformCommand(Command command,
Statement* statement) {
ControlScope* current = this;
+ ContextScope* context = this->context();
do {
- if (current->Execute(command, statement)) return;
+ 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());
+ context = current->context();
+ }
} while (current != nullptr);
UNREACHABLE();
}
« no previous file with comments | « no previous file | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698