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

Side by Side Diff: src/objects.cc

Issue 1582773003: Make JSProxies always be in slow mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 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 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 17141 matching lines...) Expand 10 before | Expand all | Expand 10 after
17152 17152
17153 template<typename Derived, typename Shape, typename Key> 17153 template<typename Derived, typename Shape, typename Key>
17154 Handle<Derived> HashTable<Derived, Shape, Key>::EnsureCapacity( 17154 Handle<Derived> HashTable<Derived, Shape, Key>::EnsureCapacity(
17155 Handle<Derived> table, 17155 Handle<Derived> table,
17156 int n, 17156 int n,
17157 Key key, 17157 Key key,
17158 PretenureFlag pretenure) { 17158 PretenureFlag pretenure) {
17159 Isolate* isolate = table->GetIsolate(); 17159 Isolate* isolate = table->GetIsolate();
17160 int capacity = table->Capacity(); 17160 int capacity = table->Capacity();
17161 int nof = table->NumberOfElements() + n; 17161 int nof = table->NumberOfElements() + n;
17162 int nod = table->NumberOfDeletedElements(); 17162
17163 // Return if: 17163 if (table->HasSufficientCapacity(n)) return table;
17164 // 50% is still free after adding n elements and
17165 // at most 50% of the free elements are deleted elements.
17166 if (nod <= (capacity - nof) >> 1) {
17167 int needed_free = nof >> 1;
17168 if (nof + needed_free <= capacity) return table;
17169 }
17170 17164
17171 const int kMinCapacityForPretenure = 256; 17165 const int kMinCapacityForPretenure = 256;
17172 bool should_pretenure = pretenure == TENURED || 17166 bool should_pretenure = pretenure == TENURED ||
17173 ((capacity > kMinCapacityForPretenure) && 17167 ((capacity > kMinCapacityForPretenure) &&
17174 !isolate->heap()->InNewSpace(*table)); 17168 !isolate->heap()->InNewSpace(*table));
17175 Handle<Derived> new_table = HashTable::New( 17169 Handle<Derived> new_table = HashTable::New(
17176 isolate, 17170 isolate,
17177 nof * 2, 17171 nof * 2,
17178 USE_DEFAULT_MINIMUM_CAPACITY, 17172 USE_DEFAULT_MINIMUM_CAPACITY,
17179 should_pretenure ? TENURED : NOT_TENURED); 17173 should_pretenure ? TENURED : NOT_TENURED);
17180 17174
17181 table->Rehash(new_table, key); 17175 table->Rehash(new_table, key);
17182 return new_table; 17176 return new_table;
17183 } 17177 }
17184 17178
17185 17179
17180 template <typename Derived, typename Shape, typename Key>
17181 bool HashTable<Derived, Shape, Key>::HasSufficientCapacity(int n) {
17182 int capacity = Capacity();
17183 int nof = NumberOfElements() + n;
17184 int nod = NumberOfDeletedElements();
17185 // Return true if:
17186 // 50% is still free after adding n elements and
17187 // at most 50% of the free elements are deleted elements.
17188 if (nod <= (capacity - nof) >> 1) {
17189 int needed_free = nof >> 1;
17190 if (nof + needed_free <= capacity) return true;
17191 }
17192 return false;
17193 }
17194
17195
17186 template<typename Derived, typename Shape, typename Key> 17196 template<typename Derived, typename Shape, typename Key>
17187 Handle<Derived> HashTable<Derived, Shape, Key>::Shrink(Handle<Derived> table, 17197 Handle<Derived> HashTable<Derived, Shape, Key>::Shrink(Handle<Derived> table,
17188 Key key) { 17198 Key key) {
17189 int capacity = table->Capacity(); 17199 int capacity = table->Capacity();
17190 int nof = table->NumberOfElements(); 17200 int nof = table->NumberOfElements();
17191 17201
17192 // Shrink to fit the number of elements if only a quarter of the 17202 // Shrink to fit the number of elements if only a quarter of the
17193 // capacity is filled with elements. 17203 // capacity is filled with elements.
17194 if (nof > (capacity >> 2)) return table; 17204 if (nof > (capacity >> 2)) return table;
17195 // Allocate a new dictionary with room for at least the current 17205 // Allocate a new dictionary with room for at least the current
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
17342 PropertyDetails); 17352 PropertyDetails);
17343 17353
17344 template Handle<SeededNumberDictionary> 17354 template Handle<SeededNumberDictionary>
17345 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>:: 17355 Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
17346 EnsureCapacity(Handle<SeededNumberDictionary>, int, uint32_t); 17356 EnsureCapacity(Handle<SeededNumberDictionary>, int, uint32_t);
17347 17357
17348 template Handle<UnseededNumberDictionary> 17358 template Handle<UnseededNumberDictionary>
17349 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>:: 17359 Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
17350 EnsureCapacity(Handle<UnseededNumberDictionary>, int, uint32_t); 17360 EnsureCapacity(Handle<UnseededNumberDictionary>, int, uint32_t);
17351 17361
17362 template void Dictionary<NameDictionary, NameDictionaryShape,
17363 Handle<Name> >::SetRequiresCopyOnCapacityChange();
17364
17352 template Handle<NameDictionary> 17365 template Handle<NameDictionary>
17353 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >:: 17366 Dictionary<NameDictionary, NameDictionaryShape, Handle<Name> >::
17354 EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>); 17367 EnsureCapacity(Handle<NameDictionary>, int, Handle<Name>);
17355 17368
17356 template bool Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, 17369 template bool Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape,
17357 uint32_t>::HasComplexElements(); 17370 uint32_t>::HasComplexElements();
17358 17371
17359 template int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape, 17372 template int HashTable<SeededNumberDictionary, SeededNumberDictionaryShape,
17360 uint32_t>::FindEntry(uint32_t); 17373 uint32_t>::FindEntry(uint32_t);
17361 17374
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
18070 PropertyDetails new_details = details.set_index(enum_index); 18083 PropertyDetails new_details = details.set_index(enum_index);
18071 dictionary->DetailsAtPut(index, new_details); 18084 dictionary->DetailsAtPut(index, new_details);
18072 } 18085 }
18073 18086
18074 // Set the next enumeration index. 18087 // Set the next enumeration index.
18075 dictionary->SetNextEnumerationIndex(PropertyDetails::kInitialIndex+length); 18088 dictionary->SetNextEnumerationIndex(PropertyDetails::kInitialIndex+length);
18076 return iteration_order; 18089 return iteration_order;
18077 } 18090 }
18078 18091
18079 18092
18080 template<typename Derived, typename Shape, typename Key> 18093 template <typename Derived, typename Shape, typename Key>
18094 void Dictionary<Derived, Shape, Key>::SetRequiresCopyOnCapacityChange() {
18095 DCHECK_EQ(0, DerivedHashTable::NumberOfElements());
18096 DCHECK_EQ(0, DerivedHashTable::NumberOfDeletedElements());
18097 // Make sure that HashTable::EnsureCapacity will create a copy.
18098 DerivedHashTable::SetNumberOfDeletedElements(DerivedHashTable::Capacity());
18099 DCHECK(!DerivedHashTable::HasSufficientCapacity(1));
18100 }
18101
18102
18103 template <typename Derived, typename Shape, typename Key>
18081 Handle<Derived> Dictionary<Derived, Shape, Key>::EnsureCapacity( 18104 Handle<Derived> Dictionary<Derived, Shape, Key>::EnsureCapacity(
18082 Handle<Derived> dictionary, int n, Key key) { 18105 Handle<Derived> dictionary, int n, Key key) {
18083 // Check whether there are enough enumeration indices to add n elements. 18106 // Check whether there are enough enumeration indices to add n elements.
18084 if (Shape::kIsEnumerable && 18107 if (Shape::kIsEnumerable &&
18085 !PropertyDetails::IsValidIndex(dictionary->NextEnumerationIndex() + n)) { 18108 !PropertyDetails::IsValidIndex(dictionary->NextEnumerationIndex() + n)) {
18086 // If not, we generate new indices for the properties. 18109 // If not, we generate new indices for the properties.
18087 GenerateNewEnumerationIndices(dictionary); 18110 GenerateNewEnumerationIndices(dictionary);
18088 } 18111 }
18089 return DerivedHashTable::EnsureCapacity(dictionary, n, key); 18112 return DerivedHashTable::EnsureCapacity(dictionary, n, key);
18090 } 18113 }
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after
19642 if (cell->value() != *new_value) { 19665 if (cell->value() != *new_value) {
19643 cell->set_value(*new_value); 19666 cell->set_value(*new_value);
19644 Isolate* isolate = cell->GetIsolate(); 19667 Isolate* isolate = cell->GetIsolate();
19645 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19668 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19646 isolate, DependentCode::kPropertyCellChangedGroup); 19669 isolate, DependentCode::kPropertyCellChangedGroup);
19647 } 19670 }
19648 } 19671 }
19649 19672
19650 } // namespace internal 19673 } // namespace internal
19651 } // namespace v8 19674 } // namespace v8
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