@@ -1335,7 +1335,6 @@ let make_constr_matching p def ctx = function
1335
1335
(arg, Alias ) :: argl
1336
1336
else match cstr.cstr_tag with
1337
1337
| Cstr_block _ when
1338
- ! Config. bs_only &&
1339
1338
Datarepr. constructor_has_optional_shape cstr
1340
1339
->
1341
1340
begin
@@ -2280,7 +2279,6 @@ let split_extension_cases tag_lambda_list =
2280
2279
| (cstr , act ) :: rem ->
2281
2280
let (consts, nonconsts) = split_rec rem in
2282
2281
match cstr with
2283
- Cstr_extension (path , true ) when not ! Config. bs_only -> ((path, act) :: consts, nonconsts)
2284
2282
| Cstr_extension (path , _ ) -> (consts, (path, act) :: nonconsts)
2285
2283
| _ -> assert false in
2286
2284
split_rec tag_lambda_list
@@ -2309,17 +2307,13 @@ let combine_constructor sw_names loc arg ex_pat cstr partial ctx def
2309
2307
match nonconsts with
2310
2308
[] -> default
2311
2309
| _ ->
2312
- let tag = Ident. create " tag" in
2313
- let tests =
2314
- List. fold_right
2315
- (fun (path , act ) rem ->
2316
- let ext = transl_extension_path ex_pat.pat_env path in
2317
- Lifthenelse (Lprim (extension_slot_eq , [Lvar tag; ext], loc),
2318
- act, rem))
2319
- nonconsts
2320
- default
2321
- in
2322
- Llet (Alias , Pgenval ,tag, arg, tests)
2310
+ List. fold_right
2311
+ (fun (path , act ) rem ->
2312
+ let ext = transl_extension_path ex_pat.pat_env path in
2313
+ Lifthenelse (Lprim (extension_slot_eq , [arg; ext], loc),
2314
+ act, rem))
2315
+ nonconsts
2316
+ default
2323
2317
in
2324
2318
List. fold_right
2325
2319
(fun (path , act ) rem ->
@@ -2355,7 +2349,7 @@ let combine_constructor sw_names loc arg ex_pat cstr partial ctx def
2355
2349
(* Typically, match on lists, will avoid isint primitive in that
2356
2350
case *)
2357
2351
let arg =
2358
- if ! Config. bs_only && Datarepr. constructor_has_optional_shape cstr then
2352
+ if Datarepr. constructor_has_optional_shape cstr then
2359
2353
Lprim (is_not_none_bs_primitve , [arg], loc)
2360
2354
else arg
2361
2355
in
@@ -2452,10 +2446,7 @@ let combine_variant names loc row arg partial ctx def
2452
2446
else
2453
2447
num_constr := max_int;
2454
2448
let test_int_or_block arg if_int if_block =
2455
- if ! Config. bs_only then
2456
- Lifthenelse (Lprim (Pccall (Primitive. simple ~name: " #is_poly_var_block" ~arity: 1 ~alloc: false ), [arg], loc), if_block, if_int)
2457
- else
2458
- Lifthenelse (Lprim (Pisint , [arg], loc), if_int, if_block) in
2449
+ Lifthenelse (Lprim (Pccall (Primitive. simple ~name: " #is_poly_var_block" ~arity: 1 ~alloc: false ), [arg], loc), if_block, if_int) in
2459
2450
let sig_complete = List. length tag_lambda_list = ! num_constr
2460
2451
and one_action = same_actions tag_lambda_list in (* reduandant work under bs context *)
2461
2452
let fail, local_jumps =
@@ -3001,67 +2992,6 @@ let simple_for_let loc param pat body =
3001
2992
catch/exit.
3002
2993
*)
3003
2994
3004
- let rec map_return f = function
3005
- | Llet (str , k , id , l1 , l2 ) -> Llet (str, k, id, l1, map_return f l2)
3006
- | Lletrec (l1 , l2 ) -> Lletrec (l1, map_return f l2)
3007
- | Lifthenelse (lcond , lthen , lelse ) ->
3008
- Lifthenelse (lcond, map_return f lthen, map_return f lelse)
3009
- | Lsequence (l1 , l2 ) -> Lsequence (l1, map_return f l2)
3010
- | Ltrywith (l1 , id , l2 ) -> Ltrywith (map_return f l1, id, map_return f l2)
3011
- | Lstaticcatch (l1 , b , l2 ) ->
3012
- Lstaticcatch (map_return f l1, b, map_return f l2)
3013
- | Lstaticraise _ | Lprim (Praise _ , _ , _ ) as l -> l
3014
- | l -> f l
3015
-
3016
- (* The 'opt' reference indicates if the optimization is worthy.
3017
-
3018
- It is shared by the different calls to 'assign_pat' performed from
3019
- 'map_return'. For example with the code
3020
- let (x, y) = if foo then z else (1,2)
3021
- the else-branch will activate the optimization for both branches.
3022
-
3023
- That means that the optimization is activated if *there exists* an
3024
- interesting tuple in one hole of the let-rhs context. We could
3025
- choose to activate it only if *all* holes are interesting. We made
3026
- that choice because being optimistic is extremely cheap (one static
3027
- exit/catch overhead in the "wrong cases"), while being pessimistic
3028
- can be costly (one unnecessary tuple allocation).
3029
- *)
3030
-
3031
- let assign_pat opt nraise catch_ids loc pat lam =
3032
- let rec collect acc pat lam = match pat.pat_desc, lam with
3033
- | Tpat_tuple patl , Lprim (Pmakeblock _ , lams , _ ) ->
3034
- opt := true ;
3035
- List. fold_left2 collect acc patl lams
3036
- | Tpat_tuple patl , Lconst (Const_block( _ , scl )) ->
3037
- opt := true ;
3038
- let collect_const acc pat sc = collect acc pat (Lconst sc) in
3039
- List. fold_left2 collect_const acc patl scl
3040
- | _ ->
3041
- (* pattern idents will be bound in staticcatch (let body), so we
3042
- refresh them here to guarantee binders uniqueness *)
3043
- let pat_ids = pat_bound_idents pat in
3044
- let fresh_ids = List. map (fun id -> id, Ident. rename id) pat_ids in
3045
- (fresh_ids, alpha_pat fresh_ids pat, lam) :: acc
3046
- in
3047
-
3048
- (* sublets were accumulated by 'collect' with the leftmost tuple
3049
- pattern at the bottom of the list; to respect right-to-left
3050
- evaluation order for tuples, we must evaluate sublets
3051
- top-to-bottom. To preserve tail-rec, we will fold_left the
3052
- reversed list. *)
3053
- let rev_sublets = List. rev (collect [] pat lam) in
3054
- let exit =
3055
- (* build an Ident.tbl to avoid quadratic refreshing costs *)
3056
- let add t (id , fresh_id ) = Ident. add id fresh_id t in
3057
- let add_ids acc (ids , _pat , _lam ) = List. fold_left add acc ids in
3058
- let tbl = List. fold_left add_ids Ident. empty rev_sublets in
3059
- let fresh_var id = Lvar (Ident. find_same id tbl) in
3060
- Lstaticraise (nraise, List. map fresh_var catch_ids)
3061
- in
3062
- let push_sublet code (_ids , pat , lam ) = simple_for_let loc lam pat code in
3063
- List. fold_left push_sublet exit rev_sublets
3064
-
3065
2995
let for_let loc param pat body =
3066
2996
match pat.pat_desc with
3067
2997
| Tpat_any ->
@@ -3072,15 +3002,7 @@ let for_let loc param pat body =
3072
3002
(* fast path, and keep track of simple bindings to unboxable numbers *)
3073
3003
Llet (Strict , Pgenval , id, param, body)
3074
3004
| _ ->
3075
- (* Turn off such optimization to reduce diff in the beginning - FIXME*)
3076
- if ! Config. bs_only then simple_for_let loc param pat body
3077
- else
3078
- let opt = ref false in
3079
- let nraise = next_raise_count () in
3080
- let catch_ids = pat_bound_idents pat in
3081
- let bind = map_return (assign_pat opt nraise catch_ids loc pat) param in
3082
- if ! opt then Lstaticcatch (bind, (nraise, catch_ids), body)
3083
- else simple_for_let loc param pat body
3005
+ simple_for_let loc param pat body
3084
3006
3085
3007
(* Handling of tupled functions and matchings *)
3086
3008
0 commit comments