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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 V(JSGlobalObject) \ | 987 V(JSGlobalObject) \ |
988 V(JSBuiltinsObject) \ | 988 V(JSBuiltinsObject) \ |
989 V(JSGlobalProxy) \ | 989 V(JSGlobalProxy) \ |
990 V(UndetectableObject) \ | 990 V(UndetectableObject) \ |
991 V(AccessCheckNeeded) \ | 991 V(AccessCheckNeeded) \ |
992 V(Cell) \ | 992 V(Cell) \ |
993 V(PropertyCell) \ | 993 V(PropertyCell) \ |
994 V(WeakCell) \ | 994 V(WeakCell) \ |
995 V(ObjectHashTable) \ | 995 V(ObjectHashTable) \ |
996 V(WeakHashTable) \ | 996 V(WeakHashTable) \ |
997 V(EmbeddedMapCache) \ | |
997 V(OrderedHashTable) | 998 V(OrderedHashTable) |
998 | 999 |
999 // Object is the abstract superclass for all classes in the | 1000 // Object is the abstract superclass for all classes in the |
1000 // object hierarchy. | 1001 // object hierarchy. |
1001 // Object does not use any virtual functions to avoid the | 1002 // Object does not use any virtual functions to avoid the |
1002 // allocation of the C++ vtable. | 1003 // allocation of the C++ vtable. |
1003 // Since both Smi and HeapObject are subclasses of Object no | 1004 // Since both Smi and HeapObject are subclasses of Object no |
1004 // data members can be present in Object. | 1005 // data members can be present in Object. |
1005 class Object { | 1006 class Object { |
1006 public: | 1007 public: |
(...skipping 2982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3989 Object* ValueAt(int entry) { | 3990 Object* ValueAt(int entry) { |
3990 return get(EntryToIndex(entry) + kValueOffset); | 3991 return get(EntryToIndex(entry) + kValueOffset); |
3991 } | 3992 } |
3992 | 3993 |
3993 private: | 3994 private: |
3994 static const int kValueOffset = 1; | 3995 static const int kValueOffset = 1; |
3995 }; | 3996 }; |
3996 | 3997 |
3997 | 3998 |
3998 template <int entrysize> | 3999 template <int entrysize> |
3999 class WeakHashTableShape : public BaseShape<Handle<Object> > { | 4000 class HeapPointerShape : public BaseShape<Handle<Object> > { |
Hannes Payer (out of office)
2014/11/17 17:34:33
Why is that a good name?
| |
4000 public: | 4001 public: |
4001 static inline bool IsMatch(Handle<Object> key, Object* other); | 4002 static inline bool IsMatch(Handle<Object> key, Object* other); |
4002 static inline uint32_t Hash(Handle<Object> key); | 4003 static inline uint32_t Hash(Handle<Object> key); |
4003 static inline uint32_t HashForObject(Handle<Object> key, Object* object); | 4004 static inline uint32_t HashForObject(Handle<Object> key, Object* object); |
4004 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key); | 4005 static inline Handle<Object> AsHandle(Isolate* isolate, Handle<Object> key); |
4005 static const int kPrefixSize = 0; | 4006 static const int kPrefixSize = 0; |
4006 static const int kEntrySize = entrysize; | 4007 static const int kEntrySize = entrysize; |
4007 }; | 4008 }; |
4008 | 4009 |
4009 | 4010 |
4010 // WeakHashTable maps keys that are arbitrary objects to object values. | 4011 // WeakHashTable maps keys that are arbitrary objects to object values. |
4011 // It is used for the global weak hash table that maps objects | 4012 // It is used for the global weak hash table that maps objects |
4012 // embedded in optimized code to dependent code lists. | 4013 // embedded in optimized code to dependent code lists. |
4013 class WeakHashTable: public HashTable<WeakHashTable, | 4014 class WeakHashTable |
4014 WeakHashTableShape<2>, | 4015 : public HashTable<WeakHashTable, HeapPointerShape<2>, Handle<Object> > { |
4015 Handle<Object> > { | 4016 typedef HashTable<WeakHashTable, HeapPointerShape<2>, Handle<Object> > |
4016 typedef HashTable< | 4017 DerivedHashTable; |
4017 WeakHashTable, WeakHashTableShape<2>, Handle<Object> > DerivedHashTable; | 4018 |
4018 public: | 4019 public: |
4019 DECLARE_CAST(WeakHashTable) | 4020 DECLARE_CAST(WeakHashTable) |
4020 | 4021 |
4021 // Looks up the value associated with the given key. The hole value is | 4022 // Looks up the value associated with the given key. The hole value is |
4022 // returned in case the key is not present. | 4023 // returned in case the key is not present. |
4023 Object* Lookup(Handle<Object> key); | 4024 Object* Lookup(Handle<Object> key); |
4024 | 4025 |
4025 // Adds (or overwrites) the value associated with the given key. Mapping a | 4026 // Adds (or overwrites) the value associated with the given key. Mapping a |
4026 // key to the hole value causes removal of the whole entry. | 4027 // key to the hole value causes removal of the whole entry. |
4027 MUST_USE_RESULT static Handle<WeakHashTable> Put(Handle<WeakHashTable> table, | 4028 MUST_USE_RESULT static Handle<WeakHashTable> Put(Handle<WeakHashTable> table, |
(...skipping 13 matching lines...) Expand all Loading... | |
4041 friend class MarkCompactCollector; | 4042 friend class MarkCompactCollector; |
4042 | 4043 |
4043 void AddEntry(int entry, Handle<Object> key, Handle<Object> value); | 4044 void AddEntry(int entry, Handle<Object> key, Handle<Object> value); |
4044 | 4045 |
4045 // Returns the index to the value of an entry. | 4046 // Returns the index to the value of an entry. |
4046 static inline int EntryToValueIndex(int entry) { | 4047 static inline int EntryToValueIndex(int entry) { |
4047 return EntryToIndex(entry) + 1; | 4048 return EntryToIndex(entry) + 1; |
4048 } | 4049 } |
4049 }; | 4050 }; |
4050 | 4051 |
4051 | 4052 |
Hannes Payer (out of office)
2014/11/17 17:34:33
Please add a detailed description about what the E
| |
4053 class EmbeddedMapCache | |
4054 : public HashTable<EmbeddedMapCache, HeapPointerShape<2>, Handle<Object> > { | |
4055 typedef HashTable<EmbeddedMapCache, HeapPointerShape<2>, Handle<Object> > | |
4056 DerivedHashTable; | |
4057 | |
4058 public: | |
4059 DECLARE_CAST(EmbeddedMapCache) | |
4060 | |
4061 MUST_USE_RESULT static Handle<EmbeddedMapCache> Put( | |
4062 Handle<EmbeddedMapCache> table, Handle<Map> key); | |
4063 | |
4064 void Age(); | |
4065 | |
4066 private: | |
4067 static const int kMaxAge = 5; | |
4068 | |
4069 friend class MarkCompactCollector; | |
4070 | |
4071 void AddEntry(int entry, Handle<Object> key, Handle<Object> value); | |
4072 | |
4073 // Returns the index to the value of an entry. | |
4074 static inline int EntryToValueIndex(int entry) { | |
4075 return EntryToIndex(entry) + 1; | |
4076 } | |
4077 }; | |
4078 | |
4079 | |
4052 // JSFunctionResultCache caches results of some JSFunction invocation. | 4080 // JSFunctionResultCache caches results of some JSFunction invocation. |
4053 // It is a fixed array with fixed structure: | 4081 // It is a fixed array with fixed structure: |
4054 // [0]: factory function | 4082 // [0]: factory function |
4055 // [1]: finger index | 4083 // [1]: finger index |
4056 // [2]: current cache size | 4084 // [2]: current cache size |
4057 // [3]: dummy field. | 4085 // [3]: dummy field. |
4058 // The rest of array are key/value pairs. | 4086 // The rest of array are key/value pairs. |
4059 class JSFunctionResultCache: public FixedArray { | 4087 class JSFunctionResultCache: public FixedArray { |
4060 public: | 4088 public: |
4061 static const int kFactoryIndex = 0; | 4089 static const int kFactoryIndex = 0; |
(...skipping 6875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10937 } else { | 10965 } else { |
10938 value &= ~(1 << bit_position); | 10966 value &= ~(1 << bit_position); |
10939 } | 10967 } |
10940 return value; | 10968 return value; |
10941 } | 10969 } |
10942 }; | 10970 }; |
10943 | 10971 |
10944 } } // namespace v8::internal | 10972 } } // namespace v8::internal |
10945 | 10973 |
10946 #endif // V8_OBJECTS_H_ | 10974 #endif // V8_OBJECTS_H_ |
OLD | NEW |