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

Unified Diff: src/interpreter/bytecodes.cc

Issue 1259193004: [Interpreter] Consistency fixes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove redundant argument to Bytecodes::Decode(). Created 5 years, 4 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/objects.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 16a71a3ed63221c352418ff7d4532836ed3d1b58..5cb2ddfbb2b1f241a0696007dc6d9858bdcc9f5a 100644
--- a/src/interpreter/bytecodes.cc
+++ b/src/interpreter/bytecodes.cc
@@ -86,6 +86,48 @@ int Bytecodes::MaximumNumberOfOperands() { return kMaxOperands; }
int Bytecodes::MaximumSize() { return 1 + kMaxOperands; }
+// static
+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++) {
+ SNPrintF(buf, "%02x ", bytecode_start[i]);
+ os << buf.start();
+ }
+ for (int i = bytecode_size; i < Bytecodes::MaximumSize(); i++) {
+ os << " ";
+ }
+
+ os << bytecode << " ";
+
+ const uint8_t* operands_start = bytecode_start + 1;
+ int operands_size = bytecode_size - 1;
+ for (int i = 0; i < operands_size; i++) {
+ OperandType op_type = GetOperandType(bytecode, i);
+ uint8_t operand = operands_start[i];
+ switch (op_type) {
+ case interpreter::OperandType::kImm8:
+ os << "#" << static_cast<int>(operand);
+ break;
+ case interpreter::OperandType::kReg:
+ os << "r" << static_cast<int>(operand);
+ break;
+ case interpreter::OperandType::kNone:
+ UNREACHABLE();
+ break;
+ }
+ if (i != operands_size - 1) {
+ os << ", ";
+ }
+ }
+ return os;
+}
+
+
std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) {
return os << Bytecodes::ToString(bytecode);
}
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698