Handling File a15.ss bound-check passed all tests! invalid-tests passed all tests! bound-check passed all tests! parse-scheme passed all tests! grade-entire-compiler passed all tests!
Yay! I'm done with my compiler!
The last bug I had to fix was of the worst kind: the kind that only manifests far, far downstream from where it was introduced. In this case, it didn't show up until build-and-run. For the test I was failing on, my compiler was generating an instruction that looked like this:
movq -1(%rax), 24(%rbp)
...which isn't okay, because both operands are memory operands (not registers or immediates), and in x86-64 assembly, apparently only one of them (either!) can be that. So I had to follow this thing, in its various guises, all the way up to
select-instructions, which was spitting
(set! fv3 (mref u.80 -1))
...which wasn't okay, because
fv3 was a frame variable, and
(mref u.80 -1) was going to be one soon. So I put in a check for that and had the thing introduce Yet Another Unspillable Variable for those situations, and it worked! I love when things work! It's kind of troubling how this bug didn't show up at any point in the last fifteen weeks, though. Also, my instruction selection pass is now even more of a rat's nest of special cases. Man, screw the x86-64.
Alex thinks it's hilarious that I wrote the parser last. I'd like to proudly add that not only did I write the parser last, I did it in a matter of hours. In fact, it took longer to ferret out the memory-operand bug than it did to write the whole parser this weekend. S-expressions win pretty hard!
Classes are over, and I'm done with grading. Now I just have to take the take-home Compilers final (which will be available in about half an hour and is due on Wednesday), study for and take my theory final on Wednesday, and try to do something for Dan's class by Thursday. And then I'll be done with the first year of grad school and we can go see Nine Inch Nails.
;; P523 ;; Lindsey Kuper ;; Assignment 15 ;; SALL-E (Space Allocation Lambda Lifter, Earth-class): ;; A clumsy, well-intentioned, and intermittently sentient Scheme compiler. (compiler-passes '(parse-scheme convert-complex-datum uncover-assigned purify-letrec convert-assignments optimize-direct-call remove-anonymous-lambda sanitize-binding-forms uncover-free convert-closures optimize-known-call ;; analyze-closure-size optimize-self-reference ;; analyze-closure-size introduce-procedure-primitives lift-letrec normalize-context specify-representation uncover-locals remove-let verify-uil remove-complex-opera* expose-allocation-pointer flatten-set! impose-calling-conventions uncover-frame-conflict pre-assign-frame assign-new-frame (iterate finalize-frame-locations select-instructions uncover-register-conflict assign-registers (break when everybody-home?) assign-frame) discard-call-live finalize-locations expose-heap-allocation-forms expose-frame-var expose-basic-blocks optimize-jumps flatten-program generate-x86-64))