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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 case interpreter::OperandType::kImm8: | 373 case interpreter::OperandType::kImm8: |
374 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); | 374 os << "#" << static_cast<int>(static_cast<int8_t>(*operand_start)); |
375 break; | 375 break; |
376 case interpreter::OperandType::kMaybeReg8: | 376 case interpreter::OperandType::kMaybeReg8: |
377 case interpreter::OperandType::kMaybeReg16: | 377 case interpreter::OperandType::kMaybeReg16: |
378 case interpreter::OperandType::kReg8: | 378 case interpreter::OperandType::kReg8: |
379 case interpreter::OperandType::kReg16: | 379 case interpreter::OperandType::kReg16: |
380 case interpreter::OperandType::kRegOut8: | 380 case interpreter::OperandType::kRegOut8: |
381 case interpreter::OperandType::kRegOut16: { | 381 case interpreter::OperandType::kRegOut16: { |
382 Register reg = DecodeRegister(operand_start, op_type); | 382 Register reg = DecodeRegister(operand_start, op_type); |
383 if (reg.is_current_context()) { | 383 os << reg.ToString(parameter_count); |
384 os << "<context>"; | |
385 } else if (reg.is_function_closure()) { | |
386 os << "<closure>"; | |
387 } else if (reg.is_new_target()) { | |
388 os << "<new.target>"; | |
389 } else if (reg.is_parameter()) { | |
390 int parameter_index = reg.ToParameterIndex(parameter_count); | |
391 if (parameter_index == 0) { | |
392 os << "<this>"; | |
393 } else { | |
394 os << "a" << parameter_index - 1; | |
395 } | |
396 } else { | |
397 os << "r" << reg.index(); | |
398 } | |
399 break; | 384 break; |
400 } | 385 } |
401 case interpreter::OperandType::kRegOutTriple8: | 386 case interpreter::OperandType::kRegOutTriple8: |
402 case interpreter::OperandType::kRegOutTriple16: | 387 case interpreter::OperandType::kRegOutTriple16: |
403 range += 1; | 388 range += 1; |
404 case interpreter::OperandType::kRegOutPair8: | 389 case interpreter::OperandType::kRegOutPair8: |
405 case interpreter::OperandType::kRegOutPair16: | 390 case interpreter::OperandType::kRegOutPair16: |
406 case interpreter::OperandType::kRegPair8: | 391 case interpreter::OperandType::kRegPair8: |
407 case interpreter::OperandType::kRegPair16: { | 392 case interpreter::OperandType::kRegPair16: { |
408 range += 1; | 393 range += 1; |
409 Register reg = DecodeRegister(operand_start, op_type); | 394 Register first_reg = DecodeRegister(operand_start, op_type); |
410 if (reg.is_parameter()) { | 395 Register last_reg = Register(first_reg.index() + range); |
411 int parameter_index = reg.ToParameterIndex(parameter_count); | 396 os << first_reg.ToString(parameter_count) << "-" |
412 DCHECK_GT(parameter_index, 0); | 397 << last_reg.ToString(parameter_count); |
413 os << "a" << parameter_index - range << "-" << parameter_index; | |
414 } else { | |
415 os << "r" << reg.index() << "-" << reg.index() + range; | |
416 } | |
417 break; | 398 break; |
418 } | 399 } |
419 case interpreter::OperandType::kNone: | 400 case interpreter::OperandType::kNone: |
420 UNREACHABLE(); | 401 UNREACHABLE(); |
421 break; | 402 break; |
422 } | 403 } |
423 if (i != number_of_operands - 1) { | 404 if (i != number_of_operands - 1) { |
424 os << ", "; | 405 os << ", "; |
425 } | 406 } |
426 } | 407 } |
427 return os; | 408 return os; |
428 } | 409 } |
429 | 410 |
430 | |
431 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { | 411 std::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) { |
432 return os << Bytecodes::ToString(bytecode); | 412 return os << Bytecodes::ToString(bytecode); |
433 } | 413 } |
434 | 414 |
435 | 415 |
436 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { | 416 std::ostream& operator<<(std::ostream& os, const OperandType& operand_type) { |
437 return os << Bytecodes::OperandTypeToString(operand_type); | 417 return os << Bytecodes::OperandTypeToString(operand_type); |
438 } | 418 } |
439 | 419 |
440 | 420 |
441 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { | 421 std::ostream& operator<<(std::ostream& os, const OperandSize& operand_size) { |
442 return os << Bytecodes::OperandSizeToString(operand_size); | 422 return os << Bytecodes::OperandSizeToString(operand_size); |
443 } | 423 } |
444 | 424 |
445 | |
446 static const int kLastParamRegisterIndex = | 425 static const int kLastParamRegisterIndex = |
447 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; | 426 -InterpreterFrameConstants::kLastParamFromRegisterPointer / kPointerSize; |
448 static const int kFunctionClosureRegisterIndex = | 427 static const int kFunctionClosureRegisterIndex = |
449 -InterpreterFrameConstants::kFunctionFromRegisterPointer / kPointerSize; | 428 -InterpreterFrameConstants::kFunctionFromRegisterPointer / kPointerSize; |
450 static const int kCurrentContextRegisterIndex = | 429 static const int kCurrentContextRegisterIndex = |
451 -InterpreterFrameConstants::kContextFromRegisterPointer / kPointerSize; | 430 -InterpreterFrameConstants::kContextFromRegisterPointer / kPointerSize; |
452 static const int kNewTargetRegisterIndex = | 431 static const int kNewTargetRegisterIndex = |
453 -InterpreterFrameConstants::kNewTargetFromRegisterPointer / kPointerSize; | 432 -InterpreterFrameConstants::kNewTargetFromRegisterPointer / kPointerSize; |
454 | 433 |
455 // The register space is a signed 16-bit space. Register operands | 434 // The register space is a signed 16-bit space. Register operands |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 } | 541 } |
563 if (reg4.is_valid() && reg3.index() + 1 != reg4.index()) { | 542 if (reg4.is_valid() && reg3.index() + 1 != reg4.index()) { |
564 return false; | 543 return false; |
565 } | 544 } |
566 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { | 545 if (reg5.is_valid() && reg4.index() + 1 != reg5.index()) { |
567 return false; | 546 return false; |
568 } | 547 } |
569 return true; | 548 return true; |
570 } | 549 } |
571 | 550 |
| 551 std::string Register::ToString(int parameter_count) { |
| 552 if (is_current_context()) { |
| 553 return std::string("<context>"); |
| 554 } else if (is_function_closure()) { |
| 555 return std::string("<closure>"); |
| 556 } else if (is_new_target()) { |
| 557 return std::string("<new.target>"); |
| 558 } else if (is_parameter()) { |
| 559 int parameter_index = ToParameterIndex(parameter_count); |
| 560 if (parameter_index == 0) { |
| 561 return std::string("<this>"); |
| 562 } else { |
| 563 std::ostringstream s; |
| 564 s << "a" << parameter_index - 1; |
| 565 return s.str(); |
| 566 } |
| 567 } else { |
| 568 std::ostringstream s; |
| 569 s << "r" << index(); |
| 570 return s.str(); |
| 571 } |
| 572 } |
| 573 |
572 } // namespace interpreter | 574 } // namespace interpreter |
573 } // namespace internal | 575 } // namespace internal |
574 } // namespace v8 | 576 } // namespace v8 |
OLD | NEW |