From 4d62ca43001cc36e9994bfbc1c655e6b47c77c0d Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Tue, 30 Apr 2013 08:21:52 +0000 Subject: [PATCH] Make UsePosition::hint immutable. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/14524008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14489 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/lithium-allocator.cc | 23 ++++++++++++----------- src/lithium-allocator.h | 16 ++++++++-------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc index 7bddef7f99..a010f4ea80 100644 --- a/src/lithium-allocator.cc +++ b/src/lithium-allocator.cc @@ -56,9 +56,11 @@ static inline LifetimePosition Max(LifetimePosition a, LifetimePosition b) { } -UsePosition::UsePosition(LifetimePosition pos, LOperand* operand) +UsePosition::UsePosition(LifetimePosition pos, + LOperand* operand, + LOperand* hint) : operand_(operand), - hint_(NULL), + hint_(hint), pos_(pos), next_(NULL), requires_reg_(false), @@ -449,13 +451,14 @@ void LiveRange::AddUseInterval(LifetimePosition start, } -UsePosition* LiveRange::AddUsePosition(LifetimePosition pos, - LOperand* operand, - Zone* zone) { +void LiveRange::AddUsePosition(LifetimePosition pos, + LOperand* operand, + LOperand* hint, + Zone* zone) { LAllocator::TraceAlloc("Add to live range %d use position %d\n", id_, pos.Value()); - UsePosition* use_pos = new(zone) UsePosition(pos, operand); + UsePosition* use_pos = new(zone) UsePosition(pos, operand, hint); UsePosition* prev = NULL; UsePosition* current = first_pos_; while (current != NULL && current->pos().Value() < pos.Value()) { @@ -470,8 +473,6 @@ UsePosition* LiveRange::AddUsePosition(LifetimePosition pos, use_pos->next_ = prev->next_; prev->next_ = use_pos; } - - return use_pos; } @@ -725,14 +726,14 @@ void LAllocator::Define(LifetimePosition position, if (range->IsEmpty() || range->Start().Value() > position.Value()) { // Can happen if there is a definition without use. range->AddUseInterval(position, position.NextInstruction(), zone_); - range->AddUsePosition(position.NextInstruction(), NULL, zone_); + range->AddUsePosition(position.NextInstruction(), NULL, NULL, zone_); } else { range->ShortenTo(position); } if (operand->IsUnallocated()) { LUnallocated* unalloc_operand = LUnallocated::cast(operand); - range->AddUsePosition(position, unalloc_operand, zone_)->set_hint(hint); + range->AddUsePosition(position, unalloc_operand, hint, zone_); } } @@ -745,7 +746,7 @@ void LAllocator::Use(LifetimePosition block_start, if (range == NULL) return; if (operand->IsUnallocated()) { LUnallocated* unalloc_operand = LUnallocated::cast(operand); - range->AddUsePosition(position, unalloc_operand, zone_)->set_hint(hint); + range->AddUsePosition(position, unalloc_operand, hint, zone_); } range->AddUseInterval(block_start, position, zone_); } diff --git a/src/lithium-allocator.h b/src/lithium-allocator.h index 8b45531d9b..0cd5ae0e8e 100644 --- a/src/lithium-allocator.h +++ b/src/lithium-allocator.h @@ -244,13 +244,12 @@ class UseInterval: public ZoneObject { // Representation of a use position. class UsePosition: public ZoneObject { public: - UsePosition(LifetimePosition pos, LOperand* operand); + UsePosition(LifetimePosition pos, LOperand* operand, LOperand* hint); LOperand* operand() const { return operand_; } bool HasOperand() const { return operand_ != NULL; } LOperand* hint() const { return hint_; } - void set_hint(LOperand* hint) { hint_ = hint; } bool HasHint() const; bool RequiresRegister() const; bool RegisterIsBeneficial() const; @@ -261,9 +260,9 @@ class UsePosition: public ZoneObject { private: void set_next(UsePosition* next) { next_ = next; } - LOperand* operand_; - LOperand* hint_; - LifetimePosition pos_; + LOperand* const operand_; + LOperand* const hint_; + LifetimePosition const pos_; UsePosition* next_; bool requires_reg_; bool register_beneficial_; @@ -367,9 +366,10 @@ class LiveRange: public ZoneObject { void AddUseInterval(LifetimePosition start, LifetimePosition end, Zone* zone); - UsePosition* AddUsePosition(LifetimePosition pos, - LOperand* operand, - Zone* zone); + void AddUsePosition(LifetimePosition pos, + LOperand* operand, + LOperand* hint, + Zone* zone); // Shorten the most recently added interval by setting a new start. void ShortenTo(LifetimePosition start);