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

Unified Diff: src/interpreter/bytecodes.cc

Issue 1640213002: [Interpreter] Add option to trace bytecode execution. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments 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.cc » ('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 54763c1876d823791d523a2d2cde7bae5099eb3c..c17e95878adb6734577db6716db56b12376cc08b 100644
--- a/src/interpreter/bytecodes.cc
+++ b/src/interpreter/bytecodes.cc
@@ -380,22 +380,7 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
case interpreter::OperandType::kRegOut8:
case interpreter::OperandType::kRegOut16: {
Register reg = DecodeRegister(operand_start, op_type);
- if (reg.is_current_context()) {
- os << "<context>";
- } else if (reg.is_function_closure()) {
- os << "<closure>";
- } else if (reg.is_new_target()) {
- os << "<new.target>";
- } else if (reg.is_parameter()) {
- int parameter_index = reg.ToParameterIndex(parameter_count);
- if (parameter_index == 0) {
- os << "<this>";
- } else {
- os << "a" << parameter_index - 1;
- }
- } else {
- os << "r" << reg.index();
- }
+ os << reg.ToString(parameter_count);
break;
}
case interpreter::OperandType::kRegOutTriple8:
@@ -406,14 +391,10 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
case interpreter::OperandType::kRegPair8:
case interpreter::OperandType::kRegPair16: {
range += 1;
- Register reg = DecodeRegister(operand_start, op_type);
- if (reg.is_parameter()) {
- int parameter_index = reg.ToParameterIndex(parameter_count);
- DCHECK_GT(parameter_index, 0);
- os << "a" << parameter_index - range << "-" << parameter_index;
- } else {
- os << "r" << reg.index() << "-" << reg.index() + range;
- }
+ Register first_reg = DecodeRegister(operand_start, op_type);
+ Register last_reg = Register(first_reg.index() + range);
+ os << first_reg.ToString(parameter_count) << "-"
+ << last_reg.ToString(parameter_count);
break;
}
case interpreter::OperandType::kNone:
@@ -427,7 +408,6 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
return os;
}
-
std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) {
return os << Bytecodes::ToString(bytecode);
}
@@ -442,7 +422,6 @@ std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) {
return os << Bytecodes::OperandSizeToString(operand_size);
}
-
static const int kLastParamRegisterIndex =
-InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize;
static const int kFunctionClosureRegisterIndex =
@@ -569,6 +548,29 @@ bool Register::AreContiguous(Register reg1, Register reg2, Register reg3,
return true;
}
+std::string Register::ToString(int parameter_count) {
+ if (is_current_context()) {
+ return std::string("<context>");
+ } else if (is_function_closure()) {
+ return std::string("<closure>");
+ } else if (is_new_target()) {
+ return std::string("<new.target>");
+ } else if (is_parameter()) {
+ int parameter_index = ToParameterIndex(parameter_count);
+ if (parameter_index == 0) {
+ return std::string("<this>");
+ } else {
+ std::ostringstream s;
+ s << "a" << parameter_index - 1;
+ return s.str();
+ }
+ } else {
+ std::ostringstream s;
+ s << "r" << index();
+ return s.str();
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698