V8 outputing/comiling into obj or as compatible source? (possible replacement for Lua?)

17 views
Skip to first unread message

Adam Strzelecki

unread,
Dec 16, 2010, 9:21:32 AM12/16/10
to v8-users
Hello,

Since V8 can generate binary native machine code for both x86 & ppc it
could be a perfect ECMA compatible scripting language for games/game
engines. So normally you could prototype your app (game) using JIT,
and what would be desired is to be able to produce binary OBJ or
assembler source that could be linked together with the whole
application for release build. So nobody sees your app (game) source
JS code inside release build.

I know JS uses eval() a lot in many cases, but I don't care if eval()
wouldn't be available at binary linked code. Most important thing I
want to achieve is that release builds of the app (game?) do not
compile anything anymore with JIT, but just relay on the code
contained by the executable, where one part of the code comes from C/C+
+ compiler and contains some app (game) engine, rest comes from JS V8
compiler and contains logic. Obviously we link also to V8 library
which contains internal ECMA/JSscript routines.

Also I would love that V8 is easily hookable to existing C++ classes
(game engine classes).

So first of all, is it possible? I know debug build of V8 can output
some machine code log, but is it possible to turn this code easily
into valid assembler source or OBJ? The perfect situation would be if
each file.js has generates file.obj containing C function symbol
"_file" or "_v8_file" that is visible by the rest of application
during linking phrase, and returning V8 JS type. Also would be great
if there was some extension for other files inclusion in v8 (or maybe
there is one already?) that will also join all the JS code from
several files into single (or several) OBJs.

If this was be feasible I think V8 would be great replacement for Lua
and .NET/Mono/MonoTouch used by many game engines.

Best regards,
--
Adam Strzelecki | nanoant.com

Erik Corry

unread,
Dec 17, 2010, 4:39:49 AM12/17/10
to v8-u...@googlegroups.com
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.

There are lots of obfuscators for JavaScript. I think those are your
only real option.

> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
>

--
Erik Corry, Software Engineer
Google Denmark ApS - Frederiksborggade 20B, 1 sal,
1360 København K - Denmark - CVR nr. 28 86 69 84

Søren Gjesse

unread,
Dec 17, 2010, 4:51:28 AM12/17/10
to v8-u...@googlegroups.com
And please note that V8 does not support the Power Architecture.

Regards,
Søren

Adam Strzelecki

unread,
Dec 17, 2010, 9:09:53 AM12/17/10
to v8-u...@googlegroups.com
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.

Regards,
--
Adam Strzelecki | nanoant.com | tel. +48 605 446 492

Reply all
Reply to author
Forward
0 new messages