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

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

Issue 1415093006: [Interpreter] Add switch support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_wideidx
Patch Set: Rebased Created 5 years, 2 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 | « src/interpreter/control-flow-builders.h ('k') | 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/control-flow-builders.cc
diff --git a/src/interpreter/control-flow-builders.cc b/src/interpreter/control-flow-builders.cc
index 3d9b1c14f4912e25b5dc26d5de9ba3cb8b23404b..3ecabe4351cb9ddbac13618b1b85e52d29ca0cd3 100644
--- a/src/interpreter/control-flow-builders.cc
+++ b/src/interpreter/control-flow-builders.cc
@@ -9,48 +9,57 @@ namespace internal {
namespace interpreter {
-LoopBuilder::~LoopBuilder() {
- DCHECK(continue_sites_.empty());
+BreakableControlFlowBuilder::~BreakableControlFlowBuilder() {
DCHECK(break_sites_.empty());
}
-void LoopBuilder::SetContinueTarget(const BytecodeLabel& target) {
- BindLabels(target, &continue_sites_);
-}
-
-
-void LoopBuilder::SetBreakTarget(const BytecodeLabel& target) {
+void BreakableControlFlowBuilder::SetBreakTarget(const BytecodeLabel& target) {
BindLabels(target, &break_sites_);
}
-void LoopBuilder::EmitJump(ZoneVector<BytecodeLabel>* sites) {
+void BreakableControlFlowBuilder::EmitJump(ZoneVector<BytecodeLabel>* sites) {
sites->push_back(BytecodeLabel());
builder()->Jump(&sites->back());
}
-void LoopBuilder::EmitJumpIfTrue(ZoneVector<BytecodeLabel>* sites) {
+void BreakableControlFlowBuilder::EmitJumpIfTrue(
+ ZoneVector<BytecodeLabel>* sites) {
sites->push_back(BytecodeLabel());
builder()->JumpIfTrue(&sites->back());
}
-void LoopBuilder::EmitJumpIfUndefined(ZoneVector<BytecodeLabel>* sites) {
+void BreakableControlFlowBuilder::EmitJumpIfUndefined(
+ ZoneVector<BytecodeLabel>* sites) {
sites->push_back(BytecodeLabel());
builder()->JumpIfUndefined(&sites->back());
}
-void LoopBuilder::EmitJumpIfNull(ZoneVector<BytecodeLabel>* sites) {
+void BreakableControlFlowBuilder::EmitJumpIfNull(
+ ZoneVector<BytecodeLabel>* sites) {
sites->push_back(BytecodeLabel());
builder()->JumpIfNull(&sites->back());
}
-void LoopBuilder::BindLabels(const BytecodeLabel& target,
- ZoneVector<BytecodeLabel>* sites) {
+void BreakableControlFlowBuilder::EmitJump(ZoneVector<BytecodeLabel>* sites,
+ int index) {
+ builder()->Jump(&sites->at(index));
+}
+
+
+void BreakableControlFlowBuilder::EmitJumpIfTrue(
+ ZoneVector<BytecodeLabel>* sites, int index) {
+ builder()->JumpIfTrue(&sites->at(index));
+}
+
+
+void BreakableControlFlowBuilder::BindLabels(const BytecodeLabel& target,
+ ZoneVector<BytecodeLabel>* sites) {
for (size_t i = 0; i < sites->size(); i++) {
BytecodeLabel& site = sites->at(i);
builder()->Bind(target, &site);
@@ -58,6 +67,29 @@ void LoopBuilder::BindLabels(const BytecodeLabel& target,
sites->clear();
}
+
+LoopBuilder::~LoopBuilder() { DCHECK(continue_sites_.empty()); }
+
+
+void LoopBuilder::SetContinueTarget(const BytecodeLabel& target) {
+ BindLabels(target, &continue_sites_);
+}
+
+
+SwitchBuilder::~SwitchBuilder() {
+#ifdef DEBUG
+ for (auto site : case_sites_) {
+ DCHECK(site.is_bound());
+ }
+#endif
+}
+
+
+void SwitchBuilder::SetCaseTarget(int index) {
+ BytecodeLabel& site = case_sites_.at(index);
+ builder()->Bind(&site);
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « src/interpreter/control-flow-builders.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698