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 1002 matching lines...) Loading... |
1019 | 1020 |
1020 | 1021 |
1021 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( | 1022 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
1022 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { | 1023 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
1023 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); | 1024 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); |
1024 DCHECK(SizeForUnsignedOperand(function_id) <= OperandSize::kShort); | 1025 DCHECK(SizeForUnsignedOperand(function_id) <= OperandSize::kShort); |
1025 if (!first_arg.is_valid()) { | 1026 if (!first_arg.is_valid()) { |
1026 DCHECK_EQ(0u, arg_count); | 1027 DCHECK_EQ(0u, arg_count); |
1027 first_arg = Register(0); | 1028 first_arg = Register(0); |
1028 } | 1029 } |
| 1030 Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) |
| 1031 ? Bytecode::kInvokeIntrinsic |
| 1032 : Bytecode::kCallRuntime; |
1029 OperandScale operand_scale = OperandSizesToScale( | 1033 OperandScale operand_scale = OperandSizesToScale( |
1030 SizeForRegisterOperand(first_arg), SizeForUnsignedOperand(arg_count)); | 1034 SizeForRegisterOperand(first_arg), SizeForUnsignedOperand(arg_count)); |
1031 OutputScaled(Bytecode::kCallRuntime, operand_scale, | 1035 OutputScaled(bytecode, operand_scale, static_cast<uint16_t>(function_id), |
1032 static_cast<uint16_t>(function_id), RegisterOperand(first_arg), | 1036 RegisterOperand(first_arg), UnsignedOperand(arg_count)); |
1033 UnsignedOperand(arg_count)); | |
1034 return *this; | 1037 return *this; |
1035 } | 1038 } |
1036 | 1039 |
1037 | 1040 |
1038 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( | 1041 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( |
1039 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, | 1042 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, |
1040 Register first_return) { | 1043 Register first_return) { |
1041 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); | 1044 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); |
1042 DCHECK(SizeForUnsignedOperand(function_id) <= OperandSize::kShort); | 1045 DCHECK(SizeForUnsignedOperand(function_id) <= OperandSize::kShort); |
1043 if (!first_arg.is_valid()) { | 1046 if (!first_arg.is_valid()) { |
(...skipping 448 matching lines...) Loading... |
1492 } | 1495 } |
1493 | 1496 |
1494 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { | 1497 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { |
1495 DCHECK_LE(value, kMaxUInt32); | 1498 DCHECK_LE(value, kMaxUInt32); |
1496 return static_cast<uint32_t>(value); | 1499 return static_cast<uint32_t>(value); |
1497 } | 1500 } |
1498 | 1501 |
1499 } // namespace interpreter | 1502 } // namespace interpreter |
1500 } // namespace internal | 1503 } // namespace internal |
1501 } // namespace v8 | 1504 } // namespace v8 |
OLD | NEW |