Re: Dream Machine

  • From: Sam Putman <atmanistan@xxxxxxxxx>
  • To: LuaJIT <luajit@xxxxxxxxxxxxx>
  • Date: Thu, 12 Feb 2015 06:59:04 -0800

On Tue, Feb 10, 2015 at 8:23 AM, Javier Guerra Giraldez <javier@xxxxxxxxxxx>
wrote:

> On Tue, Feb 10, 2015 at 11:05 AM, Sam Putman <atmanistan@xxxxxxxxx> wrote:
> > Here's what I'm wondering. Would it be possible to modify TinyCC to use
> > DynASM to generate native code from within a C program that also includes
> > LuaJIT, lay out the native code in a way that LuaJIT can understand, and
> > then trace the entire memory-resident program? Everything C would have
> to be
> > statically compiled on-the-fly, but this is what TinyCC is good for.
>
> last time I checked TCC, it was notoriously difficult to modify.
> maybe it has changed, but it was treated almost as a black box; which
> isn't too surprising since it was (remotely) based on a winning entry
> of a C obfuscation contest.
>
>
I did say TCC, but I suppose I mean *a* Tiny C Compiler, not necessarily
*the* TCC. Something small, fast and memory resident.


> > Even an explanation of why this wouldn't work would help me understand
> > LuaJIT. If this is possible, it's my idea of a dream machine. Bonus:
> LuaJIT
> > could compile and optimize itself.
>
> note that TCC is fast, but it's not too good at optimizing code.
> maybe it would be easier to extend LuaJIT's variation of Lua code to
> include C, instead of the other way around...
>

Perhaps! I find Lua easier to write than C personally.

The notion/question was 'is there a way to lay out C code using DynASM or
similar following conventions that let LuaJIT trace through', the fact that
TCC doesn't do much optimization is almost a feature, since opposite of
optimized code is code that's easy to understand, reason about, and relate
directly to the source of.

Other related posts: