Hello V8 developers,

I asked this on v8-users group but I haven't received clear answer about this 
subject. I am currently considering extending V8 with Ahead-of-Time compiler. 
Since V8 currently contains X86 & ARM assembler and as I understand looking at 
the source code it generates rellocable native machine code. It makes me 
believe that AoT compilation is possible with V8. So rather than JIT the 
scripts we could first "v8c -o somescript.o somescript.js" and then link it 
into native binary (probably together with rest of application and v8 runtime).

So I just need couple of hints where to begin extending v8 assembler classes so 
they generate rellocable native machine code into COFF or ASM (text source 
code) files. I have already peeked into V8 source code, but I have couple of 
doubts about referencing global variables and other/built-in functions. These 
are during JIT comilation state and the compiler raises an error when no 
built-in or global variable is declared/present, in case of AoT - compiler 
shouldn't complain, but generate external symbol reference, and it will be 
linker task to properly resolve this symbol.

Finally anticipating possible responses to this mail - I fully understand that 
AoT doesn't makes sense for V8 used as JS web browser engine, but my idea for 
adding AoT compilation to V8 is to use JS as scripting language for some mobile 
(iPhone) 3D game engine, where JS game source code will be JITed and executed 
at runtime when prototyping/debugging but it will be AoT compiled into single 
executable when producing release deployment build.
Ahead of Time compilation solves couple of issues here:
* No JS source code is shipped with application, so nobody can look/steal some 
ideas from the application
* Only binary code is used, so we comply with AppStore submission guidelines
* We don't JIT, which doesn't work on iPhone anyway, because rw memory blocks 
cannot have execution permission on iPhone in contradiction to Android where V8 
JIT works just fine

Altogether I want to achieve exactly the same thing as MacRuby does with its 
"macrubyc" command that generates binary executable out of Ruby code. However 
MacRuby is far less portable and far less lightweight than JavaScript and V8 
engine.

Thanks in advance for all your responses,

-- 
Adam Strzelecki | nanoant.com

Wiadomość napisana przez Adam Strzelecki w dniu 2010-12-17, o godz. 15:09:

> Erik,
> 
>> V8 does not have a byte code.  If it needs to compile something it
>> uses the source.  There is no support for compiling everything ahead
>> of time and throwing away the source.  The code snippets produced by
>> the print-code option cannot be made into .obj files.  This would
>> require extensive support from the runtime system.
> 
> You got me wrong, I know V8 uses no byte-code I don't expect it to.
> 
> All I want is either `-print-code -nolazy` dump GNU assembler compatible 
> machine code or V8 be able produce COFF (.o or .obj file) that I can link 
> into other binary code of my app.
> 
> I know V8 produces machine code so IMHO there's no problem with that, but I 
> want to know your opinion or either some directions how to make it possible.
> 
>> And please note that V8 does not support the Power Architecture.
> 
> This is not a problem for now I x86 & ARM is ok.

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to