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