From: MikkelFJ Date: 2002-10-17T02:44:07+09:00 Subject: Re: Psyco "Anders Bengtsson" wrote in message news:1034785403.1141.29.camel@spinoza... > Justin Johnson wrote: > > > > Why would it not be possible to compile the AST to native code? That's > > > what a traditional compiler does, after all. > > > You can generate bytecode but it's not going to give that much of a speed > > increase, IMHO, because it would still have to be doing dynamic method > > lookup etc. > > It may be faster to JIT-compile bytecode into native code than doing it > directly from the AST. This is useful if you want to distribute bytecode > instead of source. AST may actually be faster if the AST is optimized. Instead of storing the opcode, you can store the adress of the code to execute directly in the node. Of course the more the AST is optimized, the more blurred the difference between bytecode and AST becomes. Bytecode is also sometimes optimized by replacing the opcode with direct addresses during load. OCaml bytecode is 30% faster on gcc compared to Visual C++ because gcc has a non-standard goto functionality that allows this optimization in C. But apart from that Visual C++ generates faster code. Of course this argument does not work well for dynamic dispatch, but even then you can store the address of the dispatch code directly. Mikkel