Chromium Code Reviews| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 127 |
| 128 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); | 128 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit); |
| 129 | 129 |
| 130 table_.Register(kVisitJSWeakMap, &StaticVisitor::VisitJSWeakMap); | 130 table_.Register(kVisitJSWeakMap, &StaticVisitor::VisitJSWeakMap); |
| 131 | 131 |
| 132 table_.Register(kVisitOddball, | 132 table_.Register(kVisitOddball, |
| 133 &FixedBodyVisitor<StaticVisitor, | 133 &FixedBodyVisitor<StaticVisitor, |
| 134 Oddball::BodyDescriptor, | 134 Oddball::BodyDescriptor, |
| 135 void>::Visit); | 135 void>::Visit); |
| 136 | 136 |
| 137 table_.Register(kVisitMap, | 137 table_.Register(kVisitMap, &VisitMap); |
| 138 &FixedBodyVisitor<StaticVisitor, | |
| 139 Map::BodyDescriptor, | |
| 140 void>::Visit); | |
| 141 | 138 |
| 142 table_.Register(kVisitCode, &StaticVisitor::VisitCode); | 139 table_.Register(kVisitCode, &VisitCode); |
| 143 | 140 |
| 144 // Registration for kVisitSharedFunctionInfo is done by StaticVisitor. | 141 // Registration for kVisitSharedFunctionInfo is done by StaticVisitor. |
| 145 | 142 |
| 146 // Registration for kVisitJSFunction is done by StaticVisitor. | 143 // Registration for kVisitJSFunction is done by StaticVisitor. |
| 147 | 144 |
| 148 // Registration for kVisitJSRegExp is done by StaticVisitor. | 145 // Registration for kVisitJSRegExp is done by StaticVisitor. |
| 149 | 146 |
| 150 table_.Register(kVisitPropertyCell, | 147 table_.Register(kVisitPropertyCell, |
| 151 &FixedBodyVisitor<StaticVisitor, | 148 &FixedBodyVisitor<StaticVisitor, |
| 152 JSGlobalPropertyCell::BodyDescriptor, | 149 JSGlobalPropertyCell::BodyDescriptor, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 idx < Context::NATIVE_CONTEXT_SLOTS; | 237 idx < Context::NATIVE_CONTEXT_SLOTS; |
| 241 ++idx) { | 238 ++idx) { |
| 242 Object** slot = | 239 Object** slot = |
| 243 HeapObject::RawField(object, FixedArray::OffsetOfElementAt(idx)); | 240 HeapObject::RawField(object, FixedArray::OffsetOfElementAt(idx)); |
| 244 collector->RecordSlot(slot, slot, *slot); | 241 collector->RecordSlot(slot, slot, *slot); |
| 245 } | 242 } |
| 246 } | 243 } |
| 247 | 244 |
| 248 | 245 |
| 249 template<typename StaticVisitor> | 246 template<typename StaticVisitor> |
| 247 void StaticMarkingVisitor<StaticVisitor>::VisitMap( | |
| 248 Map* map, HeapObject* object) { | |
| 249 Heap* heap = map->GetHeap(); | |
| 250 Map* map_object = Map::cast(object); | |
| 251 | |
| 252 // Clears the cache of ICs related to this map. | |
| 253 if (FLAG_cleanup_code_caches_at_gc) { | |
| 254 map_object->ClearCodeCache(heap); | |
| 255 } | |
| 256 | |
| 257 // When map collection is enabled we have to mark through map's | |
| 258 // transitions and back pointers in a special way to make these links | |
| 259 // weak. Only maps for subclasses of JSReceiver can have transitions. | |
| 260 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | |
| 261 if (FLAG_collect_maps && | |
| 262 map_object->instance_type() >= FIRST_JS_RECEIVER_TYPE) { | |
| 263 MarkMapContents(heap, map_object); | |
| 264 } else { | |
| 265 StaticVisitor::VisitPointers(heap, | |
| 266 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset), | |
| 267 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); | |
| 268 } | |
| 269 } | |
| 270 | |
| 271 | |
| 272 template<typename StaticVisitor> | |
| 250 void StaticMarkingVisitor<StaticVisitor>::VisitCode( | 273 void StaticMarkingVisitor<StaticVisitor>::VisitCode( |
| 251 Map* map, HeapObject* object) { | 274 Map* map, HeapObject* object) { |
| 252 Heap* heap = map->GetHeap(); | 275 Heap* heap = map->GetHeap(); |
| 253 Code* code = Code::cast(object); | 276 Code* code = Code::cast(object); |
| 254 if (FLAG_cleanup_code_caches_at_gc) { | 277 if (FLAG_cleanup_code_caches_at_gc) { |
| 255 code->ClearTypeFeedbackCells(heap); | 278 code->ClearTypeFeedbackCells(heap); |
| 256 } | 279 } |
| 257 code->CodeIterateBody<StaticVisitor>(heap); | 280 code->CodeIterateBody<StaticVisitor>(heap); |
| 258 } | 281 } |
| 259 | 282 |
| 260 | 283 |
| 261 template<typename StaticVisitor> | 284 template<typename StaticVisitor> |
| 262 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp( | 285 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp( |
| 263 Map* map, HeapObject* object) { | 286 Map* map, HeapObject* object) { |
| 264 int last_property_offset = | 287 int last_property_offset = |
| 265 JSRegExp::kSize + kPointerSize * map->inobject_properties(); | 288 JSRegExp::kSize + kPointerSize * map->inobject_properties(); |
| 266 StaticVisitor::VisitPointers(map->GetHeap(), | 289 StaticVisitor::VisitPointers(map->GetHeap(), |
| 267 HeapObject::RawField(object, JSRegExp::kPropertiesOffset), | 290 HeapObject::RawField(object, JSRegExp::kPropertiesOffset), |
| 268 HeapObject::RawField(object, last_property_offset)); | 291 HeapObject::RawField(object, last_property_offset)); |
| 269 } | 292 } |
| 270 | 293 |
| 271 | 294 |
| 295 template<typename StaticVisitor> | |
| 296 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents( | |
| 297 Heap* heap, Map* map) { | |
| 298 // Make sure that the back pointer stored either in the map itself or | |
| 299 // inside its transitions array is marked. Skip recording the back | |
| 300 // pointer slot since map space is not compacted. | |
| 301 StaticVisitor::MarkObject(heap, HeapObject::cast(map->GetBackPointer())); | |
| 302 | |
| 303 // Treat pointers in the transitions array as weak and also mark that | |
| 304 // array to prevent visiting it later. Skip recording the transition | |
| 305 // array slot, since it will be implicitly recorded when the pointer | |
| 306 // fields of this map are visited. | |
| 307 TransitionArray* transitions = map->unchecked_transition_array(); | |
| 308 if (transitions->IsTransitionArray()) { | |
| 309 MarkTransitionArray(heap, transitions); | |
| 310 } else { | |
| 311 // Already marked by marking map->GetBackPointer() above. | |
| 312 ASSERT(transitions->IsMap() || transitions->IsUndefined()); | |
| 313 } | |
| 314 | |
| 315 // Mark the pointer fields of the Map. Since the transitions array has | |
| 316 // been marked already, it is fine that one of these fields contains a | |
| 317 // pointer to it. | |
| 318 StaticVisitor::VisitPointers(heap, | |
| 319 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), | |
| 320 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); | |
| 321 } | |
| 322 | |
| 323 | |
| 324 template<typename StaticVisitor> | |
| 325 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( | |
| 326 Heap* heap, TransitionArray* transitions) { | |
| 327 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; | |
| 328 | |
| 329 // Skip recording the descriptors_pointer slot since the cell space | |
| 330 // is not compacted and descriptors are reference through a cell. | |
|
Toon Verwaest
2012/09/17 09:06:36
*referenced
Michael Starzinger
2012/09/17 09:59:36
Done.
| |
| 331 StaticVisitor::MarkObject(heap, transitions->descriptors_pointer()); | |
| 332 | |
| 333 if (transitions->HasPrototypeTransitions()) { | |
| 334 // Mark prototype transitions array but do not push it onto marking | |
| 335 // stack, this will make references from it weak. We will clean dead | |
| 336 // prototype transitions in ClearNonLiveTransitions. | |
| 337 Object** slot = transitions->GetPrototypeTransitionsSlot(); | |
| 338 HeapObject* obj = HeapObject::cast(*slot); | |
| 339 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); | |
| 340 StaticVisitor::MarkObjectWithoutPush(heap, obj); | |
| 341 } | |
| 342 | |
| 343 for (int i = 0; i < transitions->number_of_transitions(); ++i) { | |
| 344 StaticVisitor::VisitPointer(heap, transitions->GetKeySlot(i)); | |
| 345 } | |
| 346 } | |
| 347 | |
| 348 | |
| 272 void Code::CodeIterateBody(ObjectVisitor* v) { | 349 void Code::CodeIterateBody(ObjectVisitor* v) { |
| 273 int mode_mask = RelocInfo::kCodeTargetMask | | 350 int mode_mask = RelocInfo::kCodeTargetMask | |
| 274 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 351 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 275 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 352 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
| 276 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 353 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 277 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | | 354 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
| 278 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 355 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
| 279 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 356 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
| 280 | 357 |
| 281 // There are two places where we iterate code bodies: here and the | 358 // There are two places where we iterate code bodies: here and the |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 RelocIterator it(this, mode_mask); | 397 RelocIterator it(this, mode_mask); |
| 321 for (; !it.done(); it.next()) { | 398 for (; !it.done(); it.next()) { |
| 322 it.rinfo()->template Visit<StaticVisitor>(heap); | 399 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 323 } | 400 } |
| 324 } | 401 } |
| 325 | 402 |
| 326 | 403 |
| 327 } } // namespace v8::internal | 404 } } // namespace v8::internal |
| 328 | 405 |
| 329 #endif // V8_OBJECTS_VISITING_INL_H_ | 406 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |