| 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 6913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6924 | 6924 |
| 6925 template<typename Shape, typename Key> | 6925 template<typename Shape, typename Key> |
| 6926 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) { | 6926 void HashTable<Shape, Key>::IterateElements(ObjectVisitor* v) { |
| 6927 IteratePointers(v, | 6927 IteratePointers(v, |
| 6928 kElementsStartOffset, | 6928 kElementsStartOffset, |
| 6929 kHeaderSize + length() * kPointerSize); | 6929 kHeaderSize + length() * kPointerSize); |
| 6930 } | 6930 } |
| 6931 | 6931 |
| 6932 | 6932 |
| 6933 template<typename Shape, typename Key> | 6933 template<typename Shape, typename Key> |
| 6934 Object* HashTable<Shape, Key>::Allocate( | 6934 Object* HashTable<Shape, Key>::Allocate(int at_least_space_for) { |
| 6935 int at_least_space_for) { | |
| 6936 int capacity = RoundUpToPowerOf2(at_least_space_for); | 6935 int capacity = RoundUpToPowerOf2(at_least_space_for); |
| 6937 if (capacity < 4) capacity = 4; // Guarantee min capacity. | 6936 if (capacity < 4) { |
| 6937 capacity = 4; // Guarantee min capacity. |
| 6938 } else if (capacity > HashTable::kMaxCapacity) { |
| 6939 return Failure::OutOfMemoryException(); |
| 6940 } |
| 6941 |
| 6938 Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity)); | 6942 Object* obj = Heap::AllocateHashTable(EntryToIndex(capacity)); |
| 6939 if (!obj->IsFailure()) { | 6943 if (!obj->IsFailure()) { |
| 6940 HashTable::cast(obj)->SetNumberOfElements(0); | 6944 HashTable::cast(obj)->SetNumberOfElements(0); |
| 6941 HashTable::cast(obj)->SetNumberOfDeletedElements(0); | 6945 HashTable::cast(obj)->SetNumberOfDeletedElements(0); |
| 6942 HashTable::cast(obj)->SetCapacity(capacity); | 6946 HashTable::cast(obj)->SetCapacity(capacity); |
| 6943 } | 6947 } |
| 6944 return obj; | 6948 return obj; |
| 6945 } | 6949 } |
| 6946 | 6950 |
| 6947 | 6951 |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8317 if (break_point_objects()->IsUndefined()) return 0; | 8321 if (break_point_objects()->IsUndefined()) return 0; |
| 8318 // Single beak point. | 8322 // Single beak point. |
| 8319 if (!break_point_objects()->IsFixedArray()) return 1; | 8323 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8320 // Multiple break points. | 8324 // Multiple break points. |
| 8321 return FixedArray::cast(break_point_objects())->length(); | 8325 return FixedArray::cast(break_point_objects())->length(); |
| 8322 } | 8326 } |
| 8323 #endif | 8327 #endif |
| 8324 | 8328 |
| 8325 | 8329 |
| 8326 } } // namespace v8::internal | 8330 } } // namespace v8::internal |
| OLD | NEW |