Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: src/objects-inl.h

Issue 235353003: Revert "HashTable::Shrink() handlified and derived template parameter added to HashTable hierarchy." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 Derived, typename Shape, typename Key> 2878 template<typename Shape, typename Key>
2879 int HashTable<Derived, Shape, Key>::ComputeCapacity(int at_least_space_for) { 2879 int HashTable<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 Derived, typename Shape, typename Key> 2889 template<typename Shape, typename Key>
2890 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { 2890 int HashTable<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 Derived, typename Shape, typename Key> 2896 template<typename Shape, typename Key>
2897 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { 2897 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) {
2898 uint32_t capacity = Capacity(); 2898 uint32_t capacity = Capacity();
2899 uint32_t entry = FirstProbe(HashTable::Hash(key), capacity); 2899 uint32_t entry = FirstProbe(HashTable<Shape, Key>::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
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 Derived, typename Shape, typename Key> 3024 template <typename Shape, typename Key>
3025 HashTable<Derived, Shape, Key>* 3025 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
3026 HashTable<Derived, Shape, Key>::cast(Object* obj) {
3027 ASSERT(obj->IsHashTable()); 3026 ASSERT(obj->IsHashTable());
3028 return reinterpret_cast<HashTable*>(obj); 3027 return reinterpret_cast<HashTable*>(obj);
3029 } 3028 }
3030 3029
3031 3030
3032 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) 3031 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
3033 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) 3032 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
3034 3033
3035 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) 3034 SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
3036 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset) 3035 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
(...skipping 3639 matching lines...) Expand 10 before | Expand all | Expand 10 after
6676 bool AccessorPair::all_can_write() { 6675 bool AccessorPair::all_can_write() {
6677 return BooleanBit::get(access_flags(), kAllCanWriteBit); 6676 return BooleanBit::get(access_flags(), kAllCanWriteBit);
6678 } 6677 }
6679 6678
6680 6679
6681 bool AccessorPair::prohibits_overwriting() { 6680 bool AccessorPair::prohibits_overwriting() {
6682 return BooleanBit::get(access_flags(), kProhibitsOverwritingBit); 6681 return BooleanBit::get(access_flags(), kProhibitsOverwritingBit);
6683 } 6682 }
6684 6683
6685 6684
6686 template<typename Derived, typename Shape, typename Key> 6685 template<typename Shape, typename Key>
6687 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 6686 void Dictionary<Shape, Key>::SetEntry(int entry,
6688 Object* key, 6687 Object* key,
6689 Object* value) { 6688 Object* value) {
6690 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); 6689 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
6691 } 6690 }
6692 6691
6693 6692
6694 template<typename Derived, typename Shape, typename Key> 6693 template<typename Shape, typename Key>
6695 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 6694 void Dictionary<Shape, Key>::SetEntry(int entry,
6696 Object* key, 6695 Object* key,
6697 Object* value, 6696 Object* value,
6698 PropertyDetails details) { 6697 PropertyDetails details) {
6699 ASSERT(!key->IsName() || 6698 ASSERT(!key->IsName() ||
6700 details.IsDeleted() || 6699 details.IsDeleted() ||
6701 details.dictionary_index() > 0); 6700 details.dictionary_index() > 0);
6702 int index = DerivedHashTable::EntryToIndex(entry); 6701 int index = HashTable<Shape, Key>::EntryToIndex(entry);
6703 DisallowHeapAllocation no_gc; 6702 DisallowHeapAllocation no_gc;
6704 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); 6703 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc);
6705 FixedArray::set(index, key, mode); 6704 FixedArray::set(index, key, mode);
6706 FixedArray::set(index+1, value, mode); 6705 FixedArray::set(index+1, value, mode);
6707 FixedArray::set(index+2, details.AsSmi()); 6706 FixedArray::set(index+2, details.AsSmi());
6708 } 6707 }
6709 6708
6710 6709
6711 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { 6710 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
6712 ASSERT(other->IsNumber()); 6711 ASSERT(other->IsNumber());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6778 uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) { 6777 uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) {
6779 return Smi::cast(other->GetHash())->value(); 6778 return Smi::cast(other->GetHash())->value();
6780 } 6779 }
6781 6780
6782 6781
6783 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) { 6782 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) {
6784 return key; 6783 return key;
6785 } 6784 }
6786 6785
6787 6786
6788 Handle<ObjectHashTable> ObjectHashTable::Shrink(
6789 Handle<ObjectHashTable> table, Handle<Object> key) {
6790 return HashTable_::Shrink(table, *key);
6791 }
6792
6793
6794 template <int entrysize> 6787 template <int entrysize>
6795 bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { 6788 bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) {
6796 return key->SameValue(other); 6789 return key->SameValue(other);
6797 } 6790 }
6798 6791
6799 6792
6800 template <int entrysize> 6793 template <int entrysize>
6801 uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) { 6794 uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) {
6802 intptr_t hash = reinterpret_cast<intptr_t>(key); 6795 intptr_t hash = reinterpret_cast<intptr_t>(key);
6803 return (uint32_t)(hash & 0xFFFFFFFF); 6796 return (uint32_t)(hash & 0xFFFFFFFF);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
7107 #undef READ_SHORT_FIELD 7100 #undef READ_SHORT_FIELD
7108 #undef WRITE_SHORT_FIELD 7101 #undef WRITE_SHORT_FIELD
7109 #undef READ_BYTE_FIELD 7102 #undef READ_BYTE_FIELD
7110 #undef WRITE_BYTE_FIELD 7103 #undef WRITE_BYTE_FIELD
7111 #undef NOBARRIER_READ_BYTE_FIELD 7104 #undef NOBARRIER_READ_BYTE_FIELD
7112 #undef NOBARRIER_WRITE_BYTE_FIELD 7105 #undef NOBARRIER_WRITE_BYTE_FIELD
7113 7106
7114 } } // namespace v8::internal 7107 } } // namespace v8::internal
7115 7108
7116 #endif // V8_OBJECTS_INL_H_ 7109 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698