| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 static inline void VisitGlobalPropertyCell(Heap* heap, RelocInfo* rinfo); | 391 static inline void VisitGlobalPropertyCell(Heap* heap, RelocInfo* rinfo); |
| 397 static inline void VisitDebugTarget(Heap* heap, RelocInfo* rinfo); | 392 static inline void VisitDebugTarget(Heap* heap, RelocInfo* rinfo); |
| 398 static inline void VisitCodeTarget(Heap* heap, RelocInfo* rinfo); | 393 static inline void VisitCodeTarget(Heap* heap, RelocInfo* rinfo); |
| 399 static inline void VisitExternalReference(RelocInfo* rinfo) { } | 394 static inline void VisitExternalReference(RelocInfo* rinfo) { } |
| 400 static inline void VisitRuntimeEntry(RelocInfo* rinfo) { } | 395 static inline void VisitRuntimeEntry(RelocInfo* rinfo) { } |
| 401 | 396 |
| 402 // TODO(mstarzinger): This should be made protected once refactoring is done. | 397 // TODO(mstarzinger): This should be made protected once refactoring is done. |
| 403 static inline void VisitNativeContext(Map* map, HeapObject* object); | 398 static inline void VisitNativeContext(Map* map, HeapObject* object); |
| 404 | 399 |
| 405 protected: | 400 protected: |
| 406 static inline void VisitMap(Map* map, HeapObject* object); | |
| 407 static inline void VisitCode(Map* map, HeapObject* object); | 401 static inline void VisitCode(Map* map, HeapObject* object); |
| 408 static inline void VisitJSRegExp(Map* map, HeapObject* object); | 402 static inline void VisitJSRegExp(Map* map, HeapObject* object); |
| 409 | 403 |
| 410 // Mark pointers in a Map and its TransitionArray together, possibly | |
| 411 // treating transitions or back pointers weak. | |
| 412 static void MarkMapContents(Heap* heap, Map* map); | |
| 413 static void MarkTransitionArray(Heap* heap, TransitionArray* transitions); | |
| 414 | |
| 415 class DataObjectVisitor { | 404 class DataObjectVisitor { |
| 416 public: | 405 public: |
| 417 template<int size> | 406 template<int size> |
| 418 static inline void VisitSpecialized(Map* map, HeapObject* object) { | 407 static inline void VisitSpecialized(Map* map, HeapObject* object) { |
| 419 } | 408 } |
| 420 | 409 |
| 421 static inline void Visit(Map* map, HeapObject* object) { | 410 static inline void Visit(Map* map, HeapObject* object) { |
| 422 } | 411 } |
| 423 }; | 412 }; |
| 424 | 413 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 437 | 426 |
| 438 | 427 |
| 439 template<typename StaticVisitor> | 428 template<typename StaticVisitor> |
| 440 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> | 429 VisitorDispatchTable<typename StaticMarkingVisitor<StaticVisitor>::Callback> |
| 441 StaticMarkingVisitor<StaticVisitor>::table_; | 430 StaticMarkingVisitor<StaticVisitor>::table_; |
| 442 | 431 |
| 443 | 432 |
| 444 } } // namespace v8::internal | 433 } } // namespace v8::internal |
| 445 | 434 |
| 446 #endif // V8_OBJECTS_VISITING_H_ | 435 #endif // V8_OBJECTS_VISITING_H_ |
| OLD | NEW |