| 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-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/globals.h" | 8 #include "src/globals.h" |
| 9 #include "src/interpreter/bytecode-array-writer.h" | 9 #include "src/interpreter/bytecode-array-writer.h" |
| 10 #include "src/interpreter/bytecode-dead-code-optimizer.h" | 10 #include "src/interpreter/bytecode-dead-code-optimizer.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op, | 153 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op, |
| 154 Register reg, | 154 Register reg, |
| 155 int feedback_slot) { | 155 int feedback_slot) { |
| 156 Output(BytecodeForBinaryOperation(op), RegisterOperand(reg), | 156 Output(BytecodeForBinaryOperation(op), RegisterOperand(reg), |
| 157 UnsignedOperand(feedback_slot)); | 157 UnsignedOperand(feedback_slot)); |
| 158 return *this; | 158 return *this; |
| 159 } | 159 } |
| 160 | 160 |
| 161 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperationSmi( |
| 162 Token::Value op, int32_t smi_value, Register reg, int feedback_slot) { |
| 163 DCHECK(Smi::IsValid(smi_value)); |
| 164 Output(BytecodeForBinaryOperationSmi(op), SignedOperand(smi_value), |
| 165 RegisterOperand(reg), UnsignedOperand(feedback_slot)); |
| 166 return *this; |
| 167 } |
| 168 |
| 161 BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op, | 169 BytecodeArrayBuilder& BytecodeArrayBuilder::CountOperation(Token::Value op, |
| 162 int feedback_slot) { | 170 int feedback_slot) { |
| 163 Output(BytecodeForCountOperation(op), UnsignedOperand(feedback_slot)); | 171 Output(BytecodeForCountOperation(op), UnsignedOperand(feedback_slot)); |
| 164 return *this; | 172 return *this; |
| 165 } | 173 } |
| 166 | 174 |
| 167 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { | 175 BytecodeArrayBuilder& BytecodeArrayBuilder::LogicalNot() { |
| 168 Output(Bytecode::kToBooleanLogicalNot); | 176 Output(Bytecode::kToBooleanLogicalNot); |
| 169 return *this; | 177 return *this; |
| 170 } | 178 } |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 return Bytecode::kShiftRight; | 847 return Bytecode::kShiftRight; |
| 840 case Token::Value::SHR: | 848 case Token::Value::SHR: |
| 841 return Bytecode::kShiftRightLogical; | 849 return Bytecode::kShiftRightLogical; |
| 842 default: | 850 default: |
| 843 UNREACHABLE(); | 851 UNREACHABLE(); |
| 844 return Bytecode::kIllegal; | 852 return Bytecode::kIllegal; |
| 845 } | 853 } |
| 846 } | 854 } |
| 847 | 855 |
| 848 // static | 856 // static |
| 857 Bytecode BytecodeArrayBuilder::BytecodeForBinaryOperationSmi(Token::Value op) { |
| 858 switch (op) { |
| 859 case Token::Value::ADD: |
| 860 return Bytecode::kAddSmi; |
| 861 case Token::Value::SUB: |
| 862 return Bytecode::kSubSmi; |
| 863 case Token::Value::BIT_OR: |
| 864 return Bytecode::kBitwiseOrSmi; |
| 865 case Token::Value::BIT_AND: |
| 866 return Bytecode::kBitwiseAndSmi; |
| 867 case Token::Value::SHL: |
| 868 return Bytecode::kShiftLeftSmi; |
| 869 case Token::Value::SAR: |
| 870 return Bytecode::kShiftRightSmi; |
| 871 default: |
| 872 UNREACHABLE(); |
| 873 return Bytecode::kIllegal; |
| 874 } |
| 875 } |
| 876 |
| 877 // static |
| 849 Bytecode BytecodeArrayBuilder::BytecodeForCountOperation(Token::Value op) { | 878 Bytecode BytecodeArrayBuilder::BytecodeForCountOperation(Token::Value op) { |
| 850 switch (op) { | 879 switch (op) { |
| 851 case Token::Value::ADD: | 880 case Token::Value::ADD: |
| 852 return Bytecode::kInc; | 881 return Bytecode::kInc; |
| 853 case Token::Value::SUB: | 882 case Token::Value::SUB: |
| 854 return Bytecode::kDec; | 883 return Bytecode::kDec; |
| 855 default: | 884 default: |
| 856 UNREACHABLE(); | 885 UNREACHABLE(); |
| 857 return Bytecode::kIllegal; | 886 return Bytecode::kIllegal; |
| 858 } | 887 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 return Bytecode::kTailCall; | 1013 return Bytecode::kTailCall; |
| 985 default: | 1014 default: |
| 986 UNREACHABLE(); | 1015 UNREACHABLE(); |
| 987 } | 1016 } |
| 988 return Bytecode::kIllegal; | 1017 return Bytecode::kIllegal; |
| 989 } | 1018 } |
| 990 | 1019 |
| 991 } // namespace interpreter | 1020 } // namespace interpreter |
| 992 } // namespace internal | 1021 } // namespace internal |
| 993 } // namespace v8 | 1022 } // namespace v8 |
| OLD | NEW |