Repository navigation
Conversation
77887be to
3bbeecb
Compare
pschachte
left a comment
There was a problem hiding this comment.
One small change, and a question.
| -- ^An argument to pass a resource | ||
| | Free -- ^An argument to be passed in the closure | ||
| -- environment | ||
| | ClosureEnv |
| proc #anon#1 > {inline} (1 calls) | ||
| 1: box_unbox_ho.#anon#1<1> | ||
| #anon#1(anon#1#1##0 <{}; {}; {0}>, ?anon#1#2##1)<{<<wybe.io.io>>}; {<<wybe.io.io>>}; {}>: | ||
| #anon#1(@#env##0:opaque, anon#1#1##0 <{}; {}; {1}>, ?anon#1#2##1)<{<<wybe.io.io>>}; {<<wybe.io.io>>}; {}>: |
There was a problem hiding this comment.
Why is there an extra environment argument in this case?
There was a problem hiding this comment.
I think I understand: you're making this explicit so you can optimise it. Is that the idea?
There was a problem hiding this comment.
Yeah. It makes it mildly easier to align the arguments when optimising LPVM.
There was a problem hiding this comment.
Okay. I want to do a bit more work on this.
I want to add explicit instructions to un-pack the closed values from the env as well. At the moment, there is still the assymetry of the env being present (and passed), but the free variables are not.
In order to do that, I need a special lpvm instruction. I'm calling it unmarshall for now. All it will do is take is the env param and the "index" of the free param of the closed variable in the non-closure variant of the proc, and return the closed value itself.
I can't use an existing instruction is because the unmarshall instructions are special. They won't have a fixed offset to read from, as some free params may be unused in the non-closure proc.
unmarshall could only be allowed in the pre-amble of a closure-proc when it comes to LLVM generation. We could also only inline a closure proc if the env is known, too, which I believe would always be the case (we only get to the point we directly call the closure proc if we inline a HO call to a FO call!)
The procs would look something like this:
def closure(#env, in, ?out) {
foreign lpvm unmarshall(#env, 0, ?closed)
non_closure(closed, in, ?out)
}
def non_closure(closed, in, ?out) {
# body
}
There was a problem hiding this comment.
Actually, I dont know if this is possible. We still need some of the information contained inside those "Free" params. We do still get that if the proc is a closure of some anonymous proc, but not when it is a closure like `+`(10) :(
I think I'll need to have both the explicit env and free params. I do still need to figure out how to factor in the unmarshall bit though. Let's see
There was a problem hiding this comment.
Should be right now :) No need for unmarshall
| ()<{<<wybe.io.io>>}; {<<wybe.io.io>>}; {}>: | ||
| AliasPairs: [] | ||
| InterestingCallProperties: [] | ||
| unary_higher_order.#anon#1<0>(?tmp#0##0:wybe.int) #0 @unary_higher_order:nn:nn |
There was a problem hiding this comment.
This is awesome, but I don't understand why unary_higher_order.#anon#1<0> didn't get inlined here, when it's marked for inlining?
There was a problem hiding this comment.
I think it's because we only do one expansion/inlining pass. The call to fetch_number is expanded, and that lowers the HO call to a FO call, but we dont get the chance to inline the FO call
6f3beb8 to
a15bed8
Compare
a15bed8 to
0d55215
Compare
9cc9093 to
35ceac9
Compare
35ceac9 to
159ee4e
Compare
|
More merge conflicts 😭 |
159ee4e to
1940309
Compare
1940309 to
658cb71
Compare
The test case exits with this on the a previous master build
I have also made the "env" param of closure procs explicit. This enabled further lowering of HO->FO calls, in some situations.