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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 V(JSGlobalObject) \ | 1005 V(JSGlobalObject) \ |
1006 V(JSBuiltinsObject) \ | 1006 V(JSBuiltinsObject) \ |
1007 V(JSGlobalProxy) \ | 1007 V(JSGlobalProxy) \ |
1008 V(UndetectableObject) \ | 1008 V(UndetectableObject) \ |
1009 V(AccessCheckNeeded) \ | 1009 V(AccessCheckNeeded) \ |
1010 V(Cell) \ | 1010 V(Cell) \ |
1011 V(PropertyCell) \ | 1011 V(PropertyCell) \ |
1012 V(WeakCell) \ | 1012 V(WeakCell) \ |
1013 V(ObjectHashTable) \ | 1013 V(ObjectHashTable) \ |
1014 V(WeakHashTable) \ | 1014 V(WeakHashTable) \ |
| 1015 V(WeakValueHashTable) \ |
1015 V(OrderedHashTable) | 1016 V(OrderedHashTable) |
1016 | 1017 |
1017 // Object is the abstract superclass for all classes in the | 1018 // Object is the abstract superclass for all classes in the |
1018 // object hierarchy. | 1019 // object hierarchy. |
1019 // Object does not use any virtual functions to avoid the | 1020 // Object does not use any virtual functions to avoid the |
1020 // allocation of the C++ vtable. | 1021 // allocation of the C++ vtable. |
1021 // Since both Smi and HeapObject are subclasses of Object no | 1022 // Since both Smi and HeapObject are subclasses of Object no |
1022 // data members can be present in Object. | 1023 // data members can be present in Object. |
1023 class Object { | 1024 class Object { |
1024 public: | 1025 public: |
(...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3951 // Adds (or overwrites) the value associated with the given key. | 3952 // Adds (or overwrites) the value associated with the given key. |
3952 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, | 3953 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, |
3953 Handle<Object> key, | 3954 Handle<Object> key, |
3954 Handle<Object> value); | 3955 Handle<Object> value); |
3955 | 3956 |
3956 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. | 3957 // Returns an ObjectHashTable (possibly |table|) where |key| has been removed. |
3957 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, | 3958 static Handle<ObjectHashTable> Remove(Handle<ObjectHashTable> table, |
3958 Handle<Object> key, | 3959 Handle<Object> key, |
3959 bool* was_present); | 3960 bool* was_present); |
3960 | 3961 |
3961 private: | 3962 protected: |
3962 friend class MarkCompactCollector; | 3963 friend class MarkCompactCollector; |
3963 | 3964 |
3964 void AddEntry(int entry, Object* key, Object* value); | 3965 void AddEntry(int entry, Object* key, Object* value); |
3965 void RemoveEntry(int entry); | 3966 void RemoveEntry(int entry); |
3966 | 3967 |
3967 // Returns the index to the value of an entry. | 3968 // Returns the index to the value of an entry. |
3968 static inline int EntryToValueIndex(int entry) { | 3969 static inline int EntryToValueIndex(int entry) { |
3969 return EntryToIndex(entry) + 1; | 3970 return EntryToIndex(entry) + 1; |
3970 } | 3971 } |
3971 }; | 3972 }; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4178 // Looks up the value associated with the given key. The hole value is | 4179 // Looks up the value associated with the given key. The hole value is |
4179 // returned in case the key is not present. | 4180 // returned in case the key is not present. |
4180 Object* Lookup(Handle<HeapObject> key); | 4181 Object* Lookup(Handle<HeapObject> key); |
4181 | 4182 |
4182 // Adds (or overwrites) the value associated with the given key. Mapping a | 4183 // Adds (or overwrites) the value associated with the given key. Mapping a |
4183 // key to the hole value causes removal of the whole entry. | 4184 // key to the hole value causes removal of the whole entry. |
4184 MUST_USE_RESULT static Handle<WeakHashTable> Put(Handle<WeakHashTable> table, | 4185 MUST_USE_RESULT static Handle<WeakHashTable> Put(Handle<WeakHashTable> table, |
4185 Handle<HeapObject> key, | 4186 Handle<HeapObject> key, |
4186 Handle<HeapObject> value); | 4187 Handle<HeapObject> value); |
4187 | 4188 |
| 4189 static Handle<FixedArray> GetValues(Handle<WeakHashTable> table); |
| 4190 |
4188 private: | 4191 private: |
4189 friend class MarkCompactCollector; | 4192 friend class MarkCompactCollector; |
4190 | 4193 |
4191 void AddEntry(int entry, Handle<WeakCell> key, Handle<HeapObject> value); | 4194 void AddEntry(int entry, Handle<WeakCell> key, Handle<HeapObject> value); |
4192 | 4195 |
4193 // Returns the index to the value of an entry. | 4196 // Returns the index to the value of an entry. |
4194 static inline int EntryToValueIndex(int entry) { | 4197 static inline int EntryToValueIndex(int entry) { |
4195 return EntryToIndex(entry) + 1; | 4198 return EntryToIndex(entry) + 1; |
4196 } | 4199 } |
4197 }; | 4200 }; |
4198 | 4201 |
4199 | 4202 |
| 4203 class WeakValueHashTable : public ObjectHashTable { |
| 4204 public: |
| 4205 DECLARE_CAST(WeakValueHashTable) |
| 4206 |
| 4207 #ifdef DEBUG |
| 4208 // Looks up the value associated with the given key. The hole value is |
| 4209 // returned in case the key is not present. |
| 4210 Object* LookupWeak(Handle<Object> key); |
| 4211 #endif // DEBUG |
| 4212 |
| 4213 // Adds (or overwrites) the value associated with the given key. Mapping a |
| 4214 // key to the hole value causes removal of the whole entry. |
| 4215 MUST_USE_RESULT static Handle<WeakValueHashTable> PutWeak( |
| 4216 Handle<WeakValueHashTable> table, Handle<Object> key, |
| 4217 Handle<HeapObject> value); |
| 4218 |
| 4219 static Handle<FixedArray> GetWeakValues(Handle<WeakValueHashTable> table); |
| 4220 }; |
| 4221 |
| 4222 |
4200 // JSFunctionResultCache caches results of some JSFunction invocation. | 4223 // JSFunctionResultCache caches results of some JSFunction invocation. |
4201 // It is a fixed array with fixed structure: | 4224 // It is a fixed array with fixed structure: |
4202 // [0]: factory function | 4225 // [0]: factory function |
4203 // [1]: finger index | 4226 // [1]: finger index |
4204 // [2]: current cache size | 4227 // [2]: current cache size |
4205 // [3]: dummy field. | 4228 // [3]: dummy field. |
4206 // The rest of array are key/value pairs. | 4229 // The rest of array are key/value pairs. |
4207 class JSFunctionResultCache: public FixedArray { | 4230 class JSFunctionResultCache : public FixedArray { |
4208 public: | 4231 public: |
4209 static const int kFactoryIndex = 0; | 4232 static const int kFactoryIndex = 0; |
4210 static const int kFingerIndex = kFactoryIndex + 1; | 4233 static const int kFingerIndex = kFactoryIndex + 1; |
4211 static const int kCacheSizeIndex = kFingerIndex + 1; | 4234 static const int kCacheSizeIndex = kFingerIndex + 1; |
4212 static const int kDummyIndex = kCacheSizeIndex + 1; | 4235 static const int kDummyIndex = kCacheSizeIndex + 1; |
4213 static const int kEntriesIndex = kDummyIndex + 1; | 4236 static const int kEntriesIndex = kDummyIndex + 1; |
4214 | 4237 |
4215 static const int kEntrySize = 2; // key + value | 4238 static const int kEntrySize = 2; // key + value |
4216 | 4239 |
4217 static const int kFactoryOffset = kHeaderSize; | 4240 static const int kFactoryOffset = kHeaderSize; |
(...skipping 6912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11130 } else { | 11153 } else { |
11131 value &= ~(1 << bit_position); | 11154 value &= ~(1 << bit_position); |
11132 } | 11155 } |
11133 return value; | 11156 return value; |
11134 } | 11157 } |
11135 }; | 11158 }; |
11136 | 11159 |
11137 } } // namespace v8::internal | 11160 } } // namespace v8::internal |
11138 | 11161 |
11139 #endif // V8_OBJECTS_H_ | 11162 #endif // V8_OBJECTS_H_ |
OLD | NEW |