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 3455 matching lines...) Loading... |
3466 // Maximal capacity of HashTable. Based on maximal length of underlying | 3466 // Maximal capacity of HashTable. Based on maximal length of underlying |
3467 // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex | 3467 // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex |
3468 // cannot overflow. | 3468 // cannot overflow. |
3469 static const int kMaxCapacity = | 3469 static const int kMaxCapacity = |
3470 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; | 3470 (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; |
3471 | 3471 |
3472 // Find entry for key otherwise return kNotFound. | 3472 // Find entry for key otherwise return kNotFound. |
3473 inline int FindEntry(Key key); | 3473 inline int FindEntry(Key key); |
3474 int FindEntry(Isolate* isolate, Key key); | 3474 int FindEntry(Isolate* isolate, Key key); |
3475 | 3475 |
| 3476 // Rehashes the table in-place. |
| 3477 void Rehash(Key key); |
| 3478 |
3476 protected: | 3479 protected: |
3477 // Find the entry at which to insert element with the given key that | 3480 // Find the entry at which to insert element with the given key that |
3478 // has the given hash value. | 3481 // has the given hash value. |
3479 uint32_t FindInsertionEntry(uint32_t hash); | 3482 uint32_t FindInsertionEntry(uint32_t hash); |
3480 | 3483 |
3481 // Returns the index for an entry (of the key) | 3484 // Returns the index for an entry (of the key) |
3482 static inline int EntryToIndex(int entry) { | 3485 static inline int EntryToIndex(int entry) { |
3483 return (entry * kEntrySize) + kElementsStartIndex; | 3486 return (entry * kEntrySize) + kElementsStartIndex; |
3484 } | 3487 } |
3485 | 3488 |
(...skipping 26 matching lines...) Loading... |
3512 | 3515 |
3513 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) { | 3516 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) { |
3514 return hash & (size - 1); | 3517 return hash & (size - 1); |
3515 } | 3518 } |
3516 | 3519 |
3517 inline static uint32_t NextProbe( | 3520 inline static uint32_t NextProbe( |
3518 uint32_t last, uint32_t number, uint32_t size) { | 3521 uint32_t last, uint32_t number, uint32_t size) { |
3519 return (last + number) & (size - 1); | 3522 return (last + number) & (size - 1); |
3520 } | 3523 } |
3521 | 3524 |
| 3525 // Returns _expected_ if one of entries given by the first _probe_ probes is |
| 3526 // equal to _expected_. Otherwise, returns the entry given by the probe |
| 3527 // number _probe_. |
| 3528 uint32_t EntryForProbe(Key key, Object* k, int probe, uint32_t expected); |
| 3529 |
| 3530 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); |
| 3531 |
3522 // Rehashes this hash-table into the new table. | 3532 // Rehashes this hash-table into the new table. |
3523 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); | 3533 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key); |
3524 | 3534 |
3525 // Attempt to shrink hash table after removal of key. | 3535 // Attempt to shrink hash table after removal of key. |
3526 MUST_USE_RESULT MaybeObject* Shrink(Key key); | 3536 MUST_USE_RESULT MaybeObject* Shrink(Key key); |
3527 | 3537 |
3528 // Ensure enough space for n additional elements. | 3538 // Ensure enough space for n additional elements. |
3529 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); | 3539 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); |
3530 }; | 3540 }; |
3531 | 3541 |
(...skipping 6692 matching lines...) Loading... |
10224 } else { | 10234 } else { |
10225 value &= ~(1 << bit_position); | 10235 value &= ~(1 << bit_position); |
10226 } | 10236 } |
10227 return value; | 10237 return value; |
10228 } | 10238 } |
10229 }; | 10239 }; |
10230 | 10240 |
10231 } } // namespace v8::internal | 10241 } } // namespace v8::internal |
10232 | 10242 |
10233 #endif // V8_OBJECTS_H_ | 10243 #endif // V8_OBJECTS_H_ |
OLD | NEW |