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

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

Issue 1205173002: [turbofan] Greedy allocator refactoring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: minor fix on splitting at interval boundaries Created 5 years, 6 months 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') | tools/gyp/v8.gyp » ('j') | 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 0a6f16072d433fd7f73c977499e3464a6f92a3fd..5bf858a86cf6e7551ce7a033603cc7c17990cbe2 100644
--- a/src/compiler/register-allocator.cc
+++ b/src/compiler/register-allocator.cc
@@ -237,6 +237,10 @@ struct LiveRange::SpillAtDefinitionList : ZoneObject {
};
+const float LiveRange::kInvalidWeight = -1;
+const float LiveRange::kMaxWeight = std::numeric_limits<float>::max();
+
+
LiveRange::LiveRange(int id, MachineType machine_type)
: id_(id),
spill_start_index_(kMaxInt),
@@ -250,7 +254,9 @@ LiveRange::LiveRange(int id, MachineType machine_type)
spills_at_definition_(nullptr),
current_interval_(nullptr),
last_processed_use_(nullptr),
- current_hint_position_(nullptr) {
+ current_hint_position_(nullptr),
+ size_(kInvalidSize),
+ weight_(kInvalidWeight) {
DCHECK(AllocatedOperand::IsSupportedMachineType(machine_type));
bits_ = SpillTypeField::encode(SpillType::kNoSpillType) |
AssignedRegisterField::encode(kUnassignedRegister) |
@@ -559,6 +565,10 @@ void LiveRange::SplitAt(LifetimePosition position, LiveRange* result,
result->next_ = next_;
next_ = result;
+ // Invalidate size and weight of this range. The child range has them
+ // invalid at construction.
+ size_ = kInvalidSize;
+ weight_ = kInvalidWeight;
#ifdef DEBUG
Verify();
result->Verify();
@@ -749,6 +759,19 @@ LifetimePosition LiveRange::FirstIntersection(LiveRange* other) const {
}
+unsigned LiveRange::GetSize() {
+ if (size_ == kInvalidSize) {
+ size_ = 0;
+ for (auto interval = first_interval(); interval != nullptr;
+ interval = interval->next()) {
+ size_ += (interval->end().value() - interval->start().value());
+ }
+ }
+
+ return static_cast<unsigned>(size_);
+}
+
+
static bool AreUseIntervalsIntersecting(UseInterval* interval1,
UseInterval* interval2) {
while (interval1 != nullptr && interval2 != nullptr) {
@@ -1852,6 +1875,15 @@ const ZoneVector<LiveRange*>& RegisterAllocator::GetFixedRegisters() const {
}
+const char* RegisterAllocator::RegisterName(int allocation_index) const {
+ if (mode() == GENERAL_REGISTERS) {
+ return data()->config()->general_register_name(allocation_index);
+ } else {
+ return data()->config()->double_register_name(allocation_index);
+ }
+}
+
+
LinearScanAllocator::LinearScanAllocator(RegisterAllocationData* data,
RegisterKind kind, Zone* local_zone)
: RegisterAllocator(data, kind),
@@ -1958,15 +1990,6 @@ void LinearScanAllocator::AllocateRegisters() {
}
-const char* LinearScanAllocator::RegisterName(int allocation_index) const {
- if (mode() == GENERAL_REGISTERS) {
- return data()->config()->general_register_name(allocation_index);
- } else {
- return data()->config()->double_register_name(allocation_index);
- }
-}
-
-
void LinearScanAllocator::SetLiveRangeAssignedRegister(LiveRange* range,
int reg) {
data()->MarkAllocated(range->kind(), reg);
« no previous file with comments | « src/compiler/register-allocator.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698