[M3devel] a trouble with passing records by value..
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Fri Sep 3 16:02:37 CEST 2010
On Fri, Sep 03, 2010 at 02:57:52AM +0000, Jay K wrote:
>
> > To avoid going into assembly langauge in my C interpreter, on many platforms I did the
> > following hack:
> >
> > Pack the parameters into a large struct (like struct big{char space[1000];} ), calculating
> > parameter positions myself. The type of the space array was completely irrelevant -- as
> > long as it ws big enough.
> >
> > Then I pass the struct by value to the called program, ignoring the types the called
> > program wanted -- you can do this with enough casts.
> >
> > This worked for a *lot* of systems.
> >
> > To avoid wasting too much stack space, I had a variety of struct types available, of
> > different sizes, each with its own code.
> >
> > -- hendrik
>
>
> Debugging would suffer like it did/does today.
Well, it was an interpreter, and so gdb would be useless anyway.
> Code quality would suffer.
Yeah. Interpreters aren't known for optimising register allocation for
the interpreted program anyway.
>
>
> Hey, I wanted to pass the static link in an extra parameter concocted by the
> frontend but Tony didn't want that loss of code quality.
The extra parameter would be the way to do it if you had to generate
standard C code, but it's not if you are able to rely on gcc extras.
> (Letting gcc do the work here has a few advantages: the optimizer
> can decide which locals even need to be in the struct, and 32bit x86
> can use a register for the extra parameter, whereas it otherwise might not).
>
>
> - Jay
>
More information about the M3devel
mailing list