| 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/interpreter/bytecode-array-writer.h" | 8 #include "src/interpreter/bytecode-array-writer.h" |
| 9 #include "src/interpreter/bytecode-label.h" | 9 #include "src/interpreter/bytecode-label.h" |
| 10 #include "src/interpreter/bytecode-peephole-optimizer.h" | 10 #include "src/interpreter/bytecode-peephole-optimizer.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 } | 566 } |
| 567 | 567 |
| 568 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( | 568 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
| 569 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { | 569 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
| 570 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); | 570 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); |
| 571 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); | 571 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); |
| 572 if (!first_arg.is_valid()) { | 572 if (!first_arg.is_valid()) { |
| 573 DCHECK_EQ(0u, arg_count); | 573 DCHECK_EQ(0u, arg_count); |
| 574 first_arg = Register(0); | 574 first_arg = Register(0); |
| 575 } | 575 } |
| 576 Bytecode bytecode; | 576 Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) |
| 577 uint32_t id; | 577 ? Bytecode::kInvokeIntrinsic |
| 578 if (IntrinsicsHelper::IsSupported(function_id)) { | 578 : Bytecode::kCallRuntime; |
| 579 bytecode = Bytecode::kInvokeIntrinsic; | 579 Output(bytecode, static_cast<uint16_t>(function_id), |
| 580 id = static_cast<uint32_t>(IntrinsicsHelper::FromRuntimeId(function_id)); | 580 RegisterOperand(first_arg), UnsignedOperand(arg_count)); |
| 581 } else { | |
| 582 bytecode = Bytecode::kCallRuntime; | |
| 583 id = static_cast<uint32_t>(function_id); | |
| 584 } | |
| 585 Output(bytecode, id, RegisterOperand(first_arg), UnsignedOperand(arg_count)); | |
| 586 return *this; | 581 return *this; |
| 587 } | 582 } |
| 588 | 583 |
| 589 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( | 584 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( |
| 590 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, | 585 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, |
| 591 Register first_return) { | 586 Register first_return) { |
| 592 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); | 587 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); |
| 593 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); | 588 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); |
| 594 if (!first_arg.is_valid()) { | 589 if (!first_arg.is_valid()) { |
| 595 DCHECK_EQ(0u, arg_count); | 590 DCHECK_EQ(0u, arg_count); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 if (i > 0 && operands[i] > 0) { | 684 if (i > 0 && operands[i] > 0) { |
| 690 Register start = Register::FromOperand(operands[i - 1]); | 685 Register start = Register::FromOperand(operands[i - 1]); |
| 691 Register end(start.index() + static_cast<int>(operands[i]) - 1); | 686 Register end(start.index() + static_cast<int>(operands[i]) - 1); |
| 692 if (!RegisterIsValid(start) || !RegisterIsValid(end) || start > end) { | 687 if (!RegisterIsValid(start) || !RegisterIsValid(end) || start > end) { |
| 693 return false; | 688 return false; |
| 694 } | 689 } |
| 695 } | 690 } |
| 696 break; | 691 break; |
| 697 } | 692 } |
| 698 case OperandType::kFlag8: | 693 case OperandType::kFlag8: |
| 699 case OperandType::kIntrinsicId: | |
| 700 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > | 694 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > |
| 701 OperandSize::kByte) { | 695 OperandSize::kByte) { |
| 702 return false; | 696 return false; |
| 703 } | 697 } |
| 704 break; | 698 break; |
| 705 case OperandType::kRuntimeId: | 699 case OperandType::kRuntimeId: |
| 706 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > | 700 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > |
| 707 OperandSize::kShort) { | 701 OperandSize::kShort) { |
| 708 return false; | 702 return false; |
| 709 } | 703 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 return Bytecode::kTailCall; | 917 return Bytecode::kTailCall; |
| 924 default: | 918 default: |
| 925 UNREACHABLE(); | 919 UNREACHABLE(); |
| 926 } | 920 } |
| 927 return Bytecode::kIllegal; | 921 return Bytecode::kIllegal; |
| 928 } | 922 } |
| 929 | 923 |
| 930 } // namespace interpreter | 924 } // namespace interpreter |
| 931 } // namespace internal | 925 } // namespace internal |
| 932 } // namespace v8 | 926 } // namespace v8 |
| OLD | NEW |