| 
									
										
										
										
											2009-10-31 03:30:48 -04:00
										 |  |  | namespace factor | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * It is up to the caller to fill in the object's fields in a meaningful | 
					
						
							|  |  |  |  * fashion! | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2009-11-10 22:06:36 -05:00
										 |  |  | inline object *factor_vm::allot_object(cell type, cell size) | 
					
						
							| 
									
										
										
										
											2009-10-31 03:30:48 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-12-02 01:48:41 -05:00
										 |  |  | #ifdef FACTOR_DEBUG
 | 
					
						
							| 
									
										
										
										
											2011-11-17 23:42:30 -05:00
										 |  |  | 	FACTOR_ASSERT(!current_gc); | 
					
						
							| 
									
										
										
										
											2009-12-02 01:48:41 -05:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 03:30:48 -04:00
										 |  |  | 	/* If the object is smaller than the nursery, allocate it in the nursery,
 | 
					
						
							|  |  |  | 	after a GC if needed */ | 
					
						
							|  |  |  | 	if(nursery.size > size) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		/* If there is insufficient room, collect the nursery */ | 
					
						
							|  |  |  | 		if(nursery.here + size > nursery.end) | 
					
						
							|  |  |  | 			primitive_minor_gc(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		object *obj = nursery.allot(size); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-10 22:06:36 -05:00
										 |  |  | 		obj->initialize(type); | 
					
						
							| 
									
										
										
										
											2009-10-31 03:30:48 -04:00
										 |  |  | 		return obj; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* If the object is bigger than the nursery, allocate it in
 | 
					
						
							|  |  |  | 	tenured space */ | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2009-11-10 22:06:36 -05:00
										 |  |  | 		return allot_large_object(type,size); | 
					
						
							| 
									
										
										
										
											2009-10-31 03:30:48 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |