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

Side by Side Diff: src/objects.h

Issue 250913003: Dictionary::SetEntry() and Dictionary::AddEntry() handlified. (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/elements.cc ('k') | src/objects.cc » ('j') | 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 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after
3829 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) { 3829 inline static uint32_t FirstProbe(uint32_t hash, uint32_t size) {
3830 return hash & (size - 1); 3830 return hash & (size - 1);
3831 } 3831 }
3832 3832
3833 inline static uint32_t NextProbe( 3833 inline static uint32_t NextProbe(
3834 uint32_t last, uint32_t number, uint32_t size) { 3834 uint32_t last, uint32_t number, uint32_t size) {
3835 return (last + number) & (size - 1); 3835 return (last + number) & (size - 1);
3836 } 3836 }
3837 3837
3838 // Attempt to shrink hash table after removal of key. 3838 // Attempt to shrink hash table after removal of key.
3839 static Handle<Derived> Shrink(Handle<Derived> table, Key key); 3839 MUST_USE_RESULT static Handle<Derived> Shrink(Handle<Derived> table, Key key);
3840 3840
3841 // Ensure enough space for n additional elements. 3841 // Ensure enough space for n additional elements.
3842 MUST_USE_RESULT static Handle<Derived> EnsureCapacity( 3842 MUST_USE_RESULT static Handle<Derived> EnsureCapacity(
3843 Handle<Derived> table, 3843 Handle<Derived> table,
3844 int n, 3844 int n,
3845 Key key, 3845 Key key,
3846 PretenureFlag pretenure = NOT_TENURED); 3846 PretenureFlag pretenure = NOT_TENURED);
3847 3847
3848 private: 3848 private:
3849 // Returns _expected_ if one of entries given by the first _probe_ probes is 3849 // Returns _expected_ if one of entries given by the first _probe_ probes is
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 // Sorting support 4005 // Sorting support
4006 void CopyValuesTo(FixedArray* elements); 4006 void CopyValuesTo(FixedArray* elements);
4007 4007
4008 // Delete a property from the dictionary. 4008 // Delete a property from the dictionary.
4009 static Handle<Object> DeleteProperty( 4009 static Handle<Object> DeleteProperty(
4010 Handle<Derived> dictionary, 4010 Handle<Derived> dictionary,
4011 int entry, 4011 int entry,
4012 JSObject::DeleteMode mode); 4012 JSObject::DeleteMode mode);
4013 4013
4014 // Attempt to shrink the dictionary after deletion of key. 4014 // Attempt to shrink the dictionary after deletion of key.
4015 static inline Handle<Derived> Shrink(Handle<Derived> dictionary, Key key) { 4015 MUST_USE_RESULT static inline Handle<Derived> Shrink(
4016 Handle<Derived> dictionary,
4017 Key key) {
4016 return DerivedHashTable::Shrink(dictionary, key); 4018 return DerivedHashTable::Shrink(dictionary, key);
4017 } 4019 }
4018 4020
4019 // Returns the number of elements in the dictionary filtering out properties 4021 // Returns the number of elements in the dictionary filtering out properties
4020 // with the specified attributes. 4022 // with the specified attributes.
4021 int NumberOfElementsFilterAttributes(PropertyAttributes filter); 4023 int NumberOfElementsFilterAttributes(PropertyAttributes filter);
4022 4024
4023 // Returns the number of enumerable elements in the dictionary. 4025 // Returns the number of enumerable elements in the dictionary.
4024 int NumberOfEnumElements(); 4026 int NumberOfEnumElements();
4025 4027
(...skipping 28 matching lines...) Expand all
4054 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key); 4056 static Handle<Derived> EnsureCapacity(Handle<Derived> obj, int n, Key key);
4055 4057
4056 #ifdef OBJECT_PRINT 4058 #ifdef OBJECT_PRINT
4057 void Print(FILE* out = stdout); 4059 void Print(FILE* out = stdout);
4058 #endif 4060 #endif
4059 // Returns the key (slow). 4061 // Returns the key (slow).
4060 Object* SlowReverseLookup(Object* value); 4062 Object* SlowReverseLookup(Object* value);
4061 4063
4062 // Sets the entry to (key, value) pair. 4064 // Sets the entry to (key, value) pair.
4063 inline void SetEntry(int entry, 4065 inline void SetEntry(int entry,
4064 Object* key, 4066 Handle<Object> key,
4065 Object* value); 4067 Handle<Object> value);
4066 inline void SetEntry(int entry, 4068 inline void SetEntry(int entry,
4067 Object* key, 4069 Handle<Object> key,
4068 Object* value, 4070 Handle<Object> value,
4069 PropertyDetails details); 4071 PropertyDetails details);
4070 4072
4071 MUST_USE_RESULT static Handle<Derived> Add( 4073 MUST_USE_RESULT static Handle<Derived> Add(
4072 Handle<Derived> dictionary, 4074 Handle<Derived> dictionary,
4073 Key key, 4075 Key key,
4074 Handle<Object> value, 4076 Handle<Object> value,
4075 PropertyDetails details); 4077 PropertyDetails details);
4076 4078
4077 protected: 4079 protected:
4078 // Generic at put operation. 4080 // Generic at put operation.
4079 MUST_USE_RESULT static Handle<Derived> AtPut( 4081 MUST_USE_RESULT static Handle<Derived> AtPut(
4080 Handle<Derived> dictionary, 4082 Handle<Derived> dictionary,
4081 Key key, 4083 Key key,
4082 Handle<Object> value); 4084 Handle<Object> value);
4083 4085
4084 // Add entry to dictionary. 4086 // Add entry to dictionary.
4085 MUST_USE_RESULT MaybeObject* AddEntry(Key key, 4087 static void AddEntry(
4086 Object* value,
4087 PropertyDetails details,
4088 uint32_t hash);
4089 MUST_USE_RESULT static Handle<Derived> AddEntry(
4090 Handle<Derived> dictionary, 4088 Handle<Derived> dictionary,
4091 Key key, 4089 Key key,
4092 Handle<Object> value, 4090 Handle<Object> value,
4093 PropertyDetails details, 4091 PropertyDetails details,
4094 uint32_t hash); 4092 uint32_t hash);
4095 4093
4096 // Generate new enumeration indices to avoid enumeration index overflow. 4094 // Generate new enumeration indices to avoid enumeration index overflow.
4097 static void GenerateNewEnumerationIndices(Handle<Derived> dictionary); 4095 static void GenerateNewEnumerationIndices(Handle<Derived> dictionary);
4098 static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; 4096 static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex;
4099 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 4097 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 static const int kPrefixSize = 0; 4270 static const int kPrefixSize = 0;
4273 static const int kEntrySize = 2; 4271 static const int kEntrySize = 2;
4274 }; 4272 };
4275 4273
4276 4274
4277 // ObjectHashTable maps keys that are arbitrary objects to object values by 4275 // ObjectHashTable maps keys that are arbitrary objects to object values by
4278 // using the identity hash of the key for hashing purposes. 4276 // using the identity hash of the key for hashing purposes.
4279 class ObjectHashTable: public HashTable<ObjectHashTable, 4277 class ObjectHashTable: public HashTable<ObjectHashTable,
4280 ObjectHashTableShape, 4278 ObjectHashTableShape,
4281 Object*> { 4279 Object*> {
4282 typedef HashTable<ObjectHashTable, ObjectHashTableShape, Object*> HashTable_; 4280 typedef HashTable<
4281 ObjectHashTable, ObjectHashTableShape, Object*> DerivedHashTable;
4283 public: 4282 public:
4284 static inline ObjectHashTable* cast(Object* obj) { 4283 static inline ObjectHashTable* cast(Object* obj) {
4285 ASSERT(obj->IsHashTable()); 4284 ASSERT(obj->IsHashTable());
4286 return reinterpret_cast<ObjectHashTable*>(obj); 4285 return reinterpret_cast<ObjectHashTable*>(obj);
4287 } 4286 }
4288 4287
4289 // Attempt to shrink hash table after removal of key. 4288 // Attempt to shrink hash table after removal of key.
4290 static inline Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table, 4289 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink(
4291 Handle<Object> key); 4290 Handle<ObjectHashTable> table,
4291 Handle<Object> key);
4292 4292
4293 // Looks up the value associated with the given key. The hole value is 4293 // Looks up the value associated with the given key. The hole value is
4294 // returned in case the key is not present. 4294 // returned in case the key is not present.
4295 Object* Lookup(Object* key); 4295 Object* Lookup(Object* key);
4296 4296
4297 // Adds (or overwrites) the value associated with the given key. Mapping a 4297 // Adds (or overwrites) the value associated with the given key. Mapping a
4298 // key to the hole value causes removal of the whole entry. 4298 // key to the hole value causes removal of the whole entry.
4299 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, 4299 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
4300 Handle<Object> key, 4300 Handle<Object> key,
4301 Handle<Object> value); 4301 Handle<Object> value);
(...skipping 6979 matching lines...) Expand 10 before | Expand all | Expand 10 after
11281 } else { 11281 } else {
11282 value &= ~(1 << bit_position); 11282 value &= ~(1 << bit_position);
11283 } 11283 }
11284 return value; 11284 return value;
11285 } 11285 }
11286 }; 11286 };
11287 11287
11288 } } // namespace v8::internal 11288 } } // namespace v8::internal
11289 11289
11290 #endif // V8_OBJECTS_H_ 11290 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698