| 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 574 } |
| 575 | 575 |
| 576 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( | 576 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( |
| 577 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { | 577 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { |
| 578 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); | 578 DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size); |
| 579 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); | 579 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); |
| 580 if (!first_arg.is_valid()) { | 580 if (!first_arg.is_valid()) { |
| 581 DCHECK_EQ(0u, arg_count); | 581 DCHECK_EQ(0u, arg_count); |
| 582 first_arg = Register(0); | 582 first_arg = Register(0); |
| 583 } | 583 } |
| 584 Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) | 584 Bytecode bytecode; |
| 585 ? Bytecode::kInvokeIntrinsic | 585 uint32_t id; |
| 586 : Bytecode::kCallRuntime; | 586 if (IntrinsicsHelper::IsSupported(function_id)) { |
| 587 Output(bytecode, static_cast<uint16_t>(function_id), | 587 bytecode = Bytecode::kInvokeIntrinsic; |
| 588 RegisterOperand(first_arg), UnsignedOperand(arg_count)); | 588 id = static_cast<uint32_t>(IntrinsicsHelper::FromRuntimeId(function_id)); |
| 589 } else { |
| 590 bytecode = Bytecode::kCallRuntime; |
| 591 id = static_cast<uint32_t>(function_id); |
| 592 } |
| 593 Output(bytecode, id, RegisterOperand(first_arg), UnsignedOperand(arg_count)); |
| 589 return *this; | 594 return *this; |
| 590 } | 595 } |
| 591 | 596 |
| 592 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( | 597 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair( |
| 593 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, | 598 Runtime::FunctionId function_id, Register first_arg, size_t arg_count, |
| 594 Register first_return) { | 599 Register first_return) { |
| 595 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); | 600 DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size); |
| 596 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); | 601 DCHECK(Bytecodes::SizeForUnsignedOperand(function_id) <= OperandSize::kShort); |
| 597 if (!first_arg.is_valid()) { | 602 if (!first_arg.is_valid()) { |
| 598 DCHECK_EQ(0u, arg_count); | 603 DCHECK_EQ(0u, arg_count); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (i > 0 && operands[i] > 0) { | 692 if (i > 0 && operands[i] > 0) { |
| 688 Register start = Register::FromOperand(operands[i - 1]); | 693 Register start = Register::FromOperand(operands[i - 1]); |
| 689 Register end(start.index() + static_cast<int>(operands[i]) - 1); | 694 Register end(start.index() + static_cast<int>(operands[i]) - 1); |
| 690 if (!RegisterIsValid(start) || !RegisterIsValid(end) || start > end) { | 695 if (!RegisterIsValid(start) || !RegisterIsValid(end) || start > end) { |
| 691 return false; | 696 return false; |
| 692 } | 697 } |
| 693 } | 698 } |
| 694 break; | 699 break; |
| 695 } | 700 } |
| 696 case OperandType::kFlag8: | 701 case OperandType::kFlag8: |
| 702 case OperandType::kIntrinsicId: |
| 697 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > | 703 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > |
| 698 OperandSize::kByte) { | 704 OperandSize::kByte) { |
| 699 return false; | 705 return false; |
| 700 } | 706 } |
| 701 break; | 707 break; |
| 702 case OperandType::kRuntimeId: | 708 case OperandType::kRuntimeId: |
| 703 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > | 709 if (Bytecodes::SizeForUnsignedOperand(operands[i]) > |
| 704 OperandSize::kShort) { | 710 OperandSize::kShort) { |
| 705 return false; | 711 return false; |
| 706 } | 712 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 return Bytecode::kTailCall; | 926 return Bytecode::kTailCall; |
| 921 default: | 927 default: |
| 922 UNREACHABLE(); | 928 UNREACHABLE(); |
| 923 } | 929 } |
| 924 return Bytecode::kIllegal; | 930 return Bytecode::kIllegal; |
| 925 } | 931 } |
| 926 | 932 |
| 927 } // namespace interpreter | 933 } // namespace interpreter |
| 928 } // namespace internal | 934 } // namespace internal |
| 929 } // namespace v8 | 935 } // namespace v8 |
| OLD | NEW |