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, end_slot); | 216 StaticVisitor::VisitPointers(heap, start_slot, 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(Heap* heap, Object** start, Object** end) { | 286 static inline void VisitPointers( |
287 Heap* heap, Object** anchor, Object** start, Object** end) { | |
287 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p); | 288 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p); |
288 } | 289 } |
289 | 290 |
290 private: | 291 private: |
291 static inline int VisitJSFunction(Map* map, HeapObject* object) { | 292 static inline int VisitJSFunction(Map* map, HeapObject* object) { |
292 Heap* heap = map->GetHeap(); | 293 Heap* heap = map->GetHeap(); |
294 Object** start = | |
Michael Starzinger
2012/09/26 11:40:07
Can we call that "start_slot" for consistency.
| |
295 HeapObject::RawField(object, JSFunction::kPropertiesOffset); | |
293 VisitPointers(heap, | 296 VisitPointers(heap, |
294 HeapObject::RawField(object, JSFunction::kPropertiesOffset), | 297 start, |
298 start, | |
295 HeapObject::RawField(object, JSFunction::kCodeEntryOffset)); | 299 HeapObject::RawField(object, JSFunction::kCodeEntryOffset)); |
296 | 300 |
297 // Don't visit code entry. We are using this visitor only during scavenges. | 301 // Don't visit code entry. We are using this visitor only during scavenges. |
298 | 302 |
299 VisitPointers( | 303 VisitPointers( |
300 heap, | 304 heap, |
305 start, | |
301 HeapObject::RawField(object, | 306 HeapObject::RawField(object, |
302 JSFunction::kCodeEntryOffset + kPointerSize), | 307 JSFunction::kCodeEntryOffset + kPointerSize), |
303 HeapObject::RawField(object, | 308 HeapObject::RawField(object, |
304 JSFunction::kNonWeakFieldsEndOffset)); | 309 JSFunction::kNonWeakFieldsEndOffset)); |
305 return JSFunction::kSize; | 310 return JSFunction::kSize; |
306 } | 311 } |
307 | 312 |
308 static inline int VisitByteArray(Map* map, HeapObject* object) { | 313 static inline int VisitByteArray(Map* map, HeapObject* object) { |
309 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 314 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
310 } | 315 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 | 437 |
433 | 438 |
434 template<typename StaticVisitor> | 439 template<typename StaticVisitor> |
435 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> | 440 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> |
436 StaticMarkingVisitor<StaticVisitor>::table_; | 441 StaticMarkingVisitor<StaticVisitor>::table_; |
437 | 442 |
438 | 443 |
439 } } // namespace v8::internal | 444 } } // namespace v8::internal |
440 | 445 |
441 #endif // V8_OBJECTS_VISITING_H_ | 446 #endif // V8_OBJECTS_VISITING_H_ |
OLD | NEW |