lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] setarg


From: Christoph Bäni
Subject: [Lightning] setarg
Date: Tue, 6 Feb 2007 19:17:05 +0100

hi

in almost any programming language, you're able to write to
the parameters of a function (although it's not their primary
purpose).

a simple example would be:
void n_times(int n) {
        while (n-- > 0) {
                printf("hello world\n");
        }
}

in this example, the parameter is written (by the "--" decrement in
the head of the wile loop).

so i can't understand, why there is no jit_setarg() in ligntning as
it would be needed to compiler such functions! as my suggestion
below shows, this would be easy to implement for architectures
where parameters are passed by registers as well as for those
where everything is passed via the stack.

core-common.h:
[...]
#ifndef JIT_FP
#define jit_setarg_i(ofs, reg)          jit_movr_i((ofs), (reg))
#else
#define jit_setarg_i(ofs, reg)          jit_stxi_i((ofs), JIT_FP, (reg));
#endif
[...]

of course, it would still be a bit of work, if you would also
like to support jit_setarg_c and all the variants. and don't forget
the floating point stuff! but i should still be possible to implement
in few hours (including tests).

i'd be glad to learn, why such a thing has never been implemented
before. what's the reason? what would we lose by doing so?

best regards
christoph







reply via email to

[Prev in Thread] Current Thread [Next in Thread]