CSC 548: Homework

Deadline: 5.30pm, Thursday June 3 2004.

Last homework!

Homework

Download the updated compiler archive for this course, and make sure you can compile and run the compiler:

  ant test

These tests should all pass, but if you try to compile amd execute a program using the garbage collector (which is used by the runtime system) it does not compile:

gcc -o output/ia32/Base.o -c -g -Wa,-gstabs output/ia32/Base.s
gcc -o output/ia32/TestList01.o -c -g -Wa,-gstabs output/ia32/TestList01.s
gcc -o src/hobbes/runtime/gc.o -c -g -Wa,-gstabs src/hobbes/runtime/gc.c
gcc -o src/hobbes/runtime/gcRoots.o -c -g -Wa,-gstabs src/hobbes/runtime/gcRoots.c
gcc -o src/hobbes/runtime/gcObject.o -c -g -Wa,-gstabs src/hobbes/runtime/gcObject.c
gcc -o output/ia32/TestList01.exe -g -Wa,--gstabs output/ia32/TestList01.o output/ia32/Base.o src/hobbes/runtime/gc.o src/hobbes/runtime/gcRoots.o src/hobbes/runtime/gcObject.o
src/hobbes/runtime/gc.o: In function `gc':
src/hobbes/runtime/gc.c:123: undefined reference to `forwardRoots'
src/hobbes/runtime/gc.c:123: undefined reference to `forwardHeap'
collect2: ld returned 1 exit status

(Under Linux, you should also link against linux.o, given by compiling src/hobbes/runtime/linux.s.)

Your job is to finish the garbage collector, by writing three functions: forwardRoots, forwardHeap and forward. These are the main functions in the copying garbage collector.

When you run the garbage collector with debugging switched on (given by a flag in debug.h you will get output similar to that in test/ok/Test*.run.

Load up the file src/hobbes/runtime/gc.c into your favourite editor, and start editing!

After you're finished, when you run programs generated by the compiler, it should produce output similar to that in Test*.run.

Submit your modified gc.c using the Courses OnLine system.

Reading

Appel, Chapter 13.