@@ -816,8 +816,10 @@ ast_rettype(ast) = ast.args[3].typ
816
816
# saved type inference data there.
817
817
function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
818
818
#dbg =
819
- #dotrace = true#is(linfo,sizestr)
820
- local ast::Expr
819
+ #dotrace = true
820
+ local ast::Expr, tfunc_idx
821
+ curtype = None
822
+ redo = false
821
823
# check cached t-functions
822
824
tf = def.tfunc
823
825
if !is(tf,())
@@ -826,11 +828,14 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
826
828
for i = 1 : length (codearr)
827
829
if typeseq (typearr[i],atypes)
828
830
code = codearr[i]
829
- if isa (code, Tuple)
830
- # compressed tree format
831
- return (code, code[3 ])
831
+ assert (isa (code, Tuple))
832
+ if code[5 ]
833
+ curtype = code[3 ]
834
+ redo = true
835
+ tfunc_idx = i
836
+ break
832
837
end
833
- return (code, ast_rettype ( code) )
838
+ return (code, code[ 3 ] )
834
839
end
835
840
end
836
841
end
@@ -888,13 +893,8 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
888
893
# our stack frame
889
894
frame = CallStack (ast0, linfo .module , atypes, inference_stack)
890
895
inference_stack = frame
891
- curtype = None
892
896
frame .result = curtype
893
897
894
- local s, sv
895
-
896
- while true
897
-
898
898
rec = false
899
899
900
900
s = { () | i= 1 : n }
@@ -1048,29 +1048,35 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
1048
1048
end
1049
1049
#print (" \n " ,ast," \n " )
1050
1050
#print (" ==> " , frame .result ," \n " )
1051
- if ! rec || typeseq (curtype, frame .result )
1052
- break
1051
+ if redo && typeseq (curtype, frame .result )
1052
+ rec = false
1053
1053
end
1054
- curtype = frame .result
1055
- end # while
1056
1054
1057
1055
fulltree = type_annotate (ast, s, sv, frame .result , vars)
1058
1056
1059
- fulltree .args [3 ] = inlining_pass (fulltree .args [3 ], vars)
1060
- tuple_elim_pass (fulltree)
1061
- linfo .inferred = true
1057
+ if ! rec
1058
+ fulltree .args [3 ] = inlining_pass (fulltree .args [3 ], vars)
1059
+ tuple_elim_pass (fulltree)
1060
+ linfo .inferred = true
1061
+ end
1062
+
1063
+ compr = ccall (: jl_compress_ast, Any, (Any,), fulltree)
1062
1064
1063
- compressed = ccall (: jl_compress_ast, Any, (Any,), fulltree)
1064
- fulltree = compressed
1065
- #compressed = fulltree
1066
- if is (def .tfunc ,())
1067
- def .tfunc = ({},{})
1068
- end
1069
- push (def .tfunc [1 ]:: Array {Any,1 }, atypes)
1070
- push (def .tfunc [2 ]:: Array {Any,1 }, compressed)
1065
+ if ! redo
1066
+ if is (def .tfunc ,())
1067
+ def .tfunc = ({},{})
1068
+ end
1069
+ compr = (compr[1 ],compr[2 ],compr[3 ],compr[4 ],rec)
1070
+ push (def .tfunc [1 ]:: Array {Any,1 }, atypes)
1071
+ push (def .tfunc [2 ]:: Array {Any,1 }, compr)
1072
+ elseif ! rec
1073
+ codearr = def .tfunc [2 ]
1074
+ compr = codearr[tfunc_idx]
1075
+ codearr[tfunc_idx] = (compr[1 ],compr[2 ],compr[3 ],compr[4 ],false )
1076
+ end
1071
1077
1072
1078
inference_stack = (inference_stack:: CallStack).prev
1073
- return (fulltree , frame .result )
1079
+ return (compr , frame .result )
1074
1080
end
1075
1081
1076
1082
function record_var_type (e :: Symbol , t , decls )
0 commit comments