OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3459 // Maximal capacity of HashTable. Based on maximal length of underlying | 3459 // Maximal capacity of HashTable. Based on maximal length of underlying |
3460 // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex | 3460 // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex |
3461 // cannot overflow. | 3461 // cannot overflow. |
3462 static const int kMaxCapacity = | 3462 static const int kMaxCapacity = |
3463 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; | 3463 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; |
3464 | 3464 |
3465 // Find entry for key otherwise return kNotFound. | 3465 // Find entry for key otherwise return kNotFound. |
3466 inline int FindEntry(Key key); | 3466 inline int FindEntry(Key key); |
3467 int FindEntry(Isolate* isolate, Key key); | 3467 int FindEntry(Isolate* isolate, Key key); |
3468 | 3468 |
3469 void Rehash(Key key); | |
Michael Starzinger
2013/09/12 09:39:16
nit: Let's add a short one-liner comment saying th
| |
3470 | |
3469 protected: | 3471 protected: |
3470 // Find the entry at which to insert element with the given key that | 3472 // Find the entry at which to insert element with the given key that |
3471 // has the given hash value. | 3473 // has the given hash value. |
3472 uint32_t FindInsertionEntry(uint32_t hash); | 3474 uint32_t FindInsertionEntry(uint32_t hash); |
3473 | 3475 |
3474 // Returns the index for an entry (of the key) | 3476 // Returns the index for an entry (of the key) |
3475 static inline int EntryToIndex(int entry) { | 3477 static inline int EntryToIndex(int entry) { |
3476 return (entry * kEntrySize) + kElementsStartIndex; | 3478 return (entry * kEntrySize) + kElementsStartIndex; |
3477 } | 3479 } |
3478 | 3480 |
(...skipping 26 matching lines...) Expand all Loading... | |
3505 | 3507 |
3506 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) { | 3508 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) { |
3507 return hash & (size - 1); | 3509 return hash & (size - 1); |
3508 } | 3510 } |
3509 | 3511 |
3510 inline static uint32_t NextProbe( | 3512 inline static uint32_t NextProbe( |
3511 uint32_t last, uint32_t number, uint32_t size) { | 3513 uint32_t last, uint32_t number, uint32_t size) { |
3512 return (last + number) & (size - 1); | 3514 return (last + number) & (size - 1); |
3513 } | 3515 } |
3514 | 3516 |
3517 // Returns _expected_ if one of entries given by the first _probe_ probes is | |
3518 // equal to _expected_. Otherwise, returns the entry given by the probe | |
3519 // number _probe_. | |
3520 uint32_t EntryForProbe(Key key, Object* k, int probe, uint32_t expected); | |
3521 | |
3522 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); | |
3523 | |
3515 // Rehashes this hash-table into the new table. | 3524 // Rehashes this hash-table into the new table. |
3516 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); | 3525 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); |
3517 | 3526 |
3518 // Attempt to shrink hash table after removal of key. | 3527 // Attempt to shrink hash table after removal of key. |
3519 MUST_USE_RESULT MaybeObject* Shrink(Key key); | 3528 MUST_USE_RESULT MaybeObject* Shrink(Key key); |
3520 | 3529 |
3521 // Ensure enough space for n additional elements. | 3530 // Ensure enough space for n additional elements. |
3522 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); | 3531 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); |
3523 }; | 3532 }; |
3524 | 3533 |
(...skipping 6685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10210 } else { | 10219 } else { |
10211 value &= ~(1 << bit_position); | 10220 value &= ~(1 << bit_position); |
10212 } | 10221 } |
10213 return value; | 10222 return value; |
10214 } | 10223 } |
10215 }; | 10224 }; |
10216 | 10225 |
10217 } } // namespace v8::internal | 10226 } } // namespace v8::internal |
10218 | 10227 |
10219 #endif // V8_OBJECTS_H_ | 10228 #endif // V8_OBJECTS_H_ |
OLD | NEW |