OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "allocation-site-scopes.h" | 8 #include "allocation-site-scopes.h" |
9 #include "api.h" | 9 #include "api.h" |
10 #include "arguments.h" | 10 #include "arguments.h" |
(...skipping 16151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16162 } | 16162 } |
16163 | 16163 |
16164 | 16164 |
16165 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table, | 16165 Handle<WeakHashTable> WeakHashTable::Put(Handle<WeakHashTable> table, |
16166 Handle<Object> key, | 16166 Handle<Object> key, |
16167 Handle<Object> value) { | 16167 Handle<Object> value) { |
16168 ASSERT(table->IsKey(*key)); | 16168 ASSERT(table->IsKey(*key)); |
16169 int entry = table->FindEntry(key); | 16169 int entry = table->FindEntry(key); |
16170 // Key is already in table, just overwrite value. | 16170 // Key is already in table, just overwrite value. |
16171 if (entry != kNotFound) { | 16171 if (entry != kNotFound) { |
16172 table->set(EntryToValueIndex(entry), *value); | 16172 // TODO(ulan): Skipping write barrier is a temporary solution to avoid |
| 16173 // memory leaks. Remove this once we have special visitor for weak fixed |
| 16174 // arrays. |
| 16175 table->set(EntryToValueIndex(entry), *value, SKIP_WRITE_BARRIER); |
16173 return table; | 16176 return table; |
16174 } | 16177 } |
16175 | 16178 |
16176 // Check whether the hash table should be extended. | 16179 // Check whether the hash table should be extended. |
16177 table = EnsureCapacity(table, 1, key, TENURED); | 16180 table = EnsureCapacity(table, 1, key, TENURED); |
16178 | 16181 |
16179 table->AddEntry(table->FindInsertionEntry(table->Hash(key)), key, value); | 16182 table->AddEntry(table->FindInsertionEntry(table->Hash(key)), key, value); |
16180 return table; | 16183 return table; |
16181 } | 16184 } |
16182 | 16185 |
16183 | 16186 |
16184 void WeakHashTable::AddEntry(int entry, | 16187 void WeakHashTable::AddEntry(int entry, |
16185 Handle<Object> key, | 16188 Handle<Object> key, |
16186 Handle<Object> value) { | 16189 Handle<Object> value) { |
16187 DisallowHeapAllocation no_allocation; | 16190 DisallowHeapAllocation no_allocation; |
16188 set(EntryToIndex(entry), *key); | 16191 // TODO(ulan): Skipping write barrier is a temporary solution to avoid |
16189 set(EntryToValueIndex(entry), *value); | 16192 // memory leaks. Remove this once we have special visitor for weak fixed |
| 16193 // arrays. |
| 16194 set(EntryToIndex(entry), *key, SKIP_WRITE_BARRIER); |
| 16195 set(EntryToValueIndex(entry), *value, SKIP_WRITE_BARRIER); |
16190 ElementAdded(); | 16196 ElementAdded(); |
16191 } | 16197 } |
16192 | 16198 |
16193 | 16199 |
16194 template<class Derived, class Iterator, int entrysize> | 16200 template<class Derived, class Iterator, int entrysize> |
16195 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Allocate( | 16201 Handle<Derived> OrderedHashTable<Derived, Iterator, entrysize>::Allocate( |
16196 Isolate* isolate, int capacity, PretenureFlag pretenure) { | 16202 Isolate* isolate, int capacity, PretenureFlag pretenure) { |
16197 // Capacity must be a power of two, since we depend on being able | 16203 // Capacity must be a power of two, since we depend on being able |
16198 // to divide and multiple by 2 (kLoadFactor) to derive capacity | 16204 // to divide and multiple by 2 (kLoadFactor) to derive capacity |
16199 // from number of buckets. If we decide to change kLoadFactor | 16205 // from number of buckets. If we decide to change kLoadFactor |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17275 #define ERROR_MESSAGES_TEXTS(C, T) T, | 17281 #define ERROR_MESSAGES_TEXTS(C, T) T, |
17276 static const char* error_messages_[] = { | 17282 static const char* error_messages_[] = { |
17277 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 17283 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
17278 }; | 17284 }; |
17279 #undef ERROR_MESSAGES_TEXTS | 17285 #undef ERROR_MESSAGES_TEXTS |
17280 return error_messages_[reason]; | 17286 return error_messages_[reason]; |
17281 } | 17287 } |
17282 | 17288 |
17283 | 17289 |
17284 } } // namespace v8::internal | 17290 } } // namespace v8::internal |
OLD | NEW |