Skip to content

Instantly share code, notes, and snippets.

@subbuss
Created August 31, 2009 22:38
Show Gist options
  • Save subbuss/178761 to your computer and use it in GitHub Desktop.
Save subbuss/178761 to your computer and use it in GitHub Desktop.
[subbu@earth jruby] java -cp ~/software/jruby/lib/jruby.jar org.jruby.compiler.ir.IR_Builder -e "a = 3; b = [a]; c = [1,a,b]; x,y,z = *c; p = y; i,j=*z;t = c[2][0]+ i*1.5-c[1]/c[0]"
------------------ Before local optimization pass ---------------------
Script: file: "-e"
constants: {__SCRIPT_ROOT__=Class __SCRIPT_ROOT__}
Class: __SCRIPT_ROOT__Module: __SCRIPT_ROOT__
Method: :_ROOT_:__SCRIPT_ROOT__
instrs:
0 self = RECV_ARG(0)
1 a = 3:fixnum
2 b = Array:[a]
3 c = Array:[1:fixnum, a, b]
4 %v_0 = *c
5 %v_1 = %v_0[0] (GET_ARRAY)
6 x = %v_1
7 %v_2 = %v_0[1] (GET_ARRAY)
8 y = %v_2
9 %v_3 = %v_0[2] (GET_ARRAY)
10 z = %v_3
11 p = y
12 %v_4 = *z
13 %v_5 = %v_4[0] (GET_ARRAY)
14 i = %v_5
15 %v_6 = %v_4[1] (GET_ARRAY)
16 j = %v_6
17 %v_7 = CALL([], [c, 2:fixnum])
18 %v_8 = CALL([], [%v_7, 0:fixnum])
19 %v_9 = CALL(*, [i, 1.5:float])
20 %v_10 = CALL(+, [%v_8, %v_9])
21 %v_11 = CALL([], [c, 1:fixnum])
22 %v_12 = CALL([], [c, 0:fixnum])
23 %v_13 = CALL(/, [%v_11, %v_12])
24 %v_14 = CALL(-, [%v_10, %v_13])
25 t = %v_14
live variables:
%v_0: 4-9
%v_1: 5-6
%v_10: 20-24
%v_11: 21-23
%v_12: 22-23
%v_13: 23-24
%v_14: 24-25
%v_2: 7-8
%v_3: 9-10
%v_4: 12-15
%v_5: 13-14
%v_6: 15-16
%v_7: 17-18
%v_8: 18-20
%v_9: 19-20
c: 3-22
i: 14-19
y: 8-11
------------------ After local optimization pass ---------------------
Script: file: "-e"
constants: {__SCRIPT_ROOT__=Class __SCRIPT_ROOT__}
Class: __SCRIPT_ROOT__Module: __SCRIPT_ROOT__
Method: :_ROOT_:__SCRIPT_ROOT__
instrs:
0 self = RECV_ARG(0)
1 a = 3:fixnum
2 b = Array:[3:fixnum]
3 c = Array:[1:fixnum, 3:fixnum, b]
4 %v_0 = *Array:[1:fixnum, 3:fixnum, b]
5 %v_1 = %v_0[0] (GET_ARRAY)
6 x = 1:fixnum
7 %v_2 = %v_0[1] (GET_ARRAY)
8 y = 3:fixnum
9 %v_3 = %v_0[2] (GET_ARRAY)
10 z = b
11 p = 3:fixnum
12 %v_4 = *Array:[3:fixnum]
13 %v_5 = %v_4[0] (GET_ARRAY)
14 i = 3:fixnum
15 %v_6 = %v_4[1] (GET_ARRAY)
16 j = nil
17 [DEAD] %v_7 = CALL([], [c, 2:fixnum])
18 ASSERT_METHOD_VERSION(Array:[]=15L, LBL_0)
19 %v_7 = b
20 [DEAD] %v_8 = CALL([], [b, 0:fixnum])
21 %v_8 = 3:fixnum
22 [DEAD] %v_9 = CALL(*, [3:fixnum, 1.5:float])
23 ASSERT_METHOD_VERSION(Fixnum:*=8L, LBL_0)
24 %v_9 = 4.5:float
25 [DEAD] %v_10 = CALL(+, [3:fixnum, 4.5:float])
26 ASSERT_METHOD_VERSION(Fixnum:+=5L, LBL_0)
27 %v_10 = 7.5:float
28 [DEAD] %v_11 = CALL([], [c, 1:fixnum])
29 %v_11 = 3:fixnum
30 [DEAD] %v_12 = CALL([], [c, 0:fixnum])
31 %v_12 = 1:fixnum
32 [DEAD] %v_13 = CALL(/, [3:fixnum, 1:fixnum])
33 ASSERT_METHOD_VERSION(Fixnum:/=7L, LBL_0)
34 %v_13 = 3:fixnum
35 [DEAD] %v_14 = CALL(-, [7.5:float, 3:fixnum])
36 ASSERT_METHOD_VERSION(Float:-=11L, LBL_0)
37 %v_14 = 4.5:float
38 t = 4.5:float
live variables:
%v_0: 4-9
%v_4: 12-15
b: 2-20
c: 3-30
[subbu@earth jruby] irb
irb(main):001:0> a = 3; b = [a]; c = [1,a,b]; x,y,z = *c; p = y; i,j=*z;t = c[2][0]+ i*1.5-c[1]/c[0]
=> 4.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment