lua-users home
lua-l archive

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


LLVM has the concept of a Module which equates to a 'translation unit'
- within which there can be many functions.

In Ravi at present each function is put into its own module - this has
the advantage that a function is independent of every other function
and when it becomes garbage, the collector releases resources.

The model in Ravi doesn't scale very well - at least in terms of
memory usage. I assume that each module in LLVM carries some overhead.
It would be nice if multiple functions could be put into a module. Two
approaches come to mind:

a) User supplies a table of functions - they all get put into the same module.
b) User compiles a source file - all functions in the source get added
to the same module.

The problem is that how and when should the module be collected? What
happens if a function becomes garbage and later on user re-invokes it?

An unrelated problem is how to share the JIT compiled code across Lua
instances; in the Ravi model each Lua instance gets its own LLVM
infrastructure. This is also wasteful as the same functions may get
compiled in multiple instances - with no way to share the compiled
code between them.

Finally I am also wondering if there is an efficient way to determine
if two function instances are really the same - i.e. same code. Given
that Lua functions have no names - an approach might be to devise some
sort of unique hash code for each function. Or just implement an
efficient comparison that compares the bytecode.

I am just thinking aloud here - these are some of the things I need to
resolve for Ravi. Not sure how though. I would welcome any feedback.

Regards
Dibyendu