| 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 "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
| 10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
| (...skipping 4491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4502 ASSERT(obj->IsOrderedHashTable()); | 4502 ASSERT(obj->IsOrderedHashTable()); |
| 4503 return reinterpret_cast<OrderedHashMap*>(obj); | 4503 return reinterpret_cast<OrderedHashMap*>(obj); |
| 4504 } | 4504 } |
| 4505 | 4505 |
| 4506 Object* Lookup(Handle<Object> key); | 4506 Object* Lookup(Handle<Object> key); |
| 4507 static Handle<OrderedHashMap> Put( | 4507 static Handle<OrderedHashMap> Put( |
| 4508 Handle<OrderedHashMap> table, | 4508 Handle<OrderedHashMap> table, |
| 4509 Handle<Object> key, | 4509 Handle<Object> key, |
| 4510 Handle<Object> value); | 4510 Handle<Object> value); |
| 4511 | 4511 |
| 4512 private: | |
| 4513 Object* ValueAt(int entry) { | 4512 Object* ValueAt(int entry) { |
| 4514 return get(EntryToIndex(entry) + kValueOffset); | 4513 return get(EntryToIndex(entry) + kValueOffset); |
| 4515 } | 4514 } |
| 4516 | 4515 |
| 4516 private: |
| 4517 static const int kValueOffset = 1; | 4517 static const int kValueOffset = 1; |
| 4518 }; | 4518 }; |
| 4519 | 4519 |
| 4520 | 4520 |
| 4521 template <int entrysize> | 4521 template <int entrysize> |
| 4522 class WeakHashTableShape : public BaseShape<Handle<Object> > { | 4522 class WeakHashTableShape : public BaseShape<Handle<Object> > { |
| 4523 public: | 4523 public: |
| 4524 static inline bool IsMatch(Handle<Object> key, Object* other); | 4524 static inline bool IsMatch(Handle<Object> key, Object* other); |
| 4525 static inline uint32_t Hash(Handle<Object> key); | 4525 static inline uint32_t Hash(Handle<Object> key); |
| 4526 static inline uint32_t HashForObject(Handle<Object> key, Object* object); | 4526 static inline uint32_t HashForObject(Handle<Object> key, Object* object); |
| (...skipping 5665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10192 kKindKeys = 1, | 10192 kKindKeys = 1, |
| 10193 kKindValues = 2, | 10193 kKindValues = 2, |
| 10194 kKindEntries = 3 | 10194 kKindEntries = 3 |
| 10195 }; | 10195 }; |
| 10196 | 10196 |
| 10197 // Returns an iterator result object: {value: any, done: boolean} and moves | 10197 // Returns an iterator result object: {value: any, done: boolean} and moves |
| 10198 // the index to the next valid entry. Closes the iterator if moving past the | 10198 // the index to the next valid entry. Closes the iterator if moving past the |
| 10199 // end. | 10199 // end. |
| 10200 static Handle<JSObject> Next(Handle<Derived> iterator); | 10200 static Handle<JSObject> Next(Handle<Derived> iterator); |
| 10201 | 10201 |
| 10202 // Whether the iterator has more elements. This needs to be called before |
| 10203 // calling |CurrentKey| and/or |CurrentValue|. |
| 10204 static bool HasMore(Handle<Derived> iterator); |
| 10205 |
| 10206 // Move the index forward one. |
| 10207 static void MoveNext(Handle<Derived> iterator) { |
| 10208 iterator->set_index( |
| 10209 Smi::FromInt(Smi::cast(iterator->index())->value() + 1)); |
| 10210 } |
| 10211 |
| 10212 // Returns the current key of the iterator. This should only be called when |
| 10213 // |HasMore| returns true. |
| 10214 static inline Handle<Object> CurrentKey(Handle<Derived> iterator); |
| 10215 |
| 10202 private: | 10216 private: |
| 10203 // Transitions the iterator to the non obsolote backing store. This is a NOP | 10217 // Transitions the iterator to the non obsolete backing store. This is a NOP |
| 10204 // if the [table] is not obsolete. | 10218 // if the [table] is not obsolete. |
| 10205 void Transition(); | 10219 void Transition(); |
| 10206 | 10220 |
| 10207 DISALLOW_IMPLICIT_CONSTRUCTORS(OrderedHashTableIterator); | 10221 DISALLOW_IMPLICIT_CONSTRUCTORS(OrderedHashTableIterator); |
| 10208 }; | 10222 }; |
| 10209 | 10223 |
| 10210 | 10224 |
| 10211 class JSSetIterator: public OrderedHashTableIterator<JSSetIterator, | 10225 class JSSetIterator: public OrderedHashTableIterator<JSSetIterator, |
| 10212 OrderedHashSet> { | 10226 OrderedHashSet> { |
| 10213 public: | 10227 public: |
| 10214 // Dispatched behavior. | 10228 // Dispatched behavior. |
| 10215 DECLARE_PRINTER(JSSetIterator) | 10229 DECLARE_PRINTER(JSSetIterator) |
| 10216 DECLARE_VERIFIER(JSSetIterator) | 10230 DECLARE_VERIFIER(JSSetIterator) |
| 10217 | 10231 |
| 10218 // Casting. | 10232 // Casting. |
| 10219 static inline JSSetIterator* cast(Object* obj); | 10233 static inline JSSetIterator* cast(Object* obj); |
| 10220 | 10234 |
| 10221 static Handle<Object> ValueForKind( | 10235 // Returns the iterator result value at the current |index| taking the |kind| |
| 10222 Handle<JSSetIterator> iterator, | 10236 // into account. This should only be called when |HasMore| returns true. |
| 10223 int entry_index); | 10237 static Handle<Object> CurrentIteratorResultValue( |
| 10238 Handle<JSSetIterator> iterator); |
| 10224 | 10239 |
| 10225 private: | 10240 private: |
| 10226 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator); | 10241 DISALLOW_IMPLICIT_CONSTRUCTORS(JSSetIterator); |
| 10227 }; | 10242 }; |
| 10228 | 10243 |
| 10229 | 10244 |
| 10230 class JSMapIterator: public OrderedHashTableIterator<JSMapIterator, | 10245 class JSMapIterator: public OrderedHashTableIterator<JSMapIterator, |
| 10231 OrderedHashMap> { | 10246 OrderedHashMap> { |
| 10232 public: | 10247 public: |
| 10233 // Dispatched behavior. | 10248 // Dispatched behavior. |
| 10234 DECLARE_PRINTER(JSMapIterator) | 10249 DECLARE_PRINTER(JSMapIterator) |
| 10235 DECLARE_VERIFIER(JSMapIterator) | 10250 DECLARE_VERIFIER(JSMapIterator) |
| 10236 | 10251 |
| 10237 // Casting. | 10252 // Casting. |
| 10238 static inline JSMapIterator* cast(Object* obj); | 10253 static inline JSMapIterator* cast(Object* obj); |
| 10239 | 10254 |
| 10240 static Handle<Object> ValueForKind( | 10255 // Returns the iterator result value at the current |index| taking the |kind| |
| 10241 Handle<JSMapIterator> iterator, | 10256 // into account. This should only be called when |HasMore| returns true. |
| 10242 int entry_index); | 10257 static Handle<Object> CurrentIteratorResultValue( |
| 10258 Handle<JSMapIterator> iterator); |
| 10259 |
| 10260 // Returns the current value of the iterator. This should only be called when |
| 10261 // |HasMore| returns true. |
| 10262 static inline Handle<Object> CurrentValue(Handle<JSMapIterator> iterator); |
| 10243 | 10263 |
| 10244 private: | 10264 private: |
| 10245 DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator); | 10265 DISALLOW_IMPLICIT_CONSTRUCTORS(JSMapIterator); |
| 10246 }; | 10266 }; |
| 10247 | 10267 |
| 10248 | 10268 |
| 10249 // Base class for both JSWeakMap and JSWeakSet | 10269 // Base class for both JSWeakMap and JSWeakSet |
| 10250 class JSWeakCollection: public JSObject { | 10270 class JSWeakCollection: public JSObject { |
| 10251 public: | 10271 public: |
| 10252 // [table]: the backing hash table mapping keys to values. | 10272 // [table]: the backing hash table mapping keys to values. |
| (...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11269 } else { | 11289 } else { |
| 11270 value &= ~(1 << bit_position); | 11290 value &= ~(1 << bit_position); |
| 11271 } | 11291 } |
| 11272 return value; | 11292 return value; |
| 11273 } | 11293 } |
| 11274 }; | 11294 }; |
| 11275 | 11295 |
| 11276 } } // namespace v8::internal | 11296 } } // namespace v8::internal |
| 11277 | 11297 |
| 11278 #endif // V8_OBJECTS_H_ | 11298 #endif // V8_OBJECTS_H_ |
| OLD | NEW |