| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  | namespace factor { | 
					
						
							| 
									
										
										
										
											2009-09-25 21:32:00 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-08 13:32:14 -04:00
										 |  |  | #if defined(WINDOWS) && defined(FACTOR_64)
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  | const cell seh_area_size = 1024; | 
					
						
							| 
									
										
										
										
											2010-04-08 13:32:14 -04:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  | const cell seh_area_size = 0; | 
					
						
							| 
									
										
										
										
											2010-04-08 13:32:14 -04:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-20 16:15:05 -04:00
										 |  |  | struct code_heap { | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // The actual memory area
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   segment* seg; | 
					
						
							| 
									
										
										
										
											2009-10-20 16:15:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Memory area reserved for safepoint guard page
 | 
					
						
							| 
									
										
										
										
											2015-08-24 02:47:36 -04:00
										 |  |  |   cell safepoint_page; | 
					
						
							| 
									
										
										
										
											2011-10-17 16:24:06 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Memory area reserved for SEH. Only used on Windows
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   char* seh_area; | 
					
						
							| 
									
										
										
										
											2010-04-08 13:32:14 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Memory allocator
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   free_list_allocator<code_block>* allocator; | 
					
						
							| 
									
										
										
										
											2009-10-20 16:15:05 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-28 14:38:52 -04:00
										 |  |  |   // For fast lookup of blocks from addresses.
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   std::set<cell> all_blocks; | 
					
						
							| 
									
										
										
										
											2011-11-17 17:29:01 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-28 14:38:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Code blocks are initialized in two steps in
 | 
					
						
							|  |  |  |   // primitive_modify_code_heap() because they might reference each
 | 
					
						
							|  |  |  |   // other. First they are all allocated and placed in this map with
 | 
					
						
							|  |  |  |   // their literal tables which are GC roots until the block is
 | 
					
						
							|  |  |  |   // initialized. Then they are all initialized by
 | 
					
						
							|  |  |  |   // initialize_code_block() which resolves relocations and updates
 | 
					
						
							|  |  |  |   // addresses. Uninitialized blocks instructions must not be visited
 | 
					
						
							|  |  |  |   // by GC.
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   std::map<code_block*, cell> uninitialized_blocks; | 
					
						
							| 
									
										
										
										
											2009-10-06 06:52:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Code blocks which may reference objects in the nursery
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   std::set<code_block*> points_to_nursery; | 
					
						
							| 
									
										
										
										
											2009-10-09 00:10:32 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-21 10:26:04 -04:00
										 |  |  |   // Code blocks which may reference objects in aging space or the nursery
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   std::set<code_block*> points_to_aging; | 
					
						
							| 
									
										
										
										
											2009-10-06 05:36:34 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   explicit code_heap(cell size); | 
					
						
							|  |  |  |   ~code_heap(); | 
					
						
							|  |  |  |   void write_barrier(code_block* compiled); | 
					
						
							|  |  |  |   void clear_remembered_set(); | 
					
						
							|  |  |  |   bool uninitialized_p(code_block* compiled); | 
					
						
							|  |  |  |   void free(code_block* compiled); | 
					
						
							|  |  |  |   void flush_icache(); | 
					
						
							| 
									
										
										
										
											2015-08-24 02:58:03 -04:00
										 |  |  |   void set_safepoint_guard(bool locked); | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   void verify_all_blocks_set(); | 
					
						
							|  |  |  |   void initialize_all_blocks_set(); | 
					
						
							| 
									
										
										
										
											2016-10-13 09:43:15 -04:00
										 |  |  |   cell high_water_mark() { return allocator->size / 20; } | 
					
						
							| 
									
										
										
										
											2011-10-19 18:39:44 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   void sweep(); | 
					
						
							| 
									
										
										
										
											2011-12-13 15:28:09 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   code_block* code_block_for_address(cell address); | 
					
						
							| 
									
										
										
										
											2015-08-12 14:32:04 -04:00
										 |  |  |   cell frame_predecessor(cell frame_top); | 
					
						
							| 
									
										
										
										
											2011-10-26 18:45:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   bool safepoint_p(cell addr) { | 
					
						
							|  |  |  |     cell page_mask = ~(getpagesize() - 1); | 
					
						
							| 
									
										
										
										
											2015-08-24 02:47:36 -04:00
										 |  |  |     return (addr & page_mask) == safepoint_page; | 
					
						
							| 
									
										
										
										
											2013-05-11 21:51:54 -04:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2009-10-03 09:47:05 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | } |