libk  Check-in [481509e134]

Overview
Comment:don't clobber callee-saved registers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 481509e13402141fbdaf5072c2e75a0369371a5fcef1c6dfbc2235d27dbaa2b5
User & Date: lexi on 2019-10-21 04:28:46
Other Links: manifest | tags
Context
2019-10-22
22:21
Add errno locations for Android, as an initial step check-in: 357c708c52 user: glow tags: trunk
19:43
Add default errno locations for building on Android with Termux Should probably be revised, but this is a starting point. Leaf check-in: 960d952eed user: glowpelt tags: BAD
2019-10-21
04:28
don't clobber callee-saved registers check-in: 481509e134 user: lexi tags: trunk
01:46
fix broken commit check-in: bdb84af41a user: lexi tags: trunk
Changes

Modified mod/kcore/syscall.fn.x86.lin.64.s from [856b7532d5] to [3fa83c18de].

    31     31   	; locals: rbx = s64* result
    32     32   	;         r12 = u64* errno
    33     33   	; arg 0 = s64* result
    34     34   	; arg 1 = errno ptr
    35     35   	; arg 2 = syscall num
    36     36   	; arg 3 = valency
    37     37   	; arg 4 = args ptr
           38  +
           39  +	; we use two registers that are supposed
           40  +	; to be callee-saved, so we need to
           41  +	; push them to the stack and then pop
           42  +	; them back off just before the fn rets.
           43  +	push rbx
           44  +	push r12
    38     45   
    39     46   	; store the locals in registers that
    40     47   	; are guaranteed not to be clobbered,
    41     48   	; saving us some cycles pushing to
    42     49   	; and popping back from the stack
    43     50   	mov rbx, ccall.reg.0
    44     51   	mov r12, ccall.reg.1
................................................................................
    82     89   	js .error ; jump if sign flag set
    83     90   	
    84     91   	; move our return values into place and
    85     92   	; return to the caller (which should
    86     93   	; always be k_platform_syscall, btw)
    87     94   	mov       [rbx], sys.reg.ret
    88     95   	mov qword [r12], 0 ; no error
    89         -	ret
           96  +	jmp .return
    90     97   
    91     98   	; an error was returned - we need to set
    92     99   	; the errno to its positive equivalent,
    93    100   	; and store -1 in the return variable
    94    101   	.error: neg sys.reg.ret
    95    102   	        mov qword [rbx], -1
    96    103   			mov       [r12], sys.reg.ret
    97         -			ret
          104  +			jmp .return
          105  +
          106  +	.return: pop r12
          107  +	         pop rbx
          108  +			 ret