Automatic Translation of Fortran to JVM Bytecode. Keith Seymour ... Java programs. ... motion, for which well-understood optimization tech- ..... The closest.
Automatic Translation of Fortran to JVM Bytecode Keith Seymour Jack Dongarra Department of Computer Science University of Tennessee, Knoxville Knoxville, TN 37996
ABSTRACT
"!$#&% # '$( )
)+*&-,. / 0 1
3245/1 30 6 45 ) 7 68 9" :*&-,":& 0 9 :*&-,HRQ68/ .
/ K 0 +FDRECC
FBC CD-RE A86 +F C [&J " .1 / 8 ,&
/ CC 4H,H CDON
I24 / ? AdX C ) 1260 eC [&G*&-,cCf0 I1 / 8 ,& A
/ CC @ ]? )g N
C 8 ]8 ) D M 8
B
0X& 0X rk^2: cL 8 0 /1A / 0 1 c 40 & 8Fc"!$#&% # '$(tH6C 8- 0"0 K /1 B*&-,HRQ24 uwv3xOv]V3 ,&]& 04 :<2: 53 6 4 *&-,. C~8 /18/ lH>:dX,&0 G.D0$9 6C1X3 / 0 1 c"-,& -3EM 7wCH3K 8- 6"2E2: D- A*&-,],& 9uwv3xOvbV3 ,&?30 1 C6D X8HG uwv3xOvcB8/
I /t eK 8- 6 ? 0 0 -24?69 /1 6 b*&-,:8Hb .:8 7D" 3 0 K0 b2:FX C 5
0EP
/ 6 8>+ $R 1 36 ) 6 9X /I $R25 -,&@D0$24 8/G860 K 0 -I6887N60 0 F?9 0 I 4"!$#&% # '$(V5WX4W7/1CD .K ]G T860 . K0 CU6@B*&-, .0 8/[ I I7/1CD->vb
-10 F C0 M :
-:3 / 0 1 G D8> v S 0 :1 4,& / 0*&-,X C@K0 "N
C1 - , 0 K0 IhL 60 1 Xi C0 K *& C t_ `-o1aNj 24 8/260 C [& K M N
R2b -,&J -5JKDFH8HJ /1
38Di 7E24 . ,H 6Q8H /1
"24 6 D N 8RQ 1,H ?@6 524 A98/ 89 /1 3. rIMPLEMENTATION k^B8C 0 B /1B }N6 A7/ R@ A)
8 K -IK 0 -2 ? 0 0 67 /1-I GPQ 6 9`>
3.1 +3 wLexical 7/ ""0 Analysis i w 1 /1and $JParsing "!$#&% # '$(.6 8
8H@ D[&5 G. 1 K6 0 X?8C0 vXZ}hrvZH6K-
D6D:8C 0 1 G7/ K/ 0 0 N
C1 K 6J:
/ C7 686 CYvXZK6 0
3.2 Optimizing the Use of Scalar Wrap+"!$#&pers % # '$(U, 0 6B1 c -N68 B
6K 6 KDF N 8> G C0 I 1 "!$#&% # '$(}6K 6 GCH M B ? 1 / C) R 14CH M 8-1 0 9/ [&:? >O84 I 8- 0 0 I 6 A > @3-2,& -Rw*&-,?6X 7)gKDFH)g, 0 6R 24 8/5 C0 O 1Q DFXCH M 8-1 O260 C B2D$E/ [& ? >O89 c?8- 0 0 ->c+]
/ @B C@60 1 7)gKDFH)
N 8 *&-,HRb2IC@67.2: / t?8- 0 1 ? KH^78->A 7-A : ?@ D , 0 6R
F77 Source
f2j Lexical/Syntactic Analysis
Abstract Syntax Tree
Intermediate Stages
Annotated AST
Java Source
Code Generation
JVM Bytecode
javac
Bytecode
GOTO Translation
Transformed Bytecode
Java Virtual Machine
2J260 wbKH^78Q2: / E24b8- 0 1 "M 0 CFK 5CH M -? ?X6K 6 > dX6 v},1 K0 5C@674K 32: / -I + `>4@,1 K0 @ 5 1 6CD3 3N68 S G GA0 B } CD 7/1CD4 ? 4
/ C 6 kD>4@,1 K0 @ 5 1 6CD3 3N68 ?
A 7 68 A0 &]I0 D8- 0b,1 K0 RQH6 8 - 31,& / 0 0 N
C 8 /1- 8H>
vQ 2: X
0 0 F 5N
5 C0 8 +FG 138H /1
4860 C : 0 0O,1 K0 413 C4 C S SA CBC -> @3-2,& -R368/S8H,&) 866 0 0 F8C1? 8G t 8- R 4 8: b N
C 8>QcM . 1"4*;5= ) 7 68 50 &X7/1 8e @2
[H@20 0:6 @?86 D 7) 6C 9 1 0 0 ,1 K0 1 X 0 0 C - b7/1 8 80
4.1.5 ZHC"!$Intrinsic #&% # '$(S DFunctions 8IN68 CFtK ? / 7)
0 1- 80 F}8
SCH } *&-,B8
Gv3x"/>JP
i C0 RJC DF]C1C1 8- 0 N68 68/e # 7.F < R gC@60 0 B80 1 /1 I G CG8C9) CK0 D8/[9i 7 3"!$#&% # '$(I6 8RHrk^bC @,1 K0 @ C Q K0 @3-2,& -Rbrk^8- e 0 GA0 C9) -AN
C "3+;Ev3u"5y" 0 B ,1 ) K0 5K ?-
D6 , 0 8-B? 5 >O 5 B+F @ 1 X 4$ >O: C - 8/I ->J : 7 8 I C9) 0 3 15 DFI+2I1 /FXK -
D6 , 0 8-GC@67 8 F 8I ?`> @3-2,& -R3 G 0 0 -2: K0 -
D6 , 0 8I1 /F9 X >O D C IhL> > )+ C 0 D 1 /F93+2 )+ C 0 D I1 /F j/R4 ? 0 031 /F?1 0 -1 \-e C A @ 885 XK 8- 0 0 FB. C. ) &1 /0 J b ) 0 :,1 K0 E0 &-@ .0 8: DF b,1 K0 1:2 ,H 60 F?-
D6 , 0 8-O>
4.1.8 S 0 "I/O W] wStatements $"C7w8 8- 0D 8Q H / 0 1)
?H6C 8- 0E0 K /1 68/A uwv3xOv~#"Jv v
4.1.10 Limitations v 69 b J b 1 J B *&-,50 1N
C0 8b.1 M 8 0 7 8 ) 86 $ROK636
3N
X 86 ,&.N68 3 X7 0 0 J8C0 0 F. C0 CD- 9rk^>J:K7/ 80 4 N60 0 F@ C0 CD < 86 J 1b 0 0 -24 5 86 ) . D N Q24 b8- 0 1 E2: / " C \-1 ?hL9ZH8 AlH> kj:24G 86 B 3 )
8 ]? ZHCE HE 7 8 E1 "C
" 6$ > P
?i C0 R:8H 1 0 ?--,H 0 Fe "3+;Ev3u"5y"24 0 0: @0 [&0 Fc / 0 120 0K ) 8- 6X68/I0 6 587 684D: :C 20 0 *&-,0 6 > ?uwv3xOvJ+ 8- R1 "3+;Ev3u"5y"?7/1CDw1 " N
C 15rk^8- c 0 98
80 FDR" .8 K - ]ZH8) Im> `> pD> 86 D 0 - B *&uwv3xOv V5WX4W 7/1CD@24 8/e -1 i0 8 0 Ft t "!$#&% # '$(B6 8X -
D6 50 D0 F >O D4 0 85XK / 8/I/1 "H6R&6 c A9iH5 R$28- - 0 FAM 0 0" A@K / 8/ /1 H "N
DFV5WX4WS7/1CD"KDF@0 D[H 6I 4K / 8/I0 K 0L>
4.2.2 Calculating Stack Depth and Branch vJ J Targets D-R& "J 8/c,1 K0 C@675K 7
-B G"! u #AEs%$ u 3 J.86 DX80 R K65i0 8 0 \-1 t8H9 50 FA ) 1-3N
E1 /F5 3 N 8b1/+F >$S /1 5KDFH8HR&24C@67"8 -1 @3-2,& -R24 S*&-, 6 8R 4 4 0 -IKDF :$; D>
"F G8- 7I1 BC@68/C
G C
/ D24 /1 KDFH8HB *&-,t6 8 8 - 8/? 7 68 I b+F )g 8 M 8>JH6R C DF3 7/ 8$ 1w2J860 +"2:F :24 /1 9 ?i ? I*&-,24 64 DF i0 8 38- 7R 2.C@674 /1+F 58H,& ) 7 68 4 KDFH8H>
S 8H /1
9-50 ?K ) +25CH U68/ $:6 5*&-,:6 8J8H /1 t AK c /1 8H cKDFH8H 0 F 2G C0 FG 1G0 K 0 9 5?-GN
. DFBCH M 8-1 B?@8H /1 6 > 9 /1 86D5 M -B '&)(+*Qh-,/.10hh-& & 4 &65-j87 &651j:9&j/R24 3& " 0, 0 6R%3 & 2 J: C 0, 0 6R ;&654 J4 8 CD/1
, 0 69_ k l1ar>
U 4.4 Resolving Calls to External Func wtions 8 @8 K E8/
D6EN
Q 0 ,H
!!"#%$'& & (') 6 )7$ !!"#%$'& & (') 8:9 ;!< $="' 8:9 ;!< $="'@? ACB;%& D%%&FE I (D%(@J$K'& '*+* >
> d : $; > d :$; > d :$; > d :$;
6 :$;
6 :$;
0%V! T V! T !$ . /0 _ 5 W
0%12 3 4+2 5/5 4!12 4 52 14 452 > 52 0=4 G/H 2 > 52 3 H 452 0 52 0/5 G 32 > 52 L/5
R M .U Z Dncp R 'N ` Z C 85i 48 CD5 i?KDFB`X 8C 1@N
@L 8 1.*&-,? .1)gK -A ) i @24 - 4S 0 5 4260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 8 8@ 7 8 D 6 5 1 ->@,&D6 0E& 0J XI -,&9D0 24 @
o
o
m
Dn65TR1Z N pYq
_ p-a@y yb 1 L^7R I>b 72: > @3 )+x" N
C 8*&-,ybH:N
ybC6/1 0wPQ0 6 Id3F C 8>H+ E D 8 # B?C D EG9 H+IJLKM M NO;sOv k H`> 7._ `a.ZHREFERENCES 6G=I 8 7F7C4+8>87:9 +;s= s$B?@s2?
_ q1a5 >;b @3F$R ":> dX HFDR A BB< D$BBC 0B1EL>OZH6G=I 8 7F7CRO=I6D/ .>xE 0 )7yb0 0 >wy1 /b0 8- v ;3 25ROyvR$`-||&nD> x"6 )+*&-,HR ybC D)gK -IZDF7C ZH C@60 1 D0$N
5yb60 - 3)g0 -1 _ k-a*DA@3 8/[H0 $R yb0 ,&.=I0 -R xQ 4cKK$R " x DF 84 37 686 -V< >+ b ,& -R J 68.=I 0 0 -R Ov =1 ixJ 8/[ R *69`-|||H> v c
0 H)rS 3cK1 D$ 1C1$> 7-> 1, ^-, H6C 8 ^ CH> _ |1ad@>dXD0 $R *> dX&1 /HR Iz9> ZHFC6 -> *&uwv3xOv J*&-,.N
36C 8- 0wybC6 >D 0B1E ! _ ``a.*>dX&1 /HR *>dX6GyJ \ROZ @X CC1 0 R E DF? sC0C B? ROpHhgkj/ |&ps ``-|HRE`-|||H> > @X $> vu$ *&HR vOv ,H $> 8C 1 H68 1 iO> DC0L> `mh7`1j/ `/sHl&kDRE`-|qqH> _ o1a5dX3v ZDF7C>W34)7W3KH^78RdX8C@K X`-|||H> _ `1k-a.*>dX&1 /HR *>dX6GyJ \R />dX6 >ER v @X CC1 0 >v ZH4 "u$,&0wl9 8.u$ -1 D$ 17 -1 8/$> 8C W34) v H+IJW7 s$B s? E D$B C D$B W3KH^78 1 iO> DC0L> Jas$EG9 X C#s$E s.uD2D 0 EZY,s /Rw`-oh7`1j/ `/s `1pDRE`-||H>
_ `-l1a ":> v LROy b 8/ +ROZ > b0 8/[DN
/OR *>dXCC0LR*> dX&1 /HR *>dX6GyJ \R v> V< HK 6CR Z 1> @X CC1 0 R v> =I8z5FDR Id@> ZH
$>[=H EH+I
P @ / # 7:9 8 #(A # E D$B> ZH7vX=AR x" 0 0 HR xOvRO`-|||H> _ `m a.v>;.> v ZHLR *>d@> 30 0 C $> I DC X u
E B X_u
7 X 9B @
s$B1# 72D D.u > v3 )rc0 FIx"6K0 ybC DFDR <- R =vR$`-|qqH> _ `1n-a.xQ> v4 & R =A>OV36/HR Z > =I [H >ER *> =I
/H2> @3 x" N
C 8@ybC6 @ *&-,Hbuw 6 GybC 0 + E D 8 # B?C D EG9 0
N KEG9 D 9DXD$B = s$B?@s2? T
s$B1#4I DC X u
. D E s s.uvu u I DC X@E
R v$`-|||H> _ `-o1a.*> =IFD 3 I3> dX-24 :> ;s W < 0 0 F v _ `1p-a.*> =IFD ->d3)+*&-,HRdX8C@K X`-||oH>Ov 8-1-> DF6$> -6 1CFD ^7,HC 1^-,H> _ `-q1a.xQ iH-> _ `-|1a.xQ>c6$R Z > =I [H >ER *>O=I
/HR G=A> V36/H> "ET8 DXZH6
N
5ybC0 i 36C@K *&-,H>+4 E D 8 # B?C D EG9 H+IJ NO;s$`-|||H> _ k 1a.v>v ybC0 iIv4 C 8 v 0 C > C$> 8> 6[ 1DC0 ybC0 i ybC0 i N
*&-,H> DC0L> _ kD`a.*> J DFD>dX byb0 XybC0 iOR k H`> v ,HL> 8C 18
1&1 / 1
/ 18C0 iO> DC> _ kk-a.3> u$ 0 C~ IPb> b0 0 $> 7:9 +
;s v3 )rc0 FDR b [&0 FDR yvRO`-||&pD> _ k l1a.v v AXlH> |1)`-|&p qHR v5ZH/R 32 b
[ R 32 b
[ R `-|&p qH> _ k1m a.*>dX&1 /H> u$ 8/[?b8/C1 [ >$_ W30 a v 0 K$>
1K 8/C1 [ 10 8/[OR W38K `-||&kD> _ kn-a.*> =I
/HR$Z > =I [H >ER G=A> V36/H> v ybC 1 J v+ E D 8 # B?C D EG9 H+IJLKM M NO;s k H`>