Friday, July 16. 2004
So the other day my
Projects page was
Slashdotted because of my work attempting to compile PHP scripts into intel assembly code. The project is called PASM, and although I managed to be
Somewhat successful in accomplishing my goal I never released any source code for it.
Since Tuesday when the project was made known to the world via Slashdot, I've gotten a flood of e-mails from users asking where they can get a copy of the source tree. Since I am much too busy to really do any signficant work on the project anymore, I figured I'll just release what I have and see if anyone out there is brave enough to make it work. So here you go:
The
PASM Source Code
The Project works like this: The 'asm' folder created when you extract the tarball is actually a PHP 5 extension which hooks into Zend Engine 2. That means you'll need PHP 5.0+ or higher to make it work (although I can't even promise you my ext will still compile in PHP 5 -- it was written way before Beta 1 was even released). The purpose of this extension is to basically hook into the Zend compiler and capture the callbacks which occur during script execution for each op-code. Those op-codes are then transfered into a giant associative array which is then accessiable within PHP itself. The second half of this project is the actual ASM code generation and it consists of three distinct parts. The first part is the PASM compiler framework, which is a PHP script in the pasm directory called pasm. It's job is to use the extension mentioned previously to call a code generation module that actually generates the assembler code. That module is the x86 module and it is found in x86_module.inc. This is where the ASM code is actually produced. The second part of the code generation is the library of FASM assembler marcos I created found in files such as pasm_var_macros.inc. These assembler routines are designed to provide "typeless" variables and on-the-fly conversion of them between types to mirror the behavior in PHP. The third and final aspect, which perhaps is the most stable of all of the things this project has done, is the PMM (or PASM memory manager). This is a completely self-contained modular memory manager written enitrely in FASM assembler. There are does (MM_README) for it so you can go from there.
To compile anything, you'll need the FASM compiler and GCC. You can find FASM
right here. If you don't already have GCC, you might as well not even bother with this one.
So there you go. Download it, be aware it is likely not to work, and considering it has been the first and only attempt of its kind I don't want any hate mail saying what a bad job I did with it. If you somehow find it useful, or even better thing you can fix it -- let me know :)