Tuesday, October 28, 2014

My JIT compiler

Been a long time since the last update. I also suspended development of my operating system and moved on to enhancing my virtual machine project called "Pessego". I wrote the software back in 2008 or something and was a glorified bytecode interpreter with crappy assembler.

The new version has a Flex/Bison-powered assembler and will be powered by a... *drumroll* Just-in-time compiler! Like all the big boys have ;-).

It's written in C++, and has log4cpp as a logging framework at the moment. It's not in a very advanced state but as of this evening, it recognizes the first instruction! Consider the following "program", it is written in PAsm, not x86 Assembly:






You would probably translate the "put" instruction to "mov eax, $1badb002", which is exactly what it will do. It generates the byte sequence [$B8, $02, $B0, $AD, $1B]. The next step is to allocate some virtual memory using the Windows API, mark it as executable, create a function pointer and call the function and my initial JIT compiler just took its first baby steps!


No comments:

Post a Comment