diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-12 15:12:03 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2023-08-12 15:12:03 +0200 |
| commit | 6be5a28bb90b391a5842a8ce3dfc7c154100ab68 (patch) | |
| tree | 22e04a263e68d983c6bf5d1fdebd662e66915e96 /include/primops.s | |
| parent | 5184299c7dfddeba4d2d2ba95d390040368f9736 (diff) | |
| download | uskel-6be5a28bb90b391a5842a8ce3dfc7c154100ab68.tar.gz uskel-6be5a28bb90b391a5842a8ce3dfc7c154100ab68.tar.bz2 | |
make a macro for pushing out thunks
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 |
