OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 6503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6514 | 6514 |
6515 | 6515 |
6516 | 6516 |
6517 // Find entry for key otherwise return -1. | 6517 // Find entry for key otherwise return -1. |
6518 template<typename Shape, typename Key> | 6518 template<typename Shape, typename Key> |
6519 int HashTable<Shape, Key>::FindEntry(Key key) { | 6519 int HashTable<Shape, Key>::FindEntry(Key key) { |
6520 uint32_t mask = Capacity() - 1; | 6520 uint32_t mask = Capacity() - 1; |
6521 uint32_t hash = Shape::Hash(key); | 6521 uint32_t hash = Shape::Hash(key); |
6522 | 6522 |
6523 // For the first probes rotate the hash to ensure a proper spread. | 6523 // For the first probes rotate the hash to ensure a proper spread. |
| 6524 uint32_t h = hash; |
6524 for (uint32_t i = 0; i < kNofFastProbes; i++) { | 6525 for (uint32_t i = 0; i < kNofFastProbes; i++) { |
6525 int entry = hash & mask; | 6526 int entry = h & mask; |
6526 Object* element = KeyAt(entry); | 6527 Object* element = KeyAt(entry); |
6527 if (element->IsUndefined()) return kNotFound; | 6528 if (element->IsUndefined()) return kNotFound; |
6528 if (!element->IsNull() && Shape::IsMatch(key, element)) return entry; | 6529 if (!element->IsNull() && Shape::IsMatch(key, element)) return entry; |
6529 hash = RotateRight(hash, kHashRotateShift); | 6530 h = RotateRight(h, kHashRotateShift); |
6530 } | 6531 } |
6531 | 6532 |
6532 | |
6533 // In this unlikely event, do a linear scan. | 6533 // In this unlikely event, do a linear scan. |
6534 for (uint32_t i = 1; i <= mask; i++) { | 6534 for (uint32_t i = 1; i <= mask; i++) { |
6535 int entry = ++hash & mask; | 6535 int entry = ++hash & mask; |
6536 Object* element = KeyAt(entry); | 6536 Object* element = KeyAt(entry); |
6537 if (element->IsUndefined()) return kNotFound; | 6537 if (element->IsUndefined()) return kNotFound; |
6538 if (!element->IsNull() && Shape::IsMatch(key, element)) return entry; | 6538 if (!element->IsNull() && Shape::IsMatch(key, element)) return entry; |
6539 } | 6539 } |
6540 return kNotFound; | 6540 return kNotFound; |
6541 } | 6541 } |
6542 | 6542 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 } | 6577 } |
6578 | 6578 |
6579 | 6579 |
6580 template<typename Shape, typename Key> | 6580 template<typename Shape, typename Key> |
6581 uint32_t HashTable<Shape, Key>::FindInsertionEntry(uint32_t hash) { | 6581 uint32_t HashTable<Shape, Key>::FindInsertionEntry(uint32_t hash) { |
6582 uint32_t mask = Capacity() - 1; | 6582 uint32_t mask = Capacity() - 1; |
6583 int entry; | 6583 int entry; |
6584 Object* element; | 6584 Object* element; |
6585 | 6585 |
6586 // For the first probes rotate the hash to ensure a proper spread. | 6586 // For the first probes rotate the hash to ensure a proper spread. |
| 6587 uint32_t h = hash; |
6587 for (uint32_t i = 0; i < kNofFastProbes; i++) { | 6588 for (uint32_t i = 0; i < kNofFastProbes; i++) { |
6588 entry = hash & mask; | 6589 entry = h & mask; |
6589 element = KeyAt(entry); | 6590 element = KeyAt(entry); |
6590 if (element->IsUndefined() || element->IsNull()) return entry; | 6591 if (element->IsUndefined() || element->IsNull()) return entry; |
6591 hash = RotateRight(hash, kHashRotateShift); | 6592 h = RotateRight(h, kHashRotateShift); |
6592 } | 6593 } |
6593 | 6594 |
6594 do { | 6595 do { |
6595 entry = ++hash & mask; | 6596 entry = ++hash & mask; |
6596 element = KeyAt(entry); | 6597 element = KeyAt(entry); |
6597 } while (!(element->IsUndefined() || element->IsNull())); | 6598 } while (!(element->IsUndefined() || element->IsNull())); |
6598 | 6599 |
6599 return entry; | 6600 return entry; |
6600 } | 6601 } |
6601 | 6602 |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7759 if (break_point_objects()->IsUndefined()) return 0; | 7760 if (break_point_objects()->IsUndefined()) return 0; |
7760 // Single beak point. | 7761 // Single beak point. |
7761 if (!break_point_objects()->IsFixedArray()) return 1; | 7762 if (!break_point_objects()->IsFixedArray()) return 1; |
7762 // Multiple break points. | 7763 // Multiple break points. |
7763 return FixedArray::cast(break_point_objects())->length(); | 7764 return FixedArray::cast(break_point_objects())->length(); |
7764 } | 7765 } |
7765 #endif | 7766 #endif |
7766 | 7767 |
7767 | 7768 |
7768 } } // namespace v8::internal | 7769 } } // namespace v8::internal |
OLD | NEW |