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

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

Issue 1417053004: [Interpreter] Add conditional expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_prologue
Patch Set: 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 | « 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 8c791db5e3d9ddbab25e65145c45bccffcb413e1..150439091610e14cbd58d8e09a2cecc3ccfc9e88 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -656,7 +656,26 @@ void BytecodeGenerator::VisitDoExpression(DoExpression* expr) {
}
-void BytecodeGenerator::VisitConditional(Conditional* expr) { UNIMPLEMENTED(); }
+void BytecodeGenerator::VisitConditional(Conditional* expr) {
+ // TODO(rmcilroy): Spot easy cases where there code would not need to
+ // emit the then block or the else block, e.g. condition is
+ // obviously true/1/false/0.
oth 2015/10/23 15:24:29 We should use ToBooleanIsFalse/True for the easy c
rmcilroy 2015/10/27 12:03:35 Ack, I'll do this in a followup CL.
+
+ BytecodeLabel else_label, end_label;
+
+ VisitForAccumulatorValue(expr->condition());
+ builder()->CastAccumulatorToBoolean();
+ builder()->JumpIfFalse(&else_label);
+
+ VisitForAccumulatorValue(expr->then_expression());
+ builder()->Jump(&end_label);
+
+ builder()->Bind(&else_label);
+ VisitForAccumulatorValue(expr->else_expression());
+ builder()->Bind(&end_label);
+
+ execution_result()->SetResultInAccumulator();
+}
void BytecodeGenerator::VisitLiteral(Literal* expr) {
« 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