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

Unified Diff: src/interpreter/control-flow-builders.cc

Issue 1373903005: [Interpreter] Add for/while/do support to the bytecode generator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate feedback from mstarzinger which revealed use after destruction bug. Created 5 years, 3 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
Index: src/interpreter/control-flow-builders.cc
diff --git a/src/interpreter/control-flow-builders.cc b/src/interpreter/control-flow-builders.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e7a95e71c6d63ec9179041c2cbb0cacf0f676e70
--- /dev/null
+++ b/src/interpreter/control-flow-builders.cc
@@ -0,0 +1,40 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/interpreter/control-flow-builders.h"
+
+namespace v8 {
+namespace internal {
+namespace interpreter {
+
+
+LoopBuilder::~LoopBuilder() {
+ BindLabels(continue_label(), &continue_labels_);
+ BindLabels(break_label(), &break_labels_);
rmcilroy 2015/10/01 09:18:56 Either move this to an explicit function or call t
oth 2015/10/01 11:43:02 Done.
+}
+
+
+void LoopBuilder::Break() {
+ break_labels_.push_back(BytecodeLabel());
+ builder()->Jump(&break_labels_.back());
+}
+
+
+void LoopBuilder::Continue() {
+ continue_labels_.push_back(BytecodeLabel());
+ builder()->Jump(&continue_labels_.back());
+}
+
+
+void LoopBuilder::BindLabels(BytecodeLabel* target,
+ ZoneVector<BytecodeLabel>* labels) {
+ for (size_t i = 0; i < labels->size(); i++) {
+ BytecodeLabel& unbound = labels->at(i);
+ builder()->Bind(&unbound, target);
+ }
+}
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698