| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 | 187 |
| 188 private: | 188 private: |
| 189 Callback callbacks_[StaticVisitorBase::kVisitorIdCount]; | 189 Callback callbacks_[StaticVisitorBase::kVisitorIdCount]; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 | 192 |
| 193 template<typename StaticVisitor> | 193 template<typename StaticVisitor> |
| 194 class BodyVisitorBase : public AllStatic { | 194 class BodyVisitorBase : public AllStatic { |
| 195 public: | 195 public: |
| 196 INLINE(static void IteratePointers(HeapObject* object, | 196 INLINE(static void IteratePointers(Heap* heap, |
| 197 HeapObject* object, |
| 197 int start_offset, | 198 int start_offset, |
| 198 int end_offset)) { | 199 int end_offset)) { |
| 199 Object** start_slot = reinterpret_cast<Object**>(object->address() + | 200 Object** start_slot = reinterpret_cast<Object**>(object->address() + |
| 200 start_offset); | 201 start_offset); |
| 201 Object** end_slot = reinterpret_cast<Object**>(object->address() + | 202 Object** end_slot = reinterpret_cast<Object**>(object->address() + |
| 202 end_offset); | 203 end_offset); |
| 203 StaticVisitor::VisitPointers(start_slot, end_slot); | 204 StaticVisitor::VisitPointers(heap, start_slot, end_slot); |
| 204 } | 205 } |
| 205 }; | 206 }; |
| 206 | 207 |
| 207 | 208 |
| 208 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> | 209 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> |
| 209 class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> { | 210 class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> { |
| 210 public: | 211 public: |
| 211 static inline ReturnType Visit(Map* map, HeapObject* object) { | 212 static inline ReturnType Visit(Map* map, HeapObject* object) { |
| 212 int object_size = BodyDescriptor::SizeOf(map, object); | 213 int object_size = BodyDescriptor::SizeOf(map, object); |
| 213 BodyVisitorBase<StaticVisitor>::IteratePointers( | 214 BodyVisitorBase<StaticVisitor>::IteratePointers( |
| 214 object, BodyDescriptor::kStartOffset, object_size); | 215 map->heap(), |
| 216 object, |
| 217 BodyDescriptor::kStartOffset, |
| 218 object_size); |
| 215 return static_cast<ReturnType>(object_size); | 219 return static_cast<ReturnType>(object_size); |
| 216 } | 220 } |
| 217 | 221 |
| 218 template<int object_size> | 222 template<int object_size> |
| 219 static inline ReturnType VisitSpecialized(Map* map, HeapObject* object) { | 223 static inline ReturnType VisitSpecialized(Map* map, HeapObject* object) { |
| 220 ASSERT(BodyDescriptor::SizeOf(map, object) == object_size); | 224 ASSERT(BodyDescriptor::SizeOf(map, object) == object_size); |
| 221 BodyVisitorBase<StaticVisitor>::IteratePointers( | 225 BodyVisitorBase<StaticVisitor>::IteratePointers( |
| 222 object, BodyDescriptor::kStartOffset, object_size); | 226 map->heap(), |
| 227 object, |
| 228 BodyDescriptor::kStartOffset, |
| 229 object_size); |
| 223 return static_cast<ReturnType>(object_size); | 230 return static_cast<ReturnType>(object_size); |
| 224 } | 231 } |
| 225 }; | 232 }; |
| 226 | 233 |
| 227 | 234 |
| 228 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> | 235 template<typename StaticVisitor, typename BodyDescriptor, typename ReturnType> |
| 229 class FixedBodyVisitor : public BodyVisitorBase<StaticVisitor> { | 236 class FixedBodyVisitor : public BodyVisitorBase<StaticVisitor> { |
| 230 public: | 237 public: |
| 231 static inline ReturnType Visit(Map* map, HeapObject* object) { | 238 static inline ReturnType Visit(Map* map, HeapObject* object) { |
| 232 BodyVisitorBase<StaticVisitor>::IteratePointers( | 239 BodyVisitorBase<StaticVisitor>::IteratePointers( |
| 233 object, BodyDescriptor::kStartOffset, BodyDescriptor::kEndOffset); | 240 map->heap(), |
| 241 object, |
| 242 BodyDescriptor::kStartOffset, |
| 243 BodyDescriptor::kEndOffset); |
| 234 return static_cast<ReturnType>(BodyDescriptor::kSize); | 244 return static_cast<ReturnType>(BodyDescriptor::kSize); |
| 235 } | 245 } |
| 236 }; | 246 }; |
| 237 | 247 |
| 238 | 248 |
| 239 // Base class for visitors used for a linear new space iteration. | 249 // Base class for visitors used for a linear new space iteration. |
| 240 // IterateBody returns size of visited object. | 250 // IterateBody returns size of visited object. |
| 241 // Certain types of objects (i.e. Code objects) are not handled | 251 // Certain types of objects (i.e. Code objects) are not handled |
| 242 // by dispatch table of this visitor because they cannot appear | 252 // by dispatch table of this visitor because they cannot appear |
| 243 // in the new space. | 253 // in the new space. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 kVisitJSObjectGeneric>(); | 309 kVisitJSObjectGeneric>(); |
| 300 table_.RegisterSpecializations<StructVisitor, | 310 table_.RegisterSpecializations<StructVisitor, |
| 301 kVisitStruct, | 311 kVisitStruct, |
| 302 kVisitStructGeneric>(); | 312 kVisitStructGeneric>(); |
| 303 } | 313 } |
| 304 | 314 |
| 305 static inline int IterateBody(Map* map, HeapObject* obj) { | 315 static inline int IterateBody(Map* map, HeapObject* obj) { |
| 306 return table_.GetVisitor(map)(map, obj); | 316 return table_.GetVisitor(map)(map, obj); |
| 307 } | 317 } |
| 308 | 318 |
| 309 static inline void VisitPointers(Object** start, Object** end) { | 319 static inline void VisitPointers(Heap* heap, Object** start, Object** end) { |
| 310 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(p); | 320 for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p); |
| 311 } | 321 } |
| 312 | 322 |
| 313 private: | 323 private: |
| 314 static inline int VisitByteArray(Map* map, HeapObject* object) { | 324 static inline int VisitByteArray(Map* map, HeapObject* object) { |
| 315 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); | 325 return reinterpret_cast<ByteArray*>(object)->ByteArraySize(); |
| 316 } | 326 } |
| 317 | 327 |
| 318 static inline int VisitSeqAsciiString(Map* map, HeapObject* object) { | 328 static inline int VisitSeqAsciiString(Map* map, HeapObject* object) { |
| 319 return SeqAsciiString::cast(object)-> | 329 return SeqAsciiString::cast(object)-> |
| 320 SeqAsciiStringSize(map->instance_type()); | 330 SeqAsciiStringSize(map->instance_type()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 IteratePointer(v, kRelocationInfoOffset); | 382 IteratePointer(v, kRelocationInfoOffset); |
| 373 IteratePointer(v, kDeoptimizationDataOffset); | 383 IteratePointer(v, kDeoptimizationDataOffset); |
| 374 | 384 |
| 375 for (; !it.done(); it.next()) { | 385 for (; !it.done(); it.next()) { |
| 376 it.rinfo()->Visit(v); | 386 it.rinfo()->Visit(v); |
| 377 } | 387 } |
| 378 } | 388 } |
| 379 | 389 |
| 380 | 390 |
| 381 template<typename StaticVisitor> | 391 template<typename StaticVisitor> |
| 382 void Code::CodeIterateBody() { | 392 void Code::CodeIterateBody(Heap* heap) { |
| 383 int mode_mask = RelocInfo::kCodeTargetMask | | 393 int mode_mask = RelocInfo::kCodeTargetMask | |
| 384 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 394 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 385 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 395 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
| 386 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 396 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 387 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | | 397 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
| 388 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 398 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 389 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 399 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 390 | 400 |
| 391 // Use the relocation info pointer before it is visited by | 401 // Use the relocation info pointer before it is visited by |
| 392 // the heap compaction in the next statement. | 402 // the heap compaction in the next statement. |
| 393 RelocIterator it(this, mode_mask); | 403 RelocIterator it(this, mode_mask); |
| 394 | 404 |
| 395 StaticVisitor::VisitPointer( | 405 StaticVisitor::VisitPointer( |
| 406 heap, |
| 396 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); | 407 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); |
| 397 StaticVisitor::VisitPointer( | 408 StaticVisitor::VisitPointer( |
| 409 heap, |
| 398 reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset)); | 410 reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset)); |
| 399 | 411 |
| 400 for (; !it.done(); it.next()) { | 412 for (; !it.done(); it.next()) { |
| 401 it.rinfo()->template Visit<StaticVisitor>(); | 413 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 402 } | 414 } |
| 403 } | 415 } |
| 404 | 416 |
| 405 | 417 |
| 406 } } // namespace v8::internal | 418 } } // namespace v8::internal |
| 407 | 419 |
| 408 #endif // V8_OBJECTS_VISITING_H_ | 420 #endif // V8_OBJECTS_VISITING_H_ |
| OLD | NEW |