[haiku-commits] Re: BRANCH xyzzy-github.x86_64 - in src/system/libroot: os/arch/x86_64 posix/string/arch/x86_64 posix/arch/x86_64

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 22 Jul 2012 18:12:45 +0200

xyzzy-github.x86_64 wrote:
> diff --git a/src/system/libroot/os/arch/x86_64/syscalls.inc 
> b/src/system/libroot/os/arch/x86_64/syscalls.inc
> new file mode 100644
> index 0000000..f318d59
> --- /dev/null
> +++ b/src/system/libroot/os/arch/x86_64/syscalls.inc
> @@ -0,0 +1,46 @@
> +/*
> + * Copyright 2012, Alex Smith, alex@xxxxxxxxxxxxxxxxx
> + * Distributed under the terms of the MIT License.
> + */
> +
> +
> +#include <asm_defs.h>
> +
> +
> +// The kernel follows the AMD64 ABI for parameter passing (first 6 arguments 
> in
> +// registers and the remaining ones in on the stack), except that RCX is used
> +// by SYSCALL so it is moved to R10. Syscall number goes in RAX.

Why not the other way around? Not that the saved instruction matters much, but 
since it's free...

That aside, it may make sense to pass all parameters to the kernel via 
registers. ATM the syscalls don't have more than 11 parameters, so that should 
be feasible. It would save the kernel entry code from accessing the userland 
stack. Not important ATM, but something to come back to when the port is 
otherwise complete.

[...]
> diff --git a/src/system/libroot/os/arch/x86_64/thread.cpp 
> b/src/system/libroot/os/arch/x86_64/thread.cpp
> new file mode 100644
> index 0000000..7b12f02
> --- /dev/null
> +++ b/src/system/libroot/os/arch/x86_64/thread.cpp
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright 2012, Alex Smith, alex@xxxxxxxxxxxxxxxxx
> + * Distributed under the terms of the MIT License.
> + */
> +
> +
> +#include <OS.h>
> +#include "syscalls.h"
> +
> +
> +thread_id
> +find_thread(const char* name)
> +{
> + // TODO x86_64: x86 is doing some TLS thing here. Should that be done here
> + // too?
> + return _kern_find_thread(name);
> +}

find_thread(NULL) is used relatively often (particularly in locking code), so 
ideally it should indeed avoid using a syscall.

[...]
> diff --git a/src/system/libroot/os/arch/x86_64/tls.cpp 
> b/src/system/libroot/os/arch/x86_64/tls.cpp
> new file mode 100644
> index 0000000..794c422
> --- /dev/null
> +++ b/src/system/libroot/os/arch/x86_64/tls.cpp
> @@ -0,0 +1,50 @@
> +/*
> + * Copyright 2012, Alex Smith, alex@xxxxxxxxxxxxxxxxx
> + * Distributed under the terms of the MIT License.
> + */
> +
> +
> +// TODO x86_64.
> +// Also want to add inline versions to support/TLS.h.

I'm a bit undecided whether the performance gain is worth exposing 
implementation details. I think I'd prefer out of line assembly implementations.

CU, Ingo

Other related posts: