OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2050 template<typename Shape, typename Key> | 2050 template<typename Shape, typename Key> |
2051 int HashTable<Shape, Key>::FindEntry(Key key) { | 2051 int HashTable<Shape, Key>::FindEntry(Key key) { |
2052 return FindEntry(GetIsolate(), key); | 2052 return FindEntry(GetIsolate(), key); |
2053 } | 2053 } |
2054 | 2054 |
2055 | 2055 |
2056 // Find entry for key otherwise return kNotFound. | 2056 // Find entry for key otherwise return kNotFound. |
2057 template<typename Shape, typename Key> | 2057 template<typename Shape, typename Key> |
2058 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 2058 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
2059 uint32_t capacity = Capacity(); | 2059 uint32_t capacity = Capacity(); |
2060 uint32_t entry = FirstProbe(Shape::Hash(key), capacity); | 2060 uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity); |
2061 uint32_t count = 1; | 2061 uint32_t count = 1; |
2062 // EnsureCapacity will guarantee the hash table is never full. | 2062 // EnsureCapacity will guarantee the hash table is never full. |
2063 while (true) { | 2063 while (true) { |
2064 Object* element = KeyAt(entry); | 2064 Object* element = KeyAt(entry); |
2065 // Empty entry. | 2065 // Empty entry. |
2066 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; | 2066 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; |
2067 if (element != isolate->heap()->raw_unchecked_the_hole_value() && | 2067 if (element != isolate->heap()->raw_unchecked_the_hole_value() && |
2068 Shape::IsMatch(key, element)) return entry; | 2068 Shape::IsMatch(key, element)) return entry; |
2069 entry = NextProbe(entry, count++, capacity); | 2069 entry = NextProbe(entry, count++, capacity); |
2070 } | 2070 } |
(...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4529 } | 4529 } |
4530 | 4530 |
4531 | 4531 |
4532 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 4532 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
4533 ASSERT(other->IsNumber()); | 4533 ASSERT(other->IsNumber()); |
4534 return key == static_cast<uint32_t>(other->Number()); | 4534 return key == static_cast<uint32_t>(other->Number()); |
4535 } | 4535 } |
4536 | 4536 |
4537 | 4537 |
4538 uint32_t NumberDictionaryShape::Hash(uint32_t key) { | 4538 uint32_t NumberDictionaryShape::Hash(uint32_t key) { |
4539 return ComputeIntegerHash(key); | 4539 // This function is unreachable, since shape has UsesSeed=true flag |
Erik Corry
2012/01/10 11:53:16
Please add a period (.) at the end of all comments
| |
4540 UNREACHABLE(); | |
4541 return 0; | |
4540 } | 4542 } |
4541 | 4543 |
4542 | 4544 |
4543 uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) { | 4545 uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) { |
4544 ASSERT(other->IsNumber()); | 4546 // This function is unreachable, since shape has UsesSeed=true flag |
4545 return ComputeIntegerHash(static_cast<uint32_t>(other->Number())); | 4547 UNREACHABLE(); |
4548 return 0; | |
4546 } | 4549 } |
4547 | 4550 |
4551 uint32_t NumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | |
4552 return ComputeIntegerHash(key, seed); | |
4553 } | |
4554 | |
4555 uint32_t NumberDictionaryShape::SeededHashForObject(uint32_t key, uint32_t seed, | |
Erik Corry
2012/01/10 11:53:16
All arguments on one line or one per line vertical
| |
4556 Object* other) { | |
4557 ASSERT(other->IsNumber()); | |
4558 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | |
4559 } | |
4548 | 4560 |
4549 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { | 4561 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { |
4550 return Isolate::Current()->heap()->NumberFromUint32(key); | 4562 return Isolate::Current()->heap()->NumberFromUint32(key); |
4551 } | 4563 } |
4552 | 4564 |
4553 | 4565 |
4554 bool StringDictionaryShape::IsMatch(String* key, Object* other) { | 4566 bool StringDictionaryShape::IsMatch(String* key, Object* other) { |
4555 // We know that all entries in a hash table had their hash keys created. | 4567 // We know that all entries in a hash table had their hash keys created. |
4556 // Use that knowledge to have fast failure. | 4568 // Use that knowledge to have fast failure. |
4557 if (key->Hash() != String::cast(other)->Hash()) return false; | 4569 if (key->Hash() != String::cast(other)->Hash()) return false; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4769 #undef WRITE_INT_FIELD | 4781 #undef WRITE_INT_FIELD |
4770 #undef READ_SHORT_FIELD | 4782 #undef READ_SHORT_FIELD |
4771 #undef WRITE_SHORT_FIELD | 4783 #undef WRITE_SHORT_FIELD |
4772 #undef READ_BYTE_FIELD | 4784 #undef READ_BYTE_FIELD |
4773 #undef WRITE_BYTE_FIELD | 4785 #undef WRITE_BYTE_FIELD |
4774 | 4786 |
4775 | 4787 |
4776 } } // namespace v8::internal | 4788 } } // namespace v8::internal |
4777 | 4789 |
4778 #endif // V8_OBJECTS_INL_H_ | 4790 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |