Chromium Code Reviews| Index: src/interpreter/bytecodes.cc |
| diff --git a/src/interpreter/bytecodes.cc b/src/interpreter/bytecodes.cc |
| index 5f7a9085aec33bdba04bcd4764a8cfac73a6e667..32dfaba70619c58ee553daf8135eab80b8690b57 100644 |
| --- a/src/interpreter/bytecodes.cc |
| +++ b/src/interpreter/bytecodes.cc |
| @@ -25,6 +25,19 @@ const char* Bytecodes::ToString(Bytecode bytecode) { |
| return ""; |
| } |
| +// static |
| +std::string Bytecodes::ToString(Bytecode bytecode, OperandScale operand_scale) { |
| + static const char kSeparator = '.'; |
| + |
| + std::string value(ToString(bytecode)); |
| + if (operand_scale > OperandScale::k1X) { |
| + Bytecode prefix_bytecode = OperandScaleToPrefixBytecode(operand_scale); |
| + std::string suffix = ToString(prefix_bytecode); |
| + return value.append(1, kSeparator).append(suffix); |
| + } else { |
| + return value; |
| + } |
| +} |
| // static |
| const char* Bytecodes::OperandTypeToString(OperandType operand_type) { |
| @@ -39,6 +52,20 @@ const char* Bytecodes::OperandTypeToString(OperandType operand_type) { |
| return ""; |
| } |
| +// static |
| +const char* Bytecodes::OperandScaleToString(OperandScale operand_scale) { |
| + switch (operand_scale) { |
| + case OperandScale::k1X: |
| + return "1X"; |
| + case OperandScale::k2X: |
| + return "2X"; |
| + case OperandScale::k4X: |
| + return "4X"; |
| + case OperandScale::kInvalid: |
| + UNREACHABLE(); |
| + } |
| + return ""; |
| +} |
| // static |
| const char* Bytecodes::OperandSizeToString(OperandSize operand_size) { |
| @@ -49,6 +76,8 @@ const char* Bytecodes::OperandSizeToString(OperandSize operand_size) { |
| return "Byte"; |
| case OperandSize::kShort: |
| return "Short"; |
| + case OperandSize::kQuad: |
| + return "Quad"; |
| } |
| UNREACHABLE(); |
| return ""; |
| @@ -72,31 +101,34 @@ Bytecode Bytecodes::FromByte(uint8_t value) { |
| // static |
| Bytecode Bytecodes::GetDebugBreak(Bytecode bytecode) { |
| - switch (Size(bytecode)) { |
| -#define CASE(Name, ...) \ |
| - case BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize: \ |
| - return Bytecode::k##Name; |
| - DEBUG_BREAK_BYTECODE_LIST(CASE) |
| -#undef CASE |
| - default: |
| - break; |
| + DCHECK(!IsDebugBreak(bytecode)); |
| + if (bytecode == Bytecode::kWide) { |
| + return Bytecode::kDebugBreakWide; |
| + } |
| + if (bytecode == Bytecode::kExtraWide) { |
| + return Bytecode::kDebugBreakExtraWide; |
| } |
| + int bytecode_size = Size(bytecode, OperandScale::k1X); |
| +#define RETURN_IF_DEBUG_BREAK_SIZE_MATCHES(Name, ...) \ |
| + if (bytecode_size == Size(Bytecode::k##Name, OperandScale::k1X)) { \ |
| + return Bytecode::k##Name; \ |
| + } |
| + DEBUG_BREAK_PLAIN_BYTECODE_LIST(RETURN_IF_DEBUG_BREAK_SIZE_MATCHES) |
| +#undef RETURN_IF_DEBUG_BREAK_SIZE_MATCHES |
| UNREACHABLE(); |
| - return static_cast<Bytecode>(-1); |
| + return Bytecode::kIllegal; |
| } |
| // static |
| -int Bytecodes::Size(Bytecode bytecode) { |
| - DCHECK(bytecode <= Bytecode::kLast); |
| - switch (bytecode) { |
| -#define CASE(Name, ...) \ |
| - case Bytecode::k##Name: \ |
| - return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize; |
| - BYTECODE_LIST(CASE) |
| -#undef CASE |
| +int Bytecodes::Size(Bytecode bytecode, OperandScale operand_scale) { |
| + int size = 1; |
| + for (int i = 0; i < NumberOfOperands(bytecode); i++) { |
| + OperandSize operand_size = GetOperandSize(bytecode, i, operand_scale); |
| + int delta = static_cast<int>(operand_size); |
|
rmcilroy
2016/03/17 17:30:50
Could you add a comment to OperandSize that we rel
oth
2016/03/21 09:16:54
Done. And OperandScale.
|
| + DCHECK(base::bits::IsPowerOfTwo32(static_cast<uint32_t>(delta))); |
| + size += delta; |
| } |
| - UNREACHABLE(); |
| - return 0; |
| + return size; |
| } |
| @@ -131,6 +163,39 @@ int Bytecodes::NumberOfRegisterOperands(Bytecode bytecode) { |
| } |
| // static |
| +Bytecode Bytecodes::OperandScaleToPrefixBytecode(OperandScale operand_scale) { |
| + switch (operand_scale) { |
| + case OperandScale::k4X: |
| + return Bytecode::kExtraWide; |
| + case OperandScale::k2X: |
| + return Bytecode::kWide; |
| + default: |
| + UNREACHABLE(); |
| + return Bytecode::kIllegal; |
| + } |
| +} |
| + |
| +// static |
| +bool Bytecodes::OperandScaleRequiresPrefixBytecode(OperandScale operand_scale) { |
| + return operand_scale != OperandScale::k1X; |
| +} |
| + |
| +// static |
| +OperandScale Bytecodes::PrefixBytecodeToOperandScale(Bytecode bytecode) { |
| + switch (bytecode) { |
| + case Bytecode::kExtraWide: |
| + case Bytecode::kDebugBreakExtraWide: |
| + return OperandScale::k4X; |
| + case Bytecode::kWide: |
| + case Bytecode::kDebugBreakWide: |
| + return OperandScale::k2X; |
| + default: |
| + UNREACHABLE(); |
| + return OperandScale::k1X; |
| + } |
| +} |
| + |
| +// static |
| OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) { |
| DCHECK(bytecode <= Bytecode::kLast); |
| switch (bytecode) { |
| @@ -144,21 +209,54 @@ OperandType Bytecodes::GetOperandType(Bytecode bytecode, int i) { |
| return OperandType::kNone; |
| } |
| +namespace { |
|
rmcilroy
2016/03/17 17:30:50
Could we do this magic in BytecodeTraits instead?
oth
2016/03/21 09:16:53
Done.
|
| -// static |
| -OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i) { |
| - DCHECK(bytecode <= Bytecode::kLast); |
| - switch (bytecode) { |
| -#define CASE(Name, ...) \ |
| - case Bytecode::k##Name: \ |
| - return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::GetOperandSize(i); |
| - BYTECODE_LIST(CASE) |
| +template <bool> |
| +struct OperandScaler { |
| + static int Multiply(int size, int operand_scale) { return 0; } |
| +}; |
| + |
| +template <> |
| +struct OperandScaler<false> { |
| + static int Multiply(int size, int operand_scale) { return size; } |
| +}; |
| + |
| +template <> |
| +struct OperandScaler<true> { |
| + static int Multiply(int size, int operand_scale) { |
| + return size * operand_scale; |
| + } |
| +}; |
| + |
| +static OperandSize ScaledOperandSize(OperandType operand_type, |
| + OperandScale operand_scale) { |
| + switch (operand_type) { |
| +#define CASE(Name, TypeInfo) \ |
| + case OperandType::k##Name: { \ |
| + OperandSize base_size = OperandTypeInfoTraits<TypeInfo>::kUnscaledSize; \ |
| + int size = \ |
| + OperandScaler<OperandTypeInfoTraits<TypeInfo>::kIsScalable>::Multiply( \ |
| + static_cast<int>(base_size), static_cast<int>(operand_scale)); \ |
| + OperandSize operand_size = static_cast<OperandSize>(size); \ |
| + DCHECK(operand_size == OperandSize::kByte || \ |
| + operand_size == OperandSize::kShort || \ |
| + operand_size == OperandSize::kQuad); \ |
| + return operand_size; \ |
| + } |
| + OPERAND_TYPE_LIST(CASE) |
| #undef CASE |
| } |
| UNREACHABLE(); |
| return OperandSize::kNone; |
| } |
| +} // namespace |
| +// static |
| +OperandSize Bytecodes::GetOperandSize(Bytecode bytecode, int i, |
| + OperandScale operand_scale) { |
| + OperandType op_type = GetOperandType(bytecode, i); |
| + return static_cast<OperandSize>(ScaledOperandSize(op_type, operand_scale)); |
| +} |
| // static |
| int Bytecodes::GetRegisterOperandBitmap(Bytecode bytecode) { |
| @@ -176,34 +274,24 @@ int Bytecodes::GetRegisterOperandBitmap(Bytecode bytecode) { |
| } |
| // static |
| -int Bytecodes::GetOperandOffset(Bytecode bytecode, int i) { |
| - DCHECK(bytecode <= Bytecode::kLast); |
| - switch (bytecode) { |
| -#define CASE(Name, ...) \ |
| - case Bytecode::k##Name: \ |
| - return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::GetOperandOffset(i); |
| - BYTECODE_LIST(CASE) |
| -#undef CASE |
| +int Bytecodes::GetOperandOffset(Bytecode bytecode, int i, |
| + OperandScale operand_scale) { |
| + int offset = 1; |
| + for (int operand_index = 0; operand_index < i; ++operand_index) { |
|
rmcilroy
2016/03/17 17:30:50
Could you add a TODO to calculate this at compile
oth
2016/03/21 09:16:53
Done.
|
| + OperandSize operand_size = |
| + GetOperandSize(bytecode, operand_index, operand_scale); |
| + offset += static_cast<int>(operand_size); |
| } |
| - UNREACHABLE(); |
| - return 0; |
| + return offset; |
| } |
| - |
| // static |
| -OperandSize Bytecodes::SizeOfOperand(OperandType operand_type) { |
| - switch (operand_type) { |
| -#define CASE(Name, Size) \ |
| - case OperandType::k##Name: \ |
| - return Size; |
| - OPERAND_TYPE_LIST(CASE) |
| -#undef CASE |
| - } |
| - UNREACHABLE(); |
| - return OperandSize::kNone; |
| +OperandSize Bytecodes::SizeOfOperand(OperandType operand_type, |
| + OperandScale operand_scale) { |
| + return static_cast<OperandSize>( |
| + ScaledOperandSize(operand_type, operand_scale)); |
| } |
| - |
| // static |
| bool Bytecodes::IsConditionalJumpImmediate(Bytecode bytecode) { |
| return bytecode == Bytecode::kJumpIfTrue || |
| @@ -227,24 +315,10 @@ bool Bytecodes::IsConditionalJumpConstant(Bytecode bytecode) { |
| bytecode == Bytecode::kJumpIfUndefinedConstant; |
| } |
| - |
| -// static |
| -bool Bytecodes::IsConditionalJumpConstantWide(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJumpIfTrueConstantWide || |
| - bytecode == Bytecode::kJumpIfFalseConstantWide || |
| - bytecode == Bytecode::kJumpIfToBooleanTrueConstantWide || |
| - bytecode == Bytecode::kJumpIfToBooleanFalseConstantWide || |
| - bytecode == Bytecode::kJumpIfNotHoleConstantWide || |
| - bytecode == Bytecode::kJumpIfNullConstantWide || |
| - bytecode == Bytecode::kJumpIfUndefinedConstantWide; |
| -} |
| - |
| - |
| // static |
| bool Bytecodes::IsConditionalJump(Bytecode bytecode) { |
| return IsConditionalJumpImmediate(bytecode) || |
| - IsConditionalJumpConstant(bytecode) || |
| - IsConditionalJumpConstantWide(bytecode); |
| + IsConditionalJumpConstant(bytecode); |
| } |
| @@ -260,34 +334,22 @@ bool Bytecodes::IsJumpConstant(Bytecode bytecode) { |
| IsConditionalJumpConstant(bytecode); |
| } |
| - |
| -// static |
| -bool Bytecodes::IsJumpConstantWide(Bytecode bytecode) { |
| - return bytecode == Bytecode::kJumpConstantWide || |
| - IsConditionalJumpConstantWide(bytecode); |
| -} |
| - |
| - |
| // static |
| bool Bytecodes::IsJump(Bytecode bytecode) { |
| - return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode) || |
| - IsJumpConstantWide(bytecode); |
| + return IsJumpImmediate(bytecode) || IsJumpConstant(bytecode); |
| } |
| // static |
| bool Bytecodes::IsCallOrNew(Bytecode bytecode) { |
| return bytecode == Bytecode::kCall || bytecode == Bytecode::kTailCall || |
| - bytecode == Bytecode::kNew || bytecode == Bytecode::kCallWide || |
| - bytecode == Bytecode::kTailCallWide || bytecode == Bytecode::kNewWide; |
| + bytecode == Bytecode::kNew; |
| } |
| // static |
| bool Bytecodes::IsCallRuntime(Bytecode bytecode) { |
| return bytecode == Bytecode::kCallRuntime || |
| - bytecode == Bytecode::kCallRuntimeWide || |
| - bytecode == Bytecode::kCallRuntimeForPair || |
| - bytecode == Bytecode::kCallRuntimeForPairWide; |
| + bytecode == Bytecode::kCallRuntimeForPair; |
| } |
| // static |
| @@ -304,31 +366,40 @@ bool Bytecodes::IsDebugBreak(Bytecode bytecode) { |
| } |
| // static |
| -bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { |
| - return bytecode == Bytecode::kReturn || IsJump(bytecode); |
| -} |
| - |
| -// static |
| -bool Bytecodes::IsIndexOperandType(OperandType operand_type) { |
| - return operand_type == OperandType::kIdx8 || |
| - operand_type == OperandType::kIdx16; |
| +bool Bytecodes::IsBytecodeWithScalableOperands(Bytecode bytecode) { |
| + switch (bytecode) { |
| +#define CASE(Name, ...) \ |
| + case Bytecode::k##Name: \ |
| + typedef BytecodeTraits<__VA_ARGS__, OPERAND_TERM> Name##Trait; \ |
| + return Name##Trait::IsScalable(); |
| + BYTECODE_LIST(CASE) |
| +#undef CASE |
| + } |
| + UNREACHABLE(); |
| + return false; |
| } |
| // static |
| -bool Bytecodes::IsImmediateOperandType(OperandType operand_type) { |
| - return operand_type == OperandType::kImm8; |
| +bool Bytecodes::IsPrefixScalingBytecode(Bytecode bytecode) { |
| + switch (bytecode) { |
| + case Bytecode::kExtraWide: |
| + case Bytecode::kDebugBreakExtraWide: |
| + case Bytecode::kWide: |
| + case Bytecode::kDebugBreakWide: |
| + return true; |
| + default: |
| + return false; |
| + } |
| } |
| // static |
| -bool Bytecodes::IsRegisterCountOperandType(OperandType operand_type) { |
| - return (operand_type == OperandType::kRegCount8 || |
| - operand_type == OperandType::kRegCount16); |
| +bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { |
| + return bytecode == Bytecode::kReturn || IsJump(bytecode); |
| } |
| // static |
| bool Bytecodes::IsMaybeRegisterOperandType(OperandType operand_type) { |
| - return (operand_type == OperandType::kMaybeReg8 || |
| - operand_type == OperandType::kMaybeReg16); |
| + return operand_type == OperandType::kMaybeReg; |
| } |
| // static |
| @@ -384,19 +455,68 @@ bool Bytecodes::IsRegisterOutputOperandType(OperandType operand_type) { |
| return false; |
| } |
| +// static |
| +bool Bytecodes::IsUnsignedOperandType(OperandType operand_type) { |
| + switch (operand_type) { |
| +#define CASE(Name, _) \ |
| + case OperandType::k##Name: \ |
| + return OperandTraits<OperandType::k##Name>::TypeInfo::kIsUnsigned; |
| + OPERAND_TYPE_LIST(CASE) |
| +#undef CASE |
| + } |
| + UNREACHABLE(); |
| + return false; |
| +} |
| + |
| +// static |
| +OperandScale Bytecodes::NextOperandScale(OperandScale operand_scale) { |
| + DCHECK(operand_scale >= OperandScale::k1X && |
| + operand_scale <= OperandScale::kMaxValid); |
| + return static_cast<OperandScale>(2 * static_cast<int>(operand_scale)); |
|
rmcilroy
2016/03/17 17:30:50
Also please add a comment in OperandScale that we
oth
2016/03/21 09:16:53
Done.
|
| +} |
| + |
| namespace { |
| -static Register DecodeRegister(const uint8_t* operand_start, |
| - OperandType operand_type) { |
| - switch (Bytecodes::SizeOfOperand(operand_type)) { |
| +static uint32_t DecodeUnsignedOperand(const uint8_t* operand_start, |
| + OperandType operand_type, |
| + OperandScale operand_scale) { |
| + DCHECK(Bytecodes::IsUnsignedOperandType(operand_type)); |
| + switch (Bytecodes::SizeOfOperand(operand_type, operand_scale)) { |
| case OperandSize::kByte: |
| - return Register::FromOperand(*operand_start); |
| + return *operand_start; |
| case OperandSize::kShort: |
| - return Register::FromWideOperand(ReadUnalignedUInt16(operand_start)); |
| - case OperandSize::kNone: { |
| + return ReadUnalignedUInt16(operand_start); |
| + case OperandSize::kQuad: |
| + return ReadUnalignedUInt32(operand_start); |
| + case OperandSize::kNone: |
| UNREACHABLE(); |
| - } |
| } |
| - return Register(); |
| + return 0; |
| +} |
| + |
| +static int32_t DecodeSignedOperand(const uint8_t* operand_start, |
| + OperandType operand_type, |
| + OperandScale operand_scale) { |
| + DCHECK(!Bytecodes::IsUnsignedOperandType(operand_type)); |
| + switch (Bytecodes::SizeOfOperand(operand_type, operand_scale)) { |
| + case OperandSize::kByte: |
| + return static_cast<int8_t>(*operand_start); |
| + case OperandSize::kShort: |
| + return static_cast<int16_t>(ReadUnalignedUInt16(operand_start)); |
| + case OperandSize::kQuad: |
| + return static_cast<int32_t>(ReadUnalignedUInt32(operand_start)); |
| + case OperandSize::kNone: |
| + UNREACHABLE(); |
| + } |
| + return 0; |
| +} |
| + |
| +static Register DecodeRegister(const uint8_t* operand_start, |
| + OperandType operand_type, |
| + OperandScale operand_scale) { |
| + DCHECK(Bytecodes::IsRegisterOperandType(operand_type)); |
| + int32_t operand = |
| + DecodeSignedOperand(operand_start, operand_type, operand_scale); |
| + return Register::FromOperand(operand); |
| } |
| } // namespace |
| @@ -407,18 +527,23 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, |
| Vector<char> buf = Vector<char>::New(50); |
| Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]); |
| - int bytecode_size = Bytecodes::Size(bytecode); |
| - |
| - for (int i = 0; i < bytecode_size; i++) { |
| + int prefix_offset = 0; |
| + OperandScale operand_scale = OperandScale::k1X; |
| + if (IsPrefixScalingBytecode(bytecode)) { |
| + prefix_offset = 1; |
| + bytecode = Bytecodes::FromByte(bytecode_start[1]); |
| + } |
| + int bytecode_size = Bytecodes::Size(bytecode, operand_scale); |
| + for (int i = 0; i < prefix_offset + bytecode_size; i++) { |
| SNPrintF(buf, "%02x ", bytecode_start[i]); |
| os << buf.start(); |
| } |
| const int kBytecodeColumnSize = 6; |
| - for (int i = bytecode_size; i < kBytecodeColumnSize; i++) { |
| + for (int i = prefix_offset + bytecode_size; i < kBytecodeColumnSize; i++) { |
| os << " "; |
| } |
| - os << bytecode << " "; |
| + os << Bytecodes::ToString(bytecode, operand_scale) << " "; |
| // Operands for the debug break are from the original instruction. |
| if (IsDebugBreak(bytecode)) return os; |
| @@ -428,42 +553,41 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, |
| for (int i = 0; i < number_of_operands; i++) { |
| OperandType op_type = GetOperandType(bytecode, i); |
| const uint8_t* operand_start = |
| - &bytecode_start[GetOperandOffset(bytecode, i)]; |
| + &bytecode_start[prefix_offset + |
| + GetOperandOffset(bytecode, i, operand_scale)]; |
| switch (op_type) { |
| - case interpreter::OperandType::kRegCount8: |
| - os << "#" << static_cast<unsigned int>(*operand_start); |
| - break; |
| - case interpreter::OperandType::kRegCount16: |
| - os << '#' << ReadUnalignedUInt16(operand_start); |
| + case interpreter::OperandType::kRegCount: |
| + os << "#" |
| + << DecodeUnsignedOperand(operand_start, op_type, operand_scale); |
| break; |
| - case interpreter::OperandType::kIdx8: |
| - os << "[" << static_cast<unsigned int>(*operand_start) << "]"; |
| + case interpreter::OperandType::kIdx: |
| + case interpreter::OperandType::kRuntimeId: |
| + os << "[" |
| + << DecodeUnsignedOperand(operand_start, op_type, operand_scale) |
| + << "]"; |
| break; |
| - case interpreter::OperandType::kIdx16: |
| - os << "[" << ReadUnalignedUInt16(operand_start) << "]"; |
| + case interpreter::OperandType::kImm: |
| + os << "[" << DecodeSignedOperand(operand_start, op_type, operand_scale) |
| + << "]"; |
| break; |
| - case interpreter::OperandType::kImm8: |
| - os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); |
| + case interpreter::OperandType::kFlag8: |
| + os << "#" |
| + << DecodeUnsignedOperand(operand_start, op_type, operand_scale); |
| break; |
| - case interpreter::OperandType::kMaybeReg8: |
| - case interpreter::OperandType::kMaybeReg16: |
| - case interpreter::OperandType::kReg8: |
| - case interpreter::OperandType::kReg16: |
| - case interpreter::OperandType::kRegOut8: |
| - case interpreter::OperandType::kRegOut16: { |
| - Register reg = DecodeRegister(operand_start, op_type); |
| + case interpreter::OperandType::kMaybeReg: |
| + case interpreter::OperandType::kReg: |
| + case interpreter::OperandType::kRegOut: { |
| + Register reg = DecodeRegister(operand_start, op_type, operand_scale); |
| os << reg.ToString(parameter_count); |
| break; |
| } |
| - case interpreter::OperandType::kRegOutTriple8: |
| - case interpreter::OperandType::kRegOutTriple16: |
| + case interpreter::OperandType::kRegOutTriple: |
| range += 1; |
| - case interpreter::OperandType::kRegOutPair8: |
| - case interpreter::OperandType::kRegOutPair16: |
| - case interpreter::OperandType::kRegPair8: |
| - case interpreter::OperandType::kRegPair16: { |
| + case interpreter::OperandType::kRegOutPair: |
| + case interpreter::OperandType::kRegPair: { |
| range += 1; |
| - Register first_reg = DecodeRegister(operand_start, op_type); |
| + Register first_reg = |
| + DecodeRegister(operand_start, op_type, operand_scale); |
| Register last_reg = Register(first_reg.index() + range); |
| os << first_reg.ToString(parameter_count) << "-" |
| << last_reg.ToString(parameter_count); |
| @@ -484,14 +608,16 @@ std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
| return os << Bytecodes::ToString(bytecode); |
| } |
| - |
| -std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { |
| - return os << Bytecodes::OperandTypeToString(operand_type); |
| +std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { |
| + return os << Bytecodes::OperandSizeToString(operand_size); |
| } |
| +std::ostream& operator<<(std::ostream& os, const OperandScale& operand_scale) { |
| + return os << Bytecodes::OperandScaleToString(operand_scale); |
| +} |
| -std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { |
| - return os << Bytecodes::OperandSizeToString(operand_size); |
| +std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { |
| + return os << Bytecodes::OperandTypeToString(operand_type); |
| } |
| static const int kLastParamRegisterIndex = |
| @@ -503,29 +629,17 @@ static const int kCurrentContextRegisterIndex = |
| static const int kNewTargetRegisterIndex = |
| -InterpreterFrameConstants::kNewTargetFromRegisterPointer / kPointerSize; |
| -// The register space is a signed 16-bit space. Register operands |
| -// occupy range above 0. Parameter indices are biased with the |
| -// negative value kLastParamRegisterIndex for ease of access in the |
| -// interpreter. |
| -static const int kMaxParameterIndex = kMaxInt16 + kLastParamRegisterIndex; |
| -static const int kMaxRegisterIndex = -kMinInt16; |
| -static const int kMaxReg8Index = -kMinInt8; |
| -static const int kMinReg8Index = -kMaxInt8; |
| -static const int kMaxReg16Index = -kMinInt16; |
| -static const int kMinReg16Index = -kMaxInt16; |
| - |
| bool Register::is_byte_operand() const { |
| - return index_ >= kMinReg8Index && index_ <= kMaxReg8Index; |
| + return index_ >= -kMaxInt8 && index_ <= -kMinInt8; |
| } |
| bool Register::is_short_operand() const { |
| - return index_ >= kMinReg16Index && index_ <= kMaxReg16Index; |
| + return index_ >= -kMaxInt16 && index_ <= -kMinInt16; |
| } |
| Register Register::FromParameterIndex(int index, int parameter_count) { |
| DCHECK_GE(index, 0); |
| DCHECK_LT(index, parameter_count); |
| - DCHECK_LE(parameter_count, kMaxParameterIndex + 1); |
| int register_index = kLastParamRegisterIndex - parameter_count + index + 1; |
| DCHECK_LT(register_index, 0); |
| return Register(register_index); |
| @@ -565,44 +679,6 @@ bool Register::is_new_target() const { |
| return index() == kNewTargetRegisterIndex; |
| } |
| -int Register::MaxParameterIndex() { return kMaxParameterIndex; } |
| - |
| -int Register::MaxRegisterIndex() { return kMaxRegisterIndex; } |
| - |
| -int Register::MaxRegisterIndexForByteOperand() { return kMaxReg8Index; } |
| - |
| -uint8_t Register::ToOperand() const { |
| - DCHECK(is_byte_operand()); |
| - return static_cast<uint8_t>(-index_); |
| -} |
| - |
| - |
| -Register Register::FromOperand(uint8_t operand) { |
| - return Register(-static_cast<int8_t>(operand)); |
| -} |
| - |
| - |
| -uint16_t Register::ToWideOperand() const { |
| - DCHECK(is_short_operand()); |
| - return static_cast<uint16_t>(-index_); |
| -} |
| - |
| - |
| -Register Register::FromWideOperand(uint16_t operand) { |
| - return Register(-static_cast<int16_t>(operand)); |
| -} |
| - |
| - |
| -uint32_t Register::ToRawOperand() const { |
| - return static_cast<uint32_t>(-index_); |
| -} |
| - |
| - |
| -Register Register::FromRawOperand(uint32_t operand) { |
| - return Register(-static_cast<int32_t>(operand)); |
| -} |
| - |
| - |
| bool Register::AreContiguous(Register reg1, Register reg2, Register reg3, |
| Register reg4, Register reg5) { |
| if (reg1.index() + 1 != reg2.index()) { |