diff --git a/runtime/runtime.c b/runtime/runtime.c index c4a110dad..dc136ae0b 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -348,3 +348,34 @@ extern int Lwrite (int n) { return 0; } +/* GC starts here */ + +extern const size_t __gc_data_end, __gc_data_start; + +extern void __gc_root_scan_data () { + size_t * p = &__gc_data_start; + + printf ("Start, end: %d, %d\n", &__gc_data_start, &__gc_data_end); + + while (p != &__gc_data_end) { + if (!UNBOXED(*p)) printf ("Root: %d\n", p); + p++; + } +} + +/* extern const void * __gc_data_end, * __gc_data_start; */ + +/* extern void __gc_root_scan_data () { */ +/* void * p = &__gc_data_start; */ + +/* printf ("Start, end: %d, %d\n", &__gc_data_start, &__gc_data_end); */ + +/* while (p != &__gc_data_end) { */ +/* if (!UNBOXED(* (size_t *) p)) printf ("Root: %d\n", p); */ +/* p = p + sizeof(size_t); */ +/* } */ +/* } */ + +extern void Ltest () { + __gc_root_scan_data (); +} diff --git a/src/testgc.expr b/src/testgc.expr new file mode 100644 index 000000000..7964e97c7 --- /dev/null +++ b/src/testgc.expr @@ -0,0 +1,11 @@ +x := 0; +y := 0; +z := 0; +t := 0; +test (); +y := "abc"; +test (); +t := []; +test (); +t := 0; +test () \ No newline at end of file