Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Unified Diff: src/compiler/register-allocator.cc

Issue 728553003: [turbofan] round robin register picking (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/register-allocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/register-allocator.cc
diff --git a/src/compiler/register-allocator.cc b/src/compiler/register-allocator.cc
index 3e1ac629417d6f5c8a66ccd425fc5f323df8730c..5970e97ec19737ba18da10d4e471cbedf5f0b304 100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -547,6 +547,7 @@ RegisterAllocator::RegisterAllocator(const RegisterConfiguration* config,
spill_ranges_(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);
@@ -2061,6 +2062,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];
@@ -2102,13 +2117,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()) {
@@ -2183,13 +2193,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()) {
« no previous file with comments | « src/compiler/register-allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698