OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 10907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10918 i++) { | 10918 i++) { |
10919 new_table->set(i, get(i), mode); | 10919 new_table->set(i, get(i), mode); |
10920 } | 10920 } |
10921 | 10921 |
10922 // Rehash the elements. | 10922 // Rehash the elements. |
10923 int capacity = Capacity(); | 10923 int capacity = Capacity(); |
10924 for (int i = 0; i < capacity; i++) { | 10924 for (int i = 0; i < capacity; i++) { |
10925 uint32_t from_index = EntryToIndex(i); | 10925 uint32_t from_index = EntryToIndex(i); |
10926 Object* k = get(from_index); | 10926 Object* k = get(from_index); |
10927 if (IsKey(k)) { | 10927 if (IsKey(k)) { |
10928 uint32_t hash = Shape::HashForObject(key, k); | 10928 uint32_t hash = Shape::HashForObject(key, GetHeap()->StringHashSeed(), k); |
10929 uint32_t insertion_index = | 10929 uint32_t insertion_index = |
10930 EntryToIndex(new_table->FindInsertionEntry(hash)); | 10930 EntryToIndex(new_table->FindInsertionEntry(hash)); |
10931 for (int j = 0; j < Shape::kEntrySize; j++) { | 10931 for (int j = 0; j < Shape::kEntrySize; j++) { |
10932 new_table->set(insertion_index + j, get(from_index + j), mode); | 10932 new_table->set(insertion_index + j, get(from_index + j), mode); |
10933 } | 10933 } |
10934 } | 10934 } |
10935 } | 10935 } |
10936 new_table->SetNumberOfElements(NumberOfElements()); | 10936 new_table->SetNumberOfElements(NumberOfElements()); |
10937 new_table->SetNumberOfDeletedElements(0); | 10937 new_table->SetNumberOfDeletedElements(0); |
10938 return new_table; | 10938 return new_table; |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12004 Object* obj; | 12004 Object* obj; |
12005 { MaybeObject* maybe_obj = EnsureCapacity(1, key); | 12005 { MaybeObject* maybe_obj = EnsureCapacity(1, key); |
12006 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 12006 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
12007 } | 12007 } |
12008 | 12008 |
12009 Object* k; | 12009 Object* k; |
12010 { MaybeObject* maybe_k = Shape::AsObject(key); | 12010 { MaybeObject* maybe_k = Shape::AsObject(key); |
12011 if (!maybe_k->ToObject(&k)) return maybe_k; | 12011 if (!maybe_k->ToObject(&k)) return maybe_k; |
12012 } | 12012 } |
12013 PropertyDetails details = PropertyDetails(NONE, NORMAL); | 12013 PropertyDetails details = PropertyDetails(NONE, NORMAL); |
12014 return Dictionary<Shape, Key>::cast(obj)-> | 12014 return Dictionary<Shape, Key>::cast(obj)->AddEntry( |
12015 AddEntry(key, value, details, Shape::Hash(key)); | 12015 key, |
| 12016 value, |
| 12017 details, |
| 12018 Shape::Hash(key, Dictionary<Shape, Key>::GetHeap()->StringHashSeed())); |
12016 } | 12019 } |
12017 | 12020 |
12018 | 12021 |
12019 template<typename Shape, typename Key> | 12022 template<typename Shape, typename Key> |
12020 MaybeObject* Dictionary<Shape, Key>::Add(Key key, | 12023 MaybeObject* Dictionary<Shape, Key>::Add(Key key, |
12021 Object* value, | 12024 Object* value, |
12022 PropertyDetails details) { | 12025 PropertyDetails details) { |
12023 // Valdate key is absent. | 12026 // Valdate key is absent. |
12024 SLOW_ASSERT((this->FindEntry(key) == Dictionary<Shape, Key>::kNotFound)); | 12027 SLOW_ASSERT((this->FindEntry(key) == Dictionary<Shape, Key>::kNotFound)); |
12025 // Check whether the dictionary should be extended. | 12028 // Check whether the dictionary should be extended. |
12026 Object* obj; | 12029 Object* obj; |
12027 { MaybeObject* maybe_obj = EnsureCapacity(1, key); | 12030 { MaybeObject* maybe_obj = EnsureCapacity(1, key); |
12028 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 12031 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
12029 } | 12032 } |
12030 return Dictionary<Shape, Key>::cast(obj)-> | 12033 return Dictionary<Shape, Key>::cast(obj)->AddEntry( |
12031 AddEntry(key, value, details, Shape::Hash(key)); | 12034 key, |
| 12035 value, |
| 12036 details, |
| 12037 Shape::Hash(key, Dictionary<Shape, Key>::GetHeap()->StringHashSeed())); |
12032 } | 12038 } |
12033 | 12039 |
12034 | 12040 |
12035 // Add a key, value pair to the dictionary. | 12041 // Add a key, value pair to the dictionary. |
12036 template<typename Shape, typename Key> | 12042 template<typename Shape, typename Key> |
12037 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key, | 12043 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key, |
12038 Object* value, | 12044 Object* value, |
12039 PropertyDetails details, | 12045 PropertyDetails details, |
12040 uint32_t hash) { | 12046 uint32_t hash) { |
12041 // Compute the key object. | 12047 // Compute the key object. |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12740 if (break_point_objects()->IsUndefined()) return 0; | 12746 if (break_point_objects()->IsUndefined()) return 0; |
12741 // Single break point. | 12747 // Single break point. |
12742 if (!break_point_objects()->IsFixedArray()) return 1; | 12748 if (!break_point_objects()->IsFixedArray()) return 1; |
12743 // Multiple break points. | 12749 // Multiple break points. |
12744 return FixedArray::cast(break_point_objects())->length(); | 12750 return FixedArray::cast(break_point_objects())->length(); |
12745 } | 12751 } |
12746 #endif // ENABLE_DEBUGGER_SUPPORT | 12752 #endif // ENABLE_DEBUGGER_SUPPORT |
12747 | 12753 |
12748 | 12754 |
12749 } } // namespace v8::internal | 12755 } } // namespace v8::internal |
OLD | NEW |