Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news.misty.com!news.iecc.com!nerds-end From: Donald Strong Newsgroups: comp.compilers Subject: Re: Need idea for a compiler project Date: Fri, 18 May 2012 00:35:20 -0700 (PDT) Organization: Compilers Central Lines: 32 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-05-010@comp.compilers> References: <12-04-038@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1337359704 27869 64.57.183.58 (18 May 2012 16:48:24 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 18 May 2012 16:48:24 +0000 (UTC) Keywords: courses, code Posted-Date: 18 May 2012 12:48:24 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:639 Hi Rapheal, I am developing a code generator called ClassMaker. https://sourceforge.net/apps/trac/classmaker/wiki The objective of Classmaker is to make code generation easy and as a consequence it is not particularly optimised. I don't really care as I intend to use ClassMaker for generating classes from within applications or as a back end for domain specific languages, so efficiency is not my primary goal. The JVM doesn't directly support boolean types in expressions. You have to push ones and zeros onto the stack and then perform tests based on these values. The result is lots of bloated bytecode around branches and shortcut logic expressions. One can use a peephole optimiser to optimise out all of this redundant code, as described in this BCEL paper. http://bcel.sourceforge.net/downloads/paper.pdf Section 2.8 I use a class called ClassFileWriter, which is pulled directly out of Mozilla Rhino Javascript compiler, to generate the bytecode. An optimiser that works on the methods (arrays of byte) that this produces might meet your requirements and may help me as well. This is not a high priority for me, but I saw your post and thought I would throw it out there. Regards Donald.