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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/interpreter/test-bytecode-generator.cc » ('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/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/control-flow-builders.h" 8 #include "src/interpreter/control-flow-builders.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 NativeFunctionLiteral* expr) { 649 NativeFunctionLiteral* expr) {
650 UNIMPLEMENTED(); 650 UNIMPLEMENTED();
651 } 651 }
652 652
653 653
654 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) { 654 void BytecodeGenerator::VisitDoExpression(DoExpression* expr) {
655 UNIMPLEMENTED(); 655 UNIMPLEMENTED();
656 } 656 }
657 657
658 658
659 void BytecodeGenerator::VisitConditional(Conditional* expr) { UNIMPLEMENTED(); } 659 void BytecodeGenerator::VisitConditional(Conditional* expr) {
660 // TODO(rmcilroy): Spot easy cases where there code would not need to
661 // emit the then block or the else block, e.g. condition is
662 // 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.
663
664 BytecodeLabel else_label, end_label;
665
666 VisitForAccumulatorValue(expr->condition());
667 builder()->CastAccumulatorToBoolean();
668 builder()->JumpIfFalse(&else_label);
669
670 VisitForAccumulatorValue(expr->then_expression());
671 builder()->Jump(&end_label);
672
673 builder()->Bind(&else_label);
674 VisitForAccumulatorValue(expr->else_expression());
675 builder()->Bind(&end_label);
676
677 execution_result()->SetResultInAccumulator();
678 }
660 679
661 680
662 void BytecodeGenerator::VisitLiteral(Literal* expr) { 681 void BytecodeGenerator::VisitLiteral(Literal* expr) {
663 if (!execution_result()->IsEffect()) { 682 if (!execution_result()->IsEffect()) {
664 Handle<Object> value = expr->value(); 683 Handle<Object> value = expr->value();
665 if (value->IsSmi()) { 684 if (value->IsSmi()) {
666 builder()->LoadLiteral(Smi::cast(*value)); 685 builder()->LoadLiteral(Smi::cast(*value));
667 } else if (value->IsUndefined()) { 686 } else if (value->IsUndefined()) {
668 builder()->LoadUndefined(); 687 builder()->LoadUndefined();
669 } else if (value->IsTrue()) { 688 } else if (value->IsTrue()) {
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 } 1835 }
1817 1836
1818 1837
1819 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 1838 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
1820 return info()->feedback_vector()->GetIndex(slot); 1839 return info()->feedback_vector()->GetIndex(slot);
1821 } 1840 }
1822 1841
1823 } // namespace interpreter 1842 } // namespace interpreter
1824 } // namespace internal 1843 } // namespace internal
1825 } // namespace v8 1844 } // namespace v8
OLDNEW
« 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