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 <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 3564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3575 Handle<Object> key, | 3575 Handle<Object> key, |
3576 Handle<Object> value, | 3576 Handle<Object> value, |
3577 PropertyDetails details); | 3577 PropertyDetails details); |
3578 | 3578 |
3579 MUST_USE_RESULT static Handle<Derived> Add( | 3579 MUST_USE_RESULT static Handle<Derived> Add( |
3580 Handle<Derived> dictionary, | 3580 Handle<Derived> dictionary, |
3581 Key key, | 3581 Key key, |
3582 Handle<Object> value, | 3582 Handle<Object> value, |
3583 PropertyDetails details); | 3583 PropertyDetails details); |
3584 | 3584 |
| 3585 // Returns iteration indices array for the |dictionary|. |
| 3586 // Values are direct indices in the |HashTable| array. |
| 3587 static Handle<FixedArray> BuildIterationIndicesArray( |
| 3588 Handle<Derived> dictionary); |
| 3589 |
3585 protected: | 3590 protected: |
3586 // Generic at put operation. | 3591 // Generic at put operation. |
3587 MUST_USE_RESULT static Handle<Derived> AtPut( | 3592 MUST_USE_RESULT static Handle<Derived> AtPut( |
3588 Handle<Derived> dictionary, | 3593 Handle<Derived> dictionary, |
3589 Key key, | 3594 Key key, |
3590 Handle<Object> value); | 3595 Handle<Object> value); |
3591 | 3596 |
3592 // Add entry to dictionary. | 3597 // Add entry to dictionary. |
3593 static void AddEntry( | 3598 static void AddEntry( |
3594 Handle<Derived> dictionary, | 3599 Handle<Derived> dictionary, |
3595 Key key, | 3600 Key key, |
3596 Handle<Object> value, | 3601 Handle<Object> value, |
3597 PropertyDetails details, | 3602 PropertyDetails details, |
3598 uint32_t hash); | 3603 uint32_t hash); |
3599 | 3604 |
3600 // Generate new enumeration indices to avoid enumeration index overflow. | 3605 // Generate new enumeration indices to avoid enumeration index overflow. |
3601 static void GenerateNewEnumerationIndices(Handle<Derived> dictionary); | 3606 // Returns iteration indices array for the |dictionary|. |
| 3607 static Handle<FixedArray> GenerateNewEnumerationIndices( |
| 3608 Handle<Derived> dictionary); |
3602 static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; | 3609 static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; |
3603 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; | 3610 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; |
3604 }; | 3611 }; |
3605 | 3612 |
3606 | 3613 |
3607 class NameDictionaryShape : public BaseShape<Handle<Name> > { | 3614 class NameDictionaryShape : public BaseShape<Handle<Name> > { |
3608 public: | 3615 public: |
3609 static inline bool IsMatch(Handle<Name> key, Object* other); | 3616 static inline bool IsMatch(Handle<Name> key, Object* other); |
3610 static inline uint32_t Hash(Handle<Name> key); | 3617 static inline uint32_t Hash(Handle<Name> key); |
3611 static inline uint32_t HashForObject(Handle<Name> key, Object* object); | 3618 static inline uint32_t HashForObject(Handle<Name> key, Object* object); |
3612 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); | 3619 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Name> key); |
3613 static const int kPrefixSize = 2; | 3620 static const int kPrefixSize = 2; |
3614 static const int kEntrySize = 3; | 3621 static const int kEntrySize = 3; |
3615 static const bool kIsEnumerable = true; | 3622 static const bool kIsEnumerable = true; |
3616 }; | 3623 }; |
3617 | 3624 |
3618 | 3625 |
3619 class NameDictionary: public Dictionary<NameDictionary, | 3626 class NameDictionary: public Dictionary<NameDictionary, |
3620 NameDictionaryShape, | 3627 NameDictionaryShape, |
3621 Handle<Name> > { | 3628 Handle<Name> > { |
3622 typedef Dictionary< | 3629 typedef Dictionary< |
3623 NameDictionary, NameDictionaryShape, Handle<Name> > DerivedDictionary; | 3630 NameDictionary, NameDictionaryShape, Handle<Name> > DerivedDictionary; |
3624 | 3631 |
3625 public: | 3632 public: |
3626 DECLARE_CAST(NameDictionary) | 3633 DECLARE_CAST(NameDictionary) |
3627 | 3634 |
3628 // Copies enumerable keys to preallocated fixed array. | 3635 // Copies enumerable keys to preallocated fixed array. |
3629 void CopyEnumKeysTo(FixedArray* storage); | 3636 void CopyEnumKeysTo(FixedArray* storage); |
3630 inline static void DoGenerateNewEnumerationIndices( | 3637 inline static Handle<FixedArray> DoGenerateNewEnumerationIndices( |
3631 Handle<NameDictionary> dictionary); | 3638 Handle<NameDictionary> dictionary); |
3632 | 3639 |
3633 // Find entry for key, otherwise return kNotFound. Optimized version of | 3640 // Find entry for key, otherwise return kNotFound. Optimized version of |
3634 // HashTable::FindEntry. | 3641 // HashTable::FindEntry. |
3635 int FindEntry(Handle<Name> key); | 3642 int FindEntry(Handle<Name> key); |
3636 }; | 3643 }; |
3637 | 3644 |
3638 | 3645 |
3639 class NumberDictionaryShape : public BaseShape<uint32_t> { | 3646 class NumberDictionaryShape : public BaseShape<uint32_t> { |
3640 public: | 3647 public: |
(...skipping 7200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10841 } else { | 10848 } else { |
10842 value &= ~(1 << bit_position); | 10849 value &= ~(1 << bit_position); |
10843 } | 10850 } |
10844 return value; | 10851 return value; |
10845 } | 10852 } |
10846 }; | 10853 }; |
10847 | 10854 |
10848 } } // namespace v8::internal | 10855 } } // namespace v8::internal |
10849 | 10856 |
10850 #endif // V8_OBJECTS_H_ | 10857 #endif // V8_OBJECTS_H_ |
OLD | NEW |