Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: src/interpreter/bytecodes.cc

Issue 1595103006: [Interpreter] Preparation for wide registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecodes.cc
diff --git a/src/interpreter/bytecodes.cc b/src/interpreter/bytecodes.cc
index 1a82f6c117e800e606080a4427668427116f8cd7..983bf9b3430dd82f2bd88a2b57e1b78db3a01243 100644
--- a/src/interpreter/bytecodes.cc
+++ b/src/interpreter/bytecodes.cc
@@ -232,6 +232,23 @@ bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) {
}
+namespace {
+static Register DecodeRegister(const uint8_t* operand_start,
+ OperandType operand_type) {
+ switch (Bytecodes::SizeOfOperand(operand_type)) {
+ case OperandSize::kByte:
+ return Register::FromOperand(*operand_start);
+ case OperandSize::kShort:
+ return Register::FromWideOperand(ReadUnalignedUInt16(operand_start));
+ case OperandSize::kNone: {
+ UNREACHABLE();
+ }
+ }
+ return Register();
+}
+} // namespace
+
+
// static
std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
int parameter_count) {
@@ -257,10 +274,10 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
const uint8_t* operand_start =
&bytecode_start[GetOperandOffset(bytecode, i)];
switch (op_type) {
- case interpreter::OperandType::kCount8:
+ case interpreter::OperandType::kRegCount8:
os << "#" << static_cast<unsigned int>(*operand_start);
break;
- case interpreter::OperandType::kCount16:
+ case interpreter::OperandType::kRegCount16:
os << '#' << ReadUnalignedUInt16(operand_start);
break;
case interpreter::OperandType::kIdx8:
@@ -272,9 +289,11 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
case interpreter::OperandType::kImm8:
os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start));
break;
+ case interpreter::OperandType::kMaybeReg8:
+ case interpreter::OperandType::kMaybeReg16:
case interpreter::OperandType::kReg8:
- case interpreter::OperandType::kMaybeReg8: {
- Register reg = Register::FromOperand(*operand_start);
+ case interpreter::OperandType::kReg16: {
+ Register reg = DecodeRegister(operand_start, op_type);
if (reg.is_function_context()) {
os << "<context>";
} else if (reg.is_function_closure()) {
@@ -294,30 +313,20 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
break;
}
case interpreter::OperandType::kRegPair8:
- case interpreter::OperandType::kRegTriple8: {
- Register reg = Register::FromOperand(*operand_start);
+ case interpreter::OperandType::kRegTriple8:
+ case interpreter::OperandType::kRegPair16:
+ case interpreter::OperandType::kRegTriple16: {
+ Register reg = DecodeRegister(operand_start, op_type);
int range = op_type == interpreter::OperandType::kRegPair8 ? 1 : 2;
if (reg.is_parameter()) {
int parameter_index = reg.ToParameterIndex(parameter_count);
- DCHECK_NE(parameter_index, 0);
+ DCHECK_GT(parameter_index, 0);
os << "a" << parameter_index - range << "-" << parameter_index;
} else {
os << "r" << reg.index() << "-" << reg.index() + range;
}
break;
}
- case interpreter::OperandType::kReg16: {
- Register reg =
- Register::FromWideOperand(ReadUnalignedUInt16(operand_start));
- if (reg.is_parameter()) {
- int parameter_index = reg.ToParameterIndex(parameter_count);
- DCHECK_NE(parameter_index, 0);
- os << "a" << parameter_index - 1;
- } else {
- os << "r" << reg.index();
- }
- break;
- }
case interpreter::OperandType::kNone:
UNREACHABLE();
break;
@@ -433,6 +442,16 @@ Register Register::FromWideOperand(uint16_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()) {
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698