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 # make a thunk
thunk 010(%rsi), %r14 thunk 010(%rsi), %r14
cmp %r12, %r14 # are we precisely at the right amount of arguments for a thunk? 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: apply_fini_pt_closure:
thunkto %rsi, %r9 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 # first move just the right amount of args off the thunk
mov %r12, %rcx mov %r12, %rcx
sub %r11, %rcx sub %r11, %rcx
cmp $0, %rcx
jz apply_fini_o_tc_skip
lea 030(%r10, %rcx, 010), %rdx lea 030(%r10, %rcx, 010), %rdx
apply_fini_o_tc_copy: apply_fini_o_tc_copy:
sub $010, %rdx sub $010, %rdx
pushq (%rdx) pushq (%rdx)
loop apply_fini_o_tc_copy loop apply_fini_o_tc_copy
apply_fini_o_tc_skip:
# move all args from the closure # move all args from the closure
mov %r11, %rcx mov %r11, %rcx
cmp $0, %rcx
jz apply_fini_o_fun_skip
lea 030(%rsi, %r11, 010), %rdx lea 030(%rsi, %r11, 010), %rdx
apply_fini_o_fun_copy: apply_fini_o_fun_copy:
sub $010, %rdx sub $010, %rdx
pushq (%rdx) pushq (%rdx)
loop apply_fini_o_fun_copy loop apply_fini_o_fun_copy
apply_fini_o_fun_skip:
# make the thunk for the application that can be evaluated later # make the thunk for the application that can be evaluated later
thunkto %r15, 010(%rsi), %r14 thunkto %r15, 010(%rsi), %r14
@ -148,12 +154,15 @@ apply_fini_o: #TODO needs to be tested
# now make a thunk with the rest of the stuff # now make a thunk with the rest of the stuff
mov %r14, %rcx mov %r14, %rcx
sub %r12, %rcx sub %r12, %rcx
mov %rcx, %r14 #backup leftover count for later mov %rcx, %r14 # backup leftover count for later
cmp $0, %rcx
jz apply_fini_o_tt_skip
lea 030(%r10, %r13, 010), %rdx lea 030(%r10, %r13, 010), %rdx
apply_fini_o_tt_copy: apply_fini_o_tt_copy:
sub $010, %rdx sub $010, %rdx
pushq (%rdx) pushq (%rdx)
loop apply_fini_o_tt_copy loop apply_fini_o_tt_copy
apply_fini_o_tt_skip:
# finish the leftovers thunk # finish the leftovers thunk
add $1, %r14 # (1 fun to apply to + args) add $1, %r14 # (1 fun to apply to + args)