removed global functions from code_gc
							parent
							
								
									39dc71e612
								
							
						
					
					
						commit
						00087e6814
					
				| 
						 | 
					@ -8,10 +8,6 @@ void factorvm::clear_free_list(heap *heap)
 | 
				
			||||||
	memset(&heap->free,0,sizeof(heap_free_list));
 | 
						memset(&heap->free,0,sizeof(heap_free_list));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void clear_free_list(heap *heap)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->clear_free_list(heap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* This malloc-style heap code is reasonably generic. Maybe in the future, it
 | 
					/* This malloc-style heap code is reasonably generic. Maybe in the future, it
 | 
				
			||||||
will be used for the data heap too, if we ever get incremental
 | 
					will be used for the data heap too, if we ever get incremental
 | 
				
			||||||
| 
						 | 
					@ -25,10 +21,6 @@ void factorvm::new_heap(heap *heap, cell size)
 | 
				
			||||||
	clear_free_list(heap);
 | 
						clear_free_list(heap);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void new_heap(heap *heap, cell size)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->new_heap(heap,size);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void factorvm::add_to_free_list(heap *heap, free_heap_block *block)
 | 
					void factorvm::add_to_free_list(heap *heap, free_heap_block *block)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -45,10 +37,6 @@ void factorvm::add_to_free_list(heap *heap, free_heap_block *block)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void add_to_free_list(heap *heap, free_heap_block *block)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->add_to_free_list(heap,block);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called after reading the code heap from the image file, and after code GC.
 | 
					/* Called after reading the code heap from the image file, and after code GC.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -106,10 +94,6 @@ void factorvm::build_free_list(heap *heap, cell size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void build_free_list(heap *heap, cell size)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->build_free_list(heap,size);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void factorvm::assert_free_block(free_heap_block *block)
 | 
					void factorvm::assert_free_block(free_heap_block *block)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -117,10 +101,6 @@ void factorvm::assert_free_block(free_heap_block *block)
 | 
				
			||||||
		critical_error("Invalid block in free list",(cell)block);
 | 
							critical_error("Invalid block in free list",(cell)block);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void assert_free_block(free_heap_block *block)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->assert_free_block(block);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
free_heap_block *factorvm::find_free_block(heap *heap, cell size)
 | 
					free_heap_block *factorvm::find_free_block(heap *heap, cell size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -162,10 +142,6 @@ free_heap_block *factorvm::find_free_block(heap *heap, cell size)
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
free_heap_block *find_free_block(heap *heap, cell size)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->find_free_block(heap,size);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
free_heap_block *factorvm::split_free_block(heap *heap, free_heap_block *block, cell size)
 | 
					free_heap_block *factorvm::split_free_block(heap *heap, free_heap_block *block, cell size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -183,10 +159,6 @@ free_heap_block *factorvm::split_free_block(heap *heap, free_heap_block *block,
 | 
				
			||||||
	return block;
 | 
						return block;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
free_heap_block *split_free_block(heap *heap, free_heap_block *block, cell size)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->split_free_block(heap,block,size);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Allocate a block of memory from the mark and sweep GC heap */
 | 
					/* Allocate a block of memory from the mark and sweep GC heap */
 | 
				
			||||||
heap_block *factorvm::heap_allot(heap *heap, cell size)
 | 
					heap_block *factorvm::heap_allot(heap *heap, cell size)
 | 
				
			||||||
| 
						 | 
					@ -205,10 +177,6 @@ heap_block *factorvm::heap_allot(heap *heap, cell size)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
heap_block *heap_allot(heap *heap, cell size)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->heap_allot(heap,size);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Deallocates a block manually */
 | 
					/* Deallocates a block manually */
 | 
				
			||||||
void factorvm::heap_free(heap *heap, heap_block *block)
 | 
					void factorvm::heap_free(heap *heap, heap_block *block)
 | 
				
			||||||
| 
						 | 
					@ -217,10 +185,6 @@ void factorvm::heap_free(heap *heap, heap_block *block)
 | 
				
			||||||
	add_to_free_list(heap,(free_heap_block *)block);
 | 
						add_to_free_list(heap,(free_heap_block *)block);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void heap_free(heap *heap, heap_block *block)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->heap_free(heap,block);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void factorvm::mark_block(heap_block *block)
 | 
					void factorvm::mark_block(heap_block *block)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -238,10 +202,6 @@ void factorvm::mark_block(heap_block *block)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void mark_block(heap_block *block)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->mark_block(block);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* If in the middle of code GC, we have to grow the heap, data GC restarts from
 | 
					/* If in the middle of code GC, we have to grow the heap, data GC restarts from
 | 
				
			||||||
scratch, so we have to unmark any marked blocks. */
 | 
					scratch, so we have to unmark any marked blocks. */
 | 
				
			||||||
| 
						 | 
					@ -258,10 +218,6 @@ void factorvm::unmark_marked(heap *heap)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void unmark_marked(heap *heap)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->unmark_marked(heap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* After code GC, all referenced code blocks have status set to B_MARKED, so any
 | 
					/* After code GC, all referenced code blocks have status set to B_MARKED, so any
 | 
				
			||||||
which are allocated and not marked can be reclaimed. */
 | 
					which are allocated and not marked can be reclaimed. */
 | 
				
			||||||
| 
						 | 
					@ -312,10 +268,6 @@ void factorvm::free_unmarked(heap *heap, heap_iterator iter)
 | 
				
			||||||
		add_to_free_list(heap,(free_heap_block *)prev);
 | 
							add_to_free_list(heap,(free_heap_block *)prev);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void free_unmarked(heap *heap, heap_iterator iter)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->free_unmarked(heap,iter);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Compute total sum of sizes of free blocks, and size of largest free block */
 | 
					/* Compute total sum of sizes of free blocks, and size of largest free block */
 | 
				
			||||||
void factorvm::heap_usage(heap *heap, cell *used, cell *total_free, cell *max_free)
 | 
					void factorvm::heap_usage(heap *heap, cell *used, cell *total_free, cell *max_free)
 | 
				
			||||||
| 
						 | 
					@ -346,10 +298,6 @@ void factorvm::heap_usage(heap *heap, cell *used, cell *total_free, cell *max_fr
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void heap_usage(heap *heap, cell *used, cell *total_free, cell *max_free)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->heap_usage(heap,used,total_free,max_free);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* The size of the heap, not including the last block if it's free */
 | 
					/* The size of the heap, not including the last block if it's free */
 | 
				
			||||||
cell factorvm::heap_size(heap *heap)
 | 
					cell factorvm::heap_size(heap *heap)
 | 
				
			||||||
| 
						 | 
					@ -367,10 +315,6 @@ cell factorvm::heap_size(heap *heap)
 | 
				
			||||||
		return heap->seg->size;
 | 
							return heap->seg->size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cell heap_size(heap *heap)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->heap_size(heap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Compute where each block is going to go, after compaction */
 | 
					/* Compute where each block is going to go, after compaction */
 | 
				
			||||||
cell factorvm::compute_heap_forwarding(heap *heap, unordered_map<heap_block *,char *> &forwarding)
 | 
					cell factorvm::compute_heap_forwarding(heap *heap, unordered_map<heap_block *,char *> &forwarding)
 | 
				
			||||||
| 
						 | 
					@ -394,10 +338,6 @@ cell factorvm::compute_heap_forwarding(heap *heap, unordered_map<heap_block *,ch
 | 
				
			||||||
	return (cell)address - heap->seg->start;
 | 
						return (cell)address - heap->seg->start;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cell compute_heap_forwarding(heap *heap, unordered_map<heap_block *,char *> &forwarding)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->compute_heap_forwarding(heap,forwarding);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void factorvm::compact_heap(heap *heap, unordered_map<heap_block *,char *> &forwarding)
 | 
					void factorvm::compact_heap(heap *heap, unordered_map<heap_block *,char *> &forwarding)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -413,9 +353,4 @@ void factorvm::compact_heap(heap *heap, unordered_map<heap_block *,char *> &forw
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void compact_heap(heap *heap, unordered_map<heap_block *,char *> &forwarding)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return vm->compact_heap(heap,forwarding);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,18 +16,6 @@ struct heap {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef void (*heap_iterator)(heap_block *compiled,factorvm *vm);
 | 
					typedef void (*heap_iterator)(heap_block *compiled,factorvm *vm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void new_heap(heap *h, cell size);
 | 
					 | 
				
			||||||
void build_free_list(heap *h, cell size);
 | 
					 | 
				
			||||||
heap_block *heap_allot(heap *h, cell size);
 | 
					 | 
				
			||||||
void heap_free(heap *h, heap_block *block);
 | 
					 | 
				
			||||||
void mark_block(heap_block *block);
 | 
					 | 
				
			||||||
void unmark_marked(heap *heap);
 | 
					 | 
				
			||||||
void free_unmarked(heap *heap, heap_iterator iter);
 | 
					 | 
				
			||||||
void heap_usage(heap *h, cell *used, cell *total_free, cell *max_free);
 | 
					 | 
				
			||||||
cell heap_size(heap *h);
 | 
					 | 
				
			||||||
cell compute_heap_forwarding(heap *h, unordered_map<heap_block *,char *> &forwarding);
 | 
					 | 
				
			||||||
void compact_heap(heap *h, unordered_map<heap_block *,char *> &forwarding);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
inline static heap_block *next_block(heap *h, heap_block *block)
 | 
					inline static heap_block *next_block(heap *h, heap_block *block)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cell next = ((cell)block + block->size);
 | 
						cell next = ((cell)block + block->size);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue