[turbofan] Get rid of SourcePositionInstruction.
R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/1060373006 Cr-Commit-Position: refs/heads/master@{#27808}
This commit is contained in:
parent
31a3d5fcd2
commit
2299f57fd3
@ -186,9 +186,7 @@ void CodeGenerator::RecordSafepoint(ReferenceMap* references,
|
||||
|
||||
void CodeGenerator::AssembleInstruction(Instruction* instr) {
|
||||
AssembleGaps(instr);
|
||||
if (instr->IsSourcePosition()) {
|
||||
AssembleSourcePosition(SourcePositionInstruction::cast(instr));
|
||||
} else {
|
||||
AssembleSourcePosition(instr);
|
||||
// Assemble architecture-specific code for the instruction.
|
||||
AssembleArchInstruction(instr);
|
||||
|
||||
@ -224,14 +222,15 @@ void CodeGenerator::AssembleInstruction(Instruction* instr) {
|
||||
AssembleArchBoolean(instr, condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CodeGenerator::AssembleSourcePosition(SourcePositionInstruction* instr) {
|
||||
SourcePosition source_position = instr->source_position();
|
||||
void CodeGenerator::AssembleSourcePosition(Instruction* instr) {
|
||||
SourcePosition source_position;
|
||||
if (!code()->GetSourcePosition(instr, &source_position)) return;
|
||||
if (source_position == current_source_position_) return;
|
||||
DCHECK(!source_position.IsInvalid());
|
||||
if (!source_position.IsUnknown()) {
|
||||
current_source_position_ = source_position;
|
||||
if (source_position.IsUnknown()) return;
|
||||
int code_pos = source_position.raw();
|
||||
masm()->positions_recorder()->RecordPosition(source_position.raw());
|
||||
masm()->positions_recorder()->WriteRecordedPositions();
|
||||
@ -251,8 +250,6 @@ void CodeGenerator::AssembleSourcePosition(SourcePositionInstruction* instr) {
|
||||
masm()->RecordComment(buffer.start());
|
||||
}
|
||||
}
|
||||
current_source_position_ = source_position;
|
||||
}
|
||||
|
||||
|
||||
void CodeGenerator::AssembleGaps(Instruction* instr) {
|
||||
|
@ -60,7 +60,7 @@ class CodeGenerator FINAL : public GapResolver::Assembler {
|
||||
|
||||
// Assemble code for the specified instruction.
|
||||
void AssembleInstruction(Instruction* instr);
|
||||
void AssembleSourcePosition(SourcePositionInstruction* instr);
|
||||
void AssembleSourcePosition(Instruction* instr);
|
||||
void AssembleGaps(Instruction* instr);
|
||||
|
||||
// ===========================================================================
|
||||
|
@ -475,6 +475,15 @@ void InstructionSelector::VisitBlock(BasicBlock* block) {
|
||||
size_t current_node_end = instructions_.size();
|
||||
VisitNode(node);
|
||||
std::reverse(instructions_.begin() + current_node_end, instructions_.end());
|
||||
if (instructions_.size() == current_node_end) continue;
|
||||
// Mark source position on first instruction emitted.
|
||||
SourcePosition source_position = source_positions_->GetSourcePosition(node);
|
||||
if (source_position.IsUnknown()) continue;
|
||||
DCHECK(!source_position.IsInvalid());
|
||||
if (FLAG_turbo_source_positions || node->opcode() == IrOpcode::kCall) {
|
||||
sequence()->SetSourcePosition(instructions_[current_node_end],
|
||||
source_position);
|
||||
}
|
||||
}
|
||||
|
||||
// We're done with the block.
|
||||
@ -581,13 +590,6 @@ void InstructionSelector::VisitControl(BasicBlock* block) {
|
||||
|
||||
void InstructionSelector::VisitNode(Node* node) {
|
||||
DCHECK_NOT_NULL(schedule()->block(node)); // should only use scheduled nodes.
|
||||
SourcePosition source_position = source_positions_->GetSourcePosition(node);
|
||||
if (!source_position.IsUnknown()) {
|
||||
DCHECK(!source_position.IsInvalid());
|
||||
if (FLAG_turbo_source_positions || node->opcode() == IrOpcode::kCall) {
|
||||
Emit(SourcePositionInstruction::New(instruction_zone(), source_position));
|
||||
}
|
||||
}
|
||||
switch (node->opcode()) {
|
||||
case IrOpcode::kStart:
|
||||
case IrOpcode::kLoop:
|
||||
|
@ -319,11 +319,6 @@ std::ostream& operator<<(std::ostream& os,
|
||||
if (instr.OutputCount() > 1) os << ") = ";
|
||||
if (instr.OutputCount() == 1) os << " = ";
|
||||
|
||||
if (instr.IsSourcePosition()) {
|
||||
const SourcePositionInstruction* pos =
|
||||
SourcePositionInstruction::cast(&instr);
|
||||
os << "position (" << pos->source_position().raw() << ")";
|
||||
} else {
|
||||
os << ArchOpcodeField::decode(instr.opcode());
|
||||
AddressingMode am = AddressingModeField::decode(instr.opcode());
|
||||
if (am != kMode_None) {
|
||||
@ -331,9 +326,7 @@ std::ostream& operator<<(std::ostream& os,
|
||||
}
|
||||
FlagsMode fm = FlagsModeField::decode(instr.opcode());
|
||||
if (fm != kFlags_none) {
|
||||
os << " && " << fm << " if "
|
||||
<< FlagsConditionField::decode(instr.opcode());
|
||||
}
|
||||
os << " && " << fm << " if " << FlagsConditionField::decode(instr.opcode());
|
||||
}
|
||||
if (instr.InputCount() > 0) {
|
||||
for (size_t i = 0; i < instr.InputCount(); i++) {
|
||||
@ -480,6 +473,7 @@ InstructionSequence::InstructionSequence(Isolate* isolate,
|
||||
: isolate_(isolate),
|
||||
zone_(instruction_zone),
|
||||
instruction_blocks_(instruction_blocks),
|
||||
source_positions_(zone()),
|
||||
block_starts_(zone()),
|
||||
constants_(ConstantMap::key_compare(),
|
||||
ConstantMap::allocator_type(zone())),
|
||||
@ -604,6 +598,23 @@ RpoNumber InstructionSequence::InputRpo(Instruction* instr, size_t index) {
|
||||
}
|
||||
|
||||
|
||||
bool InstructionSequence::GetSourcePosition(const Instruction* instr,
|
||||
SourcePosition* result) const {
|
||||
auto it = source_positions_.find(instr);
|
||||
if (it == source_positions_.end()) return false;
|
||||
*result = it->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void InstructionSequence::SetSourcePosition(const Instruction* instr,
|
||||
SourcePosition value) {
|
||||
DCHECK(!value.IsInvalid());
|
||||
DCHECK(!value.IsUnknown());
|
||||
source_positions_.insert(std::make_pair(instr, value));
|
||||
}
|
||||
|
||||
|
||||
FrameStateDescriptor::FrameStateDescriptor(
|
||||
Zone* zone, const FrameStateCallInfo& state_info, size_t parameters_count,
|
||||
size_t locals_count, size_t stack_count, FrameStateDescriptor* outer_state)
|
||||
|
@ -24,9 +24,6 @@ namespace compiler {
|
||||
|
||||
class Schedule;
|
||||
|
||||
// A couple of reserved opcodes are used for internal use.
|
||||
const InstructionCode kSourcePositionInstruction = -1;
|
||||
|
||||
class InstructionOperand {
|
||||
public:
|
||||
static const int kInvalidVirtualRegister = -1;
|
||||
@ -624,10 +621,6 @@ class Instruction {
|
||||
bool NeedsReferenceMap() const { return IsCall(); }
|
||||
bool HasReferenceMap() const { return reference_map_ != NULL; }
|
||||
|
||||
bool IsSourcePosition() const {
|
||||
return opcode() == kSourcePositionInstruction;
|
||||
}
|
||||
|
||||
bool ClobbersRegisters() const { return IsCall(); }
|
||||
bool ClobbersTemps() const { return IsCall(); }
|
||||
bool ClobbersDoubleRegisters() const { return IsCall(); }
|
||||
@ -709,37 +702,6 @@ struct PrintableInstruction {
|
||||
std::ostream& operator<<(std::ostream& os, const PrintableInstruction& instr);
|
||||
|
||||
|
||||
class SourcePositionInstruction FINAL : public Instruction {
|
||||
public:
|
||||
static SourcePositionInstruction* New(Zone* zone, SourcePosition position) {
|
||||
void* buffer = zone->New(sizeof(SourcePositionInstruction));
|
||||
return new (buffer) SourcePositionInstruction(position);
|
||||
}
|
||||
|
||||
SourcePosition source_position() const { return source_position_; }
|
||||
|
||||
static SourcePositionInstruction* cast(Instruction* instr) {
|
||||
DCHECK(instr->IsSourcePosition());
|
||||
return static_cast<SourcePositionInstruction*>(instr);
|
||||
}
|
||||
|
||||
static const SourcePositionInstruction* cast(const Instruction* instr) {
|
||||
DCHECK(instr->IsSourcePosition());
|
||||
return static_cast<const SourcePositionInstruction*>(instr);
|
||||
}
|
||||
|
||||
private:
|
||||
explicit SourcePositionInstruction(SourcePosition source_position)
|
||||
: Instruction(kSourcePositionInstruction),
|
||||
source_position_(source_position) {
|
||||
DCHECK(!source_position_.IsInvalid());
|
||||
DCHECK(!source_position_.IsUnknown());
|
||||
}
|
||||
|
||||
SourcePosition source_position_;
|
||||
};
|
||||
|
||||
|
||||
class RpoNumber FINAL {
|
||||
public:
|
||||
static const int kInvalidRpoNumber = -1;
|
||||
@ -1113,15 +1075,21 @@ class InstructionSequence FINAL : public ZoneObject {
|
||||
|
||||
RpoNumber InputRpo(Instruction* instr, size_t index);
|
||||
|
||||
bool GetSourcePosition(const Instruction* instr,
|
||||
SourcePosition* result) const;
|
||||
void SetSourcePosition(const Instruction* instr, SourcePosition value);
|
||||
|
||||
private:
|
||||
friend std::ostream& operator<<(std::ostream& os,
|
||||
const PrintableInstructionSequence& code);
|
||||
|
||||
typedef std::set<int, std::less<int>, ZoneIntAllocator> VirtualRegisterSet;
|
||||
typedef ZoneMap<const Instruction*, SourcePosition> SourcePositionMap;
|
||||
|
||||
Isolate* isolate_;
|
||||
Zone* const zone_;
|
||||
InstructionBlocks* const instruction_blocks_;
|
||||
SourcePositionMap source_positions_;
|
||||
IntVector block_starts_;
|
||||
ConstantMap constants_;
|
||||
Immediates immediates_;
|
||||
|
@ -80,10 +80,6 @@ bool JumpThreading::ComputeForwarding(Zone* local_zone,
|
||||
// can't skip instructions with non redundant moves.
|
||||
TRACE(" parallel move\n");
|
||||
fallthru = false;
|
||||
} else if (instr->IsSourcePosition()) {
|
||||
// skip source positions.
|
||||
TRACE(" src pos\n");
|
||||
continue;
|
||||
} else if (FlagsModeField::decode(instr->opcode()) != kFlags_none) {
|
||||
// can't skip instructions with flags continuations.
|
||||
TRACE(" flags\n");
|
||||
|
@ -15,9 +15,7 @@ typedef ZoneMap<MoveKey, unsigned> MoveMap;
|
||||
typedef ZoneSet<InstructionOperand> OperandSet;
|
||||
|
||||
|
||||
bool GapsCanMoveOver(Instruction* instr) {
|
||||
return instr->IsSourcePosition() || instr->IsNop();
|
||||
}
|
||||
bool GapsCanMoveOver(Instruction* instr) { return instr->IsNop(); }
|
||||
|
||||
|
||||
int FindFirstNonEmptySlot(Instruction* instr) {
|
||||
@ -145,7 +143,6 @@ void MoveOptimizer::OptimizeMerge(InstructionBlock* block) {
|
||||
for (auto pred_index : block->predecessors()) {
|
||||
auto pred = code()->InstructionBlockAt(pred_index);
|
||||
auto last_instr = code()->instructions()[pred->last_instruction_index()];
|
||||
if (last_instr->IsSourcePosition()) continue;
|
||||
if (last_instr->IsCall()) return;
|
||||
if (last_instr->TempCount() != 0) return;
|
||||
if (last_instr->OutputCount() != 0) return;
|
||||
|
Loading…
Reference in New Issue
Block a user