@@ -188,6 +188,12 @@ type ctxt =
188
188
ctxt_curr_path : Ast .name_component Stack .t ;
189
189
190
190
ctxt_rty_cache : (Ast .ty ,Il .referent_ty ) Hashtbl .t ;
191
+
192
+ ctxt_type_effect_cache : (Ast .ty ,Ast .effect ) Hashtbl .t ;
193
+ ctxt_type_points_to_heap_cache : (Ast .ty ,bool ) Hashtbl .t ;
194
+ ctxt_type_is_structured_cache : (Ast .ty ,bool ) Hashtbl .t ;
195
+ ctxt_type_contains_chan_cache : (Ast .ty ,bool ) Hashtbl .t ;
196
+ ctxt_n_used_type_parameters_cache : (Ast .ty ,int ) Hashtbl .t ;
191
197
}
192
198
;;
193
199
@@ -277,7 +283,13 @@ let new_ctxt sess abi crate =
277
283
ctxt_main_name = crate.Ast. crate_main;
278
284
279
285
ctxt_curr_path = Stack. create () ;
280
- ctxt_rty_cache = Hashtbl. create 1024 ;
286
+
287
+ ctxt_rty_cache = Hashtbl. create 0 ;
288
+ ctxt_type_effect_cache = Hashtbl. create 0 ;
289
+ ctxt_type_points_to_heap_cache = Hashtbl. create 0 ;
290
+ ctxt_type_is_structured_cache = Hashtbl. create 0 ;
291
+ ctxt_type_contains_chan_cache = Hashtbl. create 0 ;
292
+ ctxt_n_used_type_parameters_cache = Hashtbl. create 0 ;
281
293
}
282
294
;;
283
295
@@ -1110,7 +1122,8 @@ let type_is_structured (cx:ctxt) (t:Ast.ty) : bool =
1110
1122
}
1111
1123
1112
1124
in
1113
- fold_ty cx fold t
1125
+ htab_search_or_add cx.ctxt_type_is_structured_cache t
1126
+ (fun _ -> fold_ty cx fold t)
1114
1127
;;
1115
1128
1116
1129
@@ -1128,7 +1141,8 @@ let type_points_to_heap (cx:ctxt) (t:Ast.ty) : bool =
1128
1141
ty_fold_task = (fun _ -> true );
1129
1142
}
1130
1143
in
1131
- fold_ty cx fold t
1144
+ htab_search_or_add cx.ctxt_type_points_to_heap_cache t
1145
+ (fun _ -> fold_ty cx fold t)
1132
1146
;;
1133
1147
1134
1148
(* Effect analysis. *)
@@ -1152,7 +1166,8 @@ let type_effect (cx:ctxt) (t:Ast.ty) : Ast.effect =
1152
1166
let fold_mutable _ = Ast. STATE in
1153
1167
let fold = associative_binary_op_ty_fold Ast. PURE lower_effect_of in
1154
1168
let fold = { fold with ty_fold_mutable = fold_mutable } in
1155
- fold_ty cx fold t
1169
+ htab_search_or_add cx.ctxt_type_effect_cache t
1170
+ (fun _ -> fold_ty cx fold t)
1156
1171
;;
1157
1172
1158
1173
let type_has_state (cx :ctxt ) (t :Ast.ty ) : bool =
@@ -1176,7 +1191,8 @@ let type_contains_chan (cx:ctxt) (t:Ast.ty) : bool =
1176
1191
let fold_chan _ = true in
1177
1192
let fold = ty_fold_bool_or false in
1178
1193
let fold = { fold with ty_fold_chan = fold_chan } in
1179
- fold_ty cx fold t
1194
+ htab_search_or_add cx.ctxt_type_contains_chan_cache t
1195
+ (fun _ -> fold_ty cx fold t)
1180
1196
;;
1181
1197
1182
1198
@@ -1214,7 +1230,8 @@ let n_used_type_params (cx:ctxt) t =
1214
1230
let fold_param (i ,_ ) = i+ 1 in
1215
1231
let fold = ty_fold_int_max 0 in
1216
1232
let fold = { fold with ty_fold_param = fold_param } in
1217
- fold_ty cx fold t
1233
+ htab_search_or_add cx.ctxt_n_used_type_parameters_cache t
1234
+ (fun _ -> fold_ty cx fold t)
1218
1235
;;
1219
1236
1220
1237
let check_concrete params thing =
0 commit comments