| 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 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 | 1046 |
| 1047 void BytecodeArrayBuilder::EnsureReturn() { | 1047 void BytecodeArrayBuilder::EnsureReturn() { |
| 1048 if (!exit_seen_in_block_) { | 1048 if (!exit_seen_in_block_) { |
| 1049 LoadUndefined(); | 1049 LoadUndefined(); |
| 1050 Return(); | 1050 Return(); |
| 1051 } | 1051 } |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 | |
| 1055 BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable, | 1054 BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable, |
| 1056 Register receiver, | 1055 Register receiver_args, |
| 1057 size_t arg_count, | 1056 size_t receiver_args_count, |
| 1058 int feedback_slot) { | 1057 int feedback_slot) { |
| 1059 if (FitsInReg8Operand(callable) && FitsInReg8Operand(receiver) && | 1058 if (FitsInReg8Operand(callable) && FitsInReg8Operand(receiver_args) && |
| 1060 FitsInIdx8Operand(arg_count) && FitsInIdx8Operand(feedback_slot)) { | 1059 FitsInIdx8Operand(receiver_args_count) && |
| 1061 Output(Bytecode::kCall, callable.ToRawOperand(), receiver.ToRawOperand(), | 1060 FitsInIdx8Operand(feedback_slot)) { |
| 1062 static_cast<uint8_t>(arg_count), | 1061 Output(Bytecode::kCall, callable.ToRawOperand(), |
| 1062 receiver_args.ToRawOperand(), |
| 1063 static_cast<uint8_t>(receiver_args_count), |
| 1063 static_cast<uint8_t>(feedback_slot)); | 1064 static_cast<uint8_t>(feedback_slot)); |
| 1064 } else if (FitsInReg16Operand(callable) && FitsInReg16Operand(receiver) && | 1065 } else if (FitsInReg16Operand(callable) && |
| 1065 FitsInIdx16Operand(arg_count) && | 1066 FitsInReg16Operand(receiver_args) && |
| 1067 FitsInIdx16Operand(receiver_args_count) && |
| 1066 FitsInIdx16Operand(feedback_slot)) { | 1068 FitsInIdx16Operand(feedback_slot)) { |
| 1067 Output(Bytecode::kCallWide, callable.ToRawOperand(), | 1069 Output(Bytecode::kCallWide, callable.ToRawOperand(), |
| 1068 receiver.ToRawOperand(), static_cast<uint16_t>(arg_count), | 1070 receiver_args.ToRawOperand(), |
| 1071 static_cast<uint16_t>(receiver_args_count), |
| 1069 static_cast<uint16_t>(feedback_slot)); | 1072 static_cast<uint16_t>(feedback_slot)); |
| 1070 } else { | 1073 } else { |
| 1071 UNIMPLEMENTED(); | 1074 UNIMPLEMENTED(); |
| 1072 } | 1075 } |
| 1073 return *this; | 1076 return *this; |
| 1074 } | 1077 } |
| 1075 | 1078 |
| 1076 | 1079 |
| 1077 BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor, | 1080 BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor, |
| 1078 Register first_arg, | 1081 Register first_arg, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 FitsInReg16Operand(first_return)) { | 1138 FitsInReg16Operand(first_return)) { |
| 1136 Output(Bytecode::kCallRuntimeForPairWide, | 1139 Output(Bytecode::kCallRuntimeForPairWide, |
| 1137 static_cast<uint16_t>(function_id), first_arg.ToRawOperand(), | 1140 static_cast<uint16_t>(function_id), first_arg.ToRawOperand(), |
| 1138 static_cast<uint16_t>(arg_count), first_return.ToRawOperand()); | 1141 static_cast<uint16_t>(arg_count), first_return.ToRawOperand()); |
| 1139 } else { | 1142 } else { |
| 1140 UNIMPLEMENTED(); | 1143 UNIMPLEMENTED(); |
| 1141 } | 1144 } |
| 1142 return *this; | 1145 return *this; |
| 1143 } | 1146 } |
| 1144 | 1147 |
| 1145 | 1148 BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime( |
| 1146 BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index, | 1149 int context_index, Register receiver_args, size_t receiver_args_count) { |
| 1147 Register receiver, | |
| 1148 size_t arg_count) { | |
| 1149 DCHECK(FitsInIdx16Operand(context_index)); | 1150 DCHECK(FitsInIdx16Operand(context_index)); |
| 1150 if (FitsInReg8Operand(receiver) && FitsInIdx8Operand(arg_count)) { | 1151 if (FitsInReg8Operand(receiver_args) && |
| 1152 FitsInIdx8Operand(receiver_args_count)) { |
| 1151 Output(Bytecode::kCallJSRuntime, static_cast<uint16_t>(context_index), | 1153 Output(Bytecode::kCallJSRuntime, static_cast<uint16_t>(context_index), |
| 1152 receiver.ToRawOperand(), static_cast<uint8_t>(arg_count)); | 1154 receiver_args.ToRawOperand(), |
| 1153 } else if (FitsInReg16Operand(receiver) && FitsInIdx16Operand(arg_count)) { | 1155 static_cast<uint8_t>(receiver_args_count)); |
| 1156 } else if (FitsInReg16Operand(receiver_args) && |
| 1157 FitsInIdx16Operand(receiver_args_count)) { |
| 1154 Output(Bytecode::kCallJSRuntimeWide, static_cast<uint16_t>(context_index), | 1158 Output(Bytecode::kCallJSRuntimeWide, static_cast<uint16_t>(context_index), |
| 1155 receiver.ToRawOperand(), static_cast<uint16_t>(arg_count)); | 1159 receiver_args.ToRawOperand(), |
| 1160 static_cast<uint16_t>(receiver_args_count)); |
| 1156 } else { | 1161 } else { |
| 1157 UNIMPLEMENTED(); | 1162 UNIMPLEMENTED(); |
| 1158 } | 1163 } |
| 1159 return *this; | 1164 return *this; |
| 1160 } | 1165 } |
| 1161 | 1166 |
| 1162 | 1167 |
| 1163 BytecodeArrayBuilder& BytecodeArrayBuilder::Delete(Register object, | 1168 BytecodeArrayBuilder& BytecodeArrayBuilder::Delete(Register object, |
| 1164 LanguageMode language_mode) { | 1169 LanguageMode language_mode) { |
| 1165 Output(BytecodeForDelete(language_mode), object.ToRawOperand()); | 1170 Output(BytecodeForDelete(language_mode), object.ToRawOperand()); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 } | 1649 } |
| 1645 | 1650 |
| 1646 // static | 1651 // static |
| 1647 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1652 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
| 1648 return value.is_short_operand(); | 1653 return value.is_short_operand(); |
| 1649 } | 1654 } |
| 1650 | 1655 |
| 1651 } // namespace interpreter | 1656 } // namespace interpreter |
| 1652 } // namespace internal | 1657 } // namespace internal |
| 1653 } // namespace v8 | 1658 } // namespace v8 |
| OLD | NEW |