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 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2868 ASSERT(!marking_->IsMarking() || | 2868 ASSERT(!marking_->IsMarking() || |
2869 Marking::Color(array) == Marking::WHITE_OBJECT); | 2869 Marking::Color(array) == Marking::WHITE_OBJECT); |
2870 } | 2870 } |
2871 | 2871 |
2872 | 2872 |
2873 DescriptorArray::WhitenessWitness::~WhitenessWitness() { | 2873 DescriptorArray::WhitenessWitness::~WhitenessWitness() { |
2874 marking_->LeaveNoMarkingScope(); | 2874 marking_->LeaveNoMarkingScope(); |
2875 } | 2875 } |
2876 | 2876 |
2877 | 2877 |
2878 template<typename Shape, typename Key> | 2878 template<typename Derived, typename Shape, typename Key> |
2879 int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) { | 2879 int HashTable<Derived, Shape, Key>::ComputeCapacity(int at_least_space_for) { |
2880 const int kMinCapacity = 32; | 2880 const int kMinCapacity = 32; |
2881 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); | 2881 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); |
2882 if (capacity < kMinCapacity) { | 2882 if (capacity < kMinCapacity) { |
2883 capacity = kMinCapacity; // Guarantee min capacity. | 2883 capacity = kMinCapacity; // Guarantee min capacity. |
2884 } | 2884 } |
2885 return capacity; | 2885 return capacity; |
2886 } | 2886 } |
2887 | 2887 |
2888 | 2888 |
2889 template<typename Shape, typename Key> | 2889 template<typename Derived, typename Shape, typename Key> |
2890 int HashTable<Shape, Key>::FindEntry(Key key) { | 2890 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { |
2891 return FindEntry(GetIsolate(), key); | 2891 return FindEntry(GetIsolate(), key); |
2892 } | 2892 } |
2893 | 2893 |
2894 | 2894 |
2895 // Find entry for key otherwise return kNotFound. | 2895 // Find entry for key otherwise return kNotFound. |
2896 template<typename Shape, typename Key> | 2896 template<typename Derived, typename Shape, typename Key> |
2897 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) { | 2897 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { |
2898 uint32_t capacity = Capacity(); | 2898 uint32_t capacity = Capacity(); |
2899 uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity); | 2899 uint32_t entry = FirstProbe(HashTable::Hash(key), capacity); |
2900 uint32_t count = 1; | 2900 uint32_t count = 1; |
2901 // EnsureCapacity will guarantee the hash table is never full. | 2901 // EnsureCapacity will guarantee the hash table is never full. |
2902 while (true) { | 2902 while (true) { |
2903 Object* element = KeyAt(entry); | 2903 Object* element = KeyAt(entry); |
2904 // Empty entry. Uses raw unchecked accessors because it is called by the | 2904 // Empty entry. Uses raw unchecked accessors because it is called by the |
2905 // string table during bootstrapping. | 2905 // string table during bootstrapping. |
2906 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; | 2906 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; |
2907 if (element != isolate->heap()->raw_unchecked_the_hole_value() && | 2907 if (element != isolate->heap()->raw_unchecked_the_hole_value() && |
2908 Shape::IsMatch(key, element)) return entry; | 2908 Shape::IsMatch(key, element)) return entry; |
2909 entry = NextProbe(entry, count++, capacity); | 2909 entry = NextProbe(entry, count++, capacity); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3014 Traits::kInstanceType); | 3014 Traits::kInstanceType); |
3015 return reinterpret_cast<FixedTypedArray<Traits>*>(object); | 3015 return reinterpret_cast<FixedTypedArray<Traits>*>(object); |
3016 } | 3016 } |
3017 | 3017 |
3018 | 3018 |
3019 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) | 3019 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) |
3020 STRUCT_LIST(MAKE_STRUCT_CAST) | 3020 STRUCT_LIST(MAKE_STRUCT_CAST) |
3021 #undef MAKE_STRUCT_CAST | 3021 #undef MAKE_STRUCT_CAST |
3022 | 3022 |
3023 | 3023 |
3024 template <typename Shape, typename Key> | 3024 template <typename Derived, typename Shape, typename Key> |
3025 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { | 3025 HashTable<Derived, Shape, Key>* |
| 3026 HashTable<Derived, Shape, Key>::cast(Object* obj) { |
3026 ASSERT(obj->IsHashTable()); | 3027 ASSERT(obj->IsHashTable()); |
3027 return reinterpret_cast<HashTable*>(obj); | 3028 return reinterpret_cast<HashTable*>(obj); |
3028 } | 3029 } |
3029 | 3030 |
3030 | 3031 |
3031 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) | 3032 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) |
3032 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) | 3033 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) |
3033 | 3034 |
3034 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) | 3035 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) |
3035 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset) | 3036 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset) |
(...skipping 3645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6681 bool AccessorPair::all_can_write() { | 6682 bool AccessorPair::all_can_write() { |
6682 return BooleanBit::get(access_flags(), kAllCanWriteBit); | 6683 return BooleanBit::get(access_flags(), kAllCanWriteBit); |
6683 } | 6684 } |
6684 | 6685 |
6685 | 6686 |
6686 bool AccessorPair::prohibits_overwriting() { | 6687 bool AccessorPair::prohibits_overwriting() { |
6687 return BooleanBit::get(access_flags(), kProhibitsOverwritingBit); | 6688 return BooleanBit::get(access_flags(), kProhibitsOverwritingBit); |
6688 } | 6689 } |
6689 | 6690 |
6690 | 6691 |
6691 template<typename Shape, typename Key> | 6692 template<typename Derived, typename Shape, typename Key> |
6692 void Dictionary<Shape, Key>::SetEntry(int entry, | 6693 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
6693 Object* key, | 6694 Object* key, |
6694 Object* value) { | 6695 Object* value) { |
6695 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); | 6696 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); |
6696 } | 6697 } |
6697 | 6698 |
6698 | 6699 |
6699 template<typename Shape, typename Key> | 6700 template<typename Derived, typename Shape, typename Key> |
6700 void Dictionary<Shape, Key>::SetEntry(int entry, | 6701 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, |
6701 Object* key, | 6702 Object* key, |
6702 Object* value, | 6703 Object* value, |
6703 PropertyDetails details) { | 6704 PropertyDetails details) { |
6704 ASSERT(!key->IsName() || | 6705 ASSERT(!key->IsName() || |
6705 details.IsDeleted() || | 6706 details.IsDeleted() || |
6706 details.dictionary_index() > 0); | 6707 details.dictionary_index() > 0); |
6707 int index = HashTable<Shape, Key>::EntryToIndex(entry); | 6708 int index = HashTable_::EntryToIndex(entry); |
6708 DisallowHeapAllocation no_gc; | 6709 DisallowHeapAllocation no_gc; |
6709 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); | 6710 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); |
6710 FixedArray::set(index, key, mode); | 6711 FixedArray::set(index, key, mode); |
6711 FixedArray::set(index+1, value, mode); | 6712 FixedArray::set(index+1, value, mode); |
6712 FixedArray::set(index+2, details.AsSmi()); | 6713 FixedArray::set(index+2, details.AsSmi()); |
6713 } | 6714 } |
6714 | 6715 |
6715 | 6716 |
6716 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { | 6717 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { |
6717 ASSERT(other->IsNumber()); | 6718 ASSERT(other->IsNumber()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6783 uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) { | 6784 uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) { |
6784 return Smi::cast(other->GetHash())->value(); | 6785 return Smi::cast(other->GetHash())->value(); |
6785 } | 6786 } |
6786 | 6787 |
6787 | 6788 |
6788 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) { | 6789 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) { |
6789 return key; | 6790 return key; |
6790 } | 6791 } |
6791 | 6792 |
6792 | 6793 |
| 6794 Handle<ObjectHashTable> ObjectHashTable::Shrink( |
| 6795 Handle<ObjectHashTable> table, Handle<Object> key) { |
| 6796 return HashTable_::Shrink(table, *key); |
| 6797 } |
| 6798 |
| 6799 |
6793 template <int entrysize> | 6800 template <int entrysize> |
6794 bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { | 6801 bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { |
6795 return key->SameValue(other); | 6802 return key->SameValue(other); |
6796 } | 6803 } |
6797 | 6804 |
6798 | 6805 |
6799 template <int entrysize> | 6806 template <int entrysize> |
6800 uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) { | 6807 uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) { |
6801 intptr_t hash = reinterpret_cast<intptr_t>(key); | 6808 intptr_t hash = reinterpret_cast<intptr_t>(key); |
6802 return (uint32_t)(hash & 0xFFFFFFFF); | 6809 return (uint32_t)(hash & 0xFFFFFFFF); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7106 #undef READ_SHORT_FIELD | 7113 #undef READ_SHORT_FIELD |
7107 #undef WRITE_SHORT_FIELD | 7114 #undef WRITE_SHORT_FIELD |
7108 #undef READ_BYTE_FIELD | 7115 #undef READ_BYTE_FIELD |
7109 #undef WRITE_BYTE_FIELD | 7116 #undef WRITE_BYTE_FIELD |
7110 #undef NOBARRIER_READ_BYTE_FIELD | 7117 #undef NOBARRIER_READ_BYTE_FIELD |
7111 #undef NOBARRIER_WRITE_BYTE_FIELD | 7118 #undef NOBARRIER_WRITE_BYTE_FIELD |
7112 | 7119 |
7113 } } // namespace v8::internal | 7120 } } // namespace v8::internal |
7114 | 7121 |
7115 #endif // V8_OBJECTS_INL_H_ | 7122 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |