| 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 2054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 2071 return kNotFound; | 2071 return kNotFound; |
| 2072 } | 2072 } |
| 2073 | 2073 |
| 2074 | 2074 |
| 2075 bool NumberDictionary::requires_slow_elements() { | 2075 bool NumberDictionaryBase::requires_slow_elements() { |
| 2076 Object* max_index_object = get(kMaxNumberKeyIndex); | 2076 Object* max_index_object = as_dict()->get( |
| 2077 NumberDictionary::kMaxNumberKeyIndex); |
| 2077 if (!max_index_object->IsSmi()) return false; | 2078 if (!max_index_object->IsSmi()) return false; |
| 2078 return 0 != | 2079 return 0 != |
| 2079 (Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask); | 2080 (Smi::cast(max_index_object)->value() & |
| 2081 NumberDictionary::kRequiresSlowElementsMask); |
| 2080 } | 2082 } |
| 2081 | 2083 |
| 2082 uint32_t NumberDictionary::max_number_key() { | 2084 uint32_t NumberDictionaryBase::max_number_key() { |
| 2083 ASSERT(!requires_slow_elements()); | 2085 ASSERT(!requires_slow_elements()); |
| 2084 Object* max_index_object = get(kMaxNumberKeyIndex); | 2086 Object* max_index_object = as_dict()->get( |
| 2087 NumberDictionary::kMaxNumberKeyIndex); |
| 2085 if (!max_index_object->IsSmi()) return 0; | 2088 if (!max_index_object->IsSmi()) return 0; |
| 2086 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); | 2089 uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value()); |
| 2087 return value >> kRequiresSlowElementsTagSize; | 2090 return value >> NumberDictionary::kRequiresSlowElementsTagSize; |
| 2088 } | 2091 } |
| 2089 | 2092 |
| 2090 void NumberDictionary::set_requires_slow_elements() { | 2093 void NumberDictionaryBase::set_requires_slow_elements() { |
| 2091 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); | 2094 as_dict()->set( |
| 2095 NumberDictionary::kMaxNumberKeyIndex, |
| 2096 Smi::FromInt(NumberDictionary::kRequiresSlowElementsMask)); |
| 2092 } | 2097 } |
| 2093 | 2098 |
| 2094 | 2099 |
| 2095 // ------------------------------------ | 2100 // ------------------------------------ |
| 2096 // Cast operations | 2101 // Cast operations |
| 2097 | 2102 |
| 2098 | 2103 |
| 2099 CAST_ACCESSOR(FixedArray) | 2104 CAST_ACCESSOR(FixedArray) |
| 2100 CAST_ACCESSOR(FixedDoubleArray) | 2105 CAST_ACCESSOR(FixedDoubleArray) |
| 2101 CAST_ACCESSOR(DescriptorArray) | 2106 CAST_ACCESSOR(DescriptorArray) |
| (...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4525 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); | 4530 ASSERT(!key->IsString() || details.IsDeleted() || details.index() > 0); |
| 4526 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 4531 int index = HashTable<Shape, Key>::EntryToIndex(entry); |
| 4527 AssertNoAllocation no_gc; | 4532 AssertNoAllocation no_gc; |
| 4528 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 4533 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
| 4529 FixedArray::set(index, key, mode); | 4534 FixedArray::set(index, key, mode); |
| 4530 FixedArray::set(index+1, value, mode); | 4535 FixedArray::set(index+1, value, mode); |
| 4531 FixedArray::set(index+2, details.AsSmi()); | 4536 FixedArray::set(index+2, details.AsSmi()); |
| 4532 } | 4537 } |
| 4533 | 4538 |
| 4534 | 4539 |
| 4535 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 4540 template <NumberDictionaryKind kind> |
| 4541 bool NumberDictionaryShape<kind>::IsMatch(uint32_t key, Object* other) { |
| 4536 ASSERT(other->IsNumber()); | 4542 ASSERT(other->IsNumber()); |
| 4537 return key == static_cast<uint32_t>(other->Number()); | 4543 return key == static_cast<uint32_t>(other->Number()); |
| 4538 } | 4544 } |
| 4539 | 4545 |
| 4540 | 4546 |
| 4541 uint32_t NumberDictionaryShape::Hash(uint32_t key) { | 4547 template <NumberDictionaryKind kind> |
| 4542 // This function is unreachable, since shape has UsesSeed=true flag. | 4548 uint32_t NumberDictionaryShape<kind>::Hash(uint32_t key) { |
| 4543 UNREACHABLE(); | 4549 return ComputeIntegerHash(key, 0); |
| 4544 return 0; | |
| 4545 } | 4550 } |
| 4546 | 4551 |
| 4547 | 4552 |
| 4548 uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) { | 4553 template <NumberDictionaryKind kind> |
| 4549 // This function is unreachable, since shape has UsesSeed=true flag. | 4554 uint32_t NumberDictionaryShape<kind>::HashForObject(uint32_t key, |
| 4550 UNREACHABLE(); | 4555 Object* other) { |
| 4551 return 0; | 4556 ASSERT(other->IsNumber()); |
| 4557 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0); |
| 4552 } | 4558 } |
| 4553 | 4559 |
| 4554 uint32_t NumberDictionaryShape::SeededHash(uint32_t key, uint32_t seed) { | 4560 |
| 4561 template <NumberDictionaryKind kind> |
| 4562 uint32_t NumberDictionaryShape<kind>::SeededHash(uint32_t key, uint32_t seed) { |
| 4555 return ComputeIntegerHash(key, seed); | 4563 return ComputeIntegerHash(key, seed); |
| 4556 } | 4564 } |
| 4557 | 4565 |
| 4558 uint32_t NumberDictionaryShape::SeededHashForObject(uint32_t key, | 4566 |
| 4559 uint32_t seed, | 4567 template <NumberDictionaryKind kind> |
| 4560 Object* other) { | 4568 uint32_t NumberDictionaryShape<kind>::SeededHashForObject(uint32_t key, |
| 4569 uint32_t seed, |
| 4570 Object* other) { |
| 4561 ASSERT(other->IsNumber()); | 4571 ASSERT(other->IsNumber()); |
| 4562 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); | 4572 return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), seed); |
| 4563 } | 4573 } |
| 4564 | 4574 |
| 4565 MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) { | 4575 |
| 4576 template <NumberDictionaryKind kind> |
| 4577 MaybeObject* NumberDictionaryShape<kind>::AsObject(uint32_t key) { |
| 4566 return Isolate::Current()->heap()->NumberFromUint32(key); | 4578 return Isolate::Current()->heap()->NumberFromUint32(key); |
| 4567 } | 4579 } |
| 4568 | 4580 |
| 4569 | 4581 |
| 4570 bool StringDictionaryShape::IsMatch(String* key, Object* other) { | 4582 bool StringDictionaryShape::IsMatch(String* key, Object* other) { |
| 4571 // We know that all entries in a hash table had their hash keys created. | 4583 // We know that all entries in a hash table had their hash keys created. |
| 4572 // Use that knowledge to have fast failure. | 4584 // Use that knowledge to have fast failure. |
| 4573 if (key->Hash() != String::cast(other)->Hash()) return false; | 4585 if (key->Hash() != String::cast(other)->Hash()) return false; |
| 4574 return key->Equals(String::cast(other)); | 4586 return key->Equals(String::cast(other)); |
| 4575 } | 4587 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4785 #undef WRITE_INT_FIELD | 4797 #undef WRITE_INT_FIELD |
| 4786 #undef READ_SHORT_FIELD | 4798 #undef READ_SHORT_FIELD |
| 4787 #undef WRITE_SHORT_FIELD | 4799 #undef WRITE_SHORT_FIELD |
| 4788 #undef READ_BYTE_FIELD | 4800 #undef READ_BYTE_FIELD |
| 4789 #undef WRITE_BYTE_FIELD | 4801 #undef WRITE_BYTE_FIELD |
| 4790 | 4802 |
| 4791 | 4803 |
| 4792 } } // namespace v8::internal | 4804 } } // namespace v8::internal |
| 4793 | 4805 |
| 4794 #endif // V8_OBJECTS_INL_H_ | 4806 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |