Use placement-new operator in the register allocator.

Pass the zone explicitly to avoid calling Isolate::Current()->zone().
Review URL: https://chromiumcodereview.appspot.com/9430002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10785 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4b54dc52
...@@ -7617,7 +7617,7 @@ void HTracer::TraceLiveRange(LiveRange* range, const char* type) { ...@@ -7617,7 +7617,7 @@ void HTracer::TraceLiveRange(LiveRange* range, const char* type) {
PrintIndent(); PrintIndent();
trace_.Add("%d %s", range->id(), type); trace_.Add("%d %s", range->id(), type);
if (range->HasRegisterAssigned()) { if (range->HasRegisterAssigned()) {
LOperand* op = range->CreateAssignedOperand(); LOperand* op = range->CreateAssignedOperand(ZONE);
int assigned_reg = op->index(); int assigned_reg = op->index();
if (op->IsDoubleRegister()) { if (op->IsDoubleRegister()) {
trace_.Add(" \"%s\"", trace_.Add(" \"%s\"",
......
This diff is collapsed.
...@@ -216,7 +216,7 @@ class UseInterval: public ZoneObject { ...@@ -216,7 +216,7 @@ class UseInterval: public ZoneObject {
// Split this interval at the given position without effecting the // Split this interval at the given position without effecting the
// live range that owns it. The interval must contain the position. // live range that owns it. The interval must contain the position.
void SplitAt(LifetimePosition pos); void SplitAt(LifetimePosition pos, Zone* zone);
// If this interval intersects with other return smallest position // If this interval intersects with other return smallest position
// that belongs to both of them. // that belongs to both of them.
...@@ -277,7 +277,7 @@ class LiveRange: public ZoneObject { ...@@ -277,7 +277,7 @@ class LiveRange: public ZoneObject {
public: public:
static const int kInvalidAssignment = 0x7fffffff; static const int kInvalidAssignment = 0x7fffffff;
explicit LiveRange(int id); LiveRange(int id, Zone* zone);
UseInterval* first_interval() const { return first_interval_; } UseInterval* first_interval() const { return first_interval_; }
UsePosition* first_pos() const { return first_pos_; } UsePosition* first_pos() const { return first_pos_; }
...@@ -288,11 +288,13 @@ class LiveRange: public ZoneObject { ...@@ -288,11 +288,13 @@ class LiveRange: public ZoneObject {
int id() const { return id_; } int id() const { return id_; }
bool IsFixed() const { return id_ < 0; } bool IsFixed() const { return id_ < 0; }
bool IsEmpty() const { return first_interval() == NULL; } bool IsEmpty() const { return first_interval() == NULL; }
LOperand* CreateAssignedOperand(); LOperand* CreateAssignedOperand(Zone* zone);
int assigned_register() const { return assigned_register_; } int assigned_register() const { return assigned_register_; }
int spill_start_index() const { return spill_start_index_; } int spill_start_index() const { return spill_start_index_; }
void set_assigned_register(int reg, RegisterKind register_kind); void set_assigned_register(int reg,
void MakeSpilled(); RegisterKind register_kind,
Zone* zone);
void MakeSpilled(Zone* zone);
// Returns use position in this live range that follows both start // Returns use position in this live range that follows both start
// and last processed use position. // and last processed use position.
...@@ -316,7 +318,7 @@ class LiveRange: public ZoneObject { ...@@ -316,7 +318,7 @@ class LiveRange: public ZoneObject {
// the range. // the range.
// All uses following the given position will be moved from this // All uses following the given position will be moved from this
// live range to the result live range. // live range to the result live range.
void SplitAt(LifetimePosition position, LiveRange* result); void SplitAt(LifetimePosition position, LiveRange* result, Zone* zone);
bool IsDouble() const { return is_double_; } bool IsDouble() const { return is_double_; }
bool HasRegisterAssigned() const { bool HasRegisterAssigned() const {
...@@ -355,9 +357,15 @@ class LiveRange: public ZoneObject { ...@@ -355,9 +357,15 @@ class LiveRange: public ZoneObject {
LifetimePosition FirstIntersection(LiveRange* other); LifetimePosition FirstIntersection(LiveRange* other);
// Add a new interval or a new use position to this live range. // Add a new interval or a new use position to this live range.
void EnsureInterval(LifetimePosition start, LifetimePosition end); void EnsureInterval(LifetimePosition start,
void AddUseInterval(LifetimePosition start, LifetimePosition end); LifetimePosition end,
UsePosition* AddUsePosition(LifetimePosition pos, LOperand* operand); Zone* zone);
void AddUseInterval(LifetimePosition start,
LifetimePosition end,
Zone* zone);
UsePosition* AddUsePosition(LifetimePosition pos,
LOperand* operand,
Zone* zone);
// Shorten the most recently added interval by setting a new start. // Shorten the most recently added interval by setting a new start.
void ShortenTo(LifetimePosition start); void ShortenTo(LifetimePosition start);
...@@ -369,7 +377,7 @@ class LiveRange: public ZoneObject { ...@@ -369,7 +377,7 @@ class LiveRange: public ZoneObject {
#endif #endif
private: private:
void ConvertOperands(); void ConvertOperands(Zone* zone);
UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const; UseInterval* FirstSearchIntervalForPosition(LifetimePosition position) const;
void AdvanceLastProcessedMarker(UseInterval* to_start_of, void AdvanceLastProcessedMarker(UseInterval* to_start_of,
LifetimePosition but_not_past) const; LifetimePosition but_not_past) const;
...@@ -400,8 +408,8 @@ class GrowableBitVector BASE_EMBEDDED { ...@@ -400,8 +408,8 @@ class GrowableBitVector BASE_EMBEDDED {
return bits_->Contains(value); return bits_->Contains(value);
} }
void Add(int value) { void Add(int value, Zone* zone) {
EnsureCapacity(value); EnsureCapacity(value, zone);
bits_->Add(value); bits_->Add(value);
} }
...@@ -412,11 +420,11 @@ class GrowableBitVector BASE_EMBEDDED { ...@@ -412,11 +420,11 @@ class GrowableBitVector BASE_EMBEDDED {
return bits_ != NULL && bits_->length() > value; return bits_ != NULL && bits_->length() > value;
} }
void EnsureCapacity(int value) { void EnsureCapacity(int value, Zone* zone) {
if (InBitsRange(value)) return; if (InBitsRange(value)) return;
int new_length = bits_ == NULL ? kInitialLength : bits_->length(); int new_length = bits_ == NULL ? kInitialLength : bits_->length();
while (new_length <= value) new_length *= 2; while (new_length <= value) new_length *= 2;
BitVector* new_bits = new BitVector(new_length); BitVector* new_bits = new(zone) BitVector(new_length);
if (bits_ != NULL) new_bits->CopyFrom(*bits_); if (bits_ != NULL) new_bits->CopyFrom(*bits_);
bits_ = new_bits; bits_ = new_bits;
} }
...@@ -587,10 +595,9 @@ class LAllocator BASE_EMBEDDED { ...@@ -587,10 +595,9 @@ class LAllocator BASE_EMBEDDED {
inline LGap* GapAt(int index); inline LGap* GapAt(int index);
LChunk* chunk_; Zone* zone_;
// Indicates success or failure during register allocation. LChunk* chunk_;
bool allocation_ok_;
// During liveness analysis keep a mapping from block id to live_in sets // During liveness analysis keep a mapping from block id to live_in sets
// for blocks already analyzed. // for blocks already analyzed.
...@@ -621,6 +628,9 @@ class LAllocator BASE_EMBEDDED { ...@@ -621,6 +628,9 @@ class LAllocator BASE_EMBEDDED {
bool has_osr_entry_; bool has_osr_entry_;
// Indicates success or failure during register allocation.
bool allocation_ok_;
DISALLOW_COPY_AND_ASSIGN(LAllocator); DISALLOW_COPY_AND_ASSIGN(LAllocator);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment