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

Side by Side Diff: src/objects.h

Issue 7385006: Reintroduced dictionary that can use objects as keys. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review by Vitaly Repeshko. Created 9 years, 4 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/handles.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 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
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 // The undefined value might be returned in case no hidden properties object
1647 // is present and creation was omitted.
1648 inline bool HasHiddenProperties();
1649 MUST_USE_RESULT MaybeObject* GetHiddenProperties(HiddenPropertiesFlag flag);
1650
1651 // Retrieves a permanent object identity hash code.
1652 //
1653 // The identity hash is stored as a hidden property. The undefined value might
1654 // be returned in case no hidden properties object is present and creation was
1655 // omitted.
1656 MUST_USE_RESULT MaybeObject* GetIdentityHash(HiddenPropertiesFlag flag);
1657
1641 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1658 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1642 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1659 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1643 1660
1644 // Tests for the fast common case for property enumeration. 1661 // Tests for the fast common case for property enumeration.
1645 bool IsSimpleEnum(); 1662 bool IsSimpleEnum();
1646 1663
1647 // Do we want to keep the elements in fast case when increasing the 1664 // Do we want to keep the elements in fast case when increasing the
1648 // capacity? 1665 // capacity?
1649 bool ShouldConvertToSlowElements(int new_capacity); 1666 bool ShouldConvertToSlowElements(int new_capacity);
1650 // Returns true if the backing storage for the slow-case elements of 1667 // Returns true if the backing storage for the slow-case elements of
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 // Remove all entries were key is a number and (from <= key && key < to). 2943 // Remove all entries were key is a number and (from <= key && key < to).
2927 void RemoveNumberEntries(uint32_t from, uint32_t to); 2944 void RemoveNumberEntries(uint32_t from, uint32_t to);
2928 2945
2929 // Bit masks. 2946 // Bit masks.
2930 static const int kRequiresSlowElementsMask = 1; 2947 static const int kRequiresSlowElementsMask = 1;
2931 static const int kRequiresSlowElementsTagSize = 1; 2948 static const int kRequiresSlowElementsTagSize = 1;
2932 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 2949 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
2933 }; 2950 };
2934 2951
2935 2952
2953 class ObjectHashTableShape {
2954 public:
2955 static inline bool IsMatch(JSObject* key, Object* other);
2956 static inline uint32_t Hash(JSObject* key);
2957 static inline uint32_t HashForObject(JSObject* key, Object* object);
2958 MUST_USE_RESULT static inline MaybeObject* AsObject(JSObject* key);
2959 static const int kPrefixSize = 0;
2960 static const int kEntrySize = 2;
2961 };
2962
2963
2964 // ObjectHashTable maps keys that are JavaScript objects to object values by
2965 // using the identity hash of the key for hashing purposes.
2966 class ObjectHashTable: public HashTable<ObjectHashTableShape, JSObject*> {
2967 public:
2968 static inline ObjectHashTable* cast(Object* obj) {
2969 ASSERT(obj->IsHashTable());
2970 return reinterpret_cast<ObjectHashTable*>(obj);
2971 }
2972
2973 // Looks up the value associated with the given key. The undefined value is
2974 // returned in case the key is not present.
2975 Object* Lookup(JSObject* key);
2976
2977 // Adds (or overwrites) the value associated with the given key. Mapping a
2978 // key to the undefined value causes removal of the whole entry.
2979 MUST_USE_RESULT MaybeObject* Put(JSObject* key, Object* value);
2980
2981 private:
2982 void AddEntry(int entry, JSObject* key, Object* value);
2983 void RemoveEntry(int entry);
2984 };
2985
2986
2936 // JSFunctionResultCache caches results of some JSFunction invocation. 2987 // JSFunctionResultCache caches results of some JSFunction invocation.
2937 // It is a fixed array with fixed structure: 2988 // It is a fixed array with fixed structure:
2938 // [0]: factory function 2989 // [0]: factory function
2939 // [1]: finger index 2990 // [1]: finger index
2940 // [2]: current cache size 2991 // [2]: current cache size
2941 // [3]: dummy field. 2992 // [3]: dummy field.
2942 // The rest of array are key/value pairs. 2993 // The rest of array are key/value pairs.
2943 class JSFunctionResultCache: public FixedArray { 2994 class JSFunctionResultCache: public FixedArray {
2944 public: 2995 public:
2945 static const int kFactoryIndex = 0; 2996 static const int kFactoryIndex = 0;
(...skipping 4257 matching lines...) Expand 10 before | Expand all | Expand 10 after
7203 } else { 7254 } else {
7204 value &= ~(1 << bit_position); 7255 value &= ~(1 << bit_position);
7205 } 7256 }
7206 return value; 7257 return value;
7207 } 7258 }
7208 }; 7259 };
7209 7260
7210 } } // namespace v8::internal 7261 } } // namespace v8::internal
7211 7262
7212 #endif // V8_OBJECTS_H_ 7263 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698