Experimenting with explicit heap copying

This commit is contained in:
Justin Ethier 2016-01-15 22:43:21 -05:00
parent f0cd203a5c
commit ea45546c62
3 changed files with 18 additions and 13 deletions

View file

@ -198,6 +198,7 @@ void Cyc_exit_thread(gc_thread_data *thd);
object Cyc_thread_sleep(void *data, object timeout);
void GC(void *,closure,object*,int);
object Cyc_trigger_minor_gc(void *data, object cont);
object copy2heap(void *data, object obj);
void Cyc_st_add(void *data, char *frame);
void Cyc_st_print(void *data, FILE *out);

View file

@ -2866,16 +2866,15 @@ object Cyc_thread_sleep(void *data, object timeout)
return boolean_t;
}
// WIP for something to use to debug/use for threads
//object copy2heap(void *data, object obj)
//{
// char stack_pos;
// gc_thread_data *thd = (gc_thread_data *)data;
// int on_stack = check_overflow(&stack_pos, obj) &&
// check_overflow(obj, thd->stack_start);
// if (!is_object_type(obj) || !on_stack) {
// return obj;
// }
//
// return gc_alloc(Cyc_heap, gc_allocated_bytes(obj, NULL, NULL), obj, data, &on_stack);
//}
object copy2heap(void *data, object obj)
{
char stack_pos;
gc_thread_data *thd = (gc_thread_data *)data;
int on_stack = check_overflow((object)(&stack_pos), obj) &&
check_overflow(obj, (object)thd->stack_start);
if (!is_object_type(obj) || !on_stack) {
return obj;
}
return gc_alloc(Cyc_heap, gc_allocated_bytes(obj, NULL, NULL), obj, data, &on_stack);
}

View file

@ -10,6 +10,7 @@
thread-yield!
; thread-terminate!
; For now, these are built-ins. No need for them here: make-mutex mutex-lock! mutex-unlock!
->heap
)
(begin
;; Threading
@ -45,4 +46,8 @@
(define (thread-yield!) (thread-sleep! 1))
; (define (thread-terminate!) (Cyc-end-thread!))
;; TODO: thread-join!
(define-c ->heap
"(void *data, int argc, closure _, object k, object obj)"
" object heap_obj = copy2heap(data, obj);
return_closcall1(data, k, heap_obj); ")
))