Chromium Code Reviews| Index: runtime/vm/object.cc |
| =================================================================== |
| --- runtime/vm/object.cc (revision 32913) |
| +++ runtime/vm/object.cc (working copy) |
| @@ -4263,7 +4263,7 @@ |
| if ((index + 2) >= length) { |
| // Grow the instantiations array. |
| // The initial array is Object::zero_array() of length 1. |
| - length = (length == 1) ? 3 : length + 4; |
| + length = (length == 1) ? 3 : ((length - 1) * 2 + 1); |
|
Ivan Posva
2014/02/21 22:26:56
How about not allowing unbounded exponential growt
regis
2014/02/21 23:08:47
Done.
|
| prior_instantiations = |
| Array::Grow(prior_instantiations, length, Heap::kOld); |
| set_instantiations(prior_instantiations); |
| @@ -12892,13 +12892,13 @@ |
| if (canonical_types.IsNull()) { |
| canonical_types = empty_array().raw(); |
| } |
| - const intptr_t canonical_types_len = canonical_types.Length(); |
| + const intptr_t length = canonical_types.Length(); |
| // Linear search to see whether this type is already present in the |
| // list of canonicalized types. |
| // TODO(asiva): Try to re-factor this lookup code to make sharing |
| // easy between the 4 versions of this loop. |
| intptr_t index = 0; |
| - while (index < canonical_types_len) { |
| + while (index < length) { |
| type ^= canonical_types.At(index); |
| if (type.IsNull()) { |
| break; |
| @@ -12917,9 +12917,8 @@ |
| type_args = type_args.Canonicalize(trail); |
| set_arguments(type_args); |
| // The type needs to be added to the list. Grow the list if it is full. |
| - if (index == canonical_types_len) { |
| - const intptr_t kLengthIncrement = 2; // Raw and parameterized. |
| - const intptr_t new_length = canonical_types.Length() + kLengthIncrement; |
| + if (index == length) { |
| + const intptr_t new_length = (length == 0) ? 1 : (length * 2); |
|
Ivan Posva
2014/02/21 22:26:56
ditto
regis
2014/02/21 23:08:47
Done.
|
| const Array& new_canonical_types = Array::Handle( |
| isolate, Array::Grow(canonical_types, new_length, Heap::kOld)); |
| cls.set_canonical_types(new_canonical_types); |