V8 as a backend?

66 views
Skip to first unread message

Lea Hayes

unread,
Mar 25, 2013, 6:31:16 AM3/25/13
to v8-u...@googlegroups.com
Hey guys

I am learning about compiler construction and want to design and create a simple programming language. I am currently exploring various backend projects which are capable of generating machine code on-the-fly.

I have been considering LLVM, Nanojit and Lightning and have found that LLVM is quite large but produces highly optimised binaries (and/or JIT). Nanojit seems a lot smaller and at this point I am unsure as to whether it can do compiled binaries as well as JIT's.

Then it occurred to me, V8 is an extremely efficient implementation of JavaScript implemented in C++. Is it feasible for me to use some of the V8 source as the backend for a multiplatform compiler that supports both JIT and native binaries?

Many thanks

Yang Guo

unread,
Mar 27, 2013, 5:03:08 AM3/27/13
to v8-u...@googlegroups.com
Hi Lea,

if you want to design your own toy language, I would not pick V8. Here is why:
- V8 is highly optimized for performance. The price is that the code is mostly not straight-forward. A big part of V8 would not be necessary if performance was not an issue.
- Javascript is a language with many quirks and pitfalls. V8 went great lengths to implement those.
- Javascript is not meant to compile code ahead of time. Therefore V8 does not compile into native binaries.

What you could consider is to compile your language into javascript, and have that run on top of V8. But that probably does not comply with your goal to learn about compiler construction.

Yang

Lea Hayes

unread,
Mar 29, 2013, 11:54:07 AM3/29/13
to v8-u...@googlegroups.com
Hi Yang

I agree, it would probably be a better exercise to use LLVM in this scenario. Though I might have a go at writing a compiler which translates a language into JavaScript first.

Thanks
Reply all
Reply to author
Forward
0 new messages