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

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: 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 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;
titzer 2014/11/19 14:02:08 On second thought, can we get rid of the modulus?
+ 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()) {
« 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