OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "allocation.h" | 8 #include "allocation.h" |
9 #include "assert-scope.h" | 9 #include "assert-scope.h" |
10 #include "builtins.h" | 10 #include "builtins.h" |
(...skipping 4116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4127 | 4127 |
4128 // Attempt to shrink hash table after removal of key. | 4128 // Attempt to shrink hash table after removal of key. |
4129 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( | 4129 MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink( |
4130 Handle<ObjectHashTable> table, | 4130 Handle<ObjectHashTable> table, |
4131 Handle<Object> key); | 4131 Handle<Object> key); |
4132 | 4132 |
4133 // Looks up the value associated with the given key. The hole value is | 4133 // Looks up the value associated with the given key. The hole value is |
4134 // returned in case the key is not present. | 4134 // returned in case the key is not present. |
4135 Object* Lookup(Handle<Object> key); | 4135 Object* Lookup(Handle<Object> key); |
4136 | 4136 |
4137 // Adds (or overwrites) the value associated with the given key. Mapping a | 4137 // Adds (or overwrites) the value associated with the given key. |
4138 // key to the hole value causes removal of the whole entry. | |
4139 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 4138 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
4140 Handle<Object> key, | 4139 Handle<Object> key, |
4141 Handle<Object> value); | 4140 Handle<Object> value); |
4142 | 4141 |
| 4142 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. |
| 4143 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
| 4144 Handle<Object> key, |
| 4145 bool* was_present); |
| 4146 |
4143 private: | 4147 private: |
4144 friend class MarkCompactCollector; | 4148 friend class MarkCompactCollector; |
4145 | 4149 |
4146 void AddEntry(int entry, Object* key, Object* value); | 4150 void AddEntry(int entry, Object* key, Object* value); |
4147 void RemoveEntry(int entry); | 4151 void RemoveEntry(int entry); |
4148 | 4152 |
4149 // Returns the index to the value of an entry. | 4153 // Returns the index to the value of an entry. |
4150 static inline int EntryToValueIndex(int entry) { | 4154 static inline int EntryToValueIndex(int entry) { |
4151 return EntryToIndex(entry) + 1; | 4155 return EntryToIndex(entry) + 1; |
4152 } | 4156 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4197 Isolate* isolate, int capacity, PretenureFlag pretenure = NOT_TENURED); | 4201 Isolate* isolate, int capacity, PretenureFlag pretenure = NOT_TENURED); |
4198 | 4202 |
4199 // Returns an OrderedHashTable (possibly |table|) with enough space | 4203 // Returns an OrderedHashTable (possibly |table|) with enough space |
4200 // to add at least one new element. | 4204 // to add at least one new element. |
4201 static Handle<Derived> EnsureGrowable(Handle<Derived> table); | 4205 static Handle<Derived> EnsureGrowable(Handle<Derived> table); |
4202 | 4206 |
4203 // Returns an OrderedHashTable (possibly |table|) that's shrunken | 4207 // Returns an OrderedHashTable (possibly |table|) that's shrunken |
4204 // if possible. | 4208 // if possible. |
4205 static Handle<Derived> Shrink(Handle<Derived> table); | 4209 static Handle<Derived> Shrink(Handle<Derived> table); |
4206 | 4210 |
4207 // Returns a new empty OrderedHashTable and updates all the iterators to | 4211 // Returns a new empty OrderedHashTable and records the clearing so that |
4208 // point to the new table. | 4212 // exisiting iterators can be updated. |
4209 static Handle<Derived> Clear(Handle<Derived> table); | 4213 static Handle<Derived> Clear(Handle<Derived> table); |
4210 | 4214 |
| 4215 // Returns an OrderedHashTable (possibly |table|) where |key| has been |
| 4216 // removed. |
| 4217 static Handle<Derived> Remove(Handle<Derived> table, Handle<Object> key, |
| 4218 bool* was_present); |
| 4219 |
4211 // Returns kNotFound if the key isn't present. | 4220 // Returns kNotFound if the key isn't present. |
4212 int FindEntry(Handle<Object> key); | 4221 int FindEntry(Handle<Object> key); |
4213 | 4222 |
4214 int NumberOfElements() { | 4223 int NumberOfElements() { |
4215 return Smi::cast(get(kNumberOfElementsIndex))->value(); | 4224 return Smi::cast(get(kNumberOfElementsIndex))->value(); |
4216 } | 4225 } |
4217 | 4226 |
4218 int NumberOfDeletedElements() { | 4227 int NumberOfDeletedElements() { |
4219 return Smi::cast(get(kNumberOfDeletedElementsIndex))->value(); | 4228 return Smi::cast(get(kNumberOfDeletedElementsIndex))->value(); |
4220 } | 4229 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4324 OrderedHashSet, JSSetIterator, 1> { | 4333 OrderedHashSet, JSSetIterator, 1> { |
4325 public: | 4334 public: |
4326 static OrderedHashSet* cast(Object* obj) { | 4335 static OrderedHashSet* cast(Object* obj) { |
4327 ASSERT(obj->IsOrderedHashTable()); | 4336 ASSERT(obj->IsOrderedHashTable()); |
4328 return reinterpret_cast<OrderedHashSet*>(obj); | 4337 return reinterpret_cast<OrderedHashSet*>(obj); |
4329 } | 4338 } |
4330 | 4339 |
4331 bool Contains(Handle<Object> key); | 4340 bool Contains(Handle<Object> key); |
4332 static Handle<OrderedHashSet> Add( | 4341 static Handle<OrderedHashSet> Add( |
4333 Handle<OrderedHashSet> table, Handle<Object> key); | 4342 Handle<OrderedHashSet> table, Handle<Object> key); |
4334 static Handle<OrderedHashSet> Remove( | |
4335 Handle<OrderedHashSet> table, Handle<Object> key, bool* was_present); | |
4336 }; | 4343 }; |
4337 | 4344 |
4338 | 4345 |
4339 class JSMapIterator; | 4346 class JSMapIterator; |
4340 | 4347 |
4341 | 4348 |
4342 class OrderedHashMap:public OrderedHashTable< | 4349 class OrderedHashMap:public OrderedHashTable< |
4343 OrderedHashMap, JSMapIterator, 2> { | 4350 OrderedHashMap, JSMapIterator, 2> { |
4344 public: | 4351 public: |
4345 static OrderedHashMap* cast(Object* obj) { | 4352 static OrderedHashMap* cast(Object* obj) { |
(...skipping 6728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11074 } else { | 11081 } else { |
11075 value &= ~(1 << bit_position); | 11082 value &= ~(1 << bit_position); |
11076 } | 11083 } |
11077 return value; | 11084 return value; |
11078 } | 11085 } |
11079 }; | 11086 }; |
11080 | 11087 |
11081 } } // namespace v8::internal | 11088 } } // namespace v8::internal |
11082 | 11089 |
11083 #endif // V8_OBJECTS_H_ | 11090 #endif // V8_OBJECTS_H_ |
OLD | NEW |