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

Side by Side Diff: src/objects.h

Issue 7349005: Added dictionary that can use objects as keys. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added unit test to gyp buildfile as well. Created 9 years, 5 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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be 1633 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be
1634 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real 1634 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real
1635 // holder. 1635 // holder.
1636 // 1636 //
1637 // These accessors do not touch interceptors or accessors. 1637 // These accessors do not touch interceptors or accessors.
1638 inline bool HasHiddenPropertiesObject(); 1638 inline bool HasHiddenPropertiesObject();
1639 inline Object* GetHiddenPropertiesObject(); 1639 inline Object* GetHiddenPropertiesObject();
1640 MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject( 1640 MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject(
1641 Object* hidden_obj); 1641 Object* hidden_obj);
1642 1642
1643 MUST_USE_RESULT MaybeObject* GetHiddenProperties(bool create_if_needed);
1644
1645 // Retrieves a permanent object identity hash code.
1646 MUST_USE_RESULT MaybeObject* GetIdentityHash();
1647
1643 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1648 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1644 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1649 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1645 1650
1646 // Tests for the fast common case for property enumeration. 1651 // Tests for the fast common case for property enumeration.
1647 bool IsSimpleEnum(); 1652 bool IsSimpleEnum();
1648 1653
1649 // Do we want to keep the elements in fast case when increasing the 1654 // Do we want to keep the elements in fast case when increasing the
1650 // capacity? 1655 // capacity?
1651 bool ShouldConvertToSlowElements(int new_capacity); 1656 bool ShouldConvertToSlowElements(int new_capacity);
1652 // Returns true if the backing storage for the slow-case elements of 1657 // Returns true if the backing storage for the slow-case elements of
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2914 // Remove all entries were key is a number and (from <= key && key < to). 2919 // Remove all entries were key is a number and (from <= key && key < to).
2915 void RemoveNumberEntries(uint32_t from, uint32_t to); 2920 void RemoveNumberEntries(uint32_t from, uint32_t to);
2916 2921
2917 // Bit masks. 2922 // Bit masks.
2918 static const int kRequiresSlowElementsMask = 1; 2923 static const int kRequiresSlowElementsMask = 1;
2919 static const int kRequiresSlowElementsTagSize = 1; 2924 static const int kRequiresSlowElementsTagSize = 1;
2920 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 2925 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
2921 }; 2926 };
2922 2927
2923 2928
2929 class ObjectDictionaryShape {
2930 public:
2931 static inline bool IsMatch(JSObject* key, Object* other);
2932 static inline uint32_t Hash(JSObject* key);
2933 static inline uint32_t HashForObject(JSObject* key, Object* object);
2934 MUST_USE_RESULT static inline MaybeObject* AsObject(JSObject* key);
2935 static const int kPrefixSize = 2;
2936 static const int kEntrySize = 3;
2937 static const bool kIsEnumerable = false;
2938 };
2939
2940
2941 class ObjectDictionary: public Dictionary<ObjectDictionaryShape, JSObject*> {
2942 public:
2943 static inline ObjectDictionary* cast(Object* obj) {
2944 ASSERT(obj->IsDictionary());
2945 return reinterpret_cast<ObjectDictionary*>(obj);
2946 }
2947
2948 MUST_USE_RESULT MaybeObject* AddChecked(JSObject* key, Object* value);
2949 };
2950
2951
2924 // JSFunctionResultCache caches results of some JSFunction invocation. 2952 // JSFunctionResultCache caches results of some JSFunction invocation.
2925 // It is a fixed array with fixed structure: 2953 // It is a fixed array with fixed structure:
2926 // [0]: factory function 2954 // [0]: factory function
2927 // [1]: finger index 2955 // [1]: finger index
2928 // [2]: current cache size 2956 // [2]: current cache size
2929 // [3]: dummy field. 2957 // [3]: dummy field.
2930 // The rest of array are key/value pairs. 2958 // The rest of array are key/value pairs.
2931 class JSFunctionResultCache: public FixedArray { 2959 class JSFunctionResultCache: public FixedArray {
2932 public: 2960 public:
2933 static const int kFactoryIndex = 0; 2961 static const int kFactoryIndex = 0;
(...skipping 4238 matching lines...) Expand 10 before | Expand all | Expand 10 after
7172 } else { 7200 } else {
7173 value &= ~(1 << bit_position); 7201 value &= ~(1 << bit_position);
7174 } 7202 }
7175 return value; 7203 return value;
7176 } 7204 }
7177 }; 7205 };
7178 7206
7179 } } // namespace v8::internal 7207 } } // namespace v8::internal
7180 7208
7181 #endif // V8_OBJECTS_H_ 7209 #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