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

Side by Side Diff: src/compiler/instruction.cc

Issue 904693002: [turbofan] Remove global InstructionOperand caches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/compiler/instruction.h ('k') | src/compiler/instruction-selector.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/instruction.h" 7 #include "src/compiler/instruction.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 case InstructionOperand::DOUBLE_REGISTER: 51 case InstructionOperand::DOUBLE_REGISTER:
52 return os << "[" << conf->double_register_name(op.index()) << "|R]"; 52 return os << "[" << conf->double_register_name(op.index()) << "|R]";
53 case InstructionOperand::INVALID: 53 case InstructionOperand::INVALID:
54 return os << "(x)"; 54 return os << "(x)";
55 } 55 }
56 UNREACHABLE(); 56 UNREACHABLE();
57 return os; 57 return os;
58 } 58 }
59 59
60 60
61 template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands>
62 SubKindOperand<kOperandKind, kNumCachedOperands>*
63 SubKindOperand<kOperandKind, kNumCachedOperands>::cache = NULL;
64
65
66 template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands>
67 void SubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() {
68 if (cache) return;
69 cache = new SubKindOperand[kNumCachedOperands];
70 for (int i = 0; i < kNumCachedOperands; i++) {
71 cache[i].ConvertTo(kOperandKind, i);
72 }
73 }
74
75
76 template <InstructionOperand::Kind kOperandKind, int kNumCachedOperands>
77 void SubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() {
78 delete[] cache;
79 cache = NULL;
80 }
81
82
83 void InstructionOperand::SetUpCaches() {
84 #define INSTRUCTION_OPERAND_SETUP(name, type, number) \
85 name##Operand::SetUpCache();
86 INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_SETUP)
87 #undef INSTRUCTION_OPERAND_SETUP
88 }
89
90
91 void InstructionOperand::TearDownCaches() {
92 #define INSTRUCTION_OPERAND_TEARDOWN(name, type, number) \
93 name##Operand::TearDownCache();
94 INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_TEARDOWN)
95 #undef INSTRUCTION_OPERAND_TEARDOWN
96 }
97
98
99 std::ostream& operator<<(std::ostream& os, 61 std::ostream& operator<<(std::ostream& os,
100 const PrintableMoveOperands& printable) { 62 const PrintableMoveOperands& printable) {
101 const MoveOperands& mo = *printable.move_operands_; 63 const MoveOperands& mo = *printable.move_operands_;
102 PrintableInstructionOperand printable_op = {printable.register_configuration_, 64 PrintableInstructionOperand printable_op = {printable.register_configuration_,
103 mo.destination()}; 65 mo.destination()};
104 66
105 os << printable_op; 67 os << printable_op;
106 if (!mo.source()->Equals(mo.destination())) { 68 if (!mo.source()->Equals(mo.destination())) {
107 printable_op.op_ = mo.source(); 69 printable_op.op_ = mo.source();
108 os << " = " << printable_op; 70 os << " = " << printable_op;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 pointer_maps_(zone()), 443 pointer_maps_(zone()),
482 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), 444 doubles_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())),
483 references_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())), 445 references_(std::less<int>(), VirtualRegisterSet::allocator_type(zone())),
484 deoptimization_entries_(zone()) { 446 deoptimization_entries_(zone()) {
485 block_starts_.reserve(instruction_blocks_->size()); 447 block_starts_.reserve(instruction_blocks_->size());
486 } 448 }
487 449
488 450
489 int InstructionSequence::NextVirtualRegister() { 451 int InstructionSequence::NextVirtualRegister() {
490 int virtual_register = next_virtual_register_++; 452 int virtual_register = next_virtual_register_++;
491 CHECK_NE(virtual_register, UnallocatedOperand::kInvalidVirtualRegister); 453 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister);
492 return virtual_register; 454 return virtual_register;
493 } 455 }
494 456
495 457
496 GapInstruction* InstructionSequence::GetBlockStart( 458 GapInstruction* InstructionSequence::GetBlockStart(
497 BasicBlock::RpoNumber rpo) const { 459 BasicBlock::RpoNumber rpo) const {
498 const InstructionBlock* block = InstructionBlockAt(rpo); 460 const InstructionBlock* block = InstructionBlockAt(rpo);
499 return GapInstruction::cast(InstructionAt(block->code_start())); 461 return GapInstruction::cast(InstructionAt(block->code_start()));
500 } 462 }
501 463
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 os << " B" << succ_block->id(); 691 os << " B" << succ_block->id();
730 } 692 }
731 os << "\n"; 693 os << "\n";
732 } 694 }
733 return os; 695 return os;
734 } 696 }
735 697
736 } // namespace compiler 698 } // namespace compiler
737 } // namespace internal 699 } // namespace internal
738 } // namespace v8 700 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698