OLD | NEW |
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 class BodyVisitorBase : public AllStatic { | 206 class BodyVisitorBase : public AllStatic { |
207 public: | 207 public: |
208 INLINE(static void IteratePointers(Heap* heap, | 208 INLINE(static void IteratePointers(Heap* heap, |
209 HeapObject* object, | 209 HeapObject* object, |
210 int start_offset, | 210 int start_offset, |
211 int end_offset)) { | 211 int end_offset)) { |
212 Object** start_slot = reinterpret_cast<Object**>(object->address() + | 212 Object** start_slot = reinterpret_cast<Object**>(object->address() + |
213 start_offset); | 213 start_offset); |
214 Object** end_slot = reinterpret_cast<Object**>(object->address() + | 214 Object** end_slot = reinterpret_cast<Object**>(object->address() + |
215 end_offset); | 215 end_offset); |
216 StaticVisitor::VisitPointers(heap, start_slot, start_slot, end_slot); | 216 StaticVisitor::VisitPointers(heap, start_slot, end_slot); |
217 } | 217 } |
218 }; | 218 }; |
219 | 219 |
220 | 220 |
221 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> | 221 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> |
222 class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> { | 222 class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> { |
223 public: | 223 public: |
224 static inline ReturnType Visit(Map* map, HeapObject* object) { | 224 static inline ReturnType Visit(Map* map, HeapObject* object) { |
225 int object_size = BodyDescriptor::SizeOf(map, object); | 225 int object_size = BodyDescriptor::SizeOf(map, object); |
226 BodyVisitorBase<StaticVisitor>::IteratePointers( | 226 BodyVisitorBase<StaticVisitor>::IteratePointers( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // inlining and specialization of StaticVisitor::VisitPointers methods). | 276 // inlining and specialization of StaticVisitor::VisitPointers methods). |
277 template<typename StaticVisitor> | 277 template<typename StaticVisitor> |
278 class StaticNewSpaceVisitor : public StaticVisitorBase { | 278 class StaticNewSpaceVisitor : public StaticVisitorBase { |
279 public: | 279 public: |
280 static void Initialize(); | 280 static void Initialize(); |
281 | 281 |
282 static inline int IterateBody(Map* map, HeapObject* obj) { | 282 static inline int IterateBody(Map* map, HeapObject* obj) { |
283 return table_.GetVisitor(map)(map, obj); | 283 return table_.GetVisitor(map)(map, obj); |
284 } | 284 } |
285 | 285 |
286 static inline void VisitPointers( | 286 static inline void VisitPointers(Heap* heap, Object** start, Object** end) { |
287 Heap* heap, Object** anchor, Object** start, Object** end) { | |
288 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p); | 287 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p); |
289 } | 288 } |
290 | 289 |
291 private: | 290 private: |
292 static inline int VisitJSFunction(Map* map, HeapObject* object) { | 291 static inline int VisitJSFunction(Map* map, HeapObject* object) { |
293 Heap* heap = map->GetHeap(); | 292 Heap* heap = map->GetHeap(); |
294 Object** start_slot = | |
295 HeapObject::RawField(object, JSFunction::kPropertiesOffset); | |
296 VisitPointers(heap, | 293 VisitPointers(heap, |
297 start_slot, | 294 HeapObject::RawField(object, JSFunction::kPropertiesOffset), |
298 start_slot, | |
299 HeapObject::RawField(object, JSFunction::kCodeEntryOffset)); | 295 HeapObject::RawField(object, JSFunction::kCodeEntryOffset)); |
300 | 296 |
301 // Don't visit code entry. We are using this visitor only during scavenges. | 297 // Don't visit code entry. We are using this visitor only during scavenges. |
302 | 298 |
303 VisitPointers( | 299 VisitPointers( |
304 heap, | 300 heap, |
305 start_slot, | |
306 HeapObject::RawField(object, | 301 HeapObject::RawField(object, |
307 JSFunction::kCodeEntryOffset + kPointerSize), | 302 JSFunction::kCodeEntryOffset + kPointerSize), |
308 HeapObject::RawField(object, | 303 HeapObject::RawField(object, |
309 JSFunction::kNonWeakFieldsEndOffset)); | 304 JSFunction::kNonWeakFieldsEndOffset)); |
310 return JSFunction::kSize; | 305 return JSFunction::kSize; |
311 } | 306 } |
312 | 307 |
313 static inline int VisitByteArray(Map* map, HeapObject* object) { | 308 static inline int VisitByteArray(Map* map, HeapObject* object) { |
314 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 309 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
315 } | 310 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 432 |
438 | 433 |
439 template<typename StaticVisitor> | 434 template<typename StaticVisitor> |
440 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> | 435 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> |
441 StaticMarkingVisitor<StaticVisitor>::table_; | 436 StaticMarkingVisitor<StaticVisitor>::table_; |
442 | 437 |
443 | 438 |
444 } } // namespace v8::internal | 439 } } // namespace v8::internal |
445 | 440 |
446 #endif // V8_OBJECTS_VISITING_H_ | 441 #endif // V8_OBJECTS_VISITING_H_ |
OLD | NEW |