public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marcin Kościelnicki" <koriakin@0x04.net>
To: Ian Lance Taylor <iant@google.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [RFC] [PR 68191] s390: Add -fsplit-stack support.
Date: Mon, 04 Jan 2016 07:35:00 -0000	[thread overview]
Message-ID: <568A20B3.2070206@0x04.net> (raw)
In-Reply-To: <CAKOQZ8xT1zBxQ5tMEDNRh6bN50aq2nMT-N5v9n0f3der+PXfkA@mail.gmail.com>

On 03/01/16 04:20, Ian Lance Taylor wrote:
> On Sat, Jan 2, 2016 at 11:16 AM, Marcin Kościelnicki <koriakin@0x04.net> wrote:
>>
>> The differences start in the __morestack calling convention.  Basically,
>> since pushing things on stuck is unwieldy and there's only one free
>> register (%r0 could be used for static chain, %r2-%r6 contain arguments,
>> %r6-%r15 are callee-saved), I stuff the parameters somewhere in .rodata
>> or .text section, and pass the address of the parameter block in %r1.
>> The parameter block also contains a (position-relative) address that
>> __morestack should jump to (x86 just mangles the return address from
>> __morestack to compute that).  On zSeries CPUs, the parameter block
>> is stuffed somewhere in .rodata, its address loaded to %r1 by larl
>> instruction, and __morestack is sibling-called by jg instruction.
>
> Does that work in a multi-threaded program if two different threads
> are calling the same function at the same time and both threads need
> to split the stack?

For a few more details - __morestack takes three parameters:

- function's frame size (initial frame size if it happens to use alloca 
or VLAs later)
- size function's arguments on stack (not including varargs, if any)
- a pointer to the label where execution should be continued after stack 
is allocated

All three are per-function consts.  The first two are computed by the 
compiler (though frame size can be mangled by linker for functions 
calling non-split-stack code), and the third by the linker (since it 
involves relocation).  Since the parameters are known at link time, 
they're put in a per-function block in .rodata or .text and never 
change.  Simultanous access to that area is not a problem, since it's 
never written.

Marcin Kościelnicki

>
> Ian
>

      parent reply	other threads:[~2016-01-04  7:35 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-02 19:16 Marcin Kościelnicki
2016-01-02 19:16 ` [PATCH 2/5] s390: Fix missing .size directives Marcin Kościelnicki
2016-01-20 13:16   ` Andreas Krebbel
2016-01-20 14:01     ` Dominik Vogt
2016-01-21  9:59     ` Andreas Krebbel
2016-01-21 10:10       ` Marcin Kościelnicki
2016-01-02 19:16 ` [PATCH 3/5] Fix NOTE_INSN_PROLOGUE_END after unconditional jump Marcin Kościelnicki
2016-04-17 21:25   ` Jeff Law
2016-01-02 19:16 ` [PATCH 4/5] Don't mark targets of unconditional jumps with side effects as FALLTHRU Marcin Kościelnicki
2016-01-21 10:05   ` Andreas Krebbel
2016-01-21 10:10     ` Marcin Kościelnicki
2016-01-21 23:10     ` Jeff Law
2016-01-22  7:44       ` Andreas Krebbel
2016-01-22 16:39         ` Marcin Kościelnicki
2016-01-27  7:11         ` Jeff Law
2016-04-17 21:24   ` Jeff Law
2016-01-02 19:17 ` [PATCH 5/5] s390: Add -fsplit-stack support Marcin Kościelnicki
2016-01-15 18:39   ` Andreas Krebbel
2016-01-15 21:08     ` Marcin Kościelnicki
2016-01-21 10:12       ` Andreas Krebbel
2016-01-21 13:04         ` Marcin Kościelnicki
2016-01-16 13:46     ` [PATCH] " Marcin Kościelnicki
2016-01-29 13:33       ` Andreas Krebbel
2016-01-29 15:43         ` Marcin Kościelnicki
2016-01-29 16:17           ` Andreas Krebbel
2016-02-02 14:52             ` Marcin Kościelnicki
2016-02-02 15:19               ` Andreas Krebbel
2016-02-02 15:31                 ` Marcin Kościelnicki
2016-02-02 18:34                   ` Ulrich Weigand
2016-02-02 20:11                     ` Marcin Kościelnicki
2016-02-03 18:40                       ` Marcin Kościelnicki
2016-02-04 15:06                         ` Ulrich Weigand
2016-02-04 15:20                           ` Marcin Kościelnicki
2016-02-04 16:27                             ` Ulrich Weigand
2016-02-05 21:13                               ` Marcin Kościelnicki
2016-02-05 22:02                                 ` Ulrich Weigand
2016-02-03  0:20                     ` Marcin Kościelnicki
2016-02-03 17:03                       ` Ulrich Weigand
2016-02-03 17:18                         ` Marcin Kościelnicki
2016-02-03 17:27                           ` Ulrich Weigand
2016-02-04 12:44                             ` Marcin Kościelnicki
2016-02-10 13:14                               ` Marcin Kościelnicki
2016-02-14 16:01                                 ` Marcin Kościelnicki
2016-02-15 10:21                                   ` Andreas Krebbel
2016-02-15 10:44                                     ` Marcin Kościelnicki
2016-02-07 12:22             ` [PATCH] testsuite/s390: Add __morestack test Marcin Kościelnicki
2016-02-19 10:21               ` Andreas Krebbel
2016-01-02 19:17 ` [PATCH 1/5] s390: Use proper read-only data section for literals Marcin Kościelnicki
2016-01-20 13:11   ` Andreas Krebbel
2016-01-21  6:56     ` Marcin Kościelnicki
2016-01-21  8:17       ` Mike Stump
2016-01-21  9:46       ` Andreas Krebbel
2016-01-03  3:21 ` [RFC] [PR 68191] s390: Add -fsplit-stack support Ian Lance Taylor
2016-01-03 10:32   ` Marcin Kościelnicki
2016-01-04  7:35   ` Marcin Kościelnicki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=568A20B3.2070206@0x04.net \
    --to=koriakin@0x04.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).