Chromium Code Reviews| Index: runtime/vm/intermediate_language.h |
| diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h |
| index 9eb0767f1938faba685537f430b2724d10b9900e..701408aabbe24c841b9ac44e88d50d881ea0e128 100644 |
| --- a/runtime/vm/intermediate_language.h |
| +++ b/runtime/vm/intermediate_language.h |
| @@ -2678,13 +2678,11 @@ class BranchInstr : public InstructionWithInputs { |
| class Environment : public ZoneAllocated { |
| public: |
| // Construct an environment by copying from an array of values. |
| - // TODO(vegorov): it's absolutely crucial that locations_ backing store |
| - // is preallocated and never reallocated. We use pointers into it |
| - // during register allocation. |
| explicit Environment(const GrowableArray<Value*>& values, |
| intptr_t fixed_parameter_count) |
| : values_(values.length()), |
| - locations_(values.length()), |
| + location_count_(0), |
| + locations_(NULL), |
| fixed_parameter_count_(fixed_parameter_count) { |
| values_.AddArray(values); |
| } |
| @@ -2693,16 +2691,22 @@ class Environment : public ZoneAllocated { |
| return values_; |
| } |
| - void AddLocation(Location value) { |
| - locations_.Add(value); |
| + void InitializeLocations() { |
| + location_count_ = values_.length(); |
|
srdjan
2012/08/06 22:49:25
ASSERT(locations_ == NULL), guaranteeing that we d
|
| + if (location_count_ > 0) { |
| + locations_ = |
| + Isolate::Current()->current_zone()->Alloc<Location>(location_count_); |
|
srdjan
2012/08/06 22:49:25
Please initialize locations_ with default Location
|
| + } |
| } |
| Location LocationAt(intptr_t ix) const { |
| + ASSERT((ix >= 0) && (ix < location_count_)); |
|
srdjan
2012/08/06 22:49:25
ASSERT(locations_ != NULL) .
|
| return locations_[ix]; |
| } |
| Location* LocationSlotAt(intptr_t ix) const { |
| - return & locations_[ix]; |
| + ASSERT((ix >= 0) && (ix < location_count_)); |
|
srdjan
2012/08/06 22:49:25
ditto
|
| + return &locations_[ix]; |
| } |
| intptr_t fixed_parameter_count() const { |
| @@ -2713,7 +2717,8 @@ class Environment : public ZoneAllocated { |
| private: |
| GrowableArray<Value*> values_; |
| - GrowableArray<Location> locations_; |
| + intptr_t location_count_; |
| + Location* locations_; |
| const intptr_t fixed_parameter_count_; |
| DISALLOW_COPY_AND_ASSIGN(Environment); |