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 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1968 // Find entry for key otherwise return kNotFound. | 1968 // Find entry for key otherwise return kNotFound. |
1969 template<typename Shape, typename Key> | 1969 template<typename Shape, typename Key> |
1970 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 1970 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
1971 uint32_t capacity = Capacity(); | 1971 uint32_t capacity = Capacity(); |
1972 uint32_t entry = FirstProbe(Shape::Hash(key), capacity); | 1972 uint32_t entry = FirstProbe(Shape::Hash(key), capacity); |
1973 uint32_t count = 1; | 1973 uint32_t count = 1; |
1974 // EnsureCapacity will guarantee the hash table is never full. | 1974 // EnsureCapacity will guarantee the hash table is never full. |
1975 while (true) { | 1975 while (true) { |
1976 Object* element = KeyAt(entry); | 1976 Object* element = KeyAt(entry); |
1977 if (element == isolate->heap()->undefined_value()) break; // Empty entry. | 1977 if (element == isolate->heap()->undefined_value()) break; // Empty entry. |
1978 if (element != isolate->heap()->null_value() && | 1978 if (element != isolate->heap()->the_hole_value() && |
1979 Shape::IsMatch(key, element)) return entry; | 1979 Shape::IsMatch(key, element)) return entry; |
1980 entry = NextProbe(entry, count++, capacity); | 1980 entry = NextProbe(entry, count++, capacity); |
1981 } | 1981 } |
1982 return kNotFound; | 1982 return kNotFound; |
1983 } | 1983 } |
1984 | 1984 |
1985 | 1985 |
1986 bool NumberDictionary::requires_slow_elements() { | 1986 bool NumberDictionary::requires_slow_elements() { |
1987 Object* max_index_object = get(kMaxNumberKeyIndex); | 1987 Object* max_index_object = get(kMaxNumberKeyIndex); |
1988 if (!max_index_object->IsSmi()) return false; | 1988 if (!max_index_object->IsSmi()) return false; |
(...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4427 | 4427 |
4428 | 4428 |
4429 template <int entrysize> | 4429 template <int entrysize> |
4430 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { | 4430 bool ObjectHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { |
4431 return key->SameValue(other); | 4431 return key->SameValue(other); |
4432 } | 4432 } |
4433 | 4433 |
4434 | 4434 |
4435 template <int entrysize> | 4435 template <int entrysize> |
4436 uint32_t ObjectHashTableShape<entrysize>::Hash(Object* key) { | 4436 uint32_t ObjectHashTableShape<entrysize>::Hash(Object* key) { |
4437 ASSERT(!key->IsUndefined() && !key->IsNull()); | |
rossberg
2011/11/02 15:17:37
Don't you still need the IsUndefined part of the a
Michael Starzinger
2011/11/02 15:52:26
This assertion is now covered by ASSERT(IsKey(key)
| |
4438 MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION); | 4437 MaybeObject* maybe_hash = key->GetHash(OMIT_CREATION); |
4439 return Smi::cast(maybe_hash->ToObjectChecked())->value(); | 4438 return Smi::cast(maybe_hash->ToObjectChecked())->value(); |
4440 } | 4439 } |
4441 | 4440 |
4442 | 4441 |
4443 template <int entrysize> | 4442 template <int entrysize> |
4444 uint32_t ObjectHashTableShape<entrysize>::HashForObject(Object* key, | 4443 uint32_t ObjectHashTableShape<entrysize>::HashForObject(Object* key, |
4445 Object* other) { | 4444 Object* other) { |
4446 ASSERT(!other->IsUndefined() && !other->IsNull()); | |
rossberg
2011/11/02 15:17:37
Same here.
Michael Starzinger
2011/11/02 15:52:26
Likewise.
| |
4447 MaybeObject* maybe_hash = other->GetHash(OMIT_CREATION); | 4445 MaybeObject* maybe_hash = other->GetHash(OMIT_CREATION); |
4448 return Smi::cast(maybe_hash->ToObjectChecked())->value(); | 4446 return Smi::cast(maybe_hash->ToObjectChecked())->value(); |
4449 } | 4447 } |
4450 | 4448 |
4451 | 4449 |
4452 template <int entrysize> | 4450 template <int entrysize> |
4453 MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Object* key) { | 4451 MaybeObject* ObjectHashTableShape<entrysize>::AsObject(Object* key) { |
4454 return key; | 4452 return key; |
4455 } | 4453 } |
4456 | 4454 |
4457 | 4455 |
4458 void ObjectHashTable::RemoveEntry(int entry) { | |
4459 RemoveEntry(entry, GetHeap()); | |
4460 } | |
4461 | |
4462 | |
4463 void Map::ClearCodeCache(Heap* heap) { | 4456 void Map::ClearCodeCache(Heap* heap) { |
4464 // No write barrier is needed since empty_fixed_array is not in new space. | 4457 // No write barrier is needed since empty_fixed_array is not in new space. |
4465 // Please note this function is used during marking: | 4458 // Please note this function is used during marking: |
4466 // - MarkCompactCollector::MarkUnmarkedObject | 4459 // - MarkCompactCollector::MarkUnmarkedObject |
4467 ASSERT(!heap->InNewSpace(heap->raw_unchecked_empty_fixed_array())); | 4460 ASSERT(!heap->InNewSpace(heap->raw_unchecked_empty_fixed_array())); |
4468 WRITE_FIELD(this, kCodeCacheOffset, heap->raw_unchecked_empty_fixed_array()); | 4461 WRITE_FIELD(this, kCodeCacheOffset, heap->raw_unchecked_empty_fixed_array()); |
4469 } | 4462 } |
4470 | 4463 |
4471 | 4464 |
4472 void JSArray::EnsureSize(int required_size) { | 4465 void JSArray::EnsureSize(int required_size) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4614 #undef WRITE_INT_FIELD | 4607 #undef WRITE_INT_FIELD |
4615 #undef READ_SHORT_FIELD | 4608 #undef READ_SHORT_FIELD |
4616 #undef WRITE_SHORT_FIELD | 4609 #undef WRITE_SHORT_FIELD |
4617 #undef READ_BYTE_FIELD | 4610 #undef READ_BYTE_FIELD |
4618 #undef WRITE_BYTE_FIELD | 4611 #undef WRITE_BYTE_FIELD |
4619 | 4612 |
4620 | 4613 |
4621 } } // namespace v8::internal | 4614 } } // namespace v8::internal |
4622 | 4615 |
4623 #endif // V8_OBJECTS_INL_H_ | 4616 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |