| OLD | NEW | 
|---|
| 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 <stack> | 7 #include <stack> | 
| 8 | 8 | 
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" | 
| 10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" | 
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 872 | 872 | 
| 873 | 873 | 
| 874 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { | 874 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { | 
| 875   UNIMPLEMENTED(); | 875   UNIMPLEMENTED(); | 
| 876 } | 876 } | 
| 877 | 877 | 
| 878 | 878 | 
| 879 void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) { | 879 void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) { | 
| 880   switch (binop->op()) { | 880   switch (binop->op()) { | 
| 881     case Token::COMMA: | 881     case Token::COMMA: | 
|  | 882       VisitCommaExpression(binop); | 
|  | 883       break; | 
| 882     case Token::OR: | 884     case Token::OR: | 
|  | 885       VisitLogicalOrExpression(binop); | 
|  | 886       break; | 
| 883     case Token::AND: | 887     case Token::AND: | 
| 884       UNIMPLEMENTED(); | 888       VisitLogicalAndExpression(binop); | 
| 885       break; | 889       break; | 
| 886     default: | 890     default: | 
| 887       VisitArithmeticExpression(binop); | 891       VisitArithmeticExpression(binop); | 
| 888       break; | 892       break; | 
| 889   } | 893   } | 
| 890 } | 894 } | 
| 891 | 895 | 
| 892 | 896 | 
| 893 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 897 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 
| 894   Token::Value op = expr->op(); | 898   Token::Value op = expr->op(); | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 972   TemporaryRegisterScope temporary_register_scope(builder()); | 976   TemporaryRegisterScope temporary_register_scope(builder()); | 
| 973   Register temporary = temporary_register_scope.NewRegister(); | 977   Register temporary = temporary_register_scope.NewRegister(); | 
| 974 | 978 | 
| 975   Visit(left); | 979   Visit(left); | 
| 976   builder()->StoreAccumulatorInRegister(temporary); | 980   builder()->StoreAccumulatorInRegister(temporary); | 
| 977   Visit(right); | 981   Visit(right); | 
| 978   builder()->BinaryOperation(op, temporary, language_mode_strength()); | 982   builder()->BinaryOperation(op, temporary, language_mode_strength()); | 
| 979 } | 983 } | 
| 980 | 984 | 
| 981 | 985 | 
|  | 986 void BytecodeGenerator::VisitCommaExpression(BinaryOperation* binop) { | 
|  | 987   Expression* left = binop->left(); | 
|  | 988   Expression* right = binop->right(); | 
|  | 989 | 
|  | 990   Visit(left); | 
|  | 991   Visit(right); | 
|  | 992 } | 
|  | 993 | 
|  | 994 | 
|  | 995 void BytecodeGenerator::VisitLogicalOrExpression(BinaryOperation* binop) { | 
|  | 996   Expression* left = binop->left(); | 
|  | 997   Expression* right = binop->right(); | 
|  | 998 | 
|  | 999   // Short-circuit evaluation- If it is known that left is always true, | 
|  | 1000   // no need to visit right | 
|  | 1001   if (left->ToBooleanIsTrue()) { | 
|  | 1002     Visit(left); | 
|  | 1003   } else { | 
|  | 1004     BytecodeLabel end_label; | 
|  | 1005 | 
|  | 1006     Visit(left); | 
|  | 1007     builder()->JumpIfToBooleanTrue(&end_label); | 
|  | 1008     Visit(right); | 
|  | 1009     builder()->Bind(&end_label); | 
|  | 1010   } | 
|  | 1011 } | 
|  | 1012 | 
|  | 1013 | 
|  | 1014 void BytecodeGenerator::VisitLogicalAndExpression(BinaryOperation* binop) { | 
|  | 1015   Expression* left = binop->left(); | 
|  | 1016   Expression* right = binop->right(); | 
|  | 1017 | 
|  | 1018   // Short-circuit evaluation- If it is known that left is always false, | 
|  | 1019   // no need to visit right | 
|  | 1020   if (left->ToBooleanIsFalse()) { | 
|  | 1021     Visit(left); | 
|  | 1022   } else { | 
|  | 1023     BytecodeLabel end_label; | 
|  | 1024 | 
|  | 1025     Visit(left); | 
|  | 1026     builder()->JumpIfToBooleanFalse(&end_label); | 
|  | 1027     Visit(right); | 
|  | 1028     builder()->Bind(&end_label); | 
|  | 1029   } | 
|  | 1030 } | 
|  | 1031 | 
|  | 1032 | 
| 982 LanguageMode BytecodeGenerator::language_mode() const { | 1033 LanguageMode BytecodeGenerator::language_mode() const { | 
| 983   return info()->language_mode(); | 1034   return info()->language_mode(); | 
| 984 } | 1035 } | 
| 985 | 1036 | 
| 986 | 1037 | 
| 987 Strength BytecodeGenerator::language_mode_strength() const { | 1038 Strength BytecodeGenerator::language_mode_strength() const { | 
| 988   return strength(language_mode()); | 1039   return strength(language_mode()); | 
| 989 } | 1040 } | 
| 990 | 1041 | 
| 991 | 1042 | 
| 992 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 1043 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 
| 993   return info()->feedback_vector()->GetIndex(slot); | 1044   return info()->feedback_vector()->GetIndex(slot); | 
| 994 } | 1045 } | 
| 995 | 1046 | 
| 996 }  // namespace interpreter | 1047 }  // namespace interpreter | 
| 997 }  // namespace internal | 1048 }  // namespace internal | 
| 998 }  // namespace v8 | 1049 }  // namespace v8 | 
| OLD | NEW | 
|---|