| 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 UNREACHABLE(); |
| 85 return static_cast<Bytecode>(-1); |
| 86 } |
| 87 |
| 88 // static |
| 74 int Bytecodes::Size(Bytecode bytecode) { | 89 int Bytecodes::Size(Bytecode bytecode) { |
| 75 DCHECK(bytecode <= Bytecode::kLast); | 90 DCHECK(bytecode <= Bytecode::kLast); |
| 76 switch (bytecode) { | 91 switch (bytecode) { |
| 77 #define CASE(Name, ...) \ | 92 #define CASE(Name, ...) \ |
| 78 case Bytecode::k##Name: \ | 93 case Bytecode::k##Name: \ |
| 79 return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize; | 94 return BytecodeTraits<__VA_ARGS__, OPERAND_TERM>::kSize; |
| 80 BYTECODE_LIST(CASE) | 95 BYTECODE_LIST(CASE) |
| 81 #undef CASE | 96 #undef CASE |
| 82 } | 97 } |
| 83 UNREACHABLE(); | 98 UNREACHABLE(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 276 |
| 262 | 277 |
| 263 // static | 278 // static |
| 264 bool Bytecodes::IsCallOrNew(Bytecode bytecode) { | 279 bool Bytecodes::IsCallOrNew(Bytecode bytecode) { |
| 265 return bytecode == Bytecode::kCall || bytecode == Bytecode::kTailCall || | 280 return bytecode == Bytecode::kCall || bytecode == Bytecode::kTailCall || |
| 266 bytecode == Bytecode::kNew || bytecode == Bytecode::kCallWide || | 281 bytecode == Bytecode::kNew || bytecode == Bytecode::kCallWide || |
| 267 bytecode == Bytecode::kTailCallWide || bytecode == Bytecode::kNewWide; | 282 bytecode == Bytecode::kTailCallWide || bytecode == Bytecode::kNewWide; |
| 268 } | 283 } |
| 269 | 284 |
| 270 // static | 285 // static |
| 286 bool Bytecodes::IsDebugBreak(Bytecode bytecode) { |
| 287 switch (bytecode) { |
| 288 #define CASE(Name, ...) case Bytecode::k##Name: |
| 289 DEBUG_BREAK_BYTECODE_LIST(CASE); |
| 290 #undef CASE |
| 291 return true; |
| 292 default: |
| 293 break; |
| 294 } |
| 295 return false; |
| 296 } |
| 297 |
| 298 // static |
| 271 bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { | 299 bool Bytecodes::IsJumpOrReturn(Bytecode bytecode) { |
| 272 return bytecode == Bytecode::kReturn || IsJump(bytecode); | 300 return bytecode == Bytecode::kReturn || IsJump(bytecode); |
| 273 } | 301 } |
| 274 | 302 |
| 275 // static | 303 // static |
| 276 bool Bytecodes::IsIndexOperandType(OperandType operand_type) { | 304 bool Bytecodes::IsIndexOperandType(OperandType operand_type) { |
| 277 return operand_type == OperandType::kIdx8 || | 305 return operand_type == OperandType::kIdx8 || |
| 278 operand_type == OperandType::kIdx16; | 306 operand_type == OperandType::kIdx16; |
| 279 } | 307 } |
| 280 | 308 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 SNPrintF(buf, "%02x ", bytecode_start[i]); | 405 SNPrintF(buf, "%02x ", bytecode_start[i]); |
| 378 os << buf.start(); | 406 os << buf.start(); |
| 379 } | 407 } |
| 380 const int kBytecodeColumnSize = 6; | 408 const int kBytecodeColumnSize = 6; |
| 381 for (int i = bytecode_size; i < kBytecodeColumnSize; i++) { | 409 for (int i = bytecode_size; i < kBytecodeColumnSize; i++) { |
| 382 os << " "; | 410 os << " "; |
| 383 } | 411 } |
| 384 | 412 |
| 385 os << bytecode << " "; | 413 os << bytecode << " "; |
| 386 | 414 |
| 415 // Operands for the debug break are from the original instruction. |
| 416 if (IsDebugBreak(bytecode)) return os; |
| 417 |
| 387 int number_of_operands = NumberOfOperands(bytecode); | 418 int number_of_operands = NumberOfOperands(bytecode); |
| 388 int range = 0; | 419 int range = 0; |
| 389 for (int i = 0; i < number_of_operands; i++) { | 420 for (int i = 0; i < number_of_operands; i++) { |
| 390 OperandType op_type = GetOperandType(bytecode, i); | 421 OperandType op_type = GetOperandType(bytecode, i); |
| 391 const uint8_t* operand_start = | 422 const uint8_t* operand_start = |
| 392 &bytecode_start[GetOperandOffset(bytecode, i)]; | 423 &bytecode_start[GetOperandOffset(bytecode, i)]; |
| 393 switch (op_type) { | 424 switch (op_type) { |
| 394 case interpreter::OperandType::kRegCount8: | 425 case interpreter::OperandType::kRegCount8: |
| 395 os << "#" << static_cast<unsigned int>(*operand_start); | 426 os << "#" << static_cast<unsigned int>(*operand_start); |
| 396 break; | 427 break; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 } else { | 631 } else { |
| 601 std::ostringstream s; | 632 std::ostringstream s; |
| 602 s << "r" << index(); | 633 s << "r" << index(); |
| 603 return s.str(); | 634 return s.str(); |
| 604 } | 635 } |
| 605 } | 636 } |
| 606 | 637 |
| 607 } // namespace interpreter | 638 } // namespace interpreter |
| 608 } // namespace internal | 639 } // namespace internal |
| 609 } // namespace v8 | 640 } // namespace v8 |
| OLD | NEW |