[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaThreads with LuaJIT (and maybe lua_tcc)
- From: Javier Guerra <javier@...>
- Date: Tue, 11 Apr 2006 11:37:38 -0500
On Tuesday 11 April 2006 10:47 am, Jerome Vuarand wrote:
> I'm also planning to use lua_tcc at some point to optimize by hand some
> part of my engine. The principle would be to turn static data of my
> problem into ultra-specific hardcoded C routines that would be almost
> optimal with no cost in data complexity.
i don't want to discourage you, but don't rely too much on lua_tcc.
unfortunately, it seems TCC has some unclean usage of global variables; so
it's usable to use it with very static environment (usual C program
initialisation and such), but might be unstable with a dynamic language
environment.
in particular, each time you use it to compile some C, lua_tcc allocates a new
TCC state. this state has to be there as long as you want to use the compiled
code, so the returned function(s) are closure with a 'hidden' reference to a
userdata that holds the TCC state. that way, when the last function is
disposed, the lua_tcc userdata can be collected and the TCC state
deallocated; but if you create two TCC states, the first deallocation
succeeds, and the second one fails (it tries to deallocate some globals
_again_).
for this, lua_tcc is nice to experiment and try new things; but when you're
satisfied with your C code, you should use a real compiler.
--
Javier
Attachment:
pgpgLh6r8d2Es.pgp
Description: PGP signature