fix apply-over

This commit is contained in:
Mirek Kratochvil 2023-08-15 11:07:06 +02:00
parent dab08fcbc0
commit d31d550a85

View file

@ -105,7 +105,7 @@ apply_fini_pt:
# make a thunk
thunk 010(%rsi), %r14
cmp %r12, %r14 # are we precisely at the right amount of arguments for a thunk?
je apply_fini_pt_thunk # if not wrap a closure
je apply_fini_pt_thunk # if not, wrap a closure
apply_fini_pt_closure:
thunkto %rsi, %r9
@ -128,19 +128,25 @@ apply_fini_o: #TODO needs to be tested
# first move just the right amount of args off the thunk
mov %r12, %rcx
sub %r11, %rcx
cmp $0, %rcx
jz apply_fini_o_tc_skip
lea 030(%r10, %rcx, 010), %rdx
apply_fini_o_tc_copy:
sub $010, %rdx
pushq (%rdx)
loop apply_fini_o_tc_copy
apply_fini_o_tc_skip:
# move all args from the closure
mov %r11, %rcx
cmp $0, %rcx
jz apply_fini_o_fun_skip
lea 030(%rsi, %r11, 010), %rdx
apply_fini_o_fun_copy:
sub $010, %rdx
pushq (%rdx)
loop apply_fini_o_fun_copy
apply_fini_o_fun_skip:
# make the thunk for the application that can be evaluated later
thunkto %r15, 010(%rsi), %r14
@ -149,11 +155,14 @@ apply_fini_o: #TODO needs to be tested
mov %r14, %rcx
sub %r12, %rcx
mov %rcx, %r14 # backup leftover count for later
cmp $0, %rcx
jz apply_fini_o_tt_skip
lea 030(%r10, %r13, 010), %rdx
apply_fini_o_tt_copy:
sub $010, %rdx
pushq (%rdx)
loop apply_fini_o_tt_copy
apply_fini_o_tt_skip:
# finish the leftovers thunk
add $1, %r14 # (1 fun to apply to + args)