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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 255 } |
256 | 256 |
257 // When map collection is enabled we have to mark through map's | 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 | 258 // transitions and back pointers in a special way to make these links |
259 // weak. Only maps for subclasses of JSReceiver can have transitions. | 259 // weak. Only maps for subclasses of JSReceiver can have transitions. |
260 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | 260 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); |
261 if (FLAG_collect_maps && | 261 if (FLAG_collect_maps && |
262 map_object->instance_type() >= FIRST_JS_RECEIVER_TYPE) { | 262 map_object->instance_type() >= FIRST_JS_RECEIVER_TYPE) { |
263 MarkMapContents(heap, map_object); | 263 MarkMapContents(heap, map_object); |
264 } else { | 264 } else { |
265 Object** start_slot = | 265 StaticVisitor::VisitPointers(heap, |
266 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset); | 266 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset), |
267 Object** end_slot = | 267 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); |
268 HeapObject::RawField(object, Map::kPointerFieldsEndOffset); | |
269 StaticVisitor::VisitPointers(heap, start_slot, start_slot, end_slot); | |
270 } | 268 } |
271 } | 269 } |
272 | 270 |
273 | 271 |
274 template<typename StaticVisitor> | 272 template<typename StaticVisitor> |
275 void StaticMarkingVisitor<StaticVisitor>::VisitCode( | 273 void StaticMarkingVisitor<StaticVisitor>::VisitCode( |
276 Map* map, HeapObject* object) { | 274 Map* map, HeapObject* object) { |
277 Heap* heap = map->GetHeap(); | 275 Heap* heap = map->GetHeap(); |
278 Code* code = Code::cast(object); | 276 Code* code = Code::cast(object); |
279 if (FLAG_cleanup_code_caches_at_gc) { | 277 if (FLAG_cleanup_code_caches_at_gc) { |
280 code->ClearTypeFeedbackCells(heap); | 278 code->ClearTypeFeedbackCells(heap); |
281 } | 279 } |
282 code->CodeIterateBody<StaticVisitor>(heap); | 280 code->CodeIterateBody<StaticVisitor>(heap); |
283 } | 281 } |
284 | 282 |
285 | 283 |
286 template<typename StaticVisitor> | 284 template<typename StaticVisitor> |
287 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp( | 285 void StaticMarkingVisitor<StaticVisitor>::VisitJSRegExp( |
288 Map* map, HeapObject* object) { | 286 Map* map, HeapObject* object) { |
289 int last_property_offset = | 287 int last_property_offset = |
290 JSRegExp::kSize + kPointerSize * map->inobject_properties(); | 288 JSRegExp::kSize + kPointerSize * map->inobject_properties(); |
291 Object** start_slot = | 289 StaticVisitor::VisitPointers(map->GetHeap(), |
292 HeapObject::RawField(object, JSRegExp::kPropertiesOffset); | 290 HeapObject::RawField(object, JSRegExp::kPropertiesOffset), |
293 Object** end_slot = | 291 HeapObject::RawField(object, last_property_offset)); |
294 HeapObject::RawField(object, last_property_offset); | |
295 StaticVisitor::VisitPointers( | |
296 map->GetHeap(), start_slot, start_slot, end_slot); | |
297 } | 292 } |
298 | 293 |
299 | 294 |
300 template<typename StaticVisitor> | 295 template<typename StaticVisitor> |
301 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents( | 296 void StaticMarkingVisitor<StaticVisitor>::MarkMapContents( |
302 Heap* heap, Map* map) { | 297 Heap* heap, Map* map) { |
303 // Make sure that the back pointer stored either in the map itself or | 298 // Make sure that the back pointer stored either in the map itself or |
304 // inside its transitions array is marked. Skip recording the back | 299 // inside its transitions array is marked. Skip recording the back |
305 // pointer slot since map space is not compacted. | 300 // pointer slot since map space is not compacted. |
306 StaticVisitor::MarkObject(heap, HeapObject::cast(map->GetBackPointer())); | 301 StaticVisitor::MarkObject(heap, HeapObject::cast(map->GetBackPointer())); |
307 | 302 |
308 // Treat pointers in the transitions array as weak and also mark that | 303 // Treat pointers in the transitions array as weak and also mark that |
309 // array to prevent visiting it later. Skip recording the transition | 304 // array to prevent visiting it later. Skip recording the transition |
310 // array slot, since it will be implicitly recorded when the pointer | 305 // array slot, since it will be implicitly recorded when the pointer |
311 // fields of this map are visited. | 306 // fields of this map are visited. |
312 TransitionArray* transitions = map->unchecked_transition_array(); | 307 TransitionArray* transitions = map->unchecked_transition_array(); |
313 if (transitions->IsTransitionArray()) { | 308 if (transitions->IsTransitionArray()) { |
314 MarkTransitionArray(heap, transitions); | 309 MarkTransitionArray(heap, transitions); |
315 } else { | 310 } else { |
316 // Already marked by marking map->GetBackPointer() above. | 311 // Already marked by marking map->GetBackPointer() above. |
317 ASSERT(transitions->IsMap() || transitions->IsUndefined()); | 312 ASSERT(transitions->IsMap() || transitions->IsUndefined()); |
318 } | 313 } |
319 | 314 |
320 // Mark the pointer fields of the Map. Since the transitions array has | 315 // Mark the pointer fields of the Map. Since the transitions array has |
321 // been marked already, it is fine that one of these fields contains a | 316 // been marked already, it is fine that one of these fields contains a |
322 // pointer to it. | 317 // pointer to it. |
323 Object** start_slot = | 318 StaticVisitor::VisitPointers(heap, |
324 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset); | 319 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), |
325 Object** end_slot = | 320 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); |
326 HeapObject::RawField(map, Map::kPointerFieldsEndOffset); | |
327 StaticVisitor::VisitPointers(heap, start_slot, start_slot, end_slot); | |
328 } | 321 } |
329 | 322 |
330 | 323 |
331 template<typename StaticVisitor> | 324 template<typename StaticVisitor> |
332 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( | 325 void StaticMarkingVisitor<StaticVisitor>::MarkTransitionArray( |
333 Heap* heap, TransitionArray* transitions) { | 326 Heap* heap, TransitionArray* transitions) { |
334 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; | 327 if (!StaticVisitor::MarkObjectWithoutPush(heap, transitions)) return; |
335 | 328 |
336 // Skip recording the descriptors_pointer slot since the cell space | 329 // Skip recording the descriptors_pointer slot since the cell space |
337 // is not compacted and descriptors are referenced through a cell. | 330 // is not compacted and descriptors are referenced through a cell. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 RelocIterator it(this, mode_mask); | 400 RelocIterator it(this, mode_mask); |
408 for (; !it.done(); it.next()) { | 401 for (; !it.done(); it.next()) { |
409 it.rinfo()->template Visit<StaticVisitor>(heap); | 402 it.rinfo()->template Visit<StaticVisitor>(heap); |
410 } | 403 } |
411 } | 404 } |
412 | 405 |
413 | 406 |
414 } } // namespace v8::internal | 407 } } // namespace v8::internal |
415 | 408 |
416 #endif // V8_OBJECTS_VISITING_INL_H_ | 409 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |