Re: [Vala] Realize - proto2



Mikkel Kamstrup Erlandsen wrote:
2009/11/20 pancake <pancake youterm com>:
I don't see any complication in using libvala to convert from vala to
C in memory and then use libtcc to execute the generated C code
at runtime.

I was looking at libjit few days ago and it can be also used as a
backend to generate assembly code on runtime (but it can be also
used as a compiler backend to generate binaries). Thr problem here
is that the final code will be much more inefficient than the one
generated by gcc or llvm.

Why is that? I would generally assume that a good JIT compiler would
outperform a statically compiled program on most use cases?

Because JIT in interpreted languages like in Java or .NET all the objects,
functions and so are profiled in runtime, and the JIT uses this information
to optimize the code acording to the usage done by each block of code.

In Vala we use static compilation, not dynamic one. so the optimizations
must be done by doing static code analysis. There are possibilities to
pass runtime information to gcc to get those 'profilings' while the app
is running and then recompile it again to get some better execution.

In java or .NET each element in memory is about as double of its real
size because it needs to store all this profiling information. While the
code is optimized, this extra data is removed from memory.

Another nice thing done by .NET is that they store the JITted methods
in disk, so if you run the same app twice you will directly execute
the jitted method. This is nice, but IMHO can be a security issue because
the jitted code cannot be validated.

I dont really think in vala we should care too much about this. Vala
is a static language with some dynamic stuff, but at the end is not going
to change in runtime.

So I would find interesting other ways to integrate dynamic code execution
with vala. This is lua, javascript..and why not? parrot or java.

Today I was thinking about how it would be the integration of the vala
compiler with the java native interface. This is making the vala generate
code to write JNI directly from VAPIs or so. This will greatly simplify
the development on Java (not only for desktops, also for android and so)

Im not going to do anything on this front, so if anybody likes the idea
feel free the borrow it from me ;)

--pancake



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