moved write_barrier functions to vm
							parent
							
								
									be3a9f7f66
								
							
						
					
					
						commit
						b1189dc4f1
					
				| 
						 | 
					@ -86,7 +86,7 @@ void mark_object_code_block(object *scan);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void relocate_code_block(code_block *relocating);
 | 
					void relocate_code_block(code_block *relocating);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static bool stack_traces_p()
 | 
					inline bool stack_traces_p()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return userenv[STACK_TRACES_ENV] != F;
 | 
						return userenv[STACK_TRACES_ENV] != F;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								vm/vm.hpp
								
								
								
								
							
							
						
						
									
										15
									
								
								vm/vm.hpp
								
								
								
								
							| 
						 | 
					@ -156,6 +156,19 @@ struct factorvm {
 | 
				
			||||||
	template<typename T> void each_object(T &functor);
 | 
						template<typename T> void each_object(T &functor);
 | 
				
			||||||
	cell find_all_words();
 | 
						cell find_all_words();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						//write barrier
 | 
				
			||||||
 | 
						inline card *addr_to_card(cell a);
 | 
				
			||||||
 | 
						inline cell card_to_addr(card *c);
 | 
				
			||||||
 | 
						inline cell card_offset(card *c);
 | 
				
			||||||
 | 
						inline card_deck *addr_to_deck(cell a);
 | 
				
			||||||
 | 
						inline cell deck_to_addr(card_deck *c);
 | 
				
			||||||
 | 
						inline card *deck_to_card(card_deck *d);
 | 
				
			||||||
 | 
						inline card *addr_to_allot_marker(object *a);
 | 
				
			||||||
 | 
						inline void write_barrier(object *obj);
 | 
				
			||||||
 | 
						inline void allot_barrier(object *address);
 | 
				
			||||||
 | 
						// next method here:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//data_gc
 | 
						//data_gc
 | 
				
			||||||
	void init_data_gc();
 | 
						void init_data_gc();
 | 
				
			||||||
	object *copy_untagged_object_impl(object *pointer, cell size);
 | 
						object *copy_untagged_object_impl(object *pointer, cell size);
 | 
				
			||||||
| 
						 | 
					@ -192,14 +205,12 @@ struct factorvm {
 | 
				
			||||||
	template <typename TYPE> TYPE *allot(cell size);
 | 
						template <typename TYPE> TYPE *allot(cell size);
 | 
				
			||||||
	inline void check_data_pointer(object *pointer);
 | 
						inline void check_data_pointer(object *pointer);
 | 
				
			||||||
	inline void check_tagged_pointer(cell tagged);
 | 
						inline void check_tagged_pointer(cell tagged);
 | 
				
			||||||
	// next method here:
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// local roots
 | 
						// local roots
 | 
				
			||||||
	std::vector<cell> gc_locals;
 | 
						std::vector<cell> gc_locals;
 | 
				
			||||||
	std::vector<cell> gc_bignums;
 | 
						std::vector<cell> gc_bignums;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// generic arrays
 | 
						// generic arrays
 | 
				
			||||||
 | 
					 | 
				
			||||||
	template <typename TYPE> TYPE *reallot_array(TYPE *array_, cell capacity);
 | 
						template <typename TYPE> TYPE *reallot_array(TYPE *array_, cell capacity);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//debug
 | 
						//debug
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,65 +22,110 @@ static const cell card_bits = 8;
 | 
				
			||||||
static const cell card_size = (1<<card_bits);
 | 
					static const cell card_size = (1<<card_bits);
 | 
				
			||||||
static const cell addr_card_mask = (card_size-1);
 | 
					static const cell addr_card_mask = (card_size-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static card *addr_to_card(cell a)
 | 
					inline card *factorvm::addr_to_card(cell a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (card*)(((cell)(a) >> card_bits) + cards_offset);
 | 
						return (card*)(((cell)(a) >> card_bits) + cards_offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static cell card_to_addr(card *c)
 | 
					inline card *addr_to_card(cell a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->addr_to_card(a);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline cell factorvm::card_to_addr(card *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return ((cell)c - cards_offset) << card_bits;
 | 
						return ((cell)c - cards_offset) << card_bits;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static cell card_offset(card *c)
 | 
					inline cell card_to_addr(card *c)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->card_to_addr(c);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline cell factorvm::card_offset(card *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return *(c - (cell)data->cards + (cell)data->allot_markers);
 | 
						return *(c - (cell)data->cards + (cell)data->allot_markers);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline cell card_offset(card *c)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->card_offset(c);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef u8 card_deck;
 | 
					typedef u8 card_deck;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const cell deck_bits = (card_bits + 10);
 | 
					static const cell deck_bits = (card_bits + 10);
 | 
				
			||||||
static const cell deck_size = (1<<deck_bits);
 | 
					static const cell deck_size = (1<<deck_bits);
 | 
				
			||||||
static const cell addr_deck_mask = (deck_size-1);
 | 
					static const cell addr_deck_mask = (deck_size-1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static card_deck *addr_to_deck(cell a)
 | 
					inline card_deck *factorvm::addr_to_deck(cell a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (card_deck *)(((cell)a >> deck_bits) + decks_offset);
 | 
						return (card_deck *)(((cell)a >> deck_bits) + decks_offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static cell deck_to_addr(card_deck *c)
 | 
					inline card_deck *addr_to_deck(cell a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->addr_to_deck(a);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline cell factorvm::deck_to_addr(card_deck *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return ((cell)c - decks_offset) << deck_bits;
 | 
						return ((cell)c - decks_offset) << deck_bits;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static card *deck_to_card(card_deck *d)
 | 
					inline cell deck_to_addr(card_deck *c)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->deck_to_addr(c);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline card *factorvm::deck_to_card(card_deck *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (card *)((((cell)d - decks_offset) << (deck_bits - card_bits)) + cards_offset);
 | 
						return (card *)((((cell)d - decks_offset) << (deck_bits - card_bits)) + cards_offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline card *deck_to_card(card_deck *d)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->deck_to_card(d);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const cell invalid_allot_marker = 0xff;
 | 
					static const cell invalid_allot_marker = 0xff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern cell allot_markers_offset;
 | 
					extern cell allot_markers_offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inline static card *addr_to_allot_marker(object *a)
 | 
					inline card *factorvm::addr_to_allot_marker(object *a)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (card *)(((cell)a >> card_bits) + allot_markers_offset);
 | 
						return (card *)(((cell)a >> card_bits) + allot_markers_offset);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline card *addr_to_allot_marker(object *a)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->addr_to_allot_marker(a);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* the write barrier must be called any time we are potentially storing a
 | 
					/* the write barrier must be called any time we are potentially storing a
 | 
				
			||||||
pointer from an older generation to a younger one */
 | 
					pointer from an older generation to a younger one */
 | 
				
			||||||
inline static void write_barrier(object *obj)
 | 
					inline void factorvm::write_barrier(object *obj)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	*addr_to_card((cell)obj) = card_mark_mask;
 | 
						*addr_to_card((cell)obj) = card_mark_mask;
 | 
				
			||||||
	*addr_to_deck((cell)obj) = card_mark_mask;
 | 
						*addr_to_deck((cell)obj) = card_mark_mask;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void write_barrier(object *obj)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->write_barrier(obj);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* we need to remember the first object allocated in the card */
 | 
					/* we need to remember the first object allocated in the card */
 | 
				
			||||||
inline static void allot_barrier(object *address)
 | 
					inline void factorvm::allot_barrier(object *address)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	card *ptr = addr_to_allot_marker(address);
 | 
						card *ptr = addr_to_allot_marker(address);
 | 
				
			||||||
	if(*ptr == invalid_allot_marker)
 | 
						if(*ptr == invalid_allot_marker)
 | 
				
			||||||
		*ptr = ((cell)address & addr_card_mask);
 | 
							*ptr = ((cell)address & addr_card_mask);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void allot_barrier(object *address)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return vm->allot_barrier(address);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue