Lua features for RAM Limited Systems

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua features for RAM Limited Systems

Glenn edgar
Hi All:

I have been using lua in embedded systems on a few projects with great
results.  In these systems RAM is usually the gating item.  However, the
Flash memory is sufficient to support the lua interpreter.  

The RAM consumer in lua is the heap and most of the heap useage is to
register C functions which exercise the hardware.  

This brings up the question --- which is -- can the luaC function
interfaces be configured with const data structures instead of having to be
constructed at startup in ram structures?


If I could do this then this would allow me to use lua on more resource
limited systems.

Thanks

Glenn Edgar

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .




Reply | Threaded
Open this post in threaded view
|

Re: Lua features for RAM Limited Systems

Luiz Henrique de Figueiredo
> can the luaC function interfaces be configured with const data
> structures instead of having to be constructed at startup in ram
> structures?

If you mean lundump.c, then this has been on my wish list for as long as
I can remember. I think it can be done without much effort for bytecode
and line information: one only needs to add a flag somewhere to make
the garbage collector ignore those parts. Strings are a different problem
because Lua stores them internally in a block that contains other data
before the string data. So, strings would have to be copied. I'm not sure
whether this partial solution would give the savings you're after.

Another possibility is to rewrite the precompiled format to be closer to
the internal structs. This may work for better savings but the string
problem will remain unless the format includes header data for strings.

Bottom line: it can probably be done without too much work but it's not
something that can be simply "configured".
--lhf

Reply | Threaded
Open this post in threaded view
|

Re: Lua features for RAM Limited Systems

Andreas Stenius-2
Luiz Henrique de Figueiredo skrev:
can the luaC function interfaces be configured with const data
structures instead of having to be constructed at startup in ram
structures?

If you mean lundump.c, then this has been on my wish list for as long as
I can remember. I think it can be done without much effort for bytecode
and line information: one only needs to add a flag somewhere to make
the garbage collector ignore those parts. Strings are a different problem
because Lua stores them internally in a block that contains other data
before the string data. So, strings would have to be copied. I'm not sure
whether this partial solution would give the savings you're after.

Another possibility is to rewrite the precompiled format to be closer to
the internal structs. This may work for better savings but the string
problem will remain unless the format includes header data for strings.

Bottom line: it can probably be done without too much work but it's not
something that can be simply "configured".
--lhf


Very interesting, since most of my projects too runs on embedded hardware.

Haven't really pondered on this, but stayed with just removing debug information.

//A

Reply | Threaded
Open this post in threaded view
|

Re: Lua features for RAM Limited Systems

Glenn edgar
In reply to this post by Glenn edgar
>can the luaC function interfaces be configured with const data
>> structures instead of having to be constructed at startup in ram
>> structures?


>>If you mean lundump.c, then this has been on my wish list for as long as
>>I can remember. I think it can be done without much effort for bytecode
>>and line information: one only needs to add a flag somewhere to make
>>the garbage collector ignore those parts. Strings are a different problem
>>because Lua stores them internally in a block that contains other data
>>before the string data. So, strings would have to be copied. I'm not sure
>>whether this partial solution would give the savings you're after.

>>Another possibility is to rewrite the precompiled format to be closer to
>>the internal structs. This may work for better savings but the string
>>problem will remain unless the format includes header data for strings.

>>Bottom line: it can probably be done without too much work but it's not
>>something that can be simply "configured".
>>--lhf

I was leaning to the following approach and would like to know if it is
possible.

I was considering setting up an embedded table environment in C.  The
strings and functon pointer mappings would be in const data structures. 
Some sort of meta table mapping would allow something like this

var.method( .. parameters )  -- to map to a C gateway function that would
run the embedded C code and return data to lua.  A const C data structure
would map var, method and C function pointer together.

Not sure if the lua meta table facitlities have the capability to do this.

Glenn Edgar

  





--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .




Reply | Threaded
Open this post in threaded view
|

Re: Lua features for RAM Limited Systems

Luiz Henrique de Figueiredo
> I was considering setting up an embedded table environment in C.  The
> strings and functon pointer mappings would be in const data structures. 

I'm sorry but you've lost me here. Are we talking about the same thing?
--lhf