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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecodes.h" 5 #include "src/interpreter/bytecodes.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 80
81 // static 81 // static
82 int Bytecodes::MaximumNumberOfOperands() { return kMaxOperands; } 82 int Bytecodes::MaximumNumberOfOperands() { return kMaxOperands; }
83 83
84 84
85 // static 85 // static
86 int Bytecodes::MaximumSize() { return 1 + kMaxOperands; } 86 int Bytecodes::MaximumSize() { return 1 + kMaxOperands; }
87 87
88 88
89 // static
90 std::ostream& Bytecodes::Decode(std::ostream& os,
91 const uint8_t* bytecode_start) {
92 Vector<char> buf = Vector<char>::New(50);
93
94 Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]);
95 int bytecode_size = Bytecodes::Size(bytecode);
96
97 for (int i = 0; i < bytecode_size; i++) {
98 SNPrintF(buf, "%02x ", bytecode_start[i]);
99 os << buf.start();
100 }
101 for (int i = bytecode_size; i < Bytecodes::MaximumSize(); i++) {
102 os << " ";
103 }
104
105 os << bytecode << " ";
106
107 const uint8_t* operands_start = bytecode_start + 1;
108 int operands_size = bytecode_size - 1;
109 for (int i = 0; i < operands_size; i++) {
110 OperandType op_type = GetOperandType(bytecode, i);
111 uint8_t operand = operands_start[i];
112 switch (op_type) {
113 case interpreter::OperandType::kImm8:
114 os << "#" << static_cast<int>(operand);
115 break;
116 case interpreter::OperandType::kReg:
117 os << "r" << static_cast<int>(operand);
118 break;
119 case interpreter::OperandType::kNone:
120 UNREACHABLE();
121 break;
122 }
123 if (i != operands_size - 1) {
124 os << ", ";
125 }
126 }
127 return os;
128 }
129
130
89 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { 131 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) {
90 return os << Bytecodes::ToString(bytecode); 132 return os << Bytecodes::ToString(bytecode);
91 } 133 }
92 134
93 } // namespace interpreter 135 } // namespace interpreter
94 } // namespace internal 136 } // namespace internal
95 } // namespace v8 137 } // namespace v8
OLDNEW
« 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