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 14841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14852 // Please note this list is compiler dependent. | 14852 // Please note this list is compiler dependent. |
14853 | 14853 |
14854 template class HashTable<StringTable, StringTableShape, HashTableKey*>; | 14854 template class HashTable<StringTable, StringTableShape, HashTableKey*>; |
14855 | 14855 |
14856 template class HashTable<CompilationCacheTable, | 14856 template class HashTable<CompilationCacheTable, |
14857 CompilationCacheShape, | 14857 CompilationCacheShape, |
14858 HashTableKey*>; | 14858 HashTableKey*>; |
14859 | 14859 |
14860 template class HashTable<MapCache, MapCacheShape, HashTableKey*>; | 14860 template class HashTable<MapCache, MapCacheShape, HashTableKey*>; |
14861 | 14861 |
14862 template class HashTable<ObjectHashTable, ObjectHashTableShape, Object*>; | 14862 template class HashTable<ObjectHashTable, |
| 14863 ObjectHashTableShape, |
| 14864 Handle<Object> >; |
14863 | 14865 |
14864 template class HashTable<WeakHashTable, WeakHashTableShape<2>, Object*>; | 14866 template class HashTable<WeakHashTable, WeakHashTableShape<2>, Handle<Object> >; |
14865 | 14867 |
14866 template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >; | 14868 template class Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >; |
14867 | 14869 |
14868 template class Dictionary<SeededNumberDictionary, | 14870 template class Dictionary<SeededNumberDictionary, |
14869 SeededNumberDictionaryShape, | 14871 SeededNumberDictionaryShape, |
14870 uint32_t>; | 14872 uint32_t>; |
14871 | 14873 |
14872 template class Dictionary<UnseededNumberDictionary, | 14874 template class Dictionary<UnseededNumberDictionary, |
14873 UnseededNumberDictionaryShape, | 14875 UnseededNumberDictionaryShape, |
14874 uint32_t>; | 14876 uint32_t>; |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16134 Object* hash = key->GetHash(); | 16136 Object* hash = key->GetHash(); |
16135 if (hash->IsUndefined()) { | 16137 if (hash->IsUndefined()) { |
16136 return GetHeap()->the_hole_value(); | 16138 return GetHeap()->the_hole_value(); |
16137 } | 16139 } |
16138 int entry = FindEntry(key); | 16140 int entry = FindEntry(key); |
16139 if (entry == kNotFound) return GetHeap()->the_hole_value(); | 16141 if (entry == kNotFound) return GetHeap()->the_hole_value(); |
16140 return get(EntryToIndex(entry) + 1); | 16142 return get(EntryToIndex(entry) + 1); |
16141 } | 16143 } |
16142 | 16144 |
16143 | 16145 |
| 16146 // TODO(ishell): Try to remove this when FindEntry(Object* key) is removed |
| 16147 int ObjectHashTable::FindEntry(Handle<Object> key) { |
| 16148 return DerivedHashTable::FindEntry(key); |
| 16149 } |
| 16150 |
| 16151 |
| 16152 // TODO(ishell): Remove this when all the callers are handlified. |
| 16153 int ObjectHashTable::FindEntry(Object* key) { |
| 16154 DisallowHeapAllocation no_allocation; |
| 16155 Isolate* isolate = GetIsolate(); |
| 16156 HandleScope scope(isolate); |
| 16157 return FindEntry(handle(key, isolate)); |
| 16158 } |
| 16159 |
| 16160 |
16144 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, | 16161 Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, |
16145 Handle<Object> key, | 16162 Handle<Object> key, |
16146 Handle<Object> value) { | 16163 Handle<Object> value) { |
16147 ASSERT(table->IsKey(*key)); | 16164 ASSERT(table->IsKey(*key)); |
16148 | 16165 |
16149 Isolate* isolate = table->GetIsolate(); | 16166 Isolate* isolate = table->GetIsolate(); |
16150 | 16167 |
16151 // Make sure the key object has an identity hash code. | 16168 // Make sure the key object has an identity hash code. |
16152 Handle<Object> hash = Object::GetOrCreateHash(key, isolate); | 16169 Handle<Object> hash = Object::GetOrCreateHash(key, isolate); |
16153 | 16170 |
16154 int entry = table->FindEntry(*key); | 16171 int entry = table->FindEntry(key); |
16155 | 16172 |
16156 // Check whether to perform removal operation. | 16173 // Check whether to perform removal operation. |
16157 if (value->IsTheHole()) { | 16174 if (value->IsTheHole()) { |
16158 if (entry == kNotFound) return table; | 16175 if (entry == kNotFound) return table; |
16159 table->RemoveEntry(entry); | 16176 table->RemoveEntry(entry); |
16160 return Shrink(table, key); | 16177 return Shrink(table, key); |
16161 } | 16178 } |
16162 | 16179 |
16163 // Key is already in table, just overwrite value. | 16180 // Key is already in table, just overwrite value. |
16164 if (entry != kNotFound) { | 16181 if (entry != kNotFound) { |
16165 table->set(EntryToIndex(entry) + 1, *value); | 16182 table->set(EntryToIndex(entry) + 1, *value); |
16166 return table; | 16183 return table; |
16167 } | 16184 } |
16168 | 16185 |
16169 // Check whether the hash table should be extended. | 16186 // Check whether the hash table should be extended. |
16170 table = EnsureCapacity(table, 1, *key); | 16187 table = EnsureCapacity(table, 1, key); |
16171 table->AddEntry(table->FindInsertionEntry(Handle<Smi>::cast(hash)->value()), | 16188 table->AddEntry(table->FindInsertionEntry(Handle<Smi>::cast(hash)->value()), |
16172 *key, | 16189 *key, |
16173 *value); | 16190 *value); |
16174 return table; | 16191 return table; |
16175 } | 16192 } |
16176 | 16193 |
16177 | 16194 |
16178 void ObjectHashTable::AddEntry(int entry, Object* key, Object* value) { | 16195 void ObjectHashTable::AddEntry(int entry, Object* key, Object* value) { |
16179 set(EntryToIndex(entry), key); | 16196 set(EntryToIndex(entry), key); |
16180 set(EntryToIndex(entry) + 1, value); | 16197 set(EntryToIndex(entry) + 1, value); |
16181 ElementAdded(); | 16198 ElementAdded(); |
16182 } | 16199 } |
16183 | 16200 |
16184 | 16201 |
16185 void ObjectHashTable::RemoveEntry(int entry) { | 16202 void ObjectHashTable::RemoveEntry(int entry) { |
16186 set_the_hole(EntryToIndex(entry)); | 16203 set_the_hole(EntryToIndex(entry)); |
16187 set_the_hole(EntryToIndex(entry) + 1); | 16204 set_the_hole(EntryToIndex(entry) + 1); |
16188 ElementRemoved(); | 16205 ElementRemoved(); |
16189 } | 16206 } |
16190 | 16207 |
16191 | 16208 |
16192 Object* WeakHashTable::Lookup(Object* key) { | 16209 Object* WeakHashTable::Lookup(Object* key) { |
16193 ASSERT(IsKey(key)); | 16210 ASSERT(IsKey(key)); |
16194 int entry = FindEntry(key); | 16211 int entry = FindEntry(key); |
16195 if (entry == kNotFound) return GetHeap()->the_hole_value(); | 16212 if (entry == kNotFound) return GetHeap()->the_hole_value(); |
16196 return get(EntryToValueIndex(entry)); | 16213 return get(EntryToValueIndex(entry)); |
16197 } | 16214 } |
16198 | 16215 |
16199 | 16216 |
| 16217 // TODO(ishell): Try to remove this when FindEntry(Object* key) is removed |
| 16218 int WeakHashTable::FindEntry(Handle<Object> key) { |
| 16219 return DerivedHashTable::FindEntry(key); |
| 16220 } |
| 16221 |
| 16222 |
| 16223 // TODO(ishell): Remove this when all the callers are handlified. |
| 16224 int WeakHashTable::FindEntry(Object* key) { |
| 16225 DisallowHeapAllocation no_allocation; |
| 16226 Isolate* isolate = GetIsolate(); |
| 16227 HandleScope scope(isolate); |
| 16228 return FindEntry(handle(key, isolate)); |
| 16229 } |
| 16230 |
| 16231 |
16200 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table, | 16232 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table, |
16201 Handle<Object> key, | 16233 Handle<Object> key, |
16202 Handle<Object> value) { | 16234 Handle<Object> value) { |
16203 ASSERT(table->IsKey(*key)); | 16235 ASSERT(table->IsKey(*key)); |
16204 int entry = table->FindEntry(*key); | 16236 int entry = table->FindEntry(key); |
16205 // Key is already in table, just overwrite value. | 16237 // Key is already in table, just overwrite value. |
16206 if (entry != kNotFound) { | 16238 if (entry != kNotFound) { |
16207 table->set(EntryToValueIndex(entry), *value); | 16239 table->set(EntryToValueIndex(entry), *value); |
16208 return table; | 16240 return table; |
16209 } | 16241 } |
16210 | 16242 |
16211 // Check whether the hash table should be extended. | 16243 // Check whether the hash table should be extended. |
16212 table = EnsureCapacity(table, 1, *key, TENURED); | 16244 table = EnsureCapacity(table, 1, key, TENURED); |
16213 | 16245 |
16214 table->AddEntry(table->FindInsertionEntry(table->Hash(*key)), key, value); | 16246 table->AddEntry(table->FindInsertionEntry(table->Hash(key)), key, value); |
16215 return table; | 16247 return table; |
16216 } | 16248 } |
16217 | 16249 |
16218 | 16250 |
16219 void WeakHashTable::AddEntry(int entry, | 16251 void WeakHashTable::AddEntry(int entry, |
16220 Handle<Object> key, | 16252 Handle<Object> key, |
16221 Handle<Object> value) { | 16253 Handle<Object> value) { |
16222 DisallowHeapAllocation no_allocation; | 16254 DisallowHeapAllocation no_allocation; |
16223 set(EntryToIndex(entry), *key); | 16255 set(EntryToIndex(entry), *key); |
16224 set(EntryToValueIndex(entry), *value); | 16256 set(EntryToValueIndex(entry), *value); |
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17306 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17338 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17307 static const char* error_messages_[] = { | 17339 static const char* error_messages_[] = { |
17308 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17340 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17309 }; | 17341 }; |
17310 #undef ERROR_MESSAGES_TEXTS | 17342 #undef ERROR_MESSAGES_TEXTS |
17311 return error_messages_[reason]; | 17343 return error_messages_[reason]; |
17312 } | 17344 } |
17313 | 17345 |
17314 | 17346 |
17315 } } // namespace v8::internal | 17347 } } // namespace v8::internal |
OLD | NEW |