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

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

Issue 237043002: Revert "Reland "HashTable::Shrink() handlified and derived template parameter added to HashTable hi… (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 2864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 ASSERT(!marking_->IsMarking() || 2875 ASSERT(!marking_->IsMarking() ||
2876 Marking::Color(array) == Marking::WHITE_OBJECT); 2876 Marking::Color(array) == Marking::WHITE_OBJECT);
2877 } 2877 }
2878 2878
2879 2879
2880 DescriptorArray::WhitenessWitness::~WhitenessWitness() { 2880 DescriptorArray::WhitenessWitness::~WhitenessWitness() {
2881 marking_->LeaveNoMarkingScope(); 2881 marking_->LeaveNoMarkingScope();
2882 } 2882 }
2883 2883
2884 2884
2885 template<typename Derived, typename Shape, typename Key> 2885 template<typename Shape, typename Key>
2886 int HashTable<Derived, Shape, Key>::ComputeCapacity(int at_least_space_for) { 2886 int HashTable<Shape, Key>::ComputeCapacity(int at_least_space_for) {
2887 const int kMinCapacity = 32; 2887 const int kMinCapacity = 32;
2888 int capacity = RoundUpToPowerOf2(at_least_space_for * 2); 2888 int capacity = RoundUpToPowerOf2(at_least_space_for * 2);
2889 if (capacity < kMinCapacity) { 2889 if (capacity < kMinCapacity) {
2890 capacity = kMinCapacity; // Guarantee min capacity. 2890 capacity = kMinCapacity; // Guarantee min capacity.
2891 } 2891 }
2892 return capacity; 2892 return capacity;
2893 } 2893 }
2894 2894
2895 2895
2896 template<typename Derived, typename Shape, typename Key> 2896 template<typename Shape, typename Key>
2897 int HashTable<Derived, Shape, Key>::FindEntry(Key key) { 2897 int HashTable<Shape, Key>::FindEntry(Key key) {
2898 return FindEntry(GetIsolate(), key); 2898 return FindEntry(GetIsolate(), key);
2899 } 2899 }
2900 2900
2901 2901
2902 // Find entry for key otherwise return kNotFound. 2902 // Find entry for key otherwise return kNotFound.
2903 template<typename Derived, typename Shape, typename Key> 2903 template<typename Shape, typename Key>
2904 int HashTable<Derived, Shape, Key>::FindEntry(Isolate* isolate, Key key) { 2904 int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) {
2905 uint32_t capacity = Capacity(); 2905 uint32_t capacity = Capacity();
2906 uint32_t entry = FirstProbe(HashTable::Hash(key), capacity); 2906 uint32_t entry = FirstProbe(HashTable<Shape, Key>::Hash(key), capacity);
2907 uint32_t count = 1; 2907 uint32_t count = 1;
2908 // EnsureCapacity will guarantee the hash table is never full. 2908 // EnsureCapacity will guarantee the hash table is never full.
2909 while (true) { 2909 while (true) {
2910 Object* element = KeyAt(entry); 2910 Object* element = KeyAt(entry);
2911 // Empty entry. Uses raw unchecked accessors because it is called by the 2911 // Empty entry. Uses raw unchecked accessors because it is called by the
2912 // string table during bootstrapping. 2912 // string table during bootstrapping.
2913 if (element == isolate->heap()->raw_unchecked_undefined_value()) break; 2913 if (element == isolate->heap()->raw_unchecked_undefined_value()) break;
2914 if (element != isolate->heap()->raw_unchecked_the_hole_value() && 2914 if (element != isolate->heap()->raw_unchecked_the_hole_value() &&
2915 Shape::IsMatch(key, element)) return entry; 2915 Shape::IsMatch(key, element)) return entry;
2916 entry = NextProbe(entry, count++, capacity); 2916 entry = NextProbe(entry, count++, capacity);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3021 Traits::kInstanceType); 3021 Traits::kInstanceType);
3022 return reinterpret_cast<FixedTypedArray<Traits>*>(object); 3022 return reinterpret_cast<FixedTypedArray<Traits>*>(object);
3023 } 3023 }
3024 3024
3025 3025
3026 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) 3026 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name)
3027 STRUCT_LIST(MAKE_STRUCT_CAST) 3027 STRUCT_LIST(MAKE_STRUCT_CAST)
3028 #undef MAKE_STRUCT_CAST 3028 #undef MAKE_STRUCT_CAST
3029 3029
3030 3030
3031 template <typename Derived, typename Shape, typename Key> 3031 template <typename Shape, typename Key>
3032 HashTable<Derived, Shape, Key>* 3032 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
3033 HashTable<Derived, Shape, Key>::cast(Object* obj) {
3034 ASSERT(obj->IsHashTable()); 3033 ASSERT(obj->IsHashTable());
3035 return reinterpret_cast<HashTable*>(obj); 3034 return reinterpret_cast<HashTable*>(obj);
3036 } 3035 }
3037 3036
3038 3037
3039 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) 3038 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
3040 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset) 3039 SYNCHRONIZED_SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
3041 3040
3042 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) 3041 SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
3043 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset) 3042 NOBARRIER_SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
(...skipping 3621 matching lines...) Expand 10 before | Expand all | Expand 10 after
6665 bool AccessorPair::all_can_write() { 6664 bool AccessorPair::all_can_write() {
6666 return BooleanBit::get(access_flags(), kAllCanWriteBit); 6665 return BooleanBit::get(access_flags(), kAllCanWriteBit);
6667 } 6666 }
6668 6667
6669 6668
6670 bool AccessorPair::prohibits_overwriting() { 6669 bool AccessorPair::prohibits_overwriting() {
6671 return BooleanBit::get(access_flags(), kProhibitsOverwritingBit); 6670 return BooleanBit::get(access_flags(), kProhibitsOverwritingBit);
6672 } 6671 }
6673 6672
6674 6673
6675 template<typename Derived, typename Shape, typename Key> 6674 template<typename Shape, typename Key>
6676 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 6675 void Dictionary<Shape, Key>::SetEntry(int entry,
6677 Object* key, 6676 Object* key,
6678 Object* value) { 6677 Object* value) {
6679 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0))); 6678 SetEntry(entry, key, value, PropertyDetails(Smi::FromInt(0)));
6680 } 6679 }
6681 6680
6682 6681
6683 template<typename Derived, typename Shape, typename Key> 6682 template<typename Shape, typename Key>
6684 void Dictionary<Derived, Shape, Key>::SetEntry(int entry, 6683 void Dictionary<Shape, Key>::SetEntry(int entry,
6685 Object* key, 6684 Object* key,
6686 Object* value, 6685 Object* value,
6687 PropertyDetails details) { 6686 PropertyDetails details) {
6688 ASSERT(!key->IsName() || 6687 ASSERT(!key->IsName() ||
6689 details.IsDeleted() || 6688 details.IsDeleted() ||
6690 details.dictionary_index() > 0); 6689 details.dictionary_index() > 0);
6691 int index = DerivedHashTable::EntryToIndex(entry); 6690 int index = HashTable<Shape, Key>::EntryToIndex(entry);
6692 DisallowHeapAllocation no_gc; 6691 DisallowHeapAllocation no_gc;
6693 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc); 6692 WriteBarrierMode mode = FixedArray::GetWriteBarrierMode(no_gc);
6694 FixedArray::set(index, key, mode); 6693 FixedArray::set(index, key, mode);
6695 FixedArray::set(index+1, value, mode); 6694 FixedArray::set(index+1, value, mode);
6696 FixedArray::set(index+2, details.AsSmi()); 6695 FixedArray::set(index+2, details.AsSmi());
6697 } 6696 }
6698 6697
6699 6698
6700 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) { 6699 bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
6701 ASSERT(other->IsNumber()); 6700 ASSERT(other->IsNumber());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6767 uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) { 6766 uint32_t ObjectHashTableShape::HashForObject(Object* key, Object* other) {
6768 return Smi::cast(other->GetHash())->value(); 6767 return Smi::cast(other->GetHash())->value();
6769 } 6768 }
6770 6769
6771 6770
6772 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) { 6771 MaybeObject* ObjectHashTableShape::AsObject(Heap* heap, Object* key) {
6773 return key; 6772 return key;
6774 } 6773 }
6775 6774
6776 6775
6777 Handle<ObjectHashTable> ObjectHashTable::Shrink(
6778 Handle<ObjectHashTable> table, Handle<Object> key) {
6779 return HashTable_::Shrink(table, *key);
6780 }
6781
6782
6783 template <int entrysize> 6776 template <int entrysize>
6784 bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) { 6777 bool WeakHashTableShape<entrysize>::IsMatch(Object* key, Object* other) {
6785 return key->SameValue(other); 6778 return key->SameValue(other);
6786 } 6779 }
6787 6780
6788 6781
6789 template <int entrysize> 6782 template <int entrysize>
6790 uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) { 6783 uint32_t WeakHashTableShape<entrysize>::Hash(Object* key) {
6791 intptr_t hash = reinterpret_cast<intptr_t>(key); 6784 intptr_t hash = reinterpret_cast<intptr_t>(key);
6792 return (uint32_t)(hash & 0xFFFFFFFF); 6785 return (uint32_t)(hash & 0xFFFFFFFF);
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
7096 #undef READ_SHORT_FIELD 7089 #undef READ_SHORT_FIELD
7097 #undef WRITE_SHORT_FIELD 7090 #undef WRITE_SHORT_FIELD
7098 #undef READ_BYTE_FIELD 7091 #undef READ_BYTE_FIELD
7099 #undef WRITE_BYTE_FIELD 7092 #undef WRITE_BYTE_FIELD
7100 #undef NOBARRIER_READ_BYTE_FIELD 7093 #undef NOBARRIER_READ_BYTE_FIELD
7101 #undef NOBARRIER_WRITE_BYTE_FIELD 7094 #undef NOBARRIER_WRITE_BYTE_FIELD
7102 7095
7103 } } // namespace v8::internal 7096 } } // namespace v8::internal
7104 7097
7105 #endif // V8_OBJECTS_INL_H_ 7098 #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