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 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 | 1116 |
1116 | 1117 |
1117 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( | 1118 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
1118 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { | 1119 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
1119 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); | 1120 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); |
1120 DCHECK(FitsInIdx16Operand(function_id)); | 1121 DCHECK(FitsInIdx16Operand(function_id)); |
1121 if (!first_arg.is_valid()) { | 1122 if (!first_arg.is_valid()) { |
1122 DCHECK_EQ(0u, arg_count); | 1123 DCHECK_EQ(0u, arg_count); |
1123 first_arg = Register(0); | 1124 first_arg = Register(0); |
1124 } | 1125 } |
| 1126 Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) |
| 1127 ? Bytecode::kInvokeIntrinsic |
| 1128 : Bytecode::kCallRuntime; |
1125 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count)) { | 1129 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count)) { |
1126 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id), | 1130 Output(bytecode, static_cast<uint16_t>(function_id), |
1127 first_arg.ToRawOperand(), static_cast<uint8_t>(arg_count)); | 1131 first_arg.ToRawOperand(), static_cast<uint8_t>(arg_count)); |
1128 } else if (FitsInReg16Operand(first_arg) && FitsInIdx16Operand(arg_count)) { | 1132 } else if (FitsInReg16Operand(first_arg) && FitsInIdx16Operand(arg_count)) { |
1129 Output(Bytecode::kCallRuntimeWide, static_cast<uint16_t>(function_id), | 1133 Output(BytecodeForWideOperands(bytecode), |
1130 first_arg.ToRawOperand(), static_cast<uint16_t>(arg_count)); | 1134 static_cast<uint16_t>(function_id), first_arg.ToRawOperand(), |
| 1135 static_cast<uint16_t>(arg_count)); |
1131 } else { | 1136 } else { |
1132 UNIMPLEMENTED(); | 1137 UNIMPLEMENTED(); |
1133 } | 1138 } |
1134 return *this; | 1139 return *this; |
1135 } | 1140 } |
1136 | 1141 |
1137 | |
1138 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( | 1142 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( |
1139 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, | 1143 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, |
1140 Register first_return) { | 1144 Register first_return) { |
1141 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); | 1145 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); |
1142 DCHECK(FitsInIdx16Operand(function_id)); | 1146 DCHECK(FitsInIdx16Operand(function_id)); |
1143 if (!first_arg.is_valid()) { | 1147 if (!first_arg.is_valid()) { |
1144 DCHECK_EQ(0u, arg_count); | 1148 DCHECK_EQ(0u, arg_count); |
1145 first_arg = Register(0); | 1149 first_arg = Register(0); |
1146 } | 1150 } |
1147 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count) && | 1151 if (FitsInReg8Operand(first_arg) && FitsInIdx8Operand(arg_count) && |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 case Bytecode::kStaGlobalStrict: | 1473 case Bytecode::kStaGlobalStrict: |
1470 return Bytecode::kStaGlobalStrictWide; | 1474 return Bytecode::kStaGlobalStrictWide; |
1471 case Bytecode::kLdaLookupSlot: | 1475 case Bytecode::kLdaLookupSlot: |
1472 return Bytecode::kLdaLookupSlotWide; | 1476 return Bytecode::kLdaLookupSlotWide; |
1473 case Bytecode::kLdaLookupSlotInsideTypeof: | 1477 case Bytecode::kLdaLookupSlotInsideTypeof: |
1474 return Bytecode::kLdaLookupSlotInsideTypeofWide; | 1478 return Bytecode::kLdaLookupSlotInsideTypeofWide; |
1475 case Bytecode::kStaLookupSlotStrict: | 1479 case Bytecode::kStaLookupSlotStrict: |
1476 return Bytecode::kStaLookupSlotStrictWide; | 1480 return Bytecode::kStaLookupSlotStrictWide; |
1477 case Bytecode::kStaLookupSlotSloppy: | 1481 case Bytecode::kStaLookupSlotSloppy: |
1478 return Bytecode::kStaLookupSlotSloppyWide; | 1482 return Bytecode::kStaLookupSlotSloppyWide; |
| 1483 case Bytecode::kInvokeIntrinsic: |
| 1484 return Bytecode::kInvokeIntrinsicWide; |
| 1485 case Bytecode::kCallRuntime: |
| 1486 return Bytecode::kCallRuntimeWide; |
1479 default: | 1487 default: |
1480 UNREACHABLE(); | 1488 UNREACHABLE(); |
1481 return static_cast<Bytecode>(-1); | 1489 return static_cast<Bytecode>(-1); |
1482 } | 1490 } |
1483 } | 1491 } |
1484 | 1492 |
1485 | 1493 |
1486 // static | 1494 // static |
1487 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { | 1495 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { |
1488 switch (language_mode) { | 1496 switch (language_mode) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 } | 1653 } |
1646 | 1654 |
1647 // static | 1655 // static |
1648 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1656 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
1649 return value.is_short_operand(); | 1657 return value.is_short_operand(); |
1650 } | 1658 } |
1651 | 1659 |
1652 } // namespace interpreter | 1660 } // namespace interpreter |
1653 } // namespace internal | 1661 } // namespace internal |
1654 } // namespace v8 | 1662 } // namespace v8 |
OLD | NEW |