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

Side by Side Diff: src/objects.h

Issue 12764003: Added an Isolate parameter to some HashTable/Dictionary methods. TypeFeedbackOracle tweaks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: TypeFeedbackOracle 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 | « src/heap.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 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(Key key); 2890 // static inline Object* AsObject(Isolate* isolate, 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 SetNumberOfElements(NumberOfElements() - 1); 2966 SetNumberOfElements(NumberOfElements() - 1);
2967 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1); 2967 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1);
2968 } 2968 }
2969 void ElementsRemoved(int n) { 2969 void ElementsRemoved(int n) {
2970 SetNumberOfElements(NumberOfElements() - n); 2970 SetNumberOfElements(NumberOfElements() - n);
2971 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); 2971 SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
2972 } 2972 }
2973 2973
2974 // Returns a new HashTable object. Might return Failure. 2974 // Returns a new HashTable object. Might return Failure.
2975 MUST_USE_RESULT static MaybeObject* Allocate( 2975 MUST_USE_RESULT static MaybeObject* Allocate(
2976 Heap* heap,
2976 int at_least_space_for, 2977 int at_least_space_for,
2977 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY, 2978 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
2978 PretenureFlag pretenure = NOT_TENURED); 2979 PretenureFlag pretenure = NOT_TENURED);
2979 2980
2980 // Computes the required capacity for a table holding the given 2981 // Computes the required capacity for a table holding the given
2981 // number of elements. May be more than HashTable::kMaxCapacity. 2982 // number of elements. May be more than HashTable::kMaxCapacity.
2982 static int ComputeCapacity(int at_least_space_for); 2983 static int ComputeCapacity(int at_least_space_for);
2983 2984
2984 // Returns the key at entry. 2985 // Returns the key at entry.
2985 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } 2986 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 public: 3106 public:
3106 static inline bool IsMatch(HashTableKey* key, Object* value) { 3107 static inline bool IsMatch(HashTableKey* key, Object* value) {
3107 return key->IsMatch(value); 3108 return key->IsMatch(value);
3108 } 3109 }
3109 static inline uint32_t Hash(HashTableKey* key) { 3110 static inline uint32_t Hash(HashTableKey* key) {
3110 return key->Hash(); 3111 return key->Hash();
3111 } 3112 }
3112 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 3113 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
3113 return key->HashForObject(object); 3114 return key->HashForObject(object);
3114 } 3115 }
3115 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { 3116 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
3117 HashTableKey* key) {
3116 return key->AsObject(); 3118 return key->AsObject();
3117 } 3119 }
3118 3120
3119 static const int kPrefixSize = 0; 3121 static const int kPrefixSize = 0;
3120 static const int kEntrySize = 1; 3122 static const int kEntrySize = 1;
3121 }; 3123 };
3122 3124
3123 class SeqOneByteString; 3125 class SeqOneByteString;
3124 3126
3125 // StringTable. 3127 // StringTable.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
3172 return key->IsMatch(value); 3174 return key->IsMatch(value);
3173 } 3175 }
3174 static inline uint32_t Hash(HashTableKey* key) { 3176 static inline uint32_t Hash(HashTableKey* key) {
3175 return key->Hash(); 3177 return key->Hash();
3176 } 3178 }
3177 3179
3178 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 3180 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
3179 return key->HashForObject(object); 3181 return key->HashForObject(object);
3180 } 3182 }
3181 3183
3182 MUST_USE_RESULT static inline MaybeObject* AsObject(HashTableKey* key) { 3184 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
3185 HashTableKey* key) {
3183 return key->AsObject(); 3186 return key->AsObject();
3184 } 3187 }
3185 3188
3186 static const int kPrefixSize = 0; 3189 static const int kPrefixSize = 0;
3187 static const int kEntrySize = 2; 3190 static const int kEntrySize = 2;
3188 }; 3191 };
3189 3192
3190 3193
3191 // MapCache. 3194 // MapCache.
3192 // 3195 //
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3261 void SetNextEnumerationIndex(int index) { 3264 void SetNextEnumerationIndex(int index) {
3262 ASSERT(index != 0); 3265 ASSERT(index != 0);
3263 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); 3266 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index));
3264 } 3267 }
3265 3268
3266 int NextEnumerationIndex() { 3269 int NextEnumerationIndex() {
3267 return Smi::cast(FixedArray::get(kNextEnumerationIndexIndex))->value(); 3270 return Smi::cast(FixedArray::get(kNextEnumerationIndexIndex))->value();
3268 } 3271 }
3269 3272
3270 // Returns a new array for dictionary usage. Might return Failure. 3273 // Returns a new array for dictionary usage. Might return Failure.
3271 MUST_USE_RESULT static MaybeObject* Allocate(int at_least_space_for); 3274 MUST_USE_RESULT static MaybeObject* Allocate(Heap* heap,
3275 int at_least_space_for);
3272 3276
3273 // Ensure enough space for n additional elements. 3277 // Ensure enough space for n additional elements.
3274 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key); 3278 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
3275 3279
3276 #ifdef OBJECT_PRINT 3280 #ifdef OBJECT_PRINT
3277 inline void Print() { 3281 inline void Print() {
3278 Print(stdout); 3282 Print(stdout);
3279 } 3283 }
3280 void Print(FILE* out); 3284 void Print(FILE* out);
3281 #endif 3285 #endif
(...skipping 29 matching lines...) Expand all
3311 HashTable<Shape, Key>::kPrefixStartIndex; 3315 HashTable<Shape, Key>::kPrefixStartIndex;
3312 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 3316 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
3313 }; 3317 };
3314 3318
3315 3319
3316 class NameDictionaryShape : public BaseShape<Name*> { 3320 class NameDictionaryShape : public BaseShape<Name*> {
3317 public: 3321 public:
3318 static inline bool IsMatch(Name* key, Object* other); 3322 static inline bool IsMatch(Name* key, Object* other);
3319 static inline uint32_t Hash(Name* key); 3323 static inline uint32_t Hash(Name* key);
3320 static inline uint32_t HashForObject(Name* key, Object* object); 3324 static inline uint32_t HashForObject(Name* key, Object* object);
3321 MUST_USE_RESULT static inline MaybeObject* AsObject(Name* key); 3325 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
3326 Name* key);
3322 static const int kPrefixSize = 2; 3327 static const int kPrefixSize = 2;
3323 static const int kEntrySize = 3; 3328 static const int kEntrySize = 3;
3324 static const bool kIsEnumerable = true; 3329 static const bool kIsEnumerable = true;
3325 }; 3330 };
3326 3331
3327 3332
3328 class NameDictionary: public Dictionary<NameDictionaryShape, Name*> { 3333 class NameDictionary: public Dictionary<NameDictionaryShape, Name*> {
3329 public: 3334 public:
3330 static inline NameDictionary* cast(Object* obj) { 3335 static inline NameDictionary* cast(Object* obj) {
3331 ASSERT(obj->IsDictionary()); 3336 ASSERT(obj->IsDictionary());
(...skipping 12 matching lines...) Expand all
3344 3349
3345 // Find entry for key, otherwise return kNotFound. Optimized version of 3350 // Find entry for key, otherwise return kNotFound. Optimized version of
3346 // HashTable::FindEntry. 3351 // HashTable::FindEntry.
3347 int FindEntry(Name* key); 3352 int FindEntry(Name* key);
3348 }; 3353 };
3349 3354
3350 3355
3351 class NumberDictionaryShape : public BaseShape<uint32_t> { 3356 class NumberDictionaryShape : public BaseShape<uint32_t> {
3352 public: 3357 public:
3353 static inline bool IsMatch(uint32_t key, Object* other); 3358 static inline bool IsMatch(uint32_t key, Object* other);
3354 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key); 3359 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
3360 uint32_t key);
3355 static const int kEntrySize = 3; 3361 static const int kEntrySize = 3;
3356 static const bool kIsEnumerable = false; 3362 static const bool kIsEnumerable = false;
3357 }; 3363 };
3358 3364
3359 3365
3360 class SeededNumberDictionaryShape : public NumberDictionaryShape { 3366 class SeededNumberDictionaryShape : public NumberDictionaryShape {
3361 public: 3367 public:
3362 static const bool UsesSeed = true; 3368 static const bool UsesSeed = true;
3363 static const int kPrefixSize = 2; 3369 static const int kPrefixSize = 2;
3364 3370
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value); 3454 MUST_USE_RESULT MaybeObject* Set(uint32_t key, Object* value);
3449 }; 3455 };
3450 3456
3451 3457
3452 template <int entrysize> 3458 template <int entrysize>
3453 class ObjectHashTableShape : public BaseShape<Object*> { 3459 class ObjectHashTableShape : public BaseShape<Object*> {
3454 public: 3460 public:
3455 static inline bool IsMatch(Object* key, Object* other); 3461 static inline bool IsMatch(Object* key, Object* other);
3456 static inline uint32_t Hash(Object* key); 3462 static inline uint32_t Hash(Object* key);
3457 static inline uint32_t HashForObject(Object* key, Object* object); 3463 static inline uint32_t HashForObject(Object* key, Object* object);
3458 MUST_USE_RESULT static inline MaybeObject* AsObject(Object* key); 3464 MUST_USE_RESULT static inline MaybeObject* AsObject(Isolate* isolate,
3465 Object* key);
3459 static const int kPrefixSize = 0; 3466 static const int kPrefixSize = 0;
3460 static const int kEntrySize = entrysize; 3467 static const int kEntrySize = entrysize;
3461 }; 3468 };
3462 3469
3463 3470
3464 // ObjectHashSet holds keys that are arbitrary objects by using the identity 3471 // ObjectHashSet holds keys that are arbitrary objects by using the identity
3465 // hash of the key for hashing purposes. 3472 // hash of the key for hashing purposes.
3466 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> { 3473 class ObjectHashSet: public HashTable<ObjectHashTableShape<1>, Object*> {
3467 public: 3474 public:
3468 static inline ObjectHashSet* cast(Object* obj) { 3475 static inline ObjectHashSet* cast(Object* obj) {
(...skipping 3430 matching lines...) Expand 10 before | Expand all | Expand 10 after
6899 } 6906 }
6900 6907
6901 static inline uint32_t Hash(HashTableKey* key) { 6908 static inline uint32_t Hash(HashTableKey* key) {
6902 return key->Hash(); 6909 return key->Hash();
6903 } 6910 }
6904 6911
6905 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 6912 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
6906 return key->HashForObject(object); 6913 return key->HashForObject(object);
6907 } 6914 }
6908 6915
6909 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) { 6916 MUST_USE_RESULT static MaybeObject* AsObject(Isolate* isolate,
6917 HashTableKey* key) {
6910 return key->AsObject(); 6918 return key->AsObject();
6911 } 6919 }
6912 6920
6913 static const int kPrefixSize = 0; 6921 static const int kPrefixSize = 0;
6914 static const int kEntrySize = 2; 6922 static const int kEntrySize = 2;
6915 }; 6923 };
6916 6924
6917 6925
6918 class CompilationCacheTable: public HashTable<CompilationCacheShape, 6926 class CompilationCacheTable: public HashTable<CompilationCacheShape,
6919 HashTableKey*> { 6927 HashTableKey*> {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7001 } 7009 }
7002 7010
7003 static inline uint32_t Hash(HashTableKey* key) { 7011 static inline uint32_t Hash(HashTableKey* key) {
7004 return key->Hash(); 7012 return key->Hash();
7005 } 7013 }
7006 7014
7007 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 7015 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
7008 return key->HashForObject(object); 7016 return key->HashForObject(object);
7009 } 7017 }
7010 7018
7011 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) { 7019 MUST_USE_RESULT static MaybeObject* AsObject(Isolate* isolate,
7020 HashTableKey* key) {
7012 return key->AsObject(); 7021 return key->AsObject();
7013 } 7022 }
7014 7023
7015 static const int kPrefixSize = 0; 7024 static const int kPrefixSize = 0;
7016 static const int kEntrySize = 2; 7025 static const int kEntrySize = 2;
7017 }; 7026 };
7018 7027
7019 7028
7020 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape, 7029 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
7021 HashTableKey*> { 7030 HashTableKey*> {
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after
9247 } else { 9256 } else {
9248 value &= ~(1 << bit_position); 9257 value &= ~(1 << bit_position);
9249 } 9258 }
9250 return value; 9259 return value;
9251 } 9260 }
9252 }; 9261 };
9253 9262
9254 } } // namespace v8::internal 9263 } } // namespace v8::internal
9255 9264
9256 #endif // V8_OBJECTS_H_ 9265 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698