diff options
Diffstat (limited to 'include/primops.s')
| -rw-r--r-- | include/primops.s | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/include/primops.s b/include/primops.s index f019bca..3fb03b8 100644 --- a/include/primops.s +++ b/include/primops.s @@ -7,25 +7,19 @@ _primops_s_file: .macro .primop2 name # | arg1 | arg2 | -> cont .thunkcode \name - # push a thunk for finishing the plus - push %rsi # cont - push %rbp # ret (self) - pushq 030(%rbp) # arg2 - pushq $3 - pushq $\name\()_step1 - - mov %rsp, %rsi # continue to the new thunk + # push a thunk for collecting the first arg and set it as continuation + thunkto %rsi, $\name\()_step1, $3, 030(%rbp), %rbp, %rsi enter 0x10(%rbp) # evaluate arg1 # arg1 -> | arg2 | ret | cont | .thunkcode \name\()_step1 - # this is guaranteed to be entered only once (it's a cont), so we can rewrite the thunk in place - mov 020(%rbp), %rax - movq $\name\()_fini, 0(%rbp) - mov %rsi, 020(%rbp) + # this is guaranteed to be entered only once (it's a case cont), so we + # can rewrite the thunk in place + xchg %rsi, 020(%rbp) # store arg1, get arg 2 + movq $\name\()_fini, 0(%rbp) # continue with finishing - mov %rbp, %rsi # continue on the rewritten thunk - enter %rax # evaluate arg1 + xchg %rbp, %rsi # continue here, evaluate arg 2 + enter_rbp # arg2 -> | arg1 | ret | cont | .thunkcode \name\()_fini @@ -35,8 +29,9 @@ _primops_s_file: .endm .macro primop2_ret_int val + # TODO: try to generalize # the result should now be in %rax - mov 030(%rbp), %rsi # save result to the original plus thunk + mov 030(%rbp), %rsi # save result to the original primop2 thunk movq \val, 010(%rsi) movq $INT_code, 0(%rsi) @@ -44,6 +39,7 @@ _primops_s_file: .endm .macro primop2_cont_indirect new + # TODO: try to generalize mov 030(%rbp), %rdi # load the original thunk mov 040(%rbp), %rsi # set the continuation movq \new, 010(%rdi) # set the indirect to the new thunk |
