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 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 3203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3214 // Attempt to shrink hash table after removal of key. | 3214 // Attempt to shrink hash table after removal of key. |
3215 MUST_USE_RESULT static Handle<Derived> Shrink(Handle<Derived> table, Key key); | 3215 MUST_USE_RESULT static Handle<Derived> Shrink(Handle<Derived> table, Key key); |
3216 | 3216 |
3217 // Ensure enough space for n additional elements. | 3217 // Ensure enough space for n additional elements. |
3218 MUST_USE_RESULT static Handle<Derived> EnsureCapacity( | 3218 MUST_USE_RESULT static Handle<Derived> EnsureCapacity( |
3219 Handle<Derived> table, | 3219 Handle<Derived> table, |
3220 int n, | 3220 int n, |
3221 Key key, | 3221 Key key, |
3222 PretenureFlag pretenure = NOT_TENURED); | 3222 PretenureFlag pretenure = NOT_TENURED); |
3223 | 3223 |
| 3224 // Returns true if this table has sufficient capacity for adding n elements. |
| 3225 bool HasSufficientCapacity(int n); |
| 3226 |
3224 // Sets the capacity of the hash table. | 3227 // Sets the capacity of the hash table. |
3225 void SetCapacity(int capacity) { | 3228 void SetCapacity(int capacity) { |
3226 // To scale a computed hash code to fit within the hash table, we | 3229 // To scale a computed hash code to fit within the hash table, we |
3227 // use bit-wise AND with a mask, so the capacity must be positive | 3230 // use bit-wise AND with a mask, so the capacity must be positive |
3228 // and non-zero. | 3231 // and non-zero. |
3229 DCHECK(capacity > 0); | 3232 DCHECK(capacity > 0); |
3230 DCHECK(capacity <= kMaxCapacity); | 3233 DCHECK(capacity <= kMaxCapacity); |
3231 set(kCapacityIndex, Smi::FromInt(capacity)); | 3234 set(kCapacityIndex, Smi::FromInt(capacity)); |
3232 } | 3235 } |
3233 | 3236 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3413 int NextEnumerationIndex() { | 3416 int NextEnumerationIndex() { |
3414 return Smi::cast(this->get(kNextEnumerationIndexIndex))->value(); | 3417 return Smi::cast(this->get(kNextEnumerationIndexIndex))->value(); |
3415 } | 3418 } |
3416 | 3419 |
3417 // Creates a new dictionary. | 3420 // Creates a new dictionary. |
3418 MUST_USE_RESULT static Handle<Derived> New( | 3421 MUST_USE_RESULT static Handle<Derived> New( |
3419 Isolate* isolate, | 3422 Isolate* isolate, |
3420 int at_least_space_for, | 3423 int at_least_space_for, |
3421 PretenureFlag pretenure = NOT_TENURED); | 3424 PretenureFlag pretenure = NOT_TENURED); |
3422 | 3425 |
| 3426 // Ensures that a new dictionary is created when the capacity is checked. |
| 3427 void SetRequiresCopyOnCapacityChange(); |
| 3428 |
3423 // Ensure enough space for n additional elements. | 3429 // Ensure enough space for n additional elements. |
3424 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key); | 3430 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key); |
3425 | 3431 |
3426 #ifdef OBJECT_PRINT | 3432 #ifdef OBJECT_PRINT |
3427 void Print(std::ostream& os); // NOLINT | 3433 void Print(std::ostream& os); // NOLINT |
3428 #endif | 3434 #endif |
3429 // Returns the key (slow). | 3435 // Returns the key (slow). |
3430 Object* SlowReverseLookup(Object* value); | 3436 Object* SlowReverseLookup(Object* value); |
3431 | 3437 |
3432 // Sets the entry to (key, value) pair. | 3438 // Sets the entry to (key, value) pair. |
(...skipping 7311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10744 } | 10750 } |
10745 return value; | 10751 return value; |
10746 } | 10752 } |
10747 }; | 10753 }; |
10748 | 10754 |
10749 | 10755 |
10750 } // NOLINT, false-positive due to second-order macros. | 10756 } // NOLINT, false-positive due to second-order macros. |
10751 } // NOLINT, false-positive due to second-order macros. | 10757 } // NOLINT, false-positive due to second-order macros. |
10752 | 10758 |
10753 #endif // V8_OBJECTS_H_ | 10759 #endif // V8_OBJECTS_H_ |
OLD | NEW |