Subj : Re: Compile the Javascript code to Bytecode. To : netscape.public.mozilla.jseng From : Peter Paulus Date : Mon Oct 03 2005 10:06 am Alfred wrote: > Hi there, > > Is there any tool that can compile the Javascript code into > Bytecode? That's to say, the input is the javascript code, and the > output is the bytecode. > > Thanks > > Alfred > Hello Alfred, If you are Spidermonkey based, I've been doing some work on dumping the bytecode in human readable form. This is far from complete though. I did some investigation in this direction, but ceased work after only a few days. If you are interested I can send you my code. What is stored internally after you have compiled a script is bytecode. On the JSScript structure the 'code' field points into the bytecode. The 'length' member field tells you what size the bytecode has. The 'main' member field tells you where executable code starts. What I haven't figured out in this respect is where the table with constants, strings etc. is. I think this is behind the 'atomMap' member field. Files 'jsopcode.h' and 'jsopcode.tbl' give you a lot of hints about bytecode. If you are interested in dumping the bytecode octets in binary form, It should not be to hard to build that. Dumping 'length' bytes of the 'code' field get's you half way. You'd only have to figure out how to dump the atomMap. Hope that helps, With kind regards, Peter Paulus .