OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1631 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be | 1631 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be |
1632 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real | 1632 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real |
1633 // holder. | 1633 // holder. |
1634 // | 1634 // |
1635 // These accessors do not touch interceptors or accessors. | 1635 // These accessors do not touch interceptors or accessors. |
1636 inline bool HasHiddenPropertiesObject(); | 1636 inline bool HasHiddenPropertiesObject(); |
1637 inline Object* GetHiddenPropertiesObject(); | 1637 inline Object* GetHiddenPropertiesObject(); |
1638 MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject( | 1638 MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject( |
1639 Object* hidden_obj); | 1639 Object* hidden_obj); |
1640 | 1640 |
1641 // Indicates whether the hidden properties object should be created. | |
1642 enum HiddenPropertiesFlag { ALLOW_CREATION, OMIT_CREATION }; | |
1643 | |
1644 // Retrieves the hidden properties object. | |
1645 // | |
1646 // Makes sure to properly call BypassGlobalProxy to be safe for JSGlobalProxy | |
Vitaly Repeshko
2011/07/28 13:30:07
I don't think the comments on proxies and fast pro
Michael Starzinger
2011/07/28 17:19:47
Fixed.
| |
1647 // objects as well. Also works on objects that have fast properties. The | |
1648 // undefined value might be returned in case no hidden properties object is | |
1649 // present and creation was omitted. | |
1650 MUST_USE_RESULT MaybeObject* GetHiddenProperties(HiddenPropertiesFlag flag); | |
1651 | |
1652 // Retrieves a permanent object identity hash code. | |
1653 // | |
1654 // The identity hash is stored as a hidden property. The undefined value might | |
1655 // be returned in case no hidden properties object is present and creation was | |
1656 // omitted. | |
1657 MUST_USE_RESULT MaybeObject* GetIdentityHash(HiddenPropertiesFlag flag); | |
1658 | |
1641 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); | 1659 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); |
1642 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); | 1660 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); |
1643 | 1661 |
1644 // Tests for the fast common case for property enumeration. | 1662 // Tests for the fast common case for property enumeration. |
1645 bool IsSimpleEnum(); | 1663 bool IsSimpleEnum(); |
1646 | 1664 |
1647 // Do we want to keep the elements in fast case when increasing the | 1665 // Do we want to keep the elements in fast case when increasing the |
1648 // capacity? | 1666 // capacity? |
1649 bool ShouldConvertToSlowElements(int new_capacity); | 1667 bool ShouldConvertToSlowElements(int new_capacity); |
1650 // Returns true if the backing storage for the slow-case elements of | 1668 // Returns true if the backing storage for the slow-case elements of |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2906 // Remove all entries were key is a number and (from <= key && key < to). | 2924 // Remove all entries were key is a number and (from <= key && key < to). |
2907 void RemoveNumberEntries(uint32_t from, uint32_t to); | 2925 void RemoveNumberEntries(uint32_t from, uint32_t to); |
2908 | 2926 |
2909 // Bit masks. | 2927 // Bit masks. |
2910 static const int kRequiresSlowElementsMask = 1; | 2928 static const int kRequiresSlowElementsMask = 1; |
2911 static const int kRequiresSlowElementsTagSize = 1; | 2929 static const int kRequiresSlowElementsTagSize = 1; |
2912 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; | 2930 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; |
2913 }; | 2931 }; |
2914 | 2932 |
2915 | 2933 |
2934 class ObjectHashTableShape { | |
2935 public: | |
2936 static inline bool IsMatch(JSObject* key, Object* other); | |
2937 static inline uint32_t Hash(JSObject* key); | |
2938 static inline uint32_t HashForObject(JSObject* key, Object* object); | |
2939 MUST_USE_RESULT static inline MaybeObject* AsObject(JSObject* key); | |
2940 static const int kPrefixSize = 0; | |
2941 static const int kEntrySize = 2; | |
2942 }; | |
2943 | |
2944 | |
2945 // ObjectHashTable maps keys that are JavaScript objects to object values by | |
2946 // using the identity hash of the key for hashing purposes. | |
2947 class ObjectHashTable: public HashTable<ObjectHashTableShape, JSObject*> { | |
2948 public: | |
2949 static inline ObjectHashTable* cast(Object* obj) { | |
2950 ASSERT(obj->IsHashTable()); | |
2951 return reinterpret_cast<ObjectHashTable*>(obj); | |
2952 } | |
2953 | |
2954 // Looks up the value associated with the given key. The undefined value is | |
2955 // returned in case the key is not present. | |
2956 Object* Lookup(JSObject* key); | |
2957 | |
2958 // Adds (or overwrites) the value associated with the given key. Mapping a | |
2959 // key to the undefined value causes removal of the whole entry. | |
2960 MUST_USE_RESULT MaybeObject* Put(JSObject* key, Object* value); | |
2961 | |
2962 private: | |
2963 void AddEntry(int entry, JSObject* key, Object* value); | |
2964 void RemoveEntry(int entry); | |
2965 }; | |
2966 | |
2967 | |
2916 // JSFunctionResultCache caches results of some JSFunction invocation. | 2968 // JSFunctionResultCache caches results of some JSFunction invocation. |
2917 // It is a fixed array with fixed structure: | 2969 // It is a fixed array with fixed structure: |
2918 // [0]: factory function | 2970 // [0]: factory function |
2919 // [1]: finger index | 2971 // [1]: finger index |
2920 // [2]: current cache size | 2972 // [2]: current cache size |
2921 // [3]: dummy field. | 2973 // [3]: dummy field. |
2922 // The rest of array are key/value pairs. | 2974 // The rest of array are key/value pairs. |
2923 class JSFunctionResultCache: public FixedArray { | 2975 class JSFunctionResultCache: public FixedArray { |
2924 public: | 2976 public: |
2925 static const int kFactoryIndex = 0; | 2977 static const int kFactoryIndex = 0; |
(...skipping 4257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7183 } else { | 7235 } else { |
7184 value &= ~(1 << bit_position); | 7236 value &= ~(1 << bit_position); |
7185 } | 7237 } |
7186 return value; | 7238 return value; |
7187 } | 7239 } |
7188 }; | 7240 }; |
7189 | 7241 |
7190 } } // namespace v8::internal | 7242 } } // namespace v8::internal |
7191 | 7243 |
7192 #endif // V8_OBJECTS_H_ | 7244 #endif // V8_OBJECTS_H_ |
OLD | NEW |