| Index: src/interpreter/bytecode-array-builder.cc
|
| diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
|
| index e34c6337b18db291a2c44ac3ad54dd0c1cf22617..67023a2dda7c65f00d590a3543d05b40f910d0ff 100644
|
| --- a/src/interpreter/bytecode-array-builder.cc
|
| +++ b/src/interpreter/bytecode-array-builder.cc
|
| @@ -109,12 +109,13 @@ Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
|
|
|
|
|
| template <size_t N>
|
| -void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) {
|
| +void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N],
|
| + RegisterValidityCheck reg_check) {
|
| DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), static_cast<int>(N));
|
| last_bytecode_start_ = bytecodes()->size();
|
| bytecodes()->push_back(Bytecodes::ToByte(bytecode));
|
| for (int i = 0; i < static_cast<int>(N); i++) {
|
| - DCHECK(OperandIsValid(bytecode, i, operands[i]));
|
| + DCHECK(OperandIsValid(bytecode, i, operands[i], reg_check));
|
| switch (Bytecodes::GetOperandSize(bytecode, i)) {
|
| case OperandSize::kNone:
|
| UNREACHABLE();
|
| @@ -134,22 +135,25 @@ void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) {
|
|
|
|
|
| void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0,
|
| - uint32_t operand1, uint32_t operand2) {
|
| + uint32_t operand1, uint32_t operand2,
|
| + RegisterValidityCheck reg_check) {
|
| uint32_t operands[] = {operand0, operand1, operand2};
|
| - Output(bytecode, operands);
|
| + Output(bytecode, operands, reg_check);
|
| }
|
|
|
|
|
| void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0,
|
| - uint32_t operand1) {
|
| + uint32_t operand1,
|
| + RegisterValidityCheck reg_check) {
|
| uint32_t operands[] = {operand0, operand1};
|
| - Output(bytecode, operands);
|
| + Output(bytecode, operands, reg_check);
|
| }
|
|
|
|
|
| -void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0) {
|
| +void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0,
|
| + RegisterValidityCheck reg_check) {
|
| uint32_t operands[] = {operand0};
|
| - Output(bytecode, operands);
|
| + Output(bytecode, operands, reg_check);
|
| }
|
|
|
|
|
| @@ -771,9 +775,14 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable,
|
| BytecodeArrayBuilder& BytecodeArrayBuilder::New(Register constructor,
|
| Register first_arg,
|
| size_t arg_count) {
|
| + RegisterValidityCheck reg_check = RegisterValidityCheck::kCheckRegisters;
|
| + if (arg_count == 0) {
|
| + first_arg = Register(0);
|
| + reg_check = RegisterValidityCheck::kDontCheckRegisters;
|
| + }
|
| DCHECK(FitsInIdx8Operand(arg_count));
|
| Output(Bytecode::kNew, constructor.ToOperand(), first_arg.ToOperand(),
|
| - static_cast<uint8_t>(arg_count));
|
| + static_cast<uint8_t>(arg_count), reg_check);
|
| return *this;
|
| }
|
|
|
| @@ -782,8 +791,24 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
|
| Runtime::FunctionId function_id, Register first_arg, size_t arg_count) {
|
| DCHECK(FitsInIdx16Operand(function_id));
|
| DCHECK(FitsInIdx8Operand(arg_count));
|
| + RegisterValidityCheck reg_check = RegisterValidityCheck::kCheckRegisters;
|
| + if (arg_count == 0) {
|
| + first_arg = Register(0);
|
| + reg_check = RegisterValidityCheck::kDontCheckRegisters;
|
| + }
|
| Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id),
|
| - first_arg.ToOperand(), static_cast<uint8_t>(arg_count));
|
| + first_arg.ToOperand(), static_cast<uint8_t>(arg_count), reg_check);
|
| + return *this;
|
| +}
|
| +
|
| +
|
| +BytecodeArrayBuilder& BytecodeArrayBuilder::CallJSRuntime(int context_index,
|
| + Register receiver,
|
| + size_t arg_count) {
|
| + DCHECK(FitsInIdx16Operand(context_index));
|
| + DCHECK(FitsInIdx8Operand(arg_count));
|
| + Output(Bytecode::kCallJSRuntime, static_cast<uint16_t>(context_index),
|
| + receiver.ToOperand(), static_cast<uint8_t>(arg_count));
|
| return *this;
|
| }
|
|
|
| @@ -887,8 +912,9 @@ bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const {
|
| }
|
|
|
|
|
| -bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
|
| - uint32_t operand_value) const {
|
| +bool BytecodeArrayBuilder::OperandIsValid(
|
| + Bytecode bytecode, int operand_index, uint32_t operand_value,
|
| + RegisterValidityCheck reg_check) const {
|
| OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index);
|
| switch (operand_type) {
|
| case OperandType::kNone:
|
| @@ -901,7 +927,9 @@ bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
|
| return static_cast<uint8_t>(operand_value) == operand_value;
|
| case OperandType::kReg8: {
|
| Register reg = Register::FromOperand(static_cast<uint8_t>(operand_value));
|
| - if (reg.is_function_context() || reg.is_function_closure()) {
|
| + if (reg_check == RegisterValidityCheck::kDontCheckRegisters) {
|
| + return true;
|
| + } else if (reg.is_function_context() || reg.is_function_closure()) {
|
| return true;
|
| } else if (reg.is_parameter()) {
|
| int parameter_index = reg.ToParameterIndex(parameter_count_);
|
|
|