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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/interpreter/bytecode_expectations/ContextVariables.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/interpreter/bytecode-register-allocator.h" 9 #include "src/interpreter/bytecode-register-allocator.h"
10 #include "src/interpreter/control-flow-builders.h" 10 #include "src/interpreter/control-flow-builders.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 355
356 private: 356 private:
357 TryFinallyBuilder* try_finally_builder_; 357 TryFinallyBuilder* try_finally_builder_;
358 DeferredCommands* commands_; 358 DeferredCommands* commands_;
359 }; 359 };
360 360
361 361
362 void BytecodeGenerator::ControlScope::PerformCommand(Command command, 362 void BytecodeGenerator::ControlScope::PerformCommand(Command command,
363 Statement* statement) { 363 Statement* statement) {
364 ControlScope* current = this; 364 ControlScope* current = this;
365 ContextScope* context = this->context(); 365 ContextScope* context = generator()->execution_context();
366 do { 366 do {
367 if (current->Execute(command, statement)) { return; }
368 current = current->outer();
369 if (current->context() != context) { 367 if (current->context() != context) {
370 // Pop context to the expected depth. 368 // Pop context to the expected depth for break and continue. For return
369 // and throw it is not required to pop. Debugger expects that the
370 // context is not popped on return. So do not pop on return.
371 // TODO(rmcilroy): Only emit a single context pop. 371 // TODO(rmcilroy): Only emit a single context pop.
372 generator()->builder()->PopContext(current->context()->reg()); 372 if (command == CMD_BREAK || command == CMD_CONTINUE) {
373 generator()->builder()->PopContext(current->context()->reg());
374 }
373 context = current->context(); 375 context = current->context();
374 } 376 }
377 if (current->Execute(command, statement)) {
378 return;
379 }
380 current = current->outer();
375 } while (current != nullptr); 381 } while (current != nullptr);
376 UNREACHABLE(); 382 UNREACHABLE();
377 } 383 }
378 384
379 385
380 class BytecodeGenerator::RegisterAllocationScope { 386 class BytecodeGenerator::RegisterAllocationScope {
381 public: 387 public:
382 explicit RegisterAllocationScope(BytecodeGenerator* generator) 388 explicit RegisterAllocationScope(BytecodeGenerator* generator)
383 : generator_(generator), 389 : generator_(generator),
384 outer_(generator->register_allocator()), 390 outer_(generator->register_allocator()),
(...skipping 2757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3142 } 3148 }
3143 3149
3144 3150
3145 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 3151 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
3146 return info()->feedback_vector()->GetIndex(slot); 3152 return info()->feedback_vector()->GetIndex(slot);
3147 } 3153 }
3148 3154
3149 } // namespace interpreter 3155 } // namespace interpreter
3150 } // namespace internal 3156 } // namespace internal
3151 } // namespace v8 3157 } // namespace v8
OLDNEW
« 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