| 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 #include "src/compiler.h" | 6 #include "src/compiler.h" |
| 7 #include "src/interpreter/interpreter-intrinsics.h" |
| 7 | 8 |
| 8 namespace v8 { | 9 namespace v8 { |
| 9 namespace internal { | 10 namespace internal { |
| 10 namespace interpreter { | 11 namespace interpreter { |
| 11 | 12 |
| 12 class BytecodeArrayBuilder::PreviousBytecodeHelper BASE_EMBEDDED { | 13 class BytecodeArrayBuilder::PreviousBytecodeHelper BASE_EMBEDDED { |
| 13 public: | 14 public: |
| 14 explicit PreviousBytecodeHelper(const BytecodeArrayBuilder& array_builder) | 15 explicit PreviousBytecodeHelper(const BytecodeArrayBuilder& array_builder) |
| 15 : array_builder_(array_builder), | 16 : array_builder_(array_builder), |
| 16 previous_bytecode_start_(array_builder_.last_bytecode_start_) { | 17 previous_bytecode_start_(array_builder_.last_bytecode_start_) { |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 | 1115 |
| 1115 | 1116 |
| 1116 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( | 1117 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
| 1117 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { | 1118 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
| 1118 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); | 1119 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); |
| 1119 DCHECK(FitsInIdx16Operand(function_id)); | 1120 DCHECK(FitsInIdx16Operand(function_id)); |
| 1120 if (!first_arg.is_valid()) { | 1121 if (!first_arg.is_valid()) { |
| 1121 DCHECK_EQ(0u, arg_count); | 1122 DCHECK_EQ(0u, arg_count); |
| 1122 first_arg = Register(0); | 1123 first_arg = Register(0); |
| 1123 } | 1124 } |
| 1125 Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) |
| 1126 ? Bytecode::kInvokeIntrinsic |
| 1127 : Bytecode::kCallRuntime; |
| 1124 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count)) { | 1128 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count)) { |
| 1125 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id), | 1129 Output(bytecode, static_cast<uint16_t>(function_id), |
| 1126 first_arg.ToRawOperand(), static_cast<uint8_t>(arg_count)); | 1130 first_arg.ToRawOperand(), static_cast<uint8_t>(arg_count)); |
| 1127 } else if (FitsInReg16Operand(first_arg) && FitsInIdx16Operand(arg_count)) { | 1131 } else if (FitsInReg16Operand(first_arg) && FitsInIdx16Operand(arg_count)) { |
| 1128 Output(Bytecode::kCallRuntimeWide, static_cast<uint16_t>(function_id), | 1132 Output(BytecodeForWideOperands(bytecode), |
| 1129 first_arg.ToRawOperand(), static_cast<uint16_t>(arg_count)); | 1133 static_cast<uint16_t>(function_id), first_arg.ToRawOperand(), |
| 1134 static_cast<uint16_t>(arg_count)); |
| 1130 } else { | 1135 } else { |
| 1131 UNIMPLEMENTED(); | 1136 UNIMPLEMENTED(); |
| 1132 } | 1137 } |
| 1133 return *this; | 1138 return *this; |
| 1134 } | 1139 } |
| 1135 | 1140 |
| 1136 | |
| 1137 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( | 1141 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( |
| 1138 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, | 1142 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, |
| 1139 Register first_return) { | 1143 Register first_return) { |
| 1140 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); | 1144 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); |
| 1141 DCHECK(FitsInIdx16Operand(function_id)); | 1145 DCHECK(FitsInIdx16Operand(function_id)); |
| 1142 if (!first_arg.is_valid()) { | 1146 if (!first_arg.is_valid()) { |
| 1143 DCHECK_EQ(0u, arg_count); | 1147 DCHECK_EQ(0u, arg_count); |
| 1144 first_arg = Register(0); | 1148 first_arg = Register(0); |
| 1145 } | 1149 } |
| 1146 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count) && | 1150 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count) && |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 case Bytecode::kStaGlobalStrict: | 1470 case Bytecode::kStaGlobalStrict: |
| 1467 return Bytecode::kStaGlobalStrictWide; | 1471 return Bytecode::kStaGlobalStrictWide; |
| 1468 case Bytecode::kLdaLookupSlot: | 1472 case Bytecode::kLdaLookupSlot: |
| 1469 return Bytecode::kLdaLookupSlotWide; | 1473 return Bytecode::kLdaLookupSlotWide; |
| 1470 case Bytecode::kLdaLookupSlotInsideTypeof: | 1474 case Bytecode::kLdaLookupSlotInsideTypeof: |
| 1471 return Bytecode::kLdaLookupSlotInsideTypeofWide; | 1475 return Bytecode::kLdaLookupSlotInsideTypeofWide; |
| 1472 case Bytecode::kStaLookupSlotStrict: | 1476 case Bytecode::kStaLookupSlotStrict: |
| 1473 return Bytecode::kStaLookupSlotStrictWide; | 1477 return Bytecode::kStaLookupSlotStrictWide; |
| 1474 case Bytecode::kStaLookupSlotSloppy: | 1478 case Bytecode::kStaLookupSlotSloppy: |
| 1475 return Bytecode::kStaLookupSlotSloppyWide; | 1479 return Bytecode::kStaLookupSlotSloppyWide; |
| 1480 case Bytecode::kInvokeIntrinsic: |
| 1481 return Bytecode::kInvokeIntrinsicWide; |
| 1482 case Bytecode::kCallRuntime: |
| 1483 return Bytecode::kCallRuntimeWide; |
| 1476 default: | 1484 default: |
| 1477 UNREACHABLE(); | 1485 UNREACHABLE(); |
| 1478 return static_cast<Bytecode>(-1); | 1486 return static_cast<Bytecode>(-1); |
| 1479 } | 1487 } |
| 1480 } | 1488 } |
| 1481 | 1489 |
| 1482 | 1490 |
| 1483 // static | 1491 // static |
| 1484 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { | 1492 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { |
| 1485 switch (language_mode) { | 1493 switch (language_mode) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 } | 1650 } |
| 1643 | 1651 |
| 1644 // static | 1652 // static |
| 1645 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1653 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
| 1646 return value.is_short_operand(); | 1654 return value.is_short_operand(); |
| 1647 } | 1655 } |
| 1648 | 1656 |
| 1649 } // namespace interpreter | 1657 } // namespace interpreter |
| 1650 } // namespace internal | 1658 } // namespace internal |
| 1651 } // namespace v8 | 1659 } // namespace v8 |
| OLD | NEW |