| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 16228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16239 | 16239 |
| 16240 | 16240 |
| 16241 Object* WeakHashTable::Lookup(Object* key) { | 16241 Object* WeakHashTable::Lookup(Object* key) { |
| 16242 ASSERT(IsKey(key)); | 16242 ASSERT(IsKey(key)); |
| 16243 int entry = FindEntry(key); | 16243 int entry = FindEntry(key); |
| 16244 if (entry == kNotFound) return GetHeap()->the_hole_value(); | 16244 if (entry == kNotFound) return GetHeap()->the_hole_value(); |
| 16245 return get(EntryToValueIndex(entry)); | 16245 return get(EntryToValueIndex(entry)); |
| 16246 } | 16246 } |
| 16247 | 16247 |
| 16248 | 16248 |
| 16249 MaybeObject* WeakHashTable::Put(Object* key, Object* value) { | 16249 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table, |
| 16250 ASSERT(IsKey(key)); | 16250 Handle<Object> key, |
| 16251 int entry = FindEntry(key); | 16251 Handle<Object> value) { |
| 16252 ASSERT(table->IsKey(*key)); |
| 16253 int entry = table->FindEntry(*key); |
| 16252 // Key is already in table, just overwrite value. | 16254 // Key is already in table, just overwrite value. |
| 16253 if (entry != kNotFound) { | 16255 if (entry != kNotFound) { |
| 16254 set(EntryToValueIndex(entry), value); | 16256 table->set(EntryToValueIndex(entry), *value); |
| 16255 return this; | 16257 return table; |
| 16256 } | 16258 } |
| 16257 | 16259 |
| 16258 // Check whether the hash table should be extended. | 16260 // Check whether the hash table should be extended. |
| 16259 Object* obj; | 16261 table = EnsureCapacity(table, 1, *key, TENURED); |
| 16260 { MaybeObject* maybe_obj = EnsureCapacity(1, key, TENURED); | 16262 |
| 16261 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 16263 table->AddEntry(table->FindInsertionEntry(table->Hash(*key)), key, value); |
| 16262 } | |
| 16263 WeakHashTable* table = WeakHashTable::cast(obj); | |
| 16264 table->AddEntry(table->FindInsertionEntry(Hash(key)), key, value); | |
| 16265 return table; | 16264 return table; |
| 16266 } | 16265 } |
| 16267 | 16266 |
| 16268 | 16267 |
| 16269 void WeakHashTable::AddEntry(int entry, Object* key, Object* value) { | 16268 void WeakHashTable::AddEntry(int entry, |
| 16270 set(EntryToIndex(entry), key); | 16269 Handle<Object> key, |
| 16271 set(EntryToValueIndex(entry), value); | 16270 Handle<Object> value) { |
| 16271 DisallowHeapAllocation no_allocation; |
| 16272 set(EntryToIndex(entry), *key); |
| 16273 set(EntryToValueIndex(entry), *value); |
| 16272 ElementAdded(); | 16274 ElementAdded(); |
| 16273 } | 16275 } |
| 16274 | 16276 |
| 16275 | 16277 |
| 16276 template<class Derived, class Iterator, int entrysize> | 16278 template<class Derived, class Iterator, int entrysize> |
| 16277 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Allocate( | 16279 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Allocate( |
| 16278 Isolate* isolate, int capacity, PretenureFlag pretenure) { | 16280 Isolate* isolate, int capacity, PretenureFlag pretenure) { |
| 16279 // Capacity must be a power of two, since we depend on being able | 16281 // Capacity must be a power of two, since we depend on being able |
| 16280 // to divide and multiple by 2 (kLoadFactor) to derive capacity | 16282 // to divide and multiple by 2 (kLoadFactor) to derive capacity |
| 16281 // from number of buckets. If we decide to change kLoadFactor | 16283 // from number of buckets. If we decide to change kLoadFactor |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17353 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17355 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 17354 static const char* error_messages_[] = { | 17356 static const char* error_messages_[] = { |
| 17355 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17357 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 17356 }; | 17358 }; |
| 17357 #undef ERROR_MESSAGES_TEXTS | 17359 #undef ERROR_MESSAGES_TEXTS |
| 17358 return error_messages_[reason]; | 17360 return error_messages_[reason]; |
| 17359 } | 17361 } |
| 17360 | 17362 |
| 17361 | 17363 |
| 17362 } } // namespace v8::internal | 17364 } } // namespace v8::internal |
| OLD | NEW |