Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/objects.cc

Issue 9148006: [objects] seed NumberDictionary (only ia32 now) Base URL: gh:v8/v8@master
Patch Set: fixed linter issues, use pseudo-random function in test Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 10909 matching lines...) Expand 10 before | Expand all | Expand 10 after
10920 i++) { 10920 i++) {
10921 new_table->set(i, get(i), mode); 10921 new_table->set(i, get(i), mode);
10922 } 10922 }
10923 10923
10924 // Rehash the elements. 10924 // Rehash the elements.
10925 int capacity = Capacity(); 10925 int capacity = Capacity();
10926 for (int i = 0; i < capacity; i++) { 10926 for (int i = 0; i < capacity; i++) {
10927 uint32_t from_index = EntryToIndex(i); 10927 uint32_t from_index = EntryToIndex(i);
10928 Object* k = get(from_index); 10928 Object* k = get(from_index);
10929 if (IsKey(k)) { 10929 if (IsKey(k)) {
10930 uint32_t hash = Shape::HashForObject(key, k); 10930 uint32_t hash = HashTable<Shape, Key>::HashForObject(key, k);
10931 uint32_t insertion_index = 10931 uint32_t insertion_index =
10932 EntryToIndex(new_table->FindInsertionEntry(hash)); 10932 EntryToIndex(new_table->FindInsertionEntry(hash));
10933 for (int j = 0; j < Shape::kEntrySize; j++) { 10933 for (int j = 0; j < Shape::kEntrySize; j++) {
10934 new_table->set(insertion_index + j, get(from_index + j), mode); 10934 new_table->set(insertion_index + j, get(from_index + j), mode);
10935 } 10935 }
10936 } 10936 }
10937 } 10937 }
10938 new_table->SetNumberOfElements(NumberOfElements()); 10938 new_table->SetNumberOfElements(NumberOfElements());
10939 new_table->SetNumberOfDeletedElements(0); 10939 new_table->SetNumberOfDeletedElements(0);
10940 return new_table; 10940 return new_table;
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
12006 Object* obj; 12006 Object* obj;
12007 { MaybeObject* maybe_obj = EnsureCapacity(1, key); 12007 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
12008 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12008 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12009 } 12009 }
12010 12010
12011 Object* k; 12011 Object* k;
12012 { MaybeObject* maybe_k = Shape::AsObject(key); 12012 { MaybeObject* maybe_k = Shape::AsObject(key);
12013 if (!maybe_k->ToObject(&k)) return maybe_k; 12013 if (!maybe_k->ToObject(&k)) return maybe_k;
12014 } 12014 }
12015 PropertyDetails details = PropertyDetails(NONE, NORMAL); 12015 PropertyDetails details = PropertyDetails(NONE, NORMAL);
12016 return Dictionary<Shape, Key>::cast(obj)-> 12016
12017 AddEntry(key, value, details, Shape::Hash(key)); 12017 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details,
12018 Dictionary<Shape, Key>::Hash(key));
12018 } 12019 }
12019 12020
12020 12021
12021 template<typename Shape, typename Key> 12022 template<typename Shape, typename Key>
12022 MaybeObject* Dictionary<Shape, Key>::Add(Key key, 12023 MaybeObject* Dictionary<Shape, Key>::Add(Key key,
12023 Object* value, 12024 Object* value,
12024 PropertyDetails details) { 12025 PropertyDetails details) {
12025 // Valdate key is absent. 12026 // Valdate key is absent.
12026 SLOW_ASSERT((this->FindEntry(key) == Dictionary<Shape, Key>::kNotFound)); 12027 SLOW_ASSERT((this->FindEntry(key) == Dictionary<Shape, Key>::kNotFound));
12027 // Check whether the dictionary should be extended. 12028 // Check whether the dictionary should be extended.
12028 Object* obj; 12029 Object* obj;
12029 { MaybeObject* maybe_obj = EnsureCapacity(1, key); 12030 { MaybeObject* maybe_obj = EnsureCapacity(1, key);
12030 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 12031 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
12031 } 12032 }
12032 return Dictionary<Shape, Key>::cast(obj)-> 12033
12033 AddEntry(key, value, details, Shape::Hash(key)); 12034 return Dictionary<Shape, Key>::cast(obj)->AddEntry(key, value, details,
12035 Dictionary<Shape, Key>::Hash(key));
12034 } 12036 }
12035 12037
12036 12038
12037 // Add a key, value pair to the dictionary. 12039 // Add a key, value pair to the dictionary.
12038 template<typename Shape, typename Key> 12040 template<typename Shape, typename Key>
12039 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key, 12041 MaybeObject* Dictionary<Shape, Key>::AddEntry(Key key,
12040 Object* value, 12042 Object* value,
12041 PropertyDetails details, 12043 PropertyDetails details,
12042 uint32_t hash) { 12044 uint32_t hash) {
12043 // Compute the key object. 12045 // Compute the key object.
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
12742 if (break_point_objects()->IsUndefined()) return 0; 12744 if (break_point_objects()->IsUndefined()) return 0;
12743 // Single break point. 12745 // Single break point.
12744 if (!break_point_objects()->IsFixedArray()) return 1; 12746 if (!break_point_objects()->IsFixedArray()) return 1;
12745 // Multiple break points. 12747 // Multiple break points.
12746 return FixedArray::cast(break_point_objects())->length(); 12748 return FixedArray::cast(break_point_objects())->length();
12747 } 12749 }
12748 #endif // ENABLE_DEBUGGER_SUPPORT 12750 #endif // ENABLE_DEBUGGER_SUPPORT
12749 12751
12750 12752
12751 } } // namespace v8::internal 12753 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698