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

Side by Side Diff: src/interpreter/bytecode-register-optimizer.cc

Issue 2100793003: [interpreter] Streamline bytecode array writing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 5 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
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecode-traits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) { 513 // operand_types is terminated by OperandType::kNone so this does not
514 if ((register_operand_bitmap & 1) == 0) { 514 // go out of bounds.
515 continue;
516 }
517 OperandType operand_type = operand_types[i];
518 int count = 0;
519 if (operand_types[i + 1] == OperandType::kRegCount) { 515 if (operand_types[i + 1] == OperandType::kRegCount) {
520 count = static_cast<int>(operands[i + 1]); 516 count = static_cast<int>(operands[i + 1]);
521 if (count == 0) {
522 continue;
523 }
524 } else { 517 } else {
525 count = Bytecodes::GetNumberOfRegistersRepresentedBy(operand_type); 518 count = Bytecodes::GetNumberOfRegistersRepresentedBy(operand_types[i]);
519 }
520
521 if (count == 0) {
522 continue;
526 } 523 }
527 524
528 Register reg = Register::FromOperand(static_cast<int32_t>(operands[i])); 525 Register reg = Register::FromOperand(static_cast<int32_t>(operands[i]));
529 if (Bytecodes::IsRegisterInputOperandType(operand_type)) { 526 if (Bytecodes::IsRegisterInputOperandType(operand_types[i])) {
530 if (count == 1) { 527 if (count == 1) {
531 PrepareRegisterInputOperand(node, reg, i); 528 PrepareRegisterInputOperand(node, reg, i);
532 } else if (count > 1) { 529 } else if (count > 1) {
533 PrepareRegisterRangeInputOperand(reg, count); 530 PrepareRegisterRangeInputOperand(reg, count);
534 } 531 }
535 } else if (Bytecodes::IsRegisterOutputOperandType(operand_type)) { 532 } else if (Bytecodes::IsRegisterOutputOperandType(operand_types[i])) {
536 PrepareRegisterRangeOutputOperand(reg, count); 533 PrepareRegisterRangeOutputOperand(reg, count);
537 } 534 }
538 } 535 }
539 } 536 }
540 537
541 void BytecodeRegisterOptimizer::PrepareAccumulator(BytecodeNode* const node) { 538 void BytecodeRegisterOptimizer::PrepareAccumulator(BytecodeNode* const node) {
542 // Materialize the accumulator if it is read by the bytecode. The 539 // Materialize the accumulator if it is read by the bytecode. The
543 // accumulator is special and no other register can be materialized 540 // accumulator is special and no other register can be materialized
544 // in it's place. 541 // in it's place.
545 if (Bytecodes::ReadsAccumulator(node->bytecode()) && 542 if (Bytecodes::ReadsAccumulator(node->bytecode()) &&
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if (info->materialized()) { 618 if (info->materialized()) {
622 CreateMaterializedEquivalent(info); 619 CreateMaterializedEquivalent(info);
623 } 620 }
624 info->MoveToNewEquivalenceSet(kInvalidEquivalenceId, false); 621 info->MoveToNewEquivalenceSet(kInvalidEquivalenceId, false);
625 } 622 }
626 } 623 }
627 624
628 } // namespace interpreter 625 } // namespace interpreter
629 } // namespace internal 626 } // namespace internal
630 } // namespace v8 627 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecode-traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698