Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 17729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17740 if (entry != kNotFound) { | 17740 if (entry != kNotFound) { |
| 17741 table->set(EntryToIndex(entry) + 1, *value); | 17741 table->set(EntryToIndex(entry) + 1, *value); |
| 17742 return table; | 17742 return table; |
| 17743 } | 17743 } |
| 17744 | 17744 |
| 17745 // Rehash if more than 33% of the entries are deleted entries. | 17745 // Rehash if more than 33% of the entries are deleted entries. |
| 17746 // TODO(jochen): Consider to shrink the fixed array in place. | 17746 // TODO(jochen): Consider to shrink the fixed array in place. |
| 17747 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { | 17747 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { |
| 17748 table->Rehash(isolate->factory()->undefined_value()); | 17748 table->Rehash(isolate->factory()->undefined_value()); |
| 17749 } | 17749 } |
| 17750 // If we're out of luck, we didn't get a GC recently, and so rehashing | |
| 17751 // isn't enough to avoid a crash. | |
| 17752 int nof = table->NumberOfElements() + 1; | |
| 17753 if (!table->HasSufficientCapacity(nof)) { | |
| 17754 int capacity = ObjectHashTable::ComputeCapacity(nof * 2); | |
| 17755 if (capacity > ObjectHashTable::kMaxCapacity) { | |
| 17756 for (size_t i = 0; i < 2; ++i) { | |
| 17757 isolate->heap()->CollectAllGarbage( | |
| 17758 Heap::kFinalizeIncrementalMarkingMask, | |
| 17759 "last resort gc (object hash table)"); | |
|
Hannes Payer (out of office)
2016/07/07 15:22:00
let's not call this last resort gc, to not confuse
| |
| 17760 } | |
| 17761 table->Rehash(isolate->factory()->undefined_value()); | |
| 17762 } | |
| 17763 } | |
| 17750 | 17764 |
| 17751 // Check whether the hash table should be extended. | 17765 // Check whether the hash table should be extended. |
| 17752 table = EnsureCapacity(table, 1, key); | 17766 table = EnsureCapacity(table, 1, key); |
| 17753 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); | 17767 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); |
| 17754 return table; | 17768 return table; |
| 17755 } | 17769 } |
| 17756 | 17770 |
| 17757 | 17771 |
| 17758 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, | 17772 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, |
| 17759 Handle<Object> key, | 17773 Handle<Object> key, |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18978 | 18992 |
| 18979 Object* data_obj = | 18993 Object* data_obj = |
| 18980 constructor->shared()->get_api_func_data()->access_check_info(); | 18994 constructor->shared()->get_api_func_data()->access_check_info(); |
| 18981 if (data_obj->IsUndefined(isolate)) return nullptr; | 18995 if (data_obj->IsUndefined(isolate)) return nullptr; |
| 18982 | 18996 |
| 18983 return AccessCheckInfo::cast(data_obj); | 18997 return AccessCheckInfo::cast(data_obj); |
| 18984 } | 18998 } |
| 18985 | 18999 |
| 18986 } // namespace internal | 19000 } // namespace internal |
| 18987 } // namespace v8 | 19001 } // namespace v8 |
| OLD | NEW |