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

Side by Side Diff: src/objects.h

Issue 12546024: Consistently pass a Heap* to HashTable-related AsObject methods. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « no previous file | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 // Shape must be a class with the following interface: 2880 // Shape must be a class with the following interface:
2881 // class ExampleShape { 2881 // class ExampleShape {
2882 // public: 2882 // public:
2883 // // Tells whether key matches other. 2883 // // Tells whether key matches other.
2884 // static bool IsMatch(Key key, Object* other); 2884 // static bool IsMatch(Key key, Object* other);
2885 // // Returns the hash value for key. 2885 // // Returns the hash value for key.
2886 // static uint32_t Hash(Key key); 2886 // static uint32_t Hash(Key key);
2887 // // Returns the hash value for object. 2887 // // Returns the hash value for object.
2888 // static uint32_t HashForObject(Key key, Object* object); 2888 // static uint32_t HashForObject(Key key, Object* object);
2889 // // Convert key to an object. 2889 // // Convert key to an object.
2890 // static inline Object* AsObject(Isolate* isolate, Key key); 2890 // static inline Object* AsObject(Heap* heap, Key key);
2891 // // The prefix size indicates number of elements in the beginning 2891 // // The prefix size indicates number of elements in the beginning
2892 // // of the backing storage. 2892 // // of the backing storage.
2893 // static const int kPrefixSize = ..; 2893 // static const int kPrefixSize = ..;
2894 // // The Element size indicates number of elements per entry. 2894 // // The Element size indicates number of elements per entry.
2895 // static const int kEntrySize = ..; 2895 // static const int kEntrySize = ..;
2896 // }; 2896 // };
2897 // The prefix size indicates an amount of memory in the 2897 // The prefix size indicates an amount of memory in the
2898 // beginning of the backing storage that can be used for non-element 2898 // beginning of the backing storage that can be used for non-element
2899 // information by subclasses. 2899 // information by subclasses.
2900 2900
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 class HashTableKey { 3089 class HashTableKey {
3090 public: 3090 public:
3091 // Returns whether the other object matches this key. 3091 // Returns whether the other object matches this key.
3092 virtual bool IsMatch(Object* other) = 0; 3092 virtual bool IsMatch(Object* other) = 0;
3093 // Returns the hash value for this key. 3093 // Returns the hash value for this key.
3094 virtual uint32_t Hash() = 0; 3094 virtual uint32_t Hash() = 0;
3095 // Returns the hash value for object. 3095 // Returns the hash value for object.
3096 virtual uint32_t HashForObject(Object* key) = 0; 3096 virtual uint32_t HashForObject(Object* key) = 0;
3097 // Returns the key object for storing into the hash table. 3097 // Returns the key object for storing into the hash table.
3098 // If allocations fails a failure object is returned. 3098 // If allocations fails a failure object is returned.
3099 MUST_USE_RESULT virtual MaybeObject* AsObject() = 0; 3099 MUST_USE_RESULT virtual MaybeObject* AsObject(Heap* heap) = 0;
3100 // Required. 3100 // Required.
3101 virtual ~HashTableKey() {} 3101 virtual ~HashTableKey() {}
3102 }; 3102 };
3103 3103
3104 3104
3105 class StringTableShape : public BaseShape<HashTableKey*> { 3105 class StringTableShape : public BaseShape<HashTableKey*> {
3106 public: 3106 public:
3107 static inline bool IsMatch(HashTableKey* key, Object* value) { 3107 static inline bool IsMatch(HashTableKey* key, Object* value) {
3108 return key->IsMatch(value); 3108 return key->IsMatch(value);
3109 } 3109 }
3110 static inline uint32_t Hash(HashTableKey* key) { 3110 static inline uint32_t Hash(HashTableKey* key) {
3111 return key->Hash(); 3111 return key->Hash();
3112 } 3112 }
3113 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 3113 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
3114 return key->HashForObject(object); 3114 return key->HashForObject(object);
3115 } 3115 }
3116 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate, 3116 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
3117 HashTableKey* key) { 3117 HashTableKey* key) {
3118 return key->AsObject(); 3118 return key->AsObject(heap);
3119 } 3119 }
3120 3120
3121 static const int kPrefixSize = 0; 3121 static const int kPrefixSize = 0;
3122 static const int kEntrySize = 1; 3122 static const int kEntrySize = 1;
3123 }; 3123 };
3124 3124
3125 class SeqOneByteString; 3125 class SeqOneByteString;
3126 3126
3127 // StringTable. 3127 // StringTable.
3128 // 3128 //
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 return key->IsMatch(value); 3174 return key->IsMatch(value);
3175 } 3175 }
3176 static inline uint32_t Hash(HashTableKey* key) { 3176 static inline uint32_t Hash(HashTableKey* key) {
3177 return key->Hash(); 3177 return key->Hash();
3178 } 3178 }
3179 3179
3180 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 3180 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
3181 return key->HashForObject(object); 3181 return key->HashForObject(object);
3182 } 3182 }
3183 3183
3184 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate, 3184 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
3185 HashTableKey* key) { 3185 HashTableKey* key) {
3186 return key->AsObject(); 3186 return key->AsObject(heap);
3187 } 3187 }
3188 3188
3189 static const int kPrefixSize = 0; 3189 static const int kPrefixSize = 0;
3190 static const int kEntrySize = 2; 3190 static const int kEntrySize = 2;
3191 }; 3191 };
3192 3192
3193 3193
3194 // MapCache. 3194 // MapCache.
3195 // 3195 //
3196 // Maps keys that are a fixed array of unique names to a map. 3196 // Maps keys that are a fixed array of unique names to a map.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 HashTable<Shape, Key>::kPrefixStartIndex; 3315 HashTable<Shape, Key>::kPrefixStartIndex;
3316 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 3316 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
3317 }; 3317 };
3318 3318
3319 3319
3320 class NameDictionaryShape : public BaseShape<Name*> { 3320 class NameDictionaryShape : public BaseShape<Name*> {
3321 public: 3321 public:
3322 static inline bool IsMatch(Name* key, Object* other); 3322 static inline bool IsMatch(Name* key, Object* other);
3323 static inline uint32_t Hash(Name* key); 3323 static inline uint32_t Hash(Name* key);
3324 static inline uint32_t HashForObject(Name* key, Object* object); 3324 static inline uint32_t HashForObject(Name* key, Object* object);
3325 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate, 3325 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
3326 Name* key); 3326 Name* key);
3327 static const int kPrefixSize = 2; 3327 static const int kPrefixSize = 2;
3328 static const int kEntrySize = 3; 3328 static const int kEntrySize = 3;
3329 static const bool kIsEnumerable = true; 3329 static const bool kIsEnumerable = true;
3330 }; 3330 };
3331 3331
3332 3332
3333 class NameDictionary: public Dictionary<NameDictionaryShape, Name*> { 3333 class NameDictionary: public Dictionary<NameDictionaryShape, Name*> {
3334 public: 3334 public:
3335 static inline NameDictionary* cast(Object* obj) { 3335 static inline NameDictionary* cast(Object* obj) {
(...skipping 13 matching lines...) Expand all
3349 3349
3350 // Find entry for key, otherwise return kNotFound. Optimized version of 3350 // Find entry for key, otherwise return kNotFound. Optimized version of
3351 // HashTable::FindEntry. 3351 // HashTable::FindEntry.
3352 int FindEntry(Name* key); 3352 int FindEntry(Name* key);
3353 }; 3353 };
3354 3354
3355 3355
3356 class NumberDictionaryShape : public BaseShape<uint32_t> { 3356 class NumberDictionaryShape : public BaseShape<uint32_t> {
3357 public: 3357 public:
3358 static inline bool IsMatch(uint32_t key, Object* other); 3358 static inline bool IsMatch(uint32_t key, Object* other);
3359 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate, 3359 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
3360 uint32_t key); 3360 uint32_t key);
3361 static const int kEntrySize = 3; 3361 static const int kEntrySize = 3;
3362 static const bool kIsEnumerable = false; 3362 static const bool kIsEnumerable = false;
3363 }; 3363 };
3364 3364
3365 3365
3366 class SeededNumberDictionaryShape : public NumberDictionaryShape { 3366 class SeededNumberDictionaryShape : public NumberDictionaryShape {
3367 public: 3367 public:
3368 static const bool UsesSeed = true; 3368 static const bool UsesSeed = true;
3369 static const int kPrefixSize = 2; 3369 static const int kPrefixSize = 2;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
3454 MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value); 3454 MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value);
3455 }; 3455 };
3456 3456
3457 3457
3458 template <int entrysize> 3458 template <int entrysize>
3459 class ObjectHashTableShape : public BaseShape<Object*> { 3459 class ObjectHashTableShape : public BaseShape<Object*> {
3460 public: 3460 public:
3461 static inline bool IsMatch(Object* key, Object* other); 3461 static inline bool IsMatch(Object* key, Object* other);
3462 static inline uint32_t Hash(Object* key); 3462 static inline uint32_t Hash(Object* key);
3463 static inline uint32_t HashForObject(Object* key, Object* object); 3463 static inline uint32_t HashForObject(Object* key, Object* object);
3464 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate, 3464 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
3465 Object* key); 3465 Object* key);
3466 static const int kPrefixSize = 0; 3466 static const int kPrefixSize = 0;
3467 static const int kEntrySize = entrysize; 3467 static const int kEntrySize = entrysize;
3468 }; 3468 };
3469 3469
3470 3470
3471 // ObjectHashSet holds keys that are arbitrary objects by using the identity 3471 // ObjectHashSet holds keys that are arbitrary objects by using the identity
3472 // hash of the key for hashing purposes. 3472 // hash of the key for hashing purposes.
3473 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { 3473 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> {
3474 public: 3474 public:
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after
6906 } 6906 }
6907 6907
6908 static inline uint32_t Hash(HashTableKey* key) { 6908 static inline uint32_t Hash(HashTableKey* key) {
6909 return key->Hash(); 6909 return key->Hash();
6910 } 6910 }
6911 6911
6912 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 6912 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
6913 return key->HashForObject(object); 6913 return key->HashForObject(object);
6914 } 6914 }
6915 6915
6916 MUST_USE_RESULT static MaybeObject* AsObject(Isolate* isolate, 6916 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap,
6917 HashTableKey* key) { 6917 HashTableKey* key) {
6918 return key->AsObject(); 6918 return key->AsObject(heap);
6919 } 6919 }
6920 6920
6921 static const int kPrefixSize = 0; 6921 static const int kPrefixSize = 0;
6922 static const int kEntrySize = 2; 6922 static const int kEntrySize = 2;
6923 }; 6923 };
6924 6924
6925 6925
6926 class CompilationCacheTable: public HashTable<CompilationCacheShape, 6926 class CompilationCacheTable: public HashTable<CompilationCacheShape,
6927 HashTableKey*> { 6927 HashTableKey*> {
6928 public: 6928 public:
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
7009 } 7009 }
7010 7010
7011 static inline uint32_t Hash(HashTableKey* key) { 7011 static inline uint32_t Hash(HashTableKey* key) {
7012 return key->Hash(); 7012 return key->Hash();
7013 } 7013 }
7014 7014
7015 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 7015 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
7016 return key->HashForObject(object); 7016 return key->HashForObject(object);
7017 } 7017 }
7018 7018
7019 MUST_USE_RESULT static MaybeObject* AsObject(Isolate* isolate, 7019 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap,
7020 HashTableKey* key) { 7020 HashTableKey* key) {
7021 return key->AsObject(); 7021 return key->AsObject(heap);
7022 } 7022 }
7023 7023
7024 static const int kPrefixSize = 0; 7024 static const int kPrefixSize = 0;
7025 static const int kEntrySize = 2; 7025 static const int kEntrySize = 2;
7026 }; 7026 };
7027 7027
7028 7028
7029 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape, 7029 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
7030 HashTableKey*> { 7030 HashTableKey*> {
7031 public: 7031 public:
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
9256 } else { 9256 } else {
9257 value &= ~(1 << bit_position); 9257 value &= ~(1 << bit_position);
9258 } 9258 }
9259 return value; 9259 return value;
9260 } 9260 }
9261 }; 9261 };
9262 9262
9263 } } // namespace v8::internal 9263 } } // namespace v8::internal
9264 9264
9265 #endif // V8_OBJECTS_H_ 9265 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698