Reviewers: titzer,
Message:
ptal
Description:
[turbofan] round robin register picking
[email protected]
BUG=
Please review this at https://codereview.chromium.org/728553003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+19, -14 lines):
M src/compiler/register-allocator.h
M src/compiler/register-allocator.cc
Index: src/compiler/register-allocator.cc
diff --git a/src/compiler/register-allocator.cc
b/src/compiler/register-allocator.cc
index
66e250c4c2cfd2f9422913d3c66f088cdeb5a94b..c76bd7bdae9d7970c801ab6e40bdeb59be9926b1
100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -526,6 +526,7 @@ RegisterAllocator::RegisterAllocator(const
RegisterConfiguration* config,
reusable_slots_(8, local_zone()),
mode_(UNALLOCATED_REGISTERS),
num_registers_(-1),
+ first_register_to_try_(0),
allocation_ok_(true) {
DCHECK(this->config()->num_general_registers() <=
RegisterConfiguration::kMaxGeneralRegisters);
@@ -1862,6 +1863,20 @@ void RegisterAllocator::InactiveToActive(LiveRange*
range) {
}
+// Pick the index of the maximum position, starting at offset start.
+static int MaximalIndex(const LifetimePosition* positions, const uint8_t
start,
+ const int count) {
+ int reg = start % count;
+ for (int i = 1; i < count; ++i) {
+ int index = (i + start) % count;
+ if (positions[index].Value() > positions[reg].Value()) {
+ reg = index;
+ }
+ }
+ return reg;
+}
+
+
bool RegisterAllocator::TryAllocateFreeReg(LiveRange* current) {
LifetimePosition
free_until_pos[RegisterConfiguration::kMaxDoubleRegisters];
@@ -1903,13 +1918,8 @@ bool
RegisterAllocator::TryAllocateFreeReg(LiveRange* current) {
}
// Find the register which stays free for the longest time.
- int reg = 0;
- for (int i = 1; i < RegisterCount(); ++i) {
- if (free_until_pos[i].Value() > free_until_pos[reg].Value()) {
- reg = i;
- }
- }
-
+ int reg =
+ MaximalIndex(free_until_pos, first_register_to_try_++,
RegisterCount());
LifetimePosition pos = free_until_pos[reg];
if (pos.Value() <= current->Start().Value()) {
@@ -1984,13 +1994,7 @@ void
RegisterAllocator::AllocateBlockedReg(LiveRange* current) {
}
}
- int reg = 0;
- for (int i = 1; i < RegisterCount(); ++i) {
- if (use_pos[i].Value() > use_pos[reg].Value()) {
- reg = i;
- }
- }
-
+ int reg = MaximalIndex(use_pos, first_register_to_try_++,
RegisterCount());
LifetimePosition pos = use_pos[reg];
if (pos.Value() < register_use->pos().Value()) {
Index: src/compiler/register-allocator.h
diff --git a/src/compiler/register-allocator.h
b/src/compiler/register-allocator.h
index
45c33712de70bb3cc3e64d4988238e6bf736d336..2b2851ed6fe2aed19855ca93110433d1d0507a23
100644
--- a/src/compiler/register-allocator.h
+++ b/src/compiler/register-allocator.h
@@ -536,6 +536,7 @@ class RegisterAllocator FINAL : public ZoneObject {
RegisterKind mode_;
int num_registers_;
+ uint8_t first_register_to_try_; // For robin round register picking.
BitVector* assigned_registers_;
BitVector* assigned_double_registers_;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.