Commit 9d51f8f5 authored by dcarney's avatar dcarney Committed by Commit bot

Revert of revert r25736 (patchset #2 id:20001 of https://codereview.chromium.org/803493002/)

Reason for revert:
performance bots were unchanged by the original revert

Original issue's description:
> revert r25736
>
> R=bmeurer@chromium.org
>
> BUG=

TBR=bmeurer@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=

Review URL: https://codereview.chromium.org/787183003

Cr-Commit-Position: refs/heads/master@{#25801}
parent 22302b51
...@@ -725,7 +725,7 @@ void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type) { ...@@ -725,7 +725,7 @@ void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type) {
} }
} else if (range->IsSpilled()) { } else if (range->IsSpilled()) {
int index = -1; int index = -1;
if (range->TopLevel()->GetSpillRange() != nullptr) { if (range->TopLevel()->HasSpillRange()) {
index = kMaxInt; // This hasn't been set yet. index = kMaxInt; // This hasn't been set yet.
} else { } else {
index = range->TopLevel()->GetSpillOperand()->index(); index = range->TopLevel()->GetSpillOperand()->index();
......
...@@ -15,8 +15,6 @@ std::ostream& operator<<(std::ostream& os, ...@@ -15,8 +15,6 @@ std::ostream& operator<<(std::ostream& os,
const InstructionOperand& op = *printable.op_; const InstructionOperand& op = *printable.op_;
const RegisterConfiguration* conf = printable.register_configuration_; const RegisterConfiguration* conf = printable.register_configuration_;
switch (op.kind()) { switch (op.kind()) {
case InstructionOperand::INVALID:
return os << "(0)";
case InstructionOperand::UNALLOCATED: { case InstructionOperand::UNALLOCATED: {
const UnallocatedOperand* unalloc = UnallocatedOperand::cast(&op); const UnallocatedOperand* unalloc = UnallocatedOperand::cast(&op);
os << "v" << unalloc->virtual_register(); os << "v" << unalloc->virtual_register();
......
...@@ -39,7 +39,6 @@ const InstructionCode kSourcePositionInstruction = -3; ...@@ -39,7 +39,6 @@ const InstructionCode kSourcePositionInstruction = -3;
class InstructionOperand : public ZoneObject { class InstructionOperand : public ZoneObject {
public: public:
enum Kind { enum Kind {
INVALID,
UNALLOCATED, UNALLOCATED,
CONSTANT, CONSTANT,
IMMEDIATE, IMMEDIATE,
...@@ -49,7 +48,6 @@ class InstructionOperand : public ZoneObject { ...@@ -49,7 +48,6 @@ class InstructionOperand : public ZoneObject {
DOUBLE_REGISTER DOUBLE_REGISTER
}; };
InstructionOperand() : value_(KindField::encode(INVALID)) {}
InstructionOperand(Kind kind, int index) { ConvertTo(kind, index); } InstructionOperand(Kind kind, int index) { ConvertTo(kind, index); }
Kind kind() const { return KindField::decode(value_); } Kind kind() const { return KindField::decode(value_); }
...@@ -58,7 +56,6 @@ class InstructionOperand : public ZoneObject { ...@@ -58,7 +56,6 @@ class InstructionOperand : public ZoneObject {
bool Is##name() const { return kind() == type; } bool Is##name() const { return kind() == type; }
INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_PREDICATE) INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_PREDICATE)
INSTRUCTION_OPERAND_PREDICATE(Unallocated, UNALLOCATED, 0) INSTRUCTION_OPERAND_PREDICATE(Unallocated, UNALLOCATED, 0)
INSTRUCTION_OPERAND_PREDICATE(Ignored, INVALID, 0)
#undef INSTRUCTION_OPERAND_PREDICATE #undef INSTRUCTION_OPERAND_PREDICATE
bool Equals(const InstructionOperand* other) const { bool Equals(const InstructionOperand* other) const {
return value_ == other->value_; return value_ == other->value_;
...@@ -291,16 +288,12 @@ class MoveOperands FINAL { ...@@ -291,16 +288,12 @@ class MoveOperands FINAL {
} }
// A move is redundant if it's been eliminated, if its source and // A move is redundant if it's been eliminated, if its source and
// destination are the same, or if its destination is unneeded or constant. // destination are the same, or if its destination is constant.
bool IsRedundant() const { bool IsRedundant() const {
return IsEliminated() || source_->Equals(destination_) || IsIgnored() || return IsEliminated() || source_->Equals(destination_) ||
(destination_ != NULL && destination_->IsConstant()); (destination_ != NULL && destination_->IsConstant());
} }
bool IsIgnored() const {
return destination_ != NULL && destination_->IsIgnored();
}
// We clear both operands to indicate move that's been eliminated. // We clear both operands to indicate move that's been eliminated.
void Eliminate() { source_ = destination_ = NULL; } void Eliminate() { source_ = destination_ = NULL; }
bool IsEliminated() const { bool IsEliminated() const {
...@@ -348,7 +341,7 @@ class SubKindOperand FINAL : public InstructionOperand { ...@@ -348,7 +341,7 @@ class SubKindOperand FINAL : public InstructionOperand {
private: private:
static SubKindOperand* cache; static SubKindOperand* cache;
SubKindOperand() : InstructionOperand() {} SubKindOperand() : InstructionOperand(kOperandKind, 0) {} // For the caches.
explicit SubKindOperand(int index) explicit SubKindOperand(int index)
: InstructionOperand(kOperandKind, index) {} : InstructionOperand(kOperandKind, index) {}
}; };
......
...@@ -585,6 +585,15 @@ struct ReuseSpillSlotsPhase { ...@@ -585,6 +585,15 @@ struct ReuseSpillSlotsPhase {
}; };
struct CommitAssignmentPhase {
static const char* phase_name() { return "commit assignment"; }
void Run(PipelineData* data, Zone* temp_zone) {
data->register_allocator()->CommitAssignment();
}
};
struct PopulatePointerMapsPhase { struct PopulatePointerMapsPhase {
static const char* phase_name() { return "populate pointer maps"; } static const char* phase_name() { return "populate pointer maps"; }
...@@ -1036,6 +1045,7 @@ void Pipeline::AllocateRegisters(const RegisterConfiguration* config, ...@@ -1036,6 +1045,7 @@ void Pipeline::AllocateRegisters(const RegisterConfiguration* config,
if (FLAG_turbo_reuse_spill_slots) { if (FLAG_turbo_reuse_spill_slots) {
Run<ReuseSpillSlotsPhase>(); Run<ReuseSpillSlotsPhase>();
} }
Run<CommitAssignmentPhase>();
Run<PopulatePointerMapsPhase>(); Run<PopulatePointerMapsPhase>();
Run<ConnectRangesPhase>(); Run<ConnectRangesPhase>();
Run<ResolveControlFlowPhase>(); Run<ResolveControlFlowPhase>();
......
...@@ -276,10 +276,8 @@ class RegisterAllocatorVerifier::OutgoingMapping : public ZoneObject { ...@@ -276,10 +276,8 @@ class RegisterAllocatorVerifier::OutgoingMapping : public ZoneObject {
auto* moves = move->move_operands(); auto* moves = move->move_operands();
for (auto i = moves->begin(); i != moves->end(); ++i) { for (auto i = moves->begin(); i != moves->end(); ++i) {
if (i->IsEliminated()) continue; if (i->IsEliminated()) continue;
CHECK(i->source()->kind() != InstructionOperand::INVALID);
auto cur = locations()->find(i->source()); auto cur = locations()->find(i->source());
CHECK(cur != locations()->end()); CHECK(cur != locations()->end());
if (i->destination()->kind() == InstructionOperand::INVALID) continue;
to_insert.insert(std::make_pair(i->destination(), cur->second)); to_insert.insert(std::make_pair(i->destination(), cur->second));
} }
// Drop current mappings. // Drop current mappings.
......
This diff is collapsed.
...@@ -197,7 +197,7 @@ class LiveRange FINAL : public ZoneObject { ...@@ -197,7 +197,7 @@ class LiveRange FINAL : public ZoneObject {
int assigned_register() const { return assigned_register_; } int assigned_register() const { return assigned_register_; }
int spill_start_index() const { return spill_start_index_; } int spill_start_index() const { return spill_start_index_; }
void set_assigned_register(int reg, Zone* zone); void set_assigned_register(int reg, Zone* zone);
void MakeSpilled(Zone* zone); void MakeSpilled();
bool is_phi() const { return is_phi_; } bool is_phi() const { return is_phi_; }
void set_is_phi(bool is_phi) { is_phi_ = is_phi; } void set_is_phi(bool is_phi) { is_phi_ = is_phi; }
bool is_non_loop_phi() const { return is_non_loop_phi_; } bool is_non_loop_phi() const { return is_non_loop_phi_; }
...@@ -260,13 +260,27 @@ class LiveRange FINAL : public ZoneObject { ...@@ -260,13 +260,27 @@ class LiveRange FINAL : public ZoneObject {
return last_interval_->end(); return last_interval_->end();
} }
bool HasAllocatedSpillOperand() const; enum class SpillType { kNoSpillType, kSpillOperand, kSpillRange };
InstructionOperand* GetSpillOperand() const { return spill_operand_; } SpillType spill_type() const { return spill_type_; }
void SetSpillOperand(InstructionOperand* operand); InstructionOperand* GetSpillOperand() const {
return spill_type_ == SpillType::kSpillOperand ? spill_operand_ : nullptr;
}
SpillRange* GetSpillRange() const {
return spill_type_ == SpillType::kSpillRange ? spill_range_ : nullptr;
}
bool HasNoSpillType() const { return spill_type_ == SpillType::kNoSpillType; }
bool HasSpillOperand() const {
return spill_type_ == SpillType::kSpillOperand;
}
bool HasSpillRange() const { return spill_type_ == SpillType::kSpillRange; }
void SetSpillRange(SpillRange* spill_range) { spill_range_ = spill_range; } void SpillAtDefinition(Zone* zone, int gap_index,
SpillRange* GetSpillRange() const { return spill_range_; } InstructionOperand* operand);
void SetSpillOperand(InstructionOperand* operand);
void SetSpillRange(SpillRange* spill_range);
void CommitSpillOperand(InstructionOperand* operand); void CommitSpillOperand(InstructionOperand* operand);
void CommitSpillsAtDefinition(InstructionSequence* sequence,
InstructionOperand* operand);
void SetSpillStartIndex(int start) { void SetSpillStartIndex(int start) {
spill_start_index_ = Min(start, spill_start_index_); spill_start_index_ = Min(start, spill_start_index_);
...@@ -293,12 +307,14 @@ class LiveRange FINAL : public ZoneObject { ...@@ -293,12 +307,14 @@ class LiveRange FINAL : public ZoneObject {
#endif #endif
private: private:
void ConvertOperands(Zone* zone); struct SpillAtDefinitionList;
void ConvertUsesToOperand(InstructionOperand* op); void ConvertUsesToOperand(InstructionOperand* op);
UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const; UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const;
void AdvanceLastProcessedMarker(UseInterval* to_start_of, void AdvanceLastProcessedMarker(UseInterval* to_start_of,
LifetimePosition but_not_past) const; LifetimePosition but_not_past) const;
// TODO(dcarney): pack this structure better.
int id_; int id_;
bool spilled_; bool spilled_;
bool is_phi_; bool is_phi_;
...@@ -315,9 +331,13 @@ class LiveRange FINAL : public ZoneObject { ...@@ -315,9 +331,13 @@ class LiveRange FINAL : public ZoneObject {
UsePosition* last_processed_use_; UsePosition* last_processed_use_;
// This is used as a cache, it's invalid outside of BuildLiveRanges. // This is used as a cache, it's invalid outside of BuildLiveRanges.
InstructionOperand* current_hint_operand_; InstructionOperand* current_hint_operand_;
InstructionOperand* spill_operand_;
int spill_start_index_; int spill_start_index_;
SpillRange* spill_range_; SpillType spill_type_;
union {
InstructionOperand* spill_operand_;
SpillRange* spill_range_;
};
SpillAtDefinitionList* spills_at_definition_;
friend class RegisterAllocator; // Assigns to kind_. friend class RegisterAllocator; // Assigns to kind_.
...@@ -388,13 +408,16 @@ class RegisterAllocator FINAL : public ZoneObject { ...@@ -388,13 +408,16 @@ class RegisterAllocator FINAL : public ZoneObject {
// Phase 5: reassign spill splots for maximal reuse. // Phase 5: reassign spill splots for maximal reuse.
void ReuseSpillSlots(); void ReuseSpillSlots();
// Phase 6: compute values for pointer maps. // Phase 6: commit assignment.
void CommitAssignment();
// Phase 7: compute values for pointer maps.
void PopulatePointerMaps(); // TODO(titzer): rename to PopulateReferenceMaps. void PopulatePointerMaps(); // TODO(titzer): rename to PopulateReferenceMaps.
// Phase 7: reconnect split ranges with moves. // Phase 8: reconnect split ranges with moves.
void ConnectRanges(); void ConnectRanges();
// Phase 8: insert moves to connect ranges across basic blocks. // Phase 9: insert moves to connect ranges across basic blocks.
void ResolveControlFlow(); void ResolveControlFlow();
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment