Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
I’d like to be able to use x86’s capacities to improve generated code performance. I might have to push this off and just have a static stack pointerArchived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
Turns out there’s a new bug withlet
that will make using push
and
pop
difficult: I’m manually rewriting the stack pointer to get
function calls to work, but that messes up my variable references
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
- State “DONE” from “TODO” [2020-03-26 Thu 22:06]
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
- State “DONE” from “TODO” [2020-03-27 Fri 20:30]
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
- State “DONE” from “TODO” [2020-04-23 Thu 21:38]
Trying to run something like this:
(compile (parse '(labels ((f (code (n) (if (= n 0) 1 (* n (app f (- n 1)))))))
(cons (app f 5) 6))))
Computes the factorial value correctly, but gives something that looks like a pointer for the cdr
.
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
I think so. It’s kind of like differentiating betweenkapp
and regular app
.
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
- State “DONE” from [2020-04-03 Fri 00:05]
These break:
(compile (parse '(labels ((f0 (code (a) (+ a 1))) (f1 (code (b) (if (= b 0) (app f0 b) (app f1 (+ b 1)))))) (app f1 1))))
(compile (parse '(labels ((f0 (code (a) (+ a 1))) (f1 (code (b) (if (= b 0) (app f0 b) (let ((c (+ b 1))) (app f1 c)))))) (app f1 1))))
But these don’t:
(compile (parse '(labels ((f0 (code (a) (+ a 1))) (f1 (code (b) (if (= b 0) (app f0 b) (let ((c (+ b 1))) (+ c 1)))))) (app f1 1))))
(compile (parse '(labels ((f0 (code (a) (+ a 1))) (f1 (code (b) (if (= b 0) (app f0 b) (app f0 7))))) (app f1 1))))
(compile (parse '(labels ((f0 (code (a) (+ a 1)))) (let ((a 1)) (app f0 (+ a 1))))))
Oh, oops. That’s because the breaking ones are actually recursing infinitely.
Archived entries from file /Users/ashton/Wiersdorf/lambda-x86/project.org
This works:
(compile (parse '(labels ((factorial (code (n) (if (= n 0) 1 (* n (app factorial (- n 1))))))) (app factorial 5))))
But this doesn’t:
(compile (parse '(labels ((factorial (code (n acc) (if (= n 0) acc (app factorial (- n 1) (* acc n)))))) (app factorial 5 1))))
I think it’s because I’m not using my stack right: instead of writing values to absolute places on the stack, I should try to use push and pop. Else, check my useage of the stack. See page 276 in the textbook for a detailed description.