Commit cd481a7d authored by mtrofin's avatar mtrofin Committed by Commit bot

Most of the issues so far encountered with the greedy allocator rest with the...

Most of the issues so far encountered with the greedy allocator rest with the splitting mechanism. This change has:

- all RegisterAllocatorTest unit tests passing, when unittest has the flags: --turbo-filter=* --always-opt --turbo-deoptimization --turbo-verify-allocation --turbo_greedy_regalloc

./tools/run-tests.py passing when providing --turbo_greedy_regalloc, but still having some failing (more than the "normal" 43) when passing all the flags. I realize just passing --turbo_greedy_regalloc does not provide full coverage, but it did uncover some bugs, still

The CL centralizes the computing of split points (for "losing" intervals) with the determination of whether an interval is irreducible, and, therefore, of infinite spill weight (if an interval can't be split or spilled, it can't lose in weight comparison because there's nothing we can do to it and make progress).

There are allocator efficiency opportunities I haven't yet taken (this refers to the code itself, not the generated code). For example, the above split/spill computation can be cached. My plan is to defer this to at least after we see numbers showing the value of the algorithm, and potentially do at the same time we remove the linear algorithm, if that is still the plan. At that time, we can look where some APIs best belong (e.g. weight computation may fully live and cache itself on LiveRange)

In addition, the CL adds a few debug-time-only Print APIs I found very useful:  on demand (while in GDB) dump of the code, live range info (use positions & operand description, and intervals), etc.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#28185}
parent 24da8908
This diff is collapsed.
......@@ -6,6 +6,7 @@
#define V8_REGISTER_ALLOCATOR_H_
#include "src/compiler/instruction.h"
#include "src/ostreams.h"
#include "src/zone-containers.h"
namespace v8 {
......@@ -152,6 +153,9 @@ class LifetimePosition final {
};
std::ostream& operator<<(std::ostream& os, const LifetimePosition pos);
// Representation of the non-empty interval [start,end[.
class UseInterval final : public ZoneObject {
public:
......@@ -468,6 +472,16 @@ class LiveRange final : public ZoneObject {
};
struct PrintableLiveRange {
const RegisterConfiguration* register_configuration_;
const LiveRange* range_;
};
std::ostream& operator<<(std::ostream& os,
const PrintableLiveRange& printable_range);
class SpillRange final : public ZoneObject {
public:
static const int kUnassignedSlot = -1;
......@@ -826,7 +840,7 @@ class LinearScanAllocator final : public RegisterAllocator {
DISALLOW_COPY_AND_ASSIGN(LinearScanAllocator);
};
class CoallescedLiveRanges;
class CoalescedLiveRanges;
// A variant of the LLVM Greedy Register Allocator. See
......@@ -839,7 +853,11 @@ class GreedyAllocator final : public RegisterAllocator {
void AllocateRegisters();
private:
LifetimePosition GetSplittablePos(LifetimePosition pos);
const RegisterConfiguration* config() const { return data()->config(); }
Zone* local_zone() const { return local_zone_; }
bool TryReuseSpillForPhi(LiveRange* range);
int GetHintedRegister(LiveRange* range);
typedef ZonePriorityQueue<std::pair<unsigned, LiveRange*>> PQueue;
......@@ -855,13 +873,18 @@ class GreedyAllocator final : public RegisterAllocator {
bool TryAllocatePhysicalRegister(unsigned reg_id, LiveRange* range,
ZoneSet<LiveRange*>* conflicting);
bool HandleSpillOperands(LiveRange* range);
bool AllocateBlockedRange(LiveRange*, const ZoneSet<LiveRange*>&);
void AllocateBlockedRange(LiveRange* current, LifetimePosition pos,
bool spill);
LiveRange* SpillBetweenUntil(LiveRange* range, LifetimePosition start,
LifetimePosition until, LifetimePosition end);
void AssignRangeToRegister(int reg_id, LiveRange* range);
ZoneVector<CoallescedLiveRanges*> allocations_;
LifetimePosition FindProgressingSplitPosition(LiveRange* range,
bool* is_spill_pos);
Zone* local_zone_;
ZoneVector<CoalescedLiveRanges*> allocations_;
PQueue queue_;
DISALLOW_COPY_AND_ASSIGN(GreedyAllocator);
};
......
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