lua-users home
lua-l archive

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


Mike,

Thank you so much for taking the time to write such a detailed and helpful
response.

> > 2) Any helpful hints that you can offer in achieving this?
> 
> Try compiling Lua for your target architecture. Start with
> something along the lines of etc/noparser.c + etc/min.c
> (but kick out lauxlib). Check if you are getting anywhere
> near your target size before you continue.
> 
> If yes, ask for more hints. If no, pick a different platform. :-)

I have the LegOS environment setup using Cygwin and I will try what you
suggest. From my correspondence with Andre and your input it seems very
unlikely that I will have success. The LegOS kernel itself needs 14KB.

Andre had a great idea of considering the generation of native code instead of
attempting to squeeze in the interpreter - a non-trivial task by any measure.

Picking a different platform pretty much implies that LRT's change its charter.
Bummer. But I should have done a bit more investigation before setting out to
do the impractical.

Depending on my mood-swings I might just, for the heck of it, bite into Andre's
idea. Although I admit my public open source projects never saw the daylight
for one reason or the other :-(

> Of course if you don't need hash tables, metamethods, coroutines
> and so on, it's hard/unfeasible to remove this from the Lua core.

Without hash tables, metamethods and coroutines it is not Lua anymore and not
fun environment to work with either.

> So Lua might not be the best choice for a really tiny embedded
> system (less than 64K of memory and only primitive I/O).
> 
> But Lua is still an excellent choice for embedded systems with
> at least 128K-256K of memory (FLASH+RAM) and advanced I/O
> (like networking).
> 
> 
> BTW: Here is a break down of the code size of the different
> functional parts of Lua. This was measured on x86 (compiled
> with -Os and with lua_Number = double) and for Lua 5.1-work6:
> 
> Essential Lua core (total 33.7 K):
> + 6.8 K  bytecode interpreter plus glue code
> + 4.4 K  stacks, frames, states (coroutine)
> + 2.8 K  functions, metamethods, misc. object support
> + 0.6 K  shared immutable strings
> + 3.0 K  hash tables
> + 4.1 K  GC, memory management
> + 4.8 K  C API glue
> + 4.5 K  C debug API glue, bytecode verifier, opcode names
> + 2.7 K  bytecode loader, bytestream support (zio)
> 
> Compiler (total 19.0 K):
> +19.0 K  lexer, parser, code generation, bytecode dumper
> 
> Lua core libraries (total 32.7 K):
> + 4.4 K  lauxlib, linit
> + 5.4 K  base library
> + 2.1 K  math library
> + 3.7 K  IO library
> + 2.2 K  OS library
> + 6.7 K  string library (including regex)
> + 1.9 K  table library
> + 2.8 K  package/module library (loadlib)
> + 3.5 K  debug library
> 
> Standalone applications (pick one):
> * 3.1 K  command line interface (lua)
> * 4.3 K  command line compiler (luac)
> 

All of the above material is good information to have on the Wiki. So that I
can assemble a similar tabulation as yours and share it with the group, could
you please tell me the file names that contributed to each line item.

Regards
Vijay Aswadhati