| 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 5729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5740 uint32_t length = 0; | 5740 uint32_t length = 0; |
| 5741 if (IsJSArray()) { | 5741 if (IsJSArray()) { |
| 5742 CHECK(Array::IndexFromObject(JSArray::cast(this)->length(), &length)); | 5742 CHECK(Array::IndexFromObject(JSArray::cast(this)->length(), &length)); |
| 5743 } else { | 5743 } else { |
| 5744 length = dictionary->max_number_key(); | 5744 length = dictionary->max_number_key(); |
| 5745 } | 5745 } |
| 5746 return static_cast<uint32_t>(dictionary->Capacity()) >= | 5746 return static_cast<uint32_t>(dictionary->Capacity()) >= |
| 5747 (length / (2 * NumberDictionary::kEntrySize)); | 5747 (length / (2 * NumberDictionary::kEntrySize)); |
| 5748 } | 5748 } |
| 5749 | 5749 |
| 5750 |
| 5751 // Certain compilers request function template instantiation when they |
| 5752 // see the definition of the other template functions in the |
| 5753 // class. This requires us to have the template functions put |
| 5754 // together, so even though this function belongs in objects-debug.cc, |
| 5755 // we keep it here instead to satisfy certain compilers. |
| 5756 #ifdef DEBUG |
| 5757 template<typename Shape, typename Key> |
| 5758 void Dictionary<Shape, Key>::Print() { |
| 5759 int capacity = HashTable<Shape, Key>::Capacity(); |
| 5760 for (int i = 0; i < capacity; i++) { |
| 5761 Object* k = HashTable<Shape, Key>::KeyAt(i); |
| 5762 if (HashTable<Shape, Key>::IsKey(k)) { |
| 5763 PrintF(" "); |
| 5764 if (k->IsString()) { |
| 5765 String::cast(k)->StringPrint(); |
| 5766 } else { |
| 5767 k->ShortPrint(); |
| 5768 } |
| 5769 PrintF(": "); |
| 5770 ValueAt(i)->ShortPrint(); |
| 5771 PrintF("\n"); |
| 5772 } |
| 5773 } |
| 5774 } |
| 5775 #endif |
| 5776 |
| 5777 |
| 5750 template<typename Shape, typename Key> | 5778 template<typename Shape, typename Key> |
| 5751 void Dictionary<Shape, Key>::CopyValuesTo(FixedArray* elements) { | 5779 void Dictionary<Shape, Key>::CopyValuesTo(FixedArray* elements) { |
| 5752 int pos = 0; | 5780 int pos = 0; |
| 5753 int capacity = HashTable<Shape, Key>::Capacity(); | 5781 int capacity = HashTable<Shape, Key>::Capacity(); |
| 5754 WriteBarrierMode mode = elements->GetWriteBarrierMode(); | 5782 WriteBarrierMode mode = elements->GetWriteBarrierMode(); |
| 5755 for (int i = 0; i < capacity; i++) { | 5783 for (int i = 0; i < capacity; i++) { |
| 5756 Object* k = Dictionary<Shape, Key>::KeyAt(i); | 5784 Object* k = Dictionary<Shape, Key>::KeyAt(i); |
| 5757 if (Dictionary<Shape, Key>::IsKey(k)) { | 5785 if (Dictionary<Shape, Key>::IsKey(k)) { |
| 5758 elements->set(pos++, ValueAt(i), mode); | 5786 elements->set(pos++, ValueAt(i), mode); |
| 5759 } | 5787 } |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7682 if (break_point_objects()->IsUndefined()) return 0; | 7710 if (break_point_objects()->IsUndefined()) return 0; |
| 7683 // Single beak point. | 7711 // Single beak point. |
| 7684 if (!break_point_objects()->IsFixedArray()) return 1; | 7712 if (!break_point_objects()->IsFixedArray()) return 1; |
| 7685 // Multiple break points. | 7713 // Multiple break points. |
| 7686 return FixedArray::cast(break_point_objects())->length(); | 7714 return FixedArray::cast(break_point_objects())->length(); |
| 7687 } | 7715 } |
| 7688 #endif | 7716 #endif |
| 7689 | 7717 |
| 7690 | 7718 |
| 7691 } } // namespace v8::internal | 7719 } } // namespace v8::internal |
| OLD | NEW |