[Vm-dev] NoDbgRegParms test case results

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 1 04:24:35 UTC 2015


Hi Tim,

    the attributes are only ever meaningful for static functions.  gcc (and
other compilers) use faster register-based calling conventions where
possible when the optimize.  Non-static functions can't be so optimized
because they have to accord with the Application Binary Interface (ABI) and
on x86 that's a purely stack-based calling convention.  But static
functions are not visible outside the file and so the optimizer is free to
so optimize.  But that breaks the use of static functions within gdb; gdb
only knows how to call functions that accord with the ABI.  Given that we
don't care too much about performance in the Debug and Assert VMs but we
/do/ care about debuggability (and hence being able to call useful
functions, be they static or not) I try and apply the "don't use register
parameters" attribute to these functions.

Des this make sense to you?  Cuz if it isn't you need to understand it
before you can fix it, otherwise you'll waste a lot of effort chasing down
rat holes.

On Tue, Mar 31, 2015 at 3:33 PM, gettimothy <gettimothy at zoho.com> wrote:

>
> Hi all.
>
>
> I implemented a simple test case to test my theory that my platform does
> not support the regparms(0) function attribute and my theory is bunk. bleah.
>
> I modified this autotools tutorial's source files at
>
> http://www.gnu.org/software/automake/manual/html_node/Creating-amhello.html
>
> to mimic the __attribute__((regparms(0))) behavior in cog.
>
> I could not recreate the error under any compination of PRODUCTION and #if
> #else conditions.
> I am at a loss at the moment (and sick with a cold) so I will have to
> revisit this later.
> CMakeVMMakerSqueak dev is blocked by this issue.
>
>
> I added a test.h file to the src directory that looks like this:
>
>
>
>  bash-4.2$ cat test.h
> #undef NoDbgRegParms
> #define PRODUCTION 1
> #if !PRODUCTION && defined(__GNUC__) && !defined(NoDbgRegParms)
> # define NoDbgRegParms __attribute__ ((regparm(0)))
> #else
> # define NoDbgRegParms __attribute__ ((deprecated))
> #endif
>
> int plus (int a, int b) NoDbgRegParms;
>
>
> and modified the main.c .
>
> bash-4.2$ cat src/main.c
> #include <config.h>
> #include <stdio.h>
> #include "test.h"
>
> int main(void){
> int p;
>
> puts("Hello World!");
> puts ("This is " PACKAGE_STRING ".");
>
> p=plus(3,3);
>
> printf("%d\n",p);
> return 0;
> }
>
> int plus (int a, int b) {
> return a + b;
> }
>
>
>
>
>
>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20150331/c00767f4/attachment.htm


More information about the Vm-dev mailing list