A Javascript AOT compiler base on LLVM
I began to find a Javascript AOT compiler more than a month ago, I wonder whether there is a Javascript AOT compiler base on V8, since it is really a good Javascript JIT compiler, and then I know about JXCORE.
I decided to wirte a Javascript AOT compiler at the end of August 2014, and a month later I write a rudiment about it--It support part syntax and can compile signal *.js file to *.obj file on windows, and then, the object file can be linked to *.exe by link.exe in Visual Studio. It work well but slowly.
After discussed with my wife when we had dinner yesterday, I decide to release the whole project under Mozilla license, regard to Brendan Eich, the creator of Javascript, the co-founder of Mozilla.
Before upload the whole project, I need to send a mail, because I use some code with modified from anther prject, and I need clean up my code too.
=====
jslang is a Javascript AOT compiler base on LLVM(yes, it's named acording to clang). There are about three parts in this project:
=====
=====
replace property hashmap to hidden class, I tried but failed, I write a type tree to record all types and all relationship of them, I have no idea to record the real type of each value in compiler "world", they are objects, but I can't find it is a NumberObject or a BooleanObject.
split generated IR code to two parts, one for load(almost all types), one for link(almost all functions), to speed up the compiling.
remove garbage collector: all memory allocations are bound to object(record and analysis all objects which are alloced in each region, destory them when leave the region, the objects returned to upper region should be marked to the real region, use refrence count if needed)
write a new lexer and syntax parser to replace flex and bison generated codes, I modify ecmascript.y base on WebKit/JavaScriptCore/parser/Grammy.y(yes, they drop it later), and write ecmascript.l acording it, They are easy to use, and Grammy.y is very robusty, but they don't have good performance actually, maybe this is the reason for WebKit droped it.
implement exception, it should work well on both *NUX and Windows platform.
implement closure, record varibles of linear predeceesor for closure, since it's an AOT compiler, I purpose just set the varibles whitch are used in closure only.
find and record a suitable Instruction when create a function, to insert variable Alloca Instructions before it if we need create some variables, for example, arguments
optimize code for runtime, shorten the time of fibnacci
(40) to one second.
implement and improve the platform dependent code, porting the project to linux and some platforms else
implement cross complie feature for jslang(though jslang just is a front-end of LLVM, but it still has some work to do)