[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stack scanning
From: |
Paulo César Pereira de Andrade |
Subject: |
Re: Stack scanning |
Date: |
Wed, 4 Jan 2023 17:06:40 -0300 |
Em qua., 4 de jan. de 2023 às 15:13, Marc Nieper-Wißkirchen
<marc.nieper+gnu@gmail.com> escreveu:
>
> I solve this using the GNU lightning trampoline approach and a software stack.
Samples of this approach are
https://git.savannah.gnu.org/cgit/lightning.git/tree/check/ctramp.c
or using the pseudo assembler used for testing
https://git.savannah.gnu.org/cgit/lightning.git/tree/check/tramp.tst
>
> Am Mi., 4. Jan. 2023 um 18:44 Uhr schrieb Francis McCabe
> <frankmccabe@icloud.com>:
> >
> > I have a request for information: how should one implement stack scanning
> > with lightning? Stack scanning is important if you are implementing a gc
> > language. There are other stack level operations that are also important:
> > switching between stacks for example; allowing debugging by reporting on
> > the value of local variables and arguments.
> >
> > Obviously the requirement is for a portable approach to this.
There is no stack walking portable approach currently.
Obviously this can be worked on depending on needs.
About variables, this depends on how the language is implemented.
There is also currently no interface to save objects, nor an
approach to have proper function prototypes or data types.
As is now, your language might need to implement a bridge with some
other language, likely C, or do its own abstraction. Something that
has been in my TODO for several years is to use
https://sourceware.org/gdb/onlinedocs/gdb/JIT-Interface.html#JIT-Interface
but it would not be in lightning itself, but in an environment that
uses lightning.
If not using the approach of "trampolines", can create and access
local variables allocating stack space with jit_allocai, and the only
stack related registers, JIT_FP.
For variables, can call jit_arg_register_p(), and use jit_getarg() and
jit_putarg(). Unfortunately a bug was found after the last release, it
it is now fixed, where jit_arg_register_p() was buggy. The actual usage
example can be found at
https://git.savannah.gnu.org/cgit/lightning.git/tree/check/carg.c
The last release works in all ports with less arguments, and an example
is https://git.savannah.gnu.org/cgit/lightning.git/tree/check/put.tst
> > Thanks
> > Francis
> >
> > Sent from my iPhone
Thanks!
Paulo