diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2013-04-30 14:47:53 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2013-04-30 14:47:53 +0200 |
commit | aa9eddfedea71a2006f114fe349b69a1cd53b432 (patch) | |
tree | 41e776b72332dcc0dda517404f6cd0da8232561f /open_issues | |
parent | 056517fc5b1758ef115179b231ab7b00a3460dd9 (diff) |
GCC: getcontext/makecontext/setcontext/swapcontext usage analysis.
Diffstat (limited to 'open_issues')
-rw-r--r-- | open_issues/gccgo.mdwn | 55 | ||||
-rw-r--r-- | open_issues/gnat.mdwn | 49 |
2 files changed, 104 insertions, 0 deletions
diff --git a/open_issues/gccgo.mdwn b/open_issues/gccgo.mdwn index e9fbf0f1..fb94cb83 100644 --- a/open_issues/gccgo.mdwn +++ b/open_issues/gccgo.mdwn @@ -38,6 +38,61 @@ been working on this, has some (unpublished) patches, and this is currently blocked on [[`getcontext`/`setcontext`|open_issues/glibc/t/tls-threadvar]]. +## `getcontext`/`makecontext`/`setcontext`/`swapcontext` usage analysis + +In context of [[glibc/t/tls-threadvar]]. Looking at GCC trunk commit +f6568ea476aa52a6e23c6db43b3e240cde55783a (2013-04-26). + +The check in `libgo/configure.ac` *whether setcontext clobbers TLS variables* +is invalid on GNU Hurd. + +The `*context` functions are used in `libgo/runtime/go-signal.c` and +`libgo/runtime/proc.c`. + +`__splitstack_getcontext`, `__splitstack_setcontext`, +`__splitstack_makecontext`, `__splitstack_resetcontext`, +`__splitstack_block_signals_context` are to be provided by libgcc. However, in +said libgo runtime files, they're used only `#ifdef USING_SPLIT_STACK`. +[[I|ŧschwinge]] would assume that before we can enable split stacks, first +[[open_issues/glibc/t/tls-threadvar]] needs to be fixed. + +In `libgo/runtime/proc.c`:`runtime_gogo`, `setcontext` is used to *switch +context to a different goroutine*. TODO. + +In `libgo/runtime/proc.c`:`runtime_mcall`, which *save[s] context and call[s] +fn passing g as a parameter*, `getcontext` and `setcontext` are used; this is +only called from `libgo/runtime/proc.c`:`runtime_gosched`. TODO. + +In `libgo/runtime/proc.c`:`runtime_tracebackothers`, `getcontext` is used to +*switch context to the goroutine*. TODO. + +In `libgo/runtime/proc.c`:`runtime_mstart`, which is *called to start an M*, +`getcontext` is used. TODO. + +In `libgo/runtime/proc.c`:`runtime_entersyscall`, which is called when *the +goroutine g is about to enter a system call*, `getcontext` is used to *save the +registers in the g structure so that any pointers held in registers will be +seen by the garbage collector*. Should be fine. + +In `libgo/runtime/proc.c`:`__go_go`, `getcontext` and `makecontext` are used. +TODO. + +In `libgo/runtime/thread.c`:`runtime_minit`, which is *[c]alled to initialize a +new m (including the bootstrap m)*, `ss.ss_sp` is set to a new stack retrieved +via `libgo/runtime/proc.c:runtime_malg`, which *allocate[s] a new g, with a +stack [...]*, and then `sigaltstack` is called. TODO. + + libgo/runtime/go-signal.c: /* We are now running on the stack registered via sigaltstack. + libgo/runtime/go-signal.c: and sigaltstack when the program starts.) */ + + libgo/runtime/proc.c: vnewg->context.uc_stack.ss_sp = vsp; + libgo/runtime/proc.c: vnewg->context.uc_stack.ss_sp += vspsize; + libgo/runtime/proc.c: vnewg->context.uc_stack.ss_size = vspsize; + +Also, in `libgo/runtime/proc.c`:`runtime_newm`, `pthread_attr_setstacksize` is +used, which we also can't support yet, for the same reason. + + --- diff --git a/open_issues/gnat.mdwn b/open_issues/gnat.mdwn index 0f404b8a..84e8f60b 100644 --- a/open_issues/gnat.mdwn +++ b/open_issues/gnat.mdwn @@ -103,6 +103,55 @@ know if the port has yet seen any real-world usage, such as using it for any bigger Ada code bases, or any Ada testsuites. +## `getcontext`/`makecontext`/`setcontext`/`swapcontext` usage analysis + +In context of [[glibc/t/tls-threadvar]]. Looking at GCC trunk commit +f6568ea476aa52a6e23c6db43b3e240cde55783a (2013-04-26). + + gcc/ada/init.c: sigaltstack (&stack, NULL); + gcc/ada/init.c: sigaltstack (&stack, NULL); + gcc/ada/init.c: sigaltstack (&stack, NULL); + gcc/ada/s-osinte-aix.ads: function sigaltstack + gcc/ada/s-osinte-aix.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-android.ads: function sigaltstack + gcc/ada/s-osinte-android.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-darwin.ads: function sigaltstack + gcc/ada/s-osinte-darwin.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-freebsd.ads: function sigaltstack + gcc/ada/s-osinte-freebsd.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-hpux.ads: function sigaltstack + gcc/ada/s-osinte-hpux.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-kfreebsd-gnu.ads: function sigaltstack + gcc/ada/s-osinte-kfreebsd-gnu.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-linux.ads: function sigaltstack + gcc/ada/s-osinte-linux.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-osinte-rtems.adb: -- sigaltstack -- + gcc/ada/s-osinte-rtems.adb: function sigaltstack + gcc/ada/s-osinte-rtems.adb: end sigaltstack; + gcc/ada/s-osinte-rtems.ads: function sigaltstack + gcc/ada/s-osinte-solaris-posix.ads: function sigaltstack + gcc/ada/s-osinte-solaris-posix.ads: pragma Import (C, sigaltstack, "sigaltstack"); + gcc/ada/s-taprop-linux.adb: Result := sigaltstack (Stack'Access, null); + gcc/ada/s-taprop-posix.adb: Result := sigaltstack (Stack'Access, null); + gcc/ada/init.c: stack.ss_sp = __gnat_alternate_stack; + gcc/ada/init.c: stack.ss_sp = __gnat_alternate_stack; + gcc/ada/init.c: stack.ss_sp = __gnat_alternate_stack; + gcc/ada/s-osinte-aix.ads: ss_sp : System.Address; + gcc/ada/s-osinte-android.ads: ss_sp : System.Address; + gcc/ada/s-osinte-darwin.ads: ss_sp : System.Address; + gcc/ada/s-osinte-darwin.ads: uc_stack : stack_t; -- Stack Used By This Context + gcc/ada/s-osinte-freebsd.ads: ss_sp : System.Address; + gcc/ada/s-osinte-hpux.ads: ss_sp : System.Address; + gcc/ada/s-osinte-kfreebsd-gnu.ads: ss_sp : System.Address; + gcc/ada/s-osinte-linux.ads: ss_sp : System.Address; + gcc/ada/s-osinte-rtems.ads: ss_sp : System.Address; + gcc/ada/s-osinte-solaris-posix.ads: ss_sp : System.Address; + gcc/ada/s-osinte-solaris.ads: ss_sp : System.Address; + gcc/ada/s-osinte-solaris.ads: uc_stack : record_type_2; + gcc/ada/s-taprop-linux.adb: Stack.ss_sp := Self_ID.Common.Task_Alternate_Stack; + gcc/ada/s-taprop-posix.adb: Stack.ss_sp := Self_ID.Common.Task_Alternate_Stack; + + --- |