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

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 from 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
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 MUST_USE_RESULT MaybeObject* GetHiddenProperties(bool create_if_needed);
Vitaly Repeshko 2011/07/26 13:53:14 Document what is returned when there are no existi
Michael Starzinger 2011/07/26 22:30:23 Fixed.
1642
1643 // Retrieves a permanent object identity hash code.
1644 MUST_USE_RESULT MaybeObject* GetIdentityHash();
1645
1641 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1646 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1642 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1647 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1643 1648
1644 // Tests for the fast common case for property enumeration. 1649 // Tests for the fast common case for property enumeration.
1645 bool IsSimpleEnum(); 1650 bool IsSimpleEnum();
1646 1651
1647 // Do we want to keep the elements in fast case when increasing the 1652 // Do we want to keep the elements in fast case when increasing the
1648 // capacity? 1653 // capacity?
1649 bool ShouldConvertToSlowElements(int new_capacity); 1654 bool ShouldConvertToSlowElements(int new_capacity);
1650 // Returns true if the backing storage for the slow-case elements of 1655 // Returns true if the backing storage for the slow-case elements of
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 // Remove all entries were key is a number and (from <= key && key < to). 2911 // Remove all entries were key is a number and (from <= key && key < to).
2907 void RemoveNumberEntries(uint32_t from, uint32_t to); 2912 void RemoveNumberEntries(uint32_t from, uint32_t to);
2908 2913
2909 // Bit masks. 2914 // Bit masks.
2910 static const int kRequiresSlowElementsMask = 1; 2915 static const int kRequiresSlowElementsMask = 1;
2911 static const int kRequiresSlowElementsTagSize = 1; 2916 static const int kRequiresSlowElementsTagSize = 1;
2912 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 2917 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
2913 }; 2918 };
2914 2919
2915 2920
2921 class ObjectDictionaryShape {
2922 public:
2923 static inline bool IsMatch(JSObject* key, Object* other);
2924 static inline uint32_t Hash(JSObject* key);
2925 static inline uint32_t HashForObject(JSObject* key, Object* object);
2926 MUST_USE_RESULT static inline MaybeObject* AsObject(JSObject* key);
2927 static const int kPrefixSize = 2;
2928 static const int kEntrySize = 3;
2929 static const bool kIsEnumerable = false;
2930 };
2931
2932
2933 class ObjectDictionary: public Dictionary<ObjectDictionaryShape, JSObject*> {
Vitaly Repeshko 2011/07/26 13:53:14 Needs a comment.
Michael Starzinger 2011/07/26 22:30:23 Fixed.
2934 public:
2935 static inline ObjectDictionary* cast(Object* obj) {
2936 ASSERT(obj->IsDictionary());
2937 return reinterpret_cast<ObjectDictionary*>(obj);
2938 }
2939
2940 // Specialized version which checks whether objects have an identity hash.
2941 int FindEntry(JSObject* key);
2942 int FindEntry(Isolate* isolate, JSObject* key);
Vitaly Repeshko 2011/07/26 13:53:14 Doesn't seem to be defined/called. Remove?
Vitaly Repeshko 2011/07/27 15:42:26 Did you miss this one?
Michael Starzinger 2011/07/28 01:23:18 Fixed. Yep, missed that one.
2943
2944 // Specialized version which makes sure objects have an identity hash.
2945 MUST_USE_RESULT MaybeObject* Add(JSObject* key, Object* value);
2946 MUST_USE_RESULT MaybeObject* Add(JSObject* key,
Vitaly Repeshko 2011/07/26 13:53:14 Same here. Are PropertyDetails really required? I
Michael Starzinger 2011/07/26 22:30:23 In that case the ObjectDictionary should use HashT
Vitaly Repeshko 2011/07/27 15:42:26 Yes, Dictionaries are used for storing properties
Michael Starzinger 2011/07/28 01:23:18 Fixed. Required a lot of other changes, but it bec
2947 Object* value,
2948 PropertyDetails details);
2949 };
2950
2951
2916 // JSFunctionResultCache caches results of some JSFunction invocation. 2952 // JSFunctionResultCache caches results of some JSFunction invocation.
2917 // It is a fixed array with fixed structure: 2953 // It is a fixed array with fixed structure:
2918 // [0]: factory function 2954 // [0]: factory function
2919 // [1]: finger index 2955 // [1]: finger index
2920 // [2]: current cache size 2956 // [2]: current cache size
2921 // [3]: dummy field. 2957 // [3]: dummy field.
2922 // The rest of array are key/value pairs. 2958 // The rest of array are key/value pairs.
2923 class JSFunctionResultCache: public FixedArray { 2959 class JSFunctionResultCache: public FixedArray {
2924 public: 2960 public:
2925 static const int kFactoryIndex = 0; 2961 static const int kFactoryIndex = 0;
(...skipping 4257 matching lines...) Expand 10 before | Expand all | Expand 10 after
7183 } else { 7219 } else {
7184 value &= ~(1 << bit_position); 7220 value &= ~(1 << bit_position);
7185 } 7221 }
7186 return value; 7222 return value;
7187 } 7223 }
7188 }; 7224 };
7189 7225
7190 } } // namespace v8::internal 7226 } } // namespace v8::internal
7191 7227
7192 #endif // V8_OBJECTS_H_ 7228 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698