From: Leo U. <leo...@ya...> - 2007-01-11 19:31:16
|
Hmmm, I was looking at the byte code generated from a leo file, specifically the call_function override it does on PyFunctionTable. This pattern emerged: 2866: aload_0 2867: aload_2 2868: invokevirtual 2869: areturn This appears to occur for each possible function invocation. Now in leoNodes(the file in question) it generates 386 invokevirtual calls. Each one appears to be surrounded by the aload_* and areturn set. I think it would be possible to simplify this greatly by moving the aload_0 and aload_2 calls before the switch. "areturn" is trickier in that you don't want to fall into invoking the other methods after the method is called. But if we do move the aloads before the switch that saves us from generating 770 instructions(in this case). I think this could work, the loop in question appears to be this(from Module.java): for(i=0; i<labels.length; i++) { labels[i].setPosition(); code.aload(0); code.aload(2); code.invokevirtual( classfile.name, ((PyCodeConstant)codes.elementAt(i)).fname, "(" + $pyFrame + ")" + $pyObj); code.areturn(); } def.setPosition(); all that should need to be done is to move the aloads out of the loop and before the iconst call. aload(0) is loading "this" aload(2) is loading the PyFrame leouser ____________________________________________________________________________________ Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now. |