| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 6868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6879 | 6879 |
| 6880 template<typename Shape, typename Key> | 6880 template<typename Shape, typename Key> |
| 6881 Object* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { | 6881 Object* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) { |
| 6882 int capacity = Capacity(); | 6882 int capacity = Capacity(); |
| 6883 int nof = NumberOfElements() + n; | 6883 int nof = NumberOfElements() + n; |
| 6884 int nod = NumberOfDeletedElements(); | 6884 int nod = NumberOfDeletedElements(); |
| 6885 // Return if: | 6885 // Return if: |
| 6886 // 50% is still free after adding n elements and | 6886 // 50% is still free after adding n elements and |
| 6887 // at most 50% of the free elements are deleted elements. | 6887 // at most 50% of the free elements are deleted elements. |
| 6888 if ((nof + (nof >> 1) <= capacity) && | 6888 if ((nof + (nof >> 1) <= capacity) && |
| 6889 (nod <= (capacity - nof) >> 1) ) return this; | 6889 (nod <= (capacity - nof) >> 1)) return this; |
| 6890 | 6890 |
| 6891 Object* obj = Allocate(nof * 2); | 6891 Object* obj = Allocate(nof * 2); |
| 6892 if (obj->IsFailure()) return obj; | 6892 if (obj->IsFailure()) return obj; |
| 6893 HashTable* table = HashTable::cast(obj); | 6893 HashTable* table = HashTable::cast(obj); |
| 6894 WriteBarrierMode mode = table->GetWriteBarrierMode(); | 6894 WriteBarrierMode mode = table->GetWriteBarrierMode(); |
| 6895 | 6895 |
| 6896 // Copy prefix to new array. | 6896 // Copy prefix to new array. |
| 6897 for (int i = kPrefixStartIndex; | 6897 for (int i = kPrefixStartIndex; |
| 6898 i < kPrefixStartIndex + Shape::kPrefixSize; | 6898 i < kPrefixStartIndex + Shape::kPrefixSize; |
| 6899 i++) { | 6899 i++) { |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8300 if (break_point_objects()->IsUndefined()) return 0; | 8300 if (break_point_objects()->IsUndefined()) return 0; |
| 8301 // Single beak point. | 8301 // Single beak point. |
| 8302 if (!break_point_objects()->IsFixedArray()) return 1; | 8302 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8303 // Multiple break points. | 8303 // Multiple break points. |
| 8304 return FixedArray::cast(break_point_objects())->length(); | 8304 return FixedArray::cast(break_point_objects())->length(); |
| 8305 } | 8305 } |
| 8306 #endif | 8306 #endif |
| 8307 | 8307 |
| 8308 | 8308 |
| 8309 } } // namespace v8::internal | 8309 } } // namespace v8::internal |
| OLD | NEW |