| 
									
										
										
										
											2009-10-07 16:48:09 -04:00
										 |  |  | #include "master.hpp"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace factor | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-19 01:16:32 -04:00
										 |  |  | aging_collector::aging_collector(factor_vm *parent_) : | 
					
						
							| 
									
										
										
										
											2009-10-15 06:51:11 -04:00
										 |  |  | 	copying_collector<aging_space,aging_policy>( | 
					
						
							| 
									
										
										
										
											2009-10-19 01:16:32 -04:00
										 |  |  | 		parent_, | 
					
						
							|  |  |  | 		parent_->data->aging, | 
					
						
							|  |  |  | 		aging_policy(parent_)) {} | 
					
						
							| 
									
										
										
										
											2009-10-07 16:48:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-08 03:10:28 -04:00
										 |  |  | void factor_vm::collect_aging() | 
					
						
							| 
									
										
										
										
											2009-10-07 16:48:09 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-16 03:55:02 -04:00
										 |  |  | 	/* Promote objects referenced from tenured space to tenured space, copy
 | 
					
						
							|  |  |  | 	everything else to the aging semi-space, and reset the nursery pointer. */ | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-10-15 06:51:11 -04:00
										 |  |  | 		/* Change the op so that if we fail here, we proceed to a full
 | 
					
						
							|  |  |  | 		tenured collection. We are collecting to tenured space, and | 
					
						
							|  |  |  | 		cards were unmarked, so we can't proceed with a to_tenured | 
					
						
							|  |  |  | 		collection. */ | 
					
						
							|  |  |  | 		current_gc->op = collect_to_tenured_op; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		to_tenured_collector collector(this); | 
					
						
							| 
									
										
										
										
											2009-10-27 00:57:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		current_gc->event->started_code_scan(); | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		collector.trace_cards(data->tenured, | 
					
						
							|  |  |  | 			card_points_to_aging, | 
					
						
							| 
									
										
										
										
											2009-10-30 04:15:50 -04:00
										 |  |  | 			full_unmarker()); | 
					
						
							| 
									
										
										
										
											2009-10-27 00:57:26 -04:00
										 |  |  | 		current_gc->event->ended_card_scan(collector.cards_scanned,collector.decks_scanned); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-20 23:20:49 -04:00
										 |  |  | 		collector.tenure_reachable_objects(); | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2009-10-15 06:51:11 -04:00
										 |  |  | 		/* If collection fails here, do a to_tenured collection. */ | 
					
						
							|  |  |  | 		current_gc->op = collect_aging_op; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		std::swap(data->aging,data->aging_semispace); | 
					
						
							| 
									
										
										
										
											2009-10-20 14:13:39 -04:00
										 |  |  | 		data->reset_generation(data->aging); | 
					
						
							| 
									
										
										
										
											2009-10-08 03:10:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		aging_collector collector(this); | 
					
						
							| 
									
										
										
										
											2009-10-08 03:10:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		collector.trace_roots(); | 
					
						
							|  |  |  | 		collector.trace_contexts(); | 
					
						
							| 
									
										
										
										
											2009-10-27 00:57:26 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		current_gc->event->started_code_scan(); | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		collector.trace_code_heap_roots(&code->points_to_aging); | 
					
						
							| 
									
										
										
										
											2009-10-27 00:57:26 -04:00
										 |  |  | 		current_gc->event->ended_code_scan(collector.code_blocks_scanned); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		collector.cheneys_algorithm(); | 
					
						
							| 
									
										
										
										
											2009-10-21 20:41:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 00:57:26 -04:00
										 |  |  | 		current_gc->event->started_code_sweep(); | 
					
						
							| 
									
										
										
										
											2009-10-15 23:31:41 -04:00
										 |  |  | 		update_code_heap_for_minor_gc(&code->points_to_aging); | 
					
						
							| 
									
										
										
										
											2009-10-27 00:57:26 -04:00
										 |  |  | 		current_gc->event->ended_code_sweep(); | 
					
						
							| 
									
										
										
										
											2009-10-08 03:10:28 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-21 20:41:54 -04:00
										 |  |  | 		data->reset_generation(&nursery); | 
					
						
							| 
									
										
										
										
											2009-10-14 07:03:52 -04:00
										 |  |  | 		code->points_to_nursery.clear(); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-07 16:48:09 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |