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

Unified Diff: src/compiler/instruction.cc

Issue 1896813003: [turbofan] store block id with instruction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/instruction.cc
diff --git a/src/compiler/instruction.cc b/src/compiler/instruction.cc
index d43d669007263c7a2e5d3f43ce9e77d7b97e205c..f2ecdead7f4e942faac3c1d138aeeafb99dddc5e 100644
--- a/src/compiler/instruction.cc
+++ b/src/compiler/instruction.cc
@@ -251,17 +251,16 @@ ExplicitOperand::ExplicitOperand(LocationKind kind, MachineRepresentation rep,
DoubleRegister::from_code(index).IsAllocatable());
}
-
Instruction::Instruction(InstructionCode opcode)
: opcode_(opcode),
bit_field_(OutputCountField::encode(0) | InputCountField::encode(0) |
TempCountField::encode(0) | IsCallField::encode(false)),
- reference_map_(nullptr) {
+ reference_map_(nullptr),
+ block_id_(RpoNumber::kInvalidRpoNumber) {
parallel_moves_[0] = nullptr;
parallel_moves_[1] = nullptr;
}
-
Instruction::Instruction(InstructionCode opcode, size_t output_count,
InstructionOperand* outputs, size_t input_count,
InstructionOperand* inputs, size_t temp_count,
@@ -271,7 +270,8 @@ Instruction::Instruction(InstructionCode opcode, size_t output_count,
InputCountField::encode(input_count) |
TempCountField::encode(temp_count) |
IsCallField::encode(false)),
- reference_map_(nullptr) {
+ reference_map_(nullptr),
+ block_id_(RpoNumber::kInvalidRpoNumber) {
parallel_moves_[0] = nullptr;
parallel_moves_[1] = nullptr;
size_t offset = 0;
@@ -611,6 +611,15 @@ static InstructionBlock* InstructionBlockFor(Zone* zone,
return instr_block;
}
+void InstructionSequence::FinishInstructionMap() {
+ for (int block_id = 0; block_id < InstructionBlockCount(); ++block_id) {
+ const InstructionBlock* block = instruction_blocks()[block_id];
+ for (int instr_index = block->first_instruction_index();
+ instr_index <= block->last_instruction_index(); ++instr_index) {
+ instructions()[instr_index]->set_block_id(block_id);
titzer 2016/04/19 08:05:17 Can you pull instructions() out of the loop? This
Mircea Trofin 2016/04/19 15:39:13 Done.
+ }
+ }
+}
InstructionBlocks* InstructionSequence::InstructionBlocksFor(
Zone* zone, const Schedule* schedule) {
@@ -683,7 +692,6 @@ void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) {
}
}
-
InstructionSequence::InstructionSequence(Isolate* isolate,
Zone* instruction_zone,
InstructionBlocks* instruction_blocks)
@@ -691,7 +699,6 @@ InstructionSequence::InstructionSequence(Isolate* isolate,
zone_(instruction_zone),
instruction_blocks_(instruction_blocks),
source_positions_(zone()),
- block_starts_(zone()),
constants_(ConstantMap::key_compare(),
ConstantMap::allocator_type(zone())),
immediates_(zone()),
@@ -699,10 +706,7 @@ InstructionSequence::InstructionSequence(Isolate* isolate,
next_virtual_register_(0),
reference_maps_(zone()),
representations_(zone()),
- deoptimization_entries_(zone()) {
- block_starts_.reserve(instruction_blocks_->size());
-}
-
+ deoptimization_entries_(zone()) {}
int InstructionSequence::NextVirtualRegister() {
int virtual_register = next_virtual_register_++;
@@ -718,11 +722,9 @@ Instruction* InstructionSequence::GetBlockStart(RpoNumber rpo) const {
void InstructionSequence::StartBlock(RpoNumber rpo) {
- DCHECK(block_starts_.size() == rpo.ToSize());
InstructionBlock* block = InstructionBlockAt(rpo);
int code_start = static_cast<int>(instructions_.size());
block->set_code_start(code_start);
- block_starts_.push_back(code_start);
}
@@ -754,18 +756,7 @@ int InstructionSequence::AddInstruction(Instruction* instr) {
InstructionBlock* InstructionSequence::GetInstructionBlock(
int instruction_index) const {
- DCHECK(instruction_blocks_->size() == block_starts_.size());
- auto begin = block_starts_.begin();
- auto end = std::lower_bound(begin, block_starts_.end(), instruction_index);
- // Post condition of std::lower_bound:
- DCHECK(end == block_starts_.end() || *end >= instruction_index);
- if (end == block_starts_.end() || *end > instruction_index) --end;
- DCHECK(*end <= instruction_index);
- size_t index = std::distance(begin, end);
- InstructionBlock* block = instruction_blocks_->at(index);
- DCHECK(block->code_start() <= instruction_index &&
- instruction_index < block->code_end());
- return block;
+ return instruction_blocks()[instructions()[instruction_index]->block_id()];
}

Powered by Google App Engine
This is Rietveld 408576698