Issue1634224
Created on 2007-01-12.17:21:02 by leouserz, last changed 2007-03-01.03:40:24 by cgroves.
File name |
Uploaded |
Description |
Edit |
Remove |
ModuleDiff.txt
|
leouserz,
2007-01-12.17:21:02
|
|
|
|
msg2593 (view) |
Author: Deleted User leouserz (leouserz) |
Date: 2007-01-12.17:21:02 |
|
Module defines a call_function by outputing byte code for each method in the module like so:
aload(0)
aload(2)
invokevirtual
areturn
with many functions/methods the aloads can add an excessibe amount of bytes to the generated class file. By moving the aloads out of the loop the amount of bytes is reduced by 2 instructions per function. Use the attached patch and run javap on the output class file to see the difference on this simple file:
def one():
print "one"
def two():
print "two"
one()
two()
OLD GENERATES:
public org.python.core.PyObject call_function(int, org.python.core.PyFrame);
Code:
0: iload_1
1: tableswitch{ //0 to 2
0: 28;
1: 34;
2: 40;
default: 46 }
28: aload_0
29: aload_2
30: invokevirtual #117; //Method f$0:(Lorg/python/core/PyFrame;)Lorg/python/core/PyObject;
33: areturn
34: aload_0
35: aload_2
36: invokevirtual #119; //Method one$1:(Lorg/python/core/PyFrame;)Lorg/python/core/PyObject;
39: areturn
40: aload_0
41: aload_2
42: invokevirtual #121; //Method two$2:(Lorg/python/core/PyFrame;)Lorg/python/core/PyObject;
45: areturn
46: aconst_null
47: areturn
PATCHED GENERATES:
public org.python.core.PyObject call_function(int, org.python.core.PyFrame);
Code:
0: aload_0
1: aload_2
2: iload_1
3: tableswitch{ //0 to 2
0: 28;
1: 32;
2: 36;
default: 40 }
28: invokevirtual #117; //Method f$0:(Lorg/python/core/PyFrame;)Lorg/python/core/PyObject;
31: areturn
32: invokevirtual #119; //Method one$1:(Lorg/python/core/PyFrame;)Lorg/python/core/PyObject;
35: areturn
36: invokevirtual #121; //Method two$2:(Lorg/python/core/PyFrame;)Lorg/python/core/PyObject;
39: areturn
40: aconst_null
41: areturn
}
So in this case we are saving 6 instructions in one simple module. In larger modules the savings are more significant.
|
msg2594 (view) |
Author: Charlie Groves (cgroves) |
Date: 2007-03-01.03:40:24 |
|
applied in r3133
|
|
Date |
User |
Action |
Args |
2007-01-12 17:21:02 | leouserz | create | |
|