OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 3444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3455 DECLARE_CAST(StringTable) | 3455 DECLARE_CAST(StringTable) |
3456 | 3456 |
3457 private: | 3457 private: |
3458 template <bool seq_one_byte> | 3458 template <bool seq_one_byte> |
3459 friend class JsonParser; | 3459 friend class JsonParser; |
3460 | 3460 |
3461 DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable); | 3461 DISALLOW_IMPLICIT_CONSTRUCTORS(StringTable); |
3462 }; | 3462 }; |
3463 | 3463 |
3464 | 3464 |
3465 class MapCacheShape : public BaseShape<HashTableKey*> { | |
3466 public: | |
3467 static inline bool IsMatch(HashTableKey* key, Object* value) { | |
3468 return key->IsMatch(value); | |
3469 } | |
3470 | |
3471 static inline uint32_t Hash(HashTableKey* key) { | |
3472 return key->Hash(); | |
3473 } | |
3474 | |
3475 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { | |
3476 return key->HashForObject(object); | |
3477 } | |
3478 | |
3479 static inline Handle<Object> AsHandle(Isolate* isolate, HashTableKey* key); | |
3480 | |
3481 static const int kPrefixSize = 0; | |
3482 static const int kEntrySize = 2; | |
3483 }; | |
3484 | |
3485 | |
3486 // MapCache. | |
3487 // | |
3488 // Maps keys that are a fixed array of unique names to a map. | |
3489 // Used for canonicalize maps for object literals. | |
3490 class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> { | |
3491 public: | |
3492 // Find cached value for a name key, otherwise return null. | |
3493 Object* Lookup(FixedArray* key); | |
3494 static Handle<MapCache> Put( | |
3495 Handle<MapCache> map_cache, Handle<FixedArray> key, Handle<Map> value); | |
3496 DECLARE_CAST(MapCache) | |
3497 | |
3498 private: | |
3499 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache); | |
3500 }; | |
3501 | |
3502 | |
3503 template <typename Derived, typename Shape, typename Key> | 3465 template <typename Derived, typename Shape, typename Key> |
3504 class Dictionary: public HashTable<Derived, Shape, Key> { | 3466 class Dictionary: public HashTable<Derived, Shape, Key> { |
3505 protected: | 3467 protected: |
3506 typedef HashTable<Derived, Shape, Key> DerivedHashTable; | 3468 typedef HashTable<Derived, Shape, Key> DerivedHashTable; |
3507 | 3469 |
3508 public: | 3470 public: |
3509 // Returns the value at entry. | 3471 // Returns the value at entry. |
3510 Object* ValueAt(int entry) { | 3472 Object* ValueAt(int entry) { |
3511 return this->get(DerivedHashTable::EntryToIndex(entry) + 1); | 3473 return this->get(DerivedHashTable::EntryToIndex(entry) + 1); |
3512 } | 3474 } |
(...skipping 7462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10975 } else { | 10937 } else { |
10976 value &= ~(1 << bit_position); | 10938 value &= ~(1 << bit_position); |
10977 } | 10939 } |
10978 return value; | 10940 return value; |
10979 } | 10941 } |
10980 }; | 10942 }; |
10981 | 10943 |
10982 } } // namespace v8::internal | 10944 } } // namespace v8::internal |
10983 | 10945 |
10984 #endif // V8_OBJECTS_H_ | 10946 #endif // V8_OBJECTS_H_ |
OLD | NEW |