aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/register-allocator.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/register-allocator.h')
-rw-r--r--deps/v8/src/compiler/register-allocator.h62
1 files changed, 37 insertions, 25 deletions
diff --git a/deps/v8/src/compiler/register-allocator.h b/deps/v8/src/compiler/register-allocator.h
index b17837ba59..d7dd1b7358 100644
--- a/deps/v8/src/compiler/register-allocator.h
+++ b/deps/v8/src/compiler/register-allocator.h
@@ -173,6 +173,33 @@ class UsePosition FINAL : public ZoneObject {
class SpillRange;
+
+// TODO(dcarney): remove this cache.
+class InstructionOperandCache FINAL : public ZoneObject {
+ public:
+ InstructionOperandCache();
+
+ InstructionOperand* RegisterOperand(int index) {
+ DCHECK(index >= 0 &&
+ index < static_cast<int>(arraysize(general_register_operands_)));
+ return &general_register_operands_[index];
+ }
+ InstructionOperand* DoubleRegisterOperand(int index) {
+ DCHECK(index >= 0 &&
+ index < static_cast<int>(arraysize(double_register_operands_)));
+ return &double_register_operands_[index];
+ }
+
+ private:
+ InstructionOperand
+ general_register_operands_[RegisterConfiguration::kMaxGeneralRegisters];
+ InstructionOperand
+ double_register_operands_[RegisterConfiguration::kMaxDoubleRegisters];
+
+ DISALLOW_COPY_AND_ASSIGN(InstructionOperandCache);
+};
+
+
// Representation of SSA values' live ranges as a collection of (continuous)
// intervals over the instruction ordering.
class LiveRange FINAL : public ZoneObject {
@@ -193,10 +220,12 @@ class LiveRange FINAL : public ZoneObject {
int id() const { return id_; }
bool IsFixed() const { return id_ < 0; }
bool IsEmpty() const { return first_interval() == nullptr; }
- InstructionOperand* CreateAssignedOperand(Zone* zone) const;
+ // TODO(dcarney): remove this.
+ InstructionOperand* GetAssignedOperand(InstructionOperandCache* cache) const;
+ InstructionOperand GetAssignedOperand() const;
int assigned_register() const { return assigned_register_; }
int spill_start_index() const { return spill_start_index_; }
- void set_assigned_register(int reg, Zone* zone);
+ void set_assigned_register(int reg, InstructionOperandCache* cache);
void MakeSpilled();
bool is_phi() const { return is_phi_; }
void set_is_phi(bool is_phi) { is_phi_ = is_phi; }
@@ -377,8 +406,6 @@ class RegisterAllocator FINAL : public ZoneObject {
InstructionSequence* code,
const char* debug_name = nullptr);
- bool AllocationOk() { return allocation_ok_; }
-
const ZoneVector<LiveRange*>& live_ranges() const { return live_ranges_; }
const ZoneVector<LiveRange*>& fixed_live_ranges() const {
return fixed_live_ranges_;
@@ -405,8 +432,8 @@ class RegisterAllocator FINAL : public ZoneObject {
void AllocateGeneralRegisters();
void AllocateDoubleRegisters();
- // Phase 5: reassign spill splots for maximal reuse.
- void ReuseSpillSlots();
+ // Phase 5: assign spill splots.
+ void AssignSpillSlots();
// Phase 6: commit assignment.
void CommitAssignment();
@@ -421,15 +448,7 @@ class RegisterAllocator FINAL : public ZoneObject {
void ResolveControlFlow();
private:
- int GetVirtualRegister() {
- int vreg = code()->NextVirtualRegister();
- if (vreg >= UnallocatedOperand::kMaxVirtualRegisters) {
- allocation_ok_ = false;
- // Maintain the invariant that we return something below the maximum.
- return 0;
- }
- return vreg;
- }
+ int GetVirtualRegister() { return code()->NextVirtualRegister(); }
// Checks whether the value of a given virtual register is a reference.
// TODO(titzer): rename this to IsReference.
@@ -494,8 +513,6 @@ class RegisterAllocator FINAL : public ZoneObject {
bool TryAllocateFreeReg(LiveRange* range);
void AllocateBlockedReg(LiveRange* range);
SpillRange* AssignSpillRangeToLiveRange(LiveRange* range);
- void FreeSpillSlot(LiveRange* range);
- InstructionOperand* TryReuseSpillSlot(LiveRange* range);
// Live range splitting helpers.
@@ -570,6 +587,7 @@ class RegisterAllocator FINAL : public ZoneObject {
Frame* frame() const { return frame_; }
const char* debug_name() const { return debug_name_; }
const RegisterConfiguration* config() const { return config_; }
+ InstructionOperandCache* operand_cache() const { return operand_cache_; }
ZoneVector<LiveRange*>& live_ranges() { return live_ranges_; }
ZoneVector<LiveRange*>& fixed_live_ranges() { return fixed_live_ranges_; }
ZoneVector<LiveRange*>& fixed_double_live_ranges() {
@@ -582,7 +600,6 @@ class RegisterAllocator FINAL : public ZoneObject {
ZoneVector<LiveRange*>& inactive_live_ranges() {
return inactive_live_ranges_;
}
- ZoneVector<LiveRange*>& reusable_slots() { return reusable_slots_; }
ZoneVector<SpillRange*>& spill_ranges() { return spill_ranges_; }
struct PhiMapValue {
@@ -591,8 +608,7 @@ class RegisterAllocator FINAL : public ZoneObject {
PhiInstruction* const phi;
const InstructionBlock* const block;
};
- typedef std::map<int, PhiMapValue, std::less<int>,
- zone_allocator<std::pair<int, PhiMapValue>>> PhiMap;
+ typedef ZoneMap<int, PhiMapValue> PhiMap;
Zone* const local_zone_;
Frame* const frame_;
@@ -600,7 +616,7 @@ class RegisterAllocator FINAL : public ZoneObject {
const char* const debug_name_;
const RegisterConfiguration* config_;
-
+ InstructionOperandCache* const operand_cache_;
PhiMap phi_map_;
// During liveness analysis keep a mapping from block id to live_in sets
@@ -616,7 +632,6 @@ class RegisterAllocator FINAL : public ZoneObject {
ZoneVector<LiveRange*> unhandled_live_ranges_;
ZoneVector<LiveRange*> active_live_ranges_;
ZoneVector<LiveRange*> inactive_live_ranges_;
- ZoneVector<LiveRange*> reusable_slots_;
ZoneVector<SpillRange*> spill_ranges_;
RegisterKind mode_;
@@ -625,9 +640,6 @@ class RegisterAllocator FINAL : public ZoneObject {
BitVector* assigned_registers_;
BitVector* assigned_double_registers_;
- // Indicates success or failure during register allocation.
- bool allocation_ok_;
-
#ifdef DEBUG
LifetimePosition allocation_finger_;
#endif