Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/bytecode-register-optimizer.h" | 5 #include "src/interpreter/bytecode-register-optimizer.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 void BytecodeRegisterOptimizer::PrepareRegisterOperands( | 497 void BytecodeRegisterOptimizer::PrepareRegisterOperands( |
| 498 BytecodeNode* const node) { | 498 BytecodeNode* const node) { |
| 499 // | 499 // |
| 500 // For each input operand, get a materialized equivalent if it is | 500 // For each input operand, get a materialized equivalent if it is |
| 501 // just a single register, otherwise materialize register range. | 501 // just a single register, otherwise materialize register range. |
| 502 // Update operand_scale if necessary. | 502 // Update operand_scale if necessary. |
| 503 // | 503 // |
| 504 // For each output register about to be clobbered, materialize an | 504 // For each output register about to be clobbered, materialize an |
| 505 // equivalent if it exists. Put each register in it's own equivalence set. | 505 // equivalent if it exists. Put each register in it's own equivalence set. |
| 506 // | 506 // |
| 507 int register_operand_bitmap = | 507 const uint32_t* operands = node->operands(); |
| 508 Bytecodes::GetRegisterOperandBitmap(node->bytecode()); | 508 int operand_count = node->operand_count(); |
| 509 const OperandType* operand_types = | 509 const OperandType* operand_types = |
| 510 Bytecodes::GetOperandTypes(node->bytecode()); | 510 Bytecodes::GetOperandTypes(node->bytecode()); |
| 511 uint32_t* operands = node->operands(); | 511 for (int i = 0; i < operand_count; ++i) { |
| 512 for (int i = 0; register_operand_bitmap != 0; | 512 int count; |
| 513 ++i, register_operand_bitmap >>= 1) { | |
| 514 if ((register_operand_bitmap & 1) == 0) { | |
| 515 continue; | |
| 516 } | |
| 517 OperandType operand_type = operand_types[i]; | |
| 518 int count = 0; | |
| 519 if (operand_types[i + 1] == OperandType::kRegCount) { | 513 if (operand_types[i + 1] == OperandType::kRegCount) { |
|
rmcilroy
2016/06/27 14:03:48
Ditto
oth
2016/06/27 18:53:50
Done.
| |
| 520 count = static_cast<int>(operands[i + 1]); | 514 count = static_cast<int>(operands[i + 1]); |
| 521 if (count == 0) { | |
| 522 continue; | |
| 523 } | |
| 524 } else { | 515 } else { |
| 525 count = Bytecodes::GetNumberOfRegistersRepresentedBy(operand_type); | 516 count = Bytecodes::GetNumberOfRegistersRepresentedBy(operand_types[i]); |
| 517 } | |
| 518 | |
| 519 if (count == 0) { | |
| 520 continue; | |
| 526 } | 521 } |
| 527 | 522 |
| 528 Register reg = Register::FromOperand(static_cast<int32_t>(operands[i])); | 523 Register reg = Register::FromOperand(static_cast<int32_t>(operands[i])); |
| 529 if (Bytecodes::IsRegisterInputOperandType(operand_type)) { | 524 if (Bytecodes::IsRegisterInputOperandType(operand_types[i])) { |
| 530 if (count == 1) { | 525 if (count == 1) { |
| 531 PrepareRegisterInputOperand(node, reg, i); | 526 PrepareRegisterInputOperand(node, reg, i); |
| 532 } else if (count > 1) { | 527 } else if (count > 1) { |
| 533 PrepareRegisterRangeInputOperand(reg, count); | 528 PrepareRegisterRangeInputOperand(reg, count); |
| 534 } | 529 } |
| 535 } else if (Bytecodes::IsRegisterOutputOperandType(operand_type)) { | 530 } else if (Bytecodes::IsRegisterOutputOperandType(operand_types[i])) { |
| 536 PrepareRegisterRangeOutputOperand(reg, count); | 531 PrepareRegisterRangeOutputOperand(reg, count); |
| 537 } | 532 } |
| 538 } | 533 } |
| 539 } | 534 } |
| 540 | 535 |
| 541 void BytecodeRegisterOptimizer::PrepareAccumulator(BytecodeNode* const node) { | 536 void BytecodeRegisterOptimizer::PrepareAccumulator(BytecodeNode* const node) { |
| 542 // Materialize the accumulator if it is read by the bytecode. The | 537 // Materialize the accumulator if it is read by the bytecode. The |
| 543 // accumulator is special and no other register can be materialized | 538 // accumulator is special and no other register can be materialized |
| 544 // in it's place. | 539 // in it's place. |
| 545 if (Bytecodes::ReadsAccumulator(node->bytecode()) && | 540 if (Bytecodes::ReadsAccumulator(node->bytecode()) && |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 if (info->materialized()) { | 616 if (info->materialized()) { |
| 622 CreateMaterializedEquivalent(info); | 617 CreateMaterializedEquivalent(info); |
| 623 } | 618 } |
| 624 info->MoveToNewEquivalenceSet(kInvalidEquivalenceId, false); | 619 info->MoveToNewEquivalenceSet(kInvalidEquivalenceId, false); |
| 625 } | 620 } |
| 626 } | 621 } |
| 627 | 622 |
| 628 } // namespace interpreter | 623 } // namespace interpreter |
| 629 } // namespace internal | 624 } // namespace internal |
| 630 } // namespace v8 | 625 } // namespace v8 |
| OLD | NEW |