| Index: src/interpreter/bytecode-array-builder.cc
|
| diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
|
| index 7b931e405923613ff93771d7f1bb851cb66fc15a..de57a8a9d96e59376da5c914b615faa8cfd74022 100644
|
| --- a/src/interpreter/bytecode-array-builder.cc
|
| +++ b/src/interpreter/bytecode-array-builder.cc
|
| @@ -1055,6 +1055,7 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor,
|
|
|
| BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
|
| Runtime::FunctionId function_id, Register first_arg, size_t arg_count) {
|
| + DCHECK_EQ(1, Runtime::FunctionForId(function_id)->result_size);
|
| DCHECK(FitsInIdx16Operand(function_id));
|
| DCHECK(FitsInIdx8Operand(arg_count));
|
| if (!first_arg.is_valid()) {
|
| @@ -1067,6 +1068,23 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
|
| }
|
|
|
|
|
| +BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntimeForPair(
|
| + Runtime::FunctionId function_id, Register first_arg, size_t arg_count,
|
| + Register first_return) {
|
| + DCHECK_EQ(2, Runtime::FunctionForId(function_id)->result_size);
|
| + DCHECK(FitsInIdx16Operand(function_id));
|
| + DCHECK(FitsInIdx8Operand(arg_count));
|
| + if (!first_arg.is_valid()) {
|
| + DCHECK_EQ(0u, arg_count);
|
| + first_arg = Register(0);
|
| + }
|
| + Output(Bytecode::kCallRuntimeForPair, static_cast<uint16_t>(function_id),
|
| + first_arg.ToOperand(), static_cast<uint8_t>(arg_count),
|
| + first_return.ToOperand());
|
| + return *this;
|
| +}
|
| +
|
| +
|
| BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index,
|
| Register receiver,
|
| size_t arg_count) {
|
| @@ -1196,6 +1214,21 @@ bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const {
|
| }
|
|
|
|
|
| +bool BytecodeArrayBuilder::RegisterIsValid(Register reg) const {
|
| + if (reg.is_function_context() || reg.is_function_closure() ||
|
| + reg.is_new_target()) {
|
| + return true;
|
| + } else if (reg.is_parameter()) {
|
| + int parameter_index = reg.ToParameterIndex(parameter_count_);
|
| + return parameter_index >= 0 && parameter_index < parameter_count_;
|
| + } else if (reg.index() < fixed_register_count()) {
|
| + return true;
|
| + } else {
|
| + return TemporaryRegisterIsLive(reg);
|
| + }
|
| +}
|
| +
|
| +
|
| bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
|
| uint32_t operand_value) const {
|
| OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index);
|
| @@ -1214,38 +1247,22 @@ bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
|
| return true;
|
| }
|
| // Fall-through to kReg8 case.
|
| - case OperandType::kReg8: {
|
| - Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value));
|
| - if (reg.is_function_context() || reg.is_function_closure() ||
|
| - reg.is_new_target()) {
|
| - return true;
|
| - } else if (reg.is_parameter()) {
|
| - int parameter_index = reg.ToParameterIndex(parameter_count_);
|
| - return parameter_index >= 0 && parameter_index < parameter_count_;
|
| - } else if (reg.index() < fixed_register_count()) {
|
| - return true;
|
| - } else {
|
| - return TemporaryRegisterIsLive(reg);
|
| - }
|
| + case OperandType::kReg8:
|
| + return RegisterIsValid(
|
| + Register::FromOperand(static_cast<uint8_t>(operand_value)));
|
| + case OperandType::kRegPair8: {
|
| + Register reg0 =
|
| + Register::FromOperand(static_cast<uint8_t>(operand_value));
|
| + Register reg1 = Register(reg0.index() + 1);
|
| + return RegisterIsValid(reg0) && RegisterIsValid(reg1);
|
| }
|
| - case OperandType::kReg16: {
|
| + case OperandType::kReg16:
|
| if (bytecode != Bytecode::kExchange &&
|
| bytecode != Bytecode::kExchangeWide) {
|
| return false;
|
| }
|
| - Register reg =
|
| - Register::FromWideOperand(static_cast<uint16_t>(operand_value));
|
| - if (reg.is_function_context() || reg.is_function_closure() ||
|
| - reg.is_new_target()) {
|
| - return false;
|
| - } else if (reg.is_parameter()) {
|
| - return false;
|
| - } else if (reg.index() < fixed_register_count()) {
|
| - return true;
|
| - } else {
|
| - return TemporaryRegisterIsLive(reg);
|
| - }
|
| - }
|
| + return RegisterIsValid(
|
| + Register::FromWideOperand(static_cast<uint16_t>(operand_value)));
|
| }
|
| UNREACHABLE();
|
| return false;
|
|
|