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

Side by Side Diff: src/interpreter/bytecodes.cc

Issue 1283313003: [interpreter]: Update BytecodeArrayBuilder register handling. (Closed) Base URL: ssh://rmcilroy.lon.corp.google.com///usr/local/google/code/v8_full/v8@master
Patch Set: Fix define in OperandTypeToString 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
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 #include "src/interpreter/bytecode-array-builder.h"
8
7 namespace v8 { 9 namespace v8 {
8 namespace internal { 10 namespace internal {
9 namespace interpreter { 11 namespace interpreter {
10 12
11 // Maximum number of operands a bytecode may have. 13 // Maximum number of operands a bytecode may have.
12 static const int kMaxOperands = 3; 14 static const int kMaxOperands = 3;
13 15
14 // kBytecodeTable relies on kNone being the same as zero to detect length. 16 // kBytecodeTable relies on kNone being the same as zero to detect length.
15 STATIC_ASSERT(static_cast<int>(OperandType::kNone) == 0); 17 STATIC_ASSERT(static_cast<int>(OperandType::kNone) == 0);
16 18
(...skipping 14 matching lines...) Expand all
31 return #Name; 33 return #Name;
32 BYTECODE_LIST(CASE) 34 BYTECODE_LIST(CASE)
33 #undef CASE 35 #undef CASE
34 } 36 }
35 UNREACHABLE(); 37 UNREACHABLE();
36 return ""; 38 return "";
37 } 39 }
38 40
39 41
40 // static 42 // static
43 const char* Bytecodes::OperandTypeToString(OperandType operand_type) {
44 switch (operand_type) {
45 #define CASE(Name) \
46 case OperandType::k##Name: \
47 return #Name;
48 OPERAND_TYPE_LIST(CASE)
49 #undef CASE
50 }
51 UNREACHABLE();
52 return "";
53 }
54
55
56 // static
41 uint8_t Bytecodes::ToByte(Bytecode bytecode) { 57 uint8_t Bytecodes::ToByte(Bytecode bytecode) {
42 return static_cast<uint8_t>(bytecode); 58 return static_cast<uint8_t>(bytecode);
43 } 59 }
44 60
45 61
46 // static 62 // static
47 Bytecode Bytecodes::FromByte(uint8_t value) { 63 Bytecode Bytecodes::FromByte(uint8_t value) {
48 Bytecode bytecode = static_cast<Bytecode>(value); 64 Bytecode bytecode = static_cast<Bytecode>(value);
49 DCHECK(bytecode <= Bytecode::kLast); 65 DCHECK(bytecode <= Bytecode::kLast);
50 return bytecode; 66 return bytecode;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const uint8_t* operands_start = bytecode_start + 1; 123 const uint8_t* operands_start = bytecode_start + 1;
108 int operands_size = bytecode_size - 1; 124 int operands_size = bytecode_size - 1;
109 for (int i = 0; i < operands_size; i++) { 125 for (int i = 0; i < operands_size; i++) {
110 OperandType op_type = GetOperandType(bytecode, i); 126 OperandType op_type = GetOperandType(bytecode, i);
111 uint8_t operand = operands_start[i]; 127 uint8_t operand = operands_start[i];
112 switch (op_type) { 128 switch (op_type) {
113 case interpreter::OperandType::kImm8: 129 case interpreter::OperandType::kImm8:
114 os << "#" << static_cast<int>(operand); 130 os << "#" << static_cast<int>(operand);
115 break; 131 break;
116 case interpreter::OperandType::kReg: 132 case interpreter::OperandType::kReg:
117 os << "r" << static_cast<int>(operand); 133 os << "r" << Register::FromOperand(operand).index();
118 break; 134 break;
119 case interpreter::OperandType::kNone: 135 case interpreter::OperandType::kNone:
120 UNREACHABLE(); 136 UNREACHABLE();
121 break; 137 break;
122 } 138 }
123 if (i != operands_size - 1) { 139 if (i != operands_size - 1) {
124 os << ", "; 140 os << ", ";
125 } 141 }
126 } 142 }
127 return os; 143 return os;
128 } 144 }
129 145
130 146
131 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { 147 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) {
132 return os << Bytecodes::ToString(bytecode); 148 return os << Bytecodes::ToString(bytecode);
133 } 149 }
134 150
151
152 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) {
153 return os << Bytecodes::OperandTypeToString(operand_type);
154 }
155
135 } // namespace interpreter 156 } // namespace interpreter
136 } // namespace internal 157 } // namespace internal
137 } // namespace v8 158 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698