OLD | NEW |
---|---|
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/frames.h" | 7 #include "src/frames.h" |
8 #include "src/interpreter/bytecode-traits.h" | 8 #include "src/interpreter/bytecode-traits.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 | 64 |
65 // static | 65 // static |
66 Bytecode Bytecodes::FromByte(uint8_t value) { | 66 Bytecode Bytecodes::FromByte(uint8_t value) { |
67 Bytecode bytecode = static_cast<Bytecode>(value); | 67 Bytecode bytecode = static_cast<Bytecode>(value); |
68 DCHECK(bytecode <= Bytecode::kLast); | 68 DCHECK(bytecode <= Bytecode::kLast); |
69 return bytecode; | 69 return bytecode; |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 // static | 73 // static |
74 Bytecode Bytecodes::GetDebugBreak(Bytecode bytecode) { | |
75 switch (Size(bytecode)) { | |
76 #define CASE(Name, ...) \ | |
77 case BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize: \ | |
78 return Bytecode::k##Name; | |
79 DEBUG_BREAK_BYTECODE_LIST(CASE) | |
80 #undef CASE | |
81 default: | |
82 break; | |
83 } | |
84 return Bytecode::kLdaUndefined; | |
rmcilroy
2016/02/16 10:46:38
UNREACHABLE() and return static_cast<Bytecode>(-1)
Yang
2016/02/19 13:09:18
Done.
| |
85 } | |
86 | |
87 // static | |
74 int Bytecodes::Size(Bytecode bytecode) { | 88 int Bytecodes::Size(Bytecode bytecode) { |
75 DCHECK(bytecode <= Bytecode::kLast); | 89 DCHECK(bytecode <= Bytecode::kLast); |
76 switch (bytecode) { | 90 switch (bytecode) { |
77 #define CASE(Name, ...) \ | 91 #define CASE(Name, ...) \ |
78 case Bytecode::k##Name: \ | 92 case Bytecode::k##Name: \ |
79 return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize; | 93 return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize; |
80 BYTECODE_LIST(CASE) | 94 BYTECODE_LIST(CASE) |
81 #undef CASE | 95 #undef CASE |
82 } | 96 } |
83 UNREACHABLE(); | 97 UNREACHABLE(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 } | 274 } |
261 | 275 |
262 | 276 |
263 // static | 277 // static |
264 bool Bytecodes::IsCallOrNew(Bytecode bytecode) { | 278 bool Bytecodes::IsCallOrNew(Bytecode bytecode) { |
265 return bytecode == Bytecode::kCall || bytecode == Bytecode::kNew || | 279 return bytecode == Bytecode::kCall || bytecode == Bytecode::kNew || |
266 bytecode == Bytecode::kCallWide || bytecode == Bytecode::kNewWide; | 280 bytecode == Bytecode::kCallWide || bytecode == Bytecode::kNewWide; |
267 } | 281 } |
268 | 282 |
269 // static | 283 // static |
284 bool Bytecodes::IsDebugBreak(Bytecode bytecode) { | |
285 #define DEBUG_BREAK(Name, ...) \ | |
286 if (bytecode == Bytecode::k##Name) return true; | |
rmcilroy
2016/02/16 10:46:38
Could you do this as a switch statement instead pl
Yang
2016/02/19 13:09:17
Done.
| |
287 DEBUG_BREAK_BYTECODE_LIST(DEBUG_BREAK); | |
288 #undef DEBUG_BREAK | |
289 return false; | |
290 } | |
291 | |
292 // static | |
270 bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { | 293 bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { |
271 return bytecode == Bytecode::kReturn || IsJump(bytecode); | 294 return bytecode == Bytecode::kReturn || IsJump(bytecode); |
272 } | 295 } |
273 | 296 |
274 // static | 297 // static |
275 bool Bytecodes::IsIndexOperandType(OperandType operand_type) { | 298 bool Bytecodes::IsIndexOperandType(OperandType operand_type) { |
276 return operand_type == OperandType::kIdx8 || | 299 return operand_type == OperandType::kIdx8 || |
277 operand_type == OperandType::kIdx16; | 300 operand_type == OperandType::kIdx16; |
278 } | 301 } |
279 | 302 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 SNPrintF(buf, "%02x ", bytecode_start[i]); | 399 SNPrintF(buf, "%02x ", bytecode_start[i]); |
377 os << buf.start(); | 400 os << buf.start(); |
378 } | 401 } |
379 const int kBytecodeColumnSize = 6; | 402 const int kBytecodeColumnSize = 6; |
380 for (int i = bytecode_size; i < kBytecodeColumnSize; i++) { | 403 for (int i = bytecode_size; i < kBytecodeColumnSize; i++) { |
381 os << " "; | 404 os << " "; |
382 } | 405 } |
383 | 406 |
384 os << bytecode << " "; | 407 os << bytecode << " "; |
385 | 408 |
409 // Operands for the debug break are from the original instruction. | |
410 if (IsDebugBreak(bytecode)) return os; | |
411 | |
386 int number_of_operands = NumberOfOperands(bytecode); | 412 int number_of_operands = NumberOfOperands(bytecode); |
387 int range = 0; | 413 int range = 0; |
388 for (int i = 0; i < number_of_operands; i++) { | 414 for (int i = 0; i < number_of_operands; i++) { |
389 OperandType op_type = GetOperandType(bytecode, i); | 415 OperandType op_type = GetOperandType(bytecode, i); |
390 const uint8_t* operand_start = | 416 const uint8_t* operand_start = |
391 &bytecode_start[GetOperandOffset(bytecode, i)]; | 417 &bytecode_start[GetOperandOffset(bytecode, i)]; |
392 switch (op_type) { | 418 switch (op_type) { |
393 case interpreter::OperandType::kRegCount8: | 419 case interpreter::OperandType::kRegCount8: |
394 os << "#" << static_cast<unsigned int>(*operand_start); | 420 os << "#" << static_cast<unsigned int>(*operand_start); |
395 break; | 421 break; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 } else { | 625 } else { |
600 std::ostringstream s; | 626 std::ostringstream s; |
601 s << "r" << index(); | 627 s << "r" << index(); |
602 return s.str(); | 628 return s.str(); |
603 } | 629 } |
604 } | 630 } |
605 | 631 |
606 } // namespace interpreter | 632 } // namespace interpreter |
607 } // namespace internal | 633 } // namespace internal |
608 } // namespace v8 | 634 } // namespace v8 |
OLD | NEW |