misc cleanup
							parent
							
								
									d25fe552ab
								
							
						
					
					
						commit
						46bab62689
					
				| 
						 | 
				
			
			@ -529,7 +529,7 @@ code_block *factorvm::allot_code_block(cell size)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
/* Might GC */
 | 
			
		||||
code_block *factorvm::add_code_block(cell type,cell code_,cell labels_,cell relocation_,cell literals_)
 | 
			
		||||
code_block *factorvm::add_code_block(cell type, cell code_, cell labels_, cell relocation_, cell literals_)
 | 
			
		||||
{
 | 
			
		||||
	gc_root<byte_array> code(code_,this);
 | 
			
		||||
	gc_root<object> labels(labels_,this);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ enum relocation_type {
 | 
			
		|||
	RT_UNTAGGED,
 | 
			
		||||
	/* address of megamorphic_cache_hits var */
 | 
			
		||||
	RT_MEGAMORPHIC_CACHE_HITS,
 | 
			
		||||
	/* address of vm object*/
 | 
			
		||||
	/* address of vm object */
 | 
			
		||||
	RT_VM,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,10 +39,10 @@ multiply_overflow:
 | 
			
		|||
	pop ARG2
 | 
			
		||||
	jmp MANGLE(overflow_fixnum_multiply)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DEF(F_FASTCALL void,c_to_factor,(CELL quot, void *vm)):
 | 
			
		||||
	PUSH_NONVOLATILE
 | 
			
		||||
	mov ARG0,NV_TEMP_REG
 | 
			
		||||
	
 | 
			
		||||
	/* Create register shadow area for Win64 */
 | 
			
		||||
	sub $32,STACK_REG
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,6 @@ void factorvm::init_data_gc()
 | 
			
		|||
	collecting_aging_again = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Given a pointer to oldspace, copy it to newspace */
 | 
			
		||||
object *factorvm::copy_untagged_object_impl(object *pointer, cell size)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +25,6 @@ object *factorvm::copy_untagged_object_impl(object *pointer, cell size)
 | 
			
		|||
	return newpointer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
object *factorvm::copy_object_impl(object *untagged)
 | 
			
		||||
{
 | 
			
		||||
	object *newpointer = copy_untagged_object_impl(untagged,untagged_object_size(untagged));
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +32,6 @@ object *factorvm::copy_object_impl(object *untagged)
 | 
			
		|||
	return newpointer;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool factorvm::should_copy_p(object *untagged)
 | 
			
		||||
{
 | 
			
		||||
	if(in_zone(newspace,untagged))
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +49,6 @@ bool factorvm::should_copy_p(object *untagged)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Follow a chain of forwarding pointers */
 | 
			
		||||
object *factorvm::resolve_forwarding(object *untagged)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -72,7 +68,6 @@ object *factorvm::resolve_forwarding(object *untagged)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <typename TYPE> TYPE *factorvm::copy_untagged_object(TYPE *untagged)
 | 
			
		||||
{
 | 
			
		||||
	check_data_pointer(untagged);
 | 
			
		||||
| 
						 | 
				
			
			@ -88,13 +83,11 @@ template <typename TYPE> TYPE *factorvm::copy_untagged_object(TYPE *untagged)
 | 
			
		|||
	return untagged;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cell factorvm::copy_object(cell pointer)
 | 
			
		||||
{
 | 
			
		||||
	return RETAG(copy_untagged_object(untag<object>(pointer)),TAG(pointer));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::copy_handle(cell *handle)
 | 
			
		||||
{
 | 
			
		||||
	cell pointer = *handle;
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +101,6 @@ void factorvm::copy_handle(cell *handle)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Scan all the objects in the card */
 | 
			
		||||
void factorvm::copy_card(card *ptr, cell gen, cell here)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +115,6 @@ void factorvm::copy_card(card *ptr, cell gen, cell here)
 | 
			
		|||
	cards_scanned++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::copy_card_deck(card_deck *deck, cell gen, card mask, card unmask)
 | 
			
		||||
{
 | 
			
		||||
	card *first_card = deck_to_card(deck);
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +146,6 @@ void factorvm::copy_card_deck(card_deck *deck, cell gen, card mask, card unmask)
 | 
			
		|||
	decks_scanned++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Copy all newspace objects referenced from marked cards to the destination */
 | 
			
		||||
void factorvm::copy_gen_cards(cell gen)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -222,7 +212,6 @@ void factorvm::copy_gen_cards(cell gen)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Scan cards in all generations older than the one being collected, copying
 | 
			
		||||
old->new references */
 | 
			
		||||
void factorvm::copy_cards()
 | 
			
		||||
| 
						 | 
				
			
			@ -236,7 +225,6 @@ void factorvm::copy_cards()
 | 
			
		|||
	card_scan_time += (current_micros() - start);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Copy all tagged pointers in a range of memory */
 | 
			
		||||
void factorvm::copy_stack_elements(segment *region, cell top)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -246,7 +234,6 @@ void factorvm::copy_stack_elements(segment *region, cell top)
 | 
			
		|||
		copy_handle((cell*)ptr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::copy_registered_locals()
 | 
			
		||||
{
 | 
			
		||||
	std::vector<cell>::const_iterator iter = gc_locals.begin();
 | 
			
		||||
| 
						 | 
				
			
			@ -256,7 +243,6 @@ void factorvm::copy_registered_locals()
 | 
			
		|||
		copy_handle((cell *)(*iter));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::copy_registered_bignums()
 | 
			
		||||
{
 | 
			
		||||
	std::vector<cell>::const_iterator iter = gc_bignums.begin();
 | 
			
		||||
| 
						 | 
				
			
			@ -279,7 +265,6 @@ void factorvm::copy_registered_bignums()
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Copy roots over at the start of GC, namely various constants, stacks,
 | 
			
		||||
the user environment and extra roots registered by local_roots.hpp */
 | 
			
		||||
void factorvm::copy_roots()
 | 
			
		||||
| 
						 | 
				
			
			@ -316,7 +301,6 @@ void factorvm::copy_roots()
 | 
			
		|||
		copy_handle(&userenv[i]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cell factorvm::copy_next_from_nursery(cell scan)
 | 
			
		||||
{
 | 
			
		||||
	cell *obj = (cell *)scan;
 | 
			
		||||
| 
						 | 
				
			
			@ -345,7 +329,6 @@ cell factorvm::copy_next_from_nursery(cell scan)
 | 
			
		|||
	return scan + untagged_object_size((object *)scan);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cell factorvm::copy_next_from_aging(cell scan)
 | 
			
		||||
{
 | 
			
		||||
	cell *obj = (cell *)scan;
 | 
			
		||||
| 
						 | 
				
			
			@ -378,7 +361,6 @@ cell factorvm::copy_next_from_aging(cell scan)
 | 
			
		|||
	return scan + untagged_object_size((object *)scan);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
cell factorvm::copy_next_from_tenured(cell scan)
 | 
			
		||||
{
 | 
			
		||||
	cell *obj = (cell *)scan;
 | 
			
		||||
| 
						 | 
				
			
			@ -409,7 +391,6 @@ cell factorvm::copy_next_from_tenured(cell scan)
 | 
			
		|||
	return scan + untagged_object_size((object *)scan);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::copy_reachable_objects(cell scan, cell *end)
 | 
			
		||||
{
 | 
			
		||||
	if(collecting_gen == data->nursery())
 | 
			
		||||
| 
						 | 
				
			
			@ -429,7 +410,6 @@ void factorvm::copy_reachable_objects(cell scan, cell *end)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Prepare to start copying reachable objects into an unused zone */
 | 
			
		||||
void factorvm::begin_gc(cell requested_bytes)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -464,7 +444,6 @@ void factorvm::begin_gc(cell requested_bytes)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::end_gc(cell gc_elapsed)
 | 
			
		||||
{
 | 
			
		||||
	gc_stats *s = &stats[collecting_gen];
 | 
			
		||||
| 
						 | 
				
			
			@ -503,7 +482,6 @@ void factorvm::end_gc(cell gc_elapsed)
 | 
			
		|||
	collecting_aging_again = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Collect gen and all younger generations.
 | 
			
		||||
If growing_data_heap_ is true, we must grow the data heap to such a size that
 | 
			
		||||
an allocation of requested_bytes won't fail */
 | 
			
		||||
| 
						 | 
				
			
			@ -585,13 +563,11 @@ void factorvm::garbage_collection(cell gen,bool growing_data_heap_,cell requeste
 | 
			
		|||
	performing_gc = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void factorvm::gc()
 | 
			
		||||
{
 | 
			
		||||
	garbage_collection(data->tenured(),false,0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
inline void factorvm::primitive_gc()
 | 
			
		||||
{
 | 
			
		||||
	gc();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -319,7 +319,7 @@ void factorvm::fixup_code_block(code_block *compiled)
 | 
			
		|||
	relocate_code_block(compiled);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fixup_code_block(code_block *compiled,factorvm *myvm)
 | 
			
		||||
void fixup_code_block(code_block *compiled, factorvm *myvm)
 | 
			
		||||
{
 | 
			
		||||
	return myvm->fixup_code_block(compiled);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -79,6 +79,4 @@
 | 
			
		|||
#include "factor.hpp"
 | 
			
		||||
#include "utilities.hpp"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* __FACTOR_MASTER_H__ */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -355,7 +355,6 @@ unsigned int bignum_producer(unsigned int digit, factorvm *myvm)
 | 
			
		|||
inline void factorvm::primitive_byte_array_to_bignum()
 | 
			
		||||
{
 | 
			
		||||
	cell n_digits = array_capacity(untag_check<byte_array>(dpeek()));
 | 
			
		||||
	//	bignum * result = factor::digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
 | 
			
		||||
	bignum * result = digit_stream_to_bignum(n_digits,factor::bignum_producer,0x100,0);
 | 
			
		||||
	drepl(tag<bignum>(result));
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -796,7 +795,7 @@ void factorvm::box_float(float flo)
 | 
			
		|||
        dpush(allot_float(flo));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VM_C_API void box_float(float flo,factorvm *myvm)      // not sure if this is ever called
 | 
			
		||||
VM_C_API void box_float(float flo, factorvm *myvm)
 | 
			
		||||
{
 | 
			
		||||
	ASSERTVM();
 | 
			
		||||
	return VM_PTR->box_float(flo);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,26 +3,22 @@
 | 
			
		|||
namespace factor
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
THREADHANDLE start_thread(void *(*start_routine)(void *),void *args){
 | 
			
		||||
    return (void*) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)start_routine, args, 0, 0); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DWORD dwTlsIndex; 
 | 
			
		||||
 | 
			
		||||
void init_platform_globals()
 | 
			
		||||
{
 | 
			
		||||
	if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) {
 | 
			
		||||
	if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
 | 
			
		||||
		fatal_error("TlsAlloc failed - out of indexes",0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void register_vm_with_thread(factorvm *vm)
 | 
			
		||||
{
 | 
			
		||||
	if (! TlsSetValue(dwTlsIndex, vm)) {
 | 
			
		||||
	if (! TlsSetValue(dwTlsIndex, vm))
 | 
			
		||||
		fatal_error("TlsSetValue failed",0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
factorvm *tls_vm()
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +26,6 @@ factorvm *tls_vm()
 | 
			
		|||
	return (factorvm*)TlsGetValue(dwTlsIndex);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
s64 current_micros()
 | 
			
		||||
{
 | 
			
		||||
	FILETIME t;
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +80,6 @@ LONG factorvm::exception_handler(PEXCEPTION_POINTERS pe)
 | 
			
		|||
	return EXCEPTION_CONTINUE_EXECUTION;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FACTOR_STDCALL LONG exception_handler(PEXCEPTION_POINTERS pe)
 | 
			
		||||
{
 | 
			
		||||
	return SIGNAL_VM_PTR()->exception_handler(pe);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue