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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 StaticVisitor::MarkObject(heap, code); | 168 StaticVisitor::MarkObject(heap, code); |
169 } | 169 } |
170 | 170 |
171 | 171 |
172 template<typename StaticVisitor> | 172 template<typename StaticVisitor> |
173 void StaticMarkingVisitor<StaticVisitor>::VisitEmbeddedPointer( | 173 void StaticMarkingVisitor<StaticVisitor>::VisitEmbeddedPointer( |
174 Heap* heap, RelocInfo* rinfo) { | 174 Heap* heap, RelocInfo* rinfo) { |
175 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); | 175 ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
176 ASSERT(!rinfo->target_object()->IsConsString()); | 176 ASSERT(!rinfo->target_object()->IsConsString()); |
177 HeapObject* object = HeapObject::cast(rinfo->target_object()); | 177 HeapObject* object = HeapObject::cast(rinfo->target_object()); |
178 heap->mark_compact_collector()->RecordRelocSlot(rinfo, object); | 178 if (rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || |
Michael Starzinger
2013/01/21 14:36:44
This should be behind the FLAG_collect_maps flag I
ulan
2013/01/21 15:56:02
Done.
| |
179 StaticVisitor::MarkObject(heap, object); | 179 !object->IsMap() || !Map::cast(object)->CanTransition()) { |
180 heap->mark_compact_collector()->RecordRelocSlot(rinfo, object); | |
181 StaticVisitor::MarkObject(heap, object); | |
182 } | |
180 } | 183 } |
181 | 184 |
182 | 185 |
183 template<typename StaticVisitor> | 186 template<typename StaticVisitor> |
184 void StaticMarkingVisitor<StaticVisitor>::VisitGlobalPropertyCell( | 187 void StaticMarkingVisitor<StaticVisitor>::VisitGlobalPropertyCell( |
185 Heap* heap, RelocInfo* rinfo) { | 188 Heap* heap, RelocInfo* rinfo) { |
186 ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL); | 189 ASSERT(rinfo->rmode() == RelocInfo::GLOBAL_PROPERTY_CELL); |
187 JSGlobalPropertyCell* cell = rinfo->target_cell(); | 190 JSGlobalPropertyCell* cell = rinfo->target_cell(); |
188 StaticVisitor::MarkObject(heap, cell); | 191 StaticVisitor::MarkObject(heap, cell); |
189 } | 192 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 void StaticMarkingVisitor<StaticVisitor>::VisitMap( | 258 void StaticMarkingVisitor<StaticVisitor>::VisitMap( |
256 Map* map, HeapObject* object) { | 259 Map* map, HeapObject* object) { |
257 Heap* heap = map->GetHeap(); | 260 Heap* heap = map->GetHeap(); |
258 Map* map_object = Map::cast(object); | 261 Map* map_object = Map::cast(object); |
259 | 262 |
260 // Clears the cache of ICs related to this map. | 263 // Clears the cache of ICs related to this map. |
261 if (FLAG_cleanup_code_caches_at_gc) { | 264 if (FLAG_cleanup_code_caches_at_gc) { |
262 map_object->ClearCodeCache(heap); | 265 map_object->ClearCodeCache(heap); |
263 } | 266 } |
264 | 267 |
265 // When map collection is enabled we have to mark through map's | 268 // When map collection is enabled we have to mark through map's transitions |
266 // transitions and back pointers in a special way to make these links | 269 // and back pointers in a special way to make these links weak. |
267 // weak. Only maps for subclasses of JSReceiver can have transitions. | 270 if (FLAG_collect_maps && map_object->CanTransition()) { |
268 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); | |
269 if (FLAG_collect_maps && | |
270 map_object->instance_type() >= FIRST_JS_RECEIVER_TYPE) { | |
271 MarkMapContents(heap, map_object); | 271 MarkMapContents(heap, map_object); |
272 } else { | 272 } else { |
273 StaticVisitor::VisitPointers(heap, | 273 StaticVisitor::VisitPointers(heap, |
274 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset), | 274 HeapObject::RawField(object, Map::kPointerFieldsBeginOffset), |
275 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); | 275 HeapObject::RawField(object, Map::kPointerFieldsEndOffset)); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 | 279 |
280 template<typename StaticVisitor> | 280 template<typename StaticVisitor> |
281 void StaticMarkingVisitor<StaticVisitor>::VisitCode( | 281 void StaticMarkingVisitor<StaticVisitor>::VisitCode( |
282 Map* map, HeapObject* object) { | 282 Map* map, HeapObject* object) { |
283 Heap* heap = map->GetHeap(); | 283 Heap* heap = map->GetHeap(); |
284 Code* code = Code::cast(object); | 284 Code* code = Code::cast(object); |
285 if (FLAG_cleanup_code_caches_at_gc) { | 285 if (FLAG_cleanup_code_caches_at_gc) { |
286 code->ClearTypeFeedbackCells(heap); | 286 code->ClearTypeFeedbackCells(heap); |
287 } | 287 } |
288 if (FLAG_age_code && !Serializer::enabled()) { | 288 if (FLAG_age_code && !Serializer::enabled()) { |
289 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); | 289 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); |
290 } | 290 } |
291 code->CodeIterateBody<StaticVisitor>(heap); | 291 code->CodeIterateBody<StaticVisitor, Code::SKIP_EMBEDDED_MAPS>(heap); |
292 } | 292 } |
293 | 293 |
294 | 294 |
295 template<typename StaticVisitor> | 295 template<typename StaticVisitor> |
296 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( | 296 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( |
297 Map* map, HeapObject* object) { | 297 Map* map, HeapObject* object) { |
298 Heap* heap = map->GetHeap(); | 298 Heap* heap = map->GetHeap(); |
299 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); | 299 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); |
300 if (shared->ic_age() != heap->global_ic_age()) { | 300 if (shared->ic_age() != heap->global_ic_age()) { |
301 shared->ResetForNewContext(heap->global_ic_age()); | 301 shared->ResetForNewContext(heap->global_ic_age()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 // array slot, since it will be implicitly recorded when the pointer | 388 // array slot, since it will be implicitly recorded when the pointer |
389 // fields of this map are visited. | 389 // fields of this map are visited. |
390 TransitionArray* transitions = map->unchecked_transition_array(); | 390 TransitionArray* transitions = map->unchecked_transition_array(); |
391 if (transitions->IsTransitionArray()) { | 391 if (transitions->IsTransitionArray()) { |
392 MarkTransitionArray(heap, transitions); | 392 MarkTransitionArray(heap, transitions); |
393 } else { | 393 } else { |
394 // Already marked by marking map->GetBackPointer() above. | 394 // Already marked by marking map->GetBackPointer() above. |
395 ASSERT(transitions->IsMap() || transitions->IsUndefined()); | 395 ASSERT(transitions->IsMap() || transitions->IsUndefined()); |
396 } | 396 } |
397 | 397 |
398 // Mark prototype dependent codes array but do not push it onto marking | |
399 // stack, this will make references from it weak. We will clean dead | |
400 // codes when we iterate over maps in ClearNonLiveTransitions. | |
401 Object** slot = HeapObject::RawField(map, Map::kDependentCodesOffset); | |
402 HeapObject* obj = HeapObject::cast(*slot); | |
403 heap->mark_compact_collector()->RecordSlot(slot, slot, obj); | |
404 StaticVisitor::MarkObjectWithoutPush(heap, obj); | |
405 | |
398 // Mark the pointer fields of the Map. Since the transitions array has | 406 // Mark the pointer fields of the Map. Since the transitions array has |
399 // been marked already, it is fine that one of these fields contains a | 407 // been marked already, it is fine that one of these fields contains a |
400 // pointer to it. | 408 // pointer to it. |
401 StaticVisitor::VisitPointers(heap, | 409 StaticVisitor::VisitPointers(heap, |
402 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), | 410 HeapObject::RawField(map, Map::kPointerFieldsBeginOffset), |
403 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); | 411 HeapObject::RawField(map, Map::kPointerFieldsEndOffset)); |
404 } | 412 } |
405 | 413 |
406 | 414 |
407 template<typename StaticVisitor> | 415 template<typename StaticVisitor> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
631 | 639 |
632 void Code::CodeIterateBody(ObjectVisitor* v) { | 640 void Code::CodeIterateBody(ObjectVisitor* v) { |
633 int mode_mask = RelocInfo::kCodeTargetMask | | 641 int mode_mask = RelocInfo::kCodeTargetMask | |
634 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 642 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
635 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 643 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
636 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 644 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
637 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | | 645 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
638 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 646 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
639 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 647 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
640 | 648 |
641 // There are two places where we iterate code bodies: here and the | 649 // There are two places where we iterate code bodies: here and the non- |
Michael Starzinger
2013/01/21 14:36:44
s/non-templated/templated/
ulan
2013/01/21 15:56:02
Done.
| |
642 // templated CodeIterateBody (below). They should be kept in sync. | 650 // templated CodeIterateBody (above). They should be kept in sync. |
Michael Starzinger
2013/01/21 14:36:44
s/above/below/
ulan
2013/01/21 15:56:02
Done.
| |
643 IteratePointer(v, kRelocationInfoOffset); | 651 IteratePointer(v, kRelocationInfoOffset); |
644 IteratePointer(v, kHandlerTableOffset); | 652 IteratePointer(v, kHandlerTableOffset); |
645 IteratePointer(v, kDeoptimizationDataOffset); | 653 IteratePointer(v, kDeoptimizationDataOffset); |
646 IteratePointer(v, kTypeFeedbackInfoOffset); | 654 IteratePointer(v, kTypeFeedbackInfoOffset); |
647 | 655 |
648 RelocIterator it(this, mode_mask); | 656 RelocIterator it(this, mode_mask); |
649 for (; !it.done(); it.next()) { | 657 for (; !it.done(); it.next()) { |
650 it.rinfo()->Visit(v); | 658 it.rinfo()->Visit(v); |
651 } | 659 } |
652 } | 660 } |
653 | 661 |
654 | 662 |
655 template<typename StaticVisitor> | 663 template<typename StaticVisitor, Code::EmbeddedMapVisitMode map_visit_mode> |
Michael Starzinger
2013/01/21 14:36:44
We should no longer need the template parameter.
ulan
2013/01/21 15:56:02
Done.
| |
656 void Code::CodeIterateBody(Heap* heap) { | 664 void Code::CodeIterateBody(Heap* heap) { |
657 int mode_mask = RelocInfo::kCodeTargetMask | | 665 int mode_mask = RelocInfo::kCodeTargetMask | |
658 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 666 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
659 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | | 667 RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) | |
660 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | 668 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
661 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | | 669 RelocInfo::ModeMask(RelocInfo::JS_RETURN) | |
662 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 670 RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | |
663 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); | 671 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY); |
664 | 672 |
665 // There are two places where we iterate code bodies: here and the | 673 // There are two places where we iterate code bodies: here and the non- |
666 // non-templated CodeIterateBody (above). They should be kept in sync. | 674 // templated CodeIterateBody (above). They should be kept in sync. |
667 StaticVisitor::VisitPointer( | 675 StaticVisitor::VisitPointer( |
668 heap, | 676 heap, |
669 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); | 677 reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset)); |
670 StaticVisitor::VisitPointer( | 678 StaticVisitor::VisitPointer( |
671 heap, | 679 heap, |
672 reinterpret_cast<Object**>(this->address() + kHandlerTableOffset)); | 680 reinterpret_cast<Object**>(this->address() + kHandlerTableOffset)); |
673 StaticVisitor::VisitPointer( | 681 StaticVisitor::VisitPointer( |
674 heap, | 682 heap, |
675 reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset)); | 683 reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset)); |
676 StaticVisitor::VisitPointer( | 684 StaticVisitor::VisitPointer( |
677 heap, | 685 heap, |
678 reinterpret_cast<Object**>(this->address() + kTypeFeedbackInfoOffset)); | 686 reinterpret_cast<Object**>(this->address() + kTypeFeedbackInfoOffset)); |
679 | 687 |
680 RelocIterator it(this, mode_mask); | 688 RelocIterator it(this, mode_mask); |
681 for (; !it.done(); it.next()) { | 689 for (; !it.done(); it.next()) { |
682 it.rinfo()->template Visit<StaticVisitor>(heap); | 690 it.rinfo()->template Visit<StaticVisitor>(heap); |
683 } | 691 } |
684 } | 692 } |
685 | 693 |
686 | 694 |
687 } } // namespace v8::internal | 695 } } // namespace v8::internal |
688 | 696 |
689 #endif // V8_OBJECTS_VISITING_INL_H_ | 697 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |