Assignment 5: Testing the compiler
Compiling and running the compiler
To compile the compiler, cd
into the src/ch6
directory
and type make
.
This will compile the compiler (which is an executable file called compile
).
You should see a number of warnings when you compile the compiler;
that's expected.
(As you fill in the code for the compiler passes,
these warnings will go away).
The command-line interface to the compile
program is identical to that
of the previous assignment, except for these things:
- There is one new pass: "expose allocation" (abbreviated "ea").
- The compiler now has one additional command-line argument:
-init-heap-size
. This is used by some of the tests of the garbage collector to restrict the size of the heap, thereby forcing garbage collections.
Testing your compiler: the test scripts
The test scripts you have been using
(scripts/run_eval_tests.py
and scripts/compare.py
)
are essentially unchanged from the last assignment,
except for those changes that had to be made
to accommodate the new compiler pass.
There is one new test script:
scripts/run_gc_tests.sh
This script can only be run if you have compiled your compiler first. It tests that the garbage collector actually does something. To run it, type
If you are running this on a Mac with an M-series processor
(not an x86-64 processor),
you will need to add the -arm64
argument:
This script compiles and runs three tests:
tests/vectors_test_10.src
tests/vectors_test_11.src
tests/vectors_test_15.src
It compiles them using the -init-heap-size
command-line argument,
with small enough heap sizes in each case to force garbage collection.
In addition, the file runtime.c
is compiled with debugging enabled,
so that a message will get printed out on each garbage collection.
You should see this exact output when the script is run:
If the collecting
messages are missing,
garbage collection isn't happening,
which is an error.
If the need 408
message prints a number different from 408,
it is probably incorrect but not necessarily
(there may be platform-specific differences
in how the garbage collector works.)
In that case, let the instructor (Mike) know about it.
The 42
, 41
and 42
outputs are the return values of the tests;
these should be the exact return values.
(This is also tested using the run_eval_tests.py
script.)