Skip to content

Commit 103b139

Browse files
authored
Remove various FIXMEs (#46)
- runtime: Already_scanned optimisation is not supported - runtime: Backwards local pointers are not possible - lambda: make function with no cases fatal - typing, lambda: remove various already-fixed FIXMEs - lambda: remove / convert to TODO some primitives FIXMEs - typing, lambda: remove local lazy support - selectgen: allow region fusion across try
1 parent 62ba2c1 commit 103b139

File tree

14 files changed

+36
-67
lines changed

14 files changed

+36
-67
lines changed

asmcomp/cmm_helpers.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ let unboxed_float_array_ref arr ofs dbg =
760760
let float_array_ref arr ofs dbg =
761761
box_float dbg Alloc_heap (unboxed_float_array_ref arr ofs dbg)
762762

763-
(* FIXME local arrays *)
763+
(* TODO support mutation of local arrays *)
764764
let addr_array_set arr ofs newval dbg =
765765
Cop(Cextcall("caml_modify", typ_void, [], false),
766766
[array_indexing log2_size_addr arr ofs dbg; newval], dbg)
@@ -1396,8 +1396,8 @@ let int64_native_prim name arity ~alloc =
13961396
~native_repr_args:(make_args arity)
13971397
~native_repr_res:u64
13981398

1399-
(* FIXME: On 32-bit, these will do heap allocations
1400-
even when local allocs are possible *)
1399+
(* TODO: On 32-bit, these will do heap allocations even in situations
1400+
where local allocs are allowed *)
14011401
let simplif_primitive_32bits :
14021402
Clambda_primitives.primitive -> Clambda_primitives.primitive = function
14031403
Pbintofint (Pint64,_) -> Pccall (default_prim "caml_int64_of_int")
@@ -2439,11 +2439,12 @@ type ternary_primitive =
24392439

24402440
let setfield_computed ptr init arg1 arg2 arg3 dbg =
24412441
match assignment_kind ptr init with
2442-
(* FIXME local *)
24432442
| Caml_modify ->
24442443
return_unit dbg (addr_array_set arg1 arg2 arg3 dbg)
24452444
| Caml_modify_local ->
2446-
return_unit dbg (addr_array_set arg1 arg2 arg3 dbg)
2445+
(* TODO: support this, if there are any uses.
2446+
(Currently, setfield_computed is only used by classes) *)
2447+
Misc.fatal_error "setfield_computed: local"
24472448
| Simple ->
24482449
return_unit dbg (int_array_set arg1 arg2 arg3 dbg)
24492450

asmcomp/cmmgen.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ let rec transl env e =
501501
bigarray_get unsafe elt_kind layout
502502
(transl env arg1) (List.map (transl env) argl) dbg in
503503
begin match elt_kind with
504-
(* FIXME allow local allocs *)
504+
(* TODO: local alloaction of bigarray elements *)
505505
Pbigarray_float32 | Pbigarray_float64 -> box_float dbg Alloc_heap elt
506506
| Pbigarray_complex32 | Pbigarray_complex64 -> elt
507507
| Pbigarray_int32 -> box_int dbg Pint32 Alloc_heap elt
@@ -790,11 +790,10 @@ and transl_ccall env prim args dbg =
790790
let typ_res, wrap_result =
791791
match prim.prim_native_repr_res with
792792
| _, Same_as_ocaml_repr -> (typ_val, fun x -> x)
793-
(* FIXME allow Alloc_local *)
793+
(* TODO: Allow Alloc_local on suitably typed C stubs *)
794794
| _, Unboxed_float -> (typ_float, box_float dbg Alloc_heap)
795795
| _, Unboxed_integer Pint64 when size_int = 4 ->
796796
([|Int; Int|], box_int dbg Pint64 Alloc_heap)
797-
(* FIXME: Allow Alloc_local on suitably typed C stubs? *)
798797
| _, Unboxed_integer bi -> (typ_int, box_int dbg bi Alloc_heap)
799798
| _, Untagged_int -> (typ_int, (fun i -> tag_int i dbg))
800799
in

asmcomp/selectgen.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,7 @@ method emit_expr (env:environment) exp =
849849
None
850850
end
851851
| Ctrywith(e1, v, e2, _dbg) ->
852-
(* FIXME: region/trywith interaction? match with exception? *)
853-
let (r1, s1) = self#emit_sequence env' e1 in
852+
let (r1, s1) = self#emit_sequence env e1 in
854853
let rv = self#regs_for typ_val in
855854
let (r2, s2) = self#emit_sequence (env_add v rv env) e2 in
856855
let r = join env r1 s1 r2 s2 in
@@ -1173,7 +1172,6 @@ method emit_tail (env:environment) exp =
11731172
self#insert env (Icatch(rec_flag, List.map aux handlers, s_body))
11741173
[||] [||]
11751174
| Ctrywith(e1, v, e2, _dbg) ->
1176-
(* FIXME regions *)
11771175
let (opt_r1, s1) = self#emit_sequence env e1 in
11781176
let rv = self#regs_for typ_val in
11791177
let s2 = self#emit_tail_sequence (env_add v rv env) e2 in

lambda/matching.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ let get_expr_args_record ~scopes head (arg, _mut) rem =
19731973
Lprim (Pfield lbl.lbl_pos, [ arg ], loc)
19741974
| Record_unboxed _ -> arg
19751975
| Record_float ->
1976-
(* FIXME: could be Alloc_local sometimes *)
1976+
(* TODO: could optimise to Alloc_local sometimes *)
19771977
Lprim (Pfloatfield (lbl.lbl_pos, Alloc_heap), [ arg ], loc)
19781978
| Record_extension _ -> Lprim (Pfield (lbl.lbl_pos + 1), [ arg ], loc)
19791979
in

lambda/simplif.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ let split_default_wrapper ~id:fun_id ~kind ~params ~return ~body
761761
(wrapper_body, (inner_id, inner_fun))
762762
in
763763
try
764-
(* FIXME: this optimisation is disabled in the presence of local returns *)
764+
(* TODO: enable this optimisation even in the presence of local returns *)
765765
begin match kind with
766766
| Curried {nlocal} when nlocal > 0 -> raise Exit
767767
| _ -> ()

lambda/translattribute.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ let get_bool_from_exp exp =
101101
| _ -> Result.Error ())
102102

103103
let parse_id_payload txt loc ~default ~empty cases payload =
104-
let(*FIXME[@local]*) warn () =
104+
let[@local] warn () =
105105
let ( %> ) f g x = g (f x) in
106106
let msg =
107107
cases

lambda/translclass.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ let transl_class ~scopes ids cl_id pub_meths cl vflag =
730730
in
731731
let new_ids_meths = ref [] in
732732
let no_env_update _ _ env = env in
733-
(* FIXME *)
734733
let msubst arr = function
735734
Lfunction {kind = Curried _ as kind;
736735
params = (self, Pgenval) :: args; body} ->

lambda/translcore.ml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ and transl_exp0 ~in_new_scope ~scopes e =
601601
(* when e needs no computation (constants, identifiers, ...), we
602602
optimize the translation just as Lazy.lazy_from_val would
603603
do *)
604+
assert (transl_value_mode e.exp_mode = Alloc_heap);
604605
begin match Typeopt.classify_lazy_argument e with
605606
| `Constant_or_function ->
606607
(* A constant expr (of type <> float if [Config.flat_float_array] is
@@ -611,7 +612,7 @@ and transl_exp0 ~in_new_scope ~scopes e =
611612
block will never be shortcutted since it points to a float
612613
and Config.flat_float_array is true. *)
613614
Lprim(Pmakeblock(Obj.forward_tag, Immutable, None,
614-
transl_value_mode e.exp_mode),
615+
Alloc_heap),
615616
[transl_exp ~scopes e], of_location ~scopes e.exp_loc)
616617
| `Identifier `Forward_value ->
617618
(* CR-someday mshinwell: Consider adding a new primitive
@@ -622,25 +623,24 @@ and transl_exp0 ~in_new_scope ~scopes e =
622623
value may subsequently turn into an immediate... *)
623624
Lprim (Popaque,
624625
[Lprim(Pmakeblock(Obj.forward_tag, Immutable, None,
625-
transl_value_mode e.exp_mode),
626+
Alloc_heap),
626627
[transl_exp ~scopes e],
627628
of_location ~scopes e.exp_loc)],
628629
of_location ~scopes e.exp_loc)
629630
| `Identifier `Other ->
630631
transl_exp ~scopes e
631632
| `Other ->
632633
(* other cases compile to a lazy block holding a function *)
633-
let mode = transl_value_mode e.exp_mode in (* FIXME test *)
634634
let fn = Lfunction {kind = Curried {nlocal=0};
635635
params= [Ident.create_local "param", Pgenval];
636636
return = Pgenval;
637637
attr = default_function_attribute;
638638
loc = of_location ~scopes e.exp_loc;
639-
mode;
639+
mode = Alloc_heap;
640640
ret_mode = Alloc_heap;
641641
body = transl_exp ~scopes e} in
642642
Lprim(Pmakeblock(Config.lazy_tag, Mutable, None,
643-
mode), [fn],
643+
Alloc_heap), [fn],
644644
of_location ~scopes e.exp_loc)
645645
end
646646
| Texp_object (cs, meths) ->
@@ -940,8 +940,7 @@ and transl_function0
940940
let arg_mode, ret_mode, kind =
941941
match cases with
942942
| [] ->
943-
(* With Camlp4, a pattern matching might be empty *)
944-
Alloc_heap, Alloc_heap, Pgenval (* FIXME can this happen? *)
943+
Misc.fatal_error "transl_function0: no cases"
945944
| {c_lhs=pat;c_rhs} :: other_cases ->
946945
(* All the patterns might not share the same types. We must take the
947946
union of the patterns types *)
@@ -1283,12 +1282,12 @@ and transl_letop ~scopes loc env let_ ands param case partial =
12831282
event_function ~scopes case.c_rhs
12841283
(function repr ->
12851284
transl_curried_function ~scopes case.c_rhs.exp_loc return_kind
1286-
repr ~mode:Alloc_heap (*FIXME*) partial param [case])
1285+
repr ~mode:Alloc_heap partial param [case])
12871286
in
12881287
let attr = default_function_attribute in
12891288
let loc = of_location ~scopes case.c_rhs.exp_loc in
12901289
Lfunction{kind; params; return; body; attr; loc;
1291-
mode=Alloc_heap(*FIXME*); ret_mode (* FIXME *)}
1290+
mode=Alloc_heap; ret_mode}
12921291
in
12931292
Lapply{
12941293
ap_loc = of_location ~scopes loc;

runtime/caml/stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#else
4545
#error "TARGET_power: wrong MODEL"
4646
#endif
47-
/* FIXME: Already_scanned optimisation not supported on this branch
47+
/* Already_scanned optimisation not supported on this branch
4848
#define Already_scanned(sp, retaddr) ((retaddr) & 1)
4949
#define Mask_already_scanned(retaddr) ((retaddr) & ~1)
5050
#define Mark_scanned(sp, retaddr) Saved_return_address(sp) = (retaddr) | 1

runtime/roots_nat.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,10 @@ static void do_local_allocations(caml_local_arenas* loc,
481481
/* forwards pointer, common case */
482482
CAMLassert(ix <= arena_ix);
483483
} else {
484-
/* FIXME: backwards pointer.
485-
This should reset sp and iterate to a fixpoint */
484+
/* If backwards pointers are ever supported (e.g. local recursive
485+
values), then this should reset sp and iterate to a fixpoint */
486486
CAMLassert(ix >= arena_ix);
487-
caml_fatal_error("FIXME: backwards local pointer");
487+
caml_fatal_error("backwards local pointer");
488488
}
489489
}
490490
}

testsuite/tests/typing-local/local.ml

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -787,32 +787,13 @@ Error: This value escapes its region
787787
(* Don't escape through a lazy value *)
788788

789789
let foo (local_ x) =
790-
lazy (print_string !x)
791-
[%%expect{|
792-
Line 2, characters 22-23:
793-
2 | lazy (print_string !x)
794-
^
795-
Error: The value x is local, so cannot be used inside a closure that might escape
796-
|}]
797-
798-
let foo (local_ x) =
799-
let l = lazy (print_string !x) in
800-
l
801-
[%%expect{|
802-
Line 3, characters 2-3:
803-
3 | l
804-
^
805-
Error: This local value escapes its region
806-
Hint: Cannot return local value without an explicit "local_" annotation
807-
|}]
808-
809-
810-
let foo (local_ x) =
811-
let l = lazy (print_string !x) in
812-
let lazy () = l in
790+
let _ = lazy (print_string !x) in
813791
()
814792
[%%expect{|
815-
val foo : local_ string ref -> unit = <fun>
793+
Line 2, characters 30-31:
794+
2 | let _ = lazy (print_string !x) in
795+
^
796+
Error: The value x is local, so cannot be used inside a closure that might escape
816797
|}]
817798

818799
(* Don't escape through a functor *)
@@ -1718,7 +1699,7 @@ Error: Wrong arity for builtin primitive "%int32_add"
17181699
|}]
17191700

17201701
(*
1721-
FIXME: perhaps allow this, but requires caml_compare changes (Is_in_value_area)
1702+
TODO: perhaps allow this, but requires caml_compare changes (Is_in_value_area)
17221703
let compare (local_ x) (local_ y) =
17231704
[x = y; x <> y; x < y; x > y; x <= y; x >= y; compare x y = 0; x == y; x != y]
17241705
[%%expect{|
@@ -1737,8 +1718,3 @@ let promote (local_ x) = +x
17371718
[%%expect{|
17381719
val promote : local_ int -> int = <fun>
17391720
|}]
1740-
1741-
(* In debug mode, Gc.minor () checks for minor heap->local pointers *)
1742-
let () = Gc.minor ()
1743-
[%%expect{|
1744-
|}]

typing/ctype.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ val unify_gadt:
274274
val unify_var: Env.t -> type_expr -> type_expr -> unit
275275
(* Same as [unify], but allow free univars when first type
276276
is a variable. *)
277+
val unify_alloc_mode: alloc_mode -> alloc_mode -> unit
277278
val filter_arrow: Env.t -> type_expr -> arg_label ->
278279
alloc_mode * type_expr * alloc_mode * type_expr
279280
(* A special case of unification (with l:'a -> 'b). *)

typing/env.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ module IdTbl =
285285
}
286286

287287
let add_lock mode next =
288-
(* FIXME optimisation: shared lock on shared ctx should be no-op *)
289288
{ current = Ident.empty; layer = Lock {mode; next} }
290289

291290
let map f next =

typing/typecore.ml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,7 +3586,7 @@ and type_expect_
35863586
None -> None
35873587
| Some sexp ->
35883588
if !Clflags.principal then begin_def ();
3589-
(* FIXME: mode can be more relaxed than this if fields are nonlocal *)
3589+
(* TODO: mode can be more relaxed than this if fields are nonlocal *)
35903590
let exp = type_exp ~recarg env (mode_subcomponent expected_mode) sexp in
35913591
if !Clflags.principal then begin
35923592
end_def ();
@@ -4011,9 +4011,11 @@ and type_expect_
40114011
filter_self_method env met Private meths privty
40124012
in
40134013
let method_type = newvar () in
4014-
let (_marg_FIXME, obj_ty, _mres_FIXME, res_ty) =
4014+
let (marg, obj_ty, mres, res_ty) =
40154015
filter_arrow env method_type Nolabel
40164016
in
4017+
unify_alloc_mode marg Alloc_mode.global;
4018+
unify_alloc_mode mres Alloc_mode.global;
40174019
unify env obj_ty desc.val_type;
40184020
unify env res_ty (instance typ);
40194021
let method_desc =
@@ -4256,14 +4258,11 @@ and type_expect_
42564258
exp_env = env;
42574259
}
42584260
| Pexp_lazy e ->
4259-
register_allocation expected_mode;
4260-
let closure_mode = Value_mode.regional_to_global expected_mode.mode in
42614261
let ty = newgenvar () in
42624262
let to_unify = Predef.type_lazy_t ty in
42634263
with_explanation (fun () ->
42644264
unify_exp_types loc env to_unify (generic_instance ty_expected));
4265-
let env = Env.add_lock closure_mode env in
4266-
let env = Env.add_region_lock env in
4265+
let env = Env.add_lock Value_mode.global env in
42674266
let arg = type_expect env mode_global e (mk_expected ty) in
42684267
re {
42694268
exp_desc = Texp_lazy arg;
@@ -4421,7 +4420,6 @@ and type_expect_
44214420
exp_env = env;
44224421
}
44234422
| Pexp_letop{ let_ = slet; ands = sands; body = sbody } ->
4424-
(* FIXME: Allow local mode binding operators *)
44254423
let rec loop spat_acc ty_acc sands =
44264424
match sands with
44274425
| [] -> spat_acc, ty_acc
@@ -5888,7 +5886,6 @@ and type_let
58885886
let l =
58895887
List.map2
58905888
(fun ((_,p), (e, _)) pvb ->
5891-
(* FIXME: maybe we want modes in the vb? *)
58925889
{vb_pat=p; vb_expr=e; vb_attributes=pvb.pvb_attributes;
58935890
vb_loc=pvb.pvb_loc;
58945891
})

0 commit comments

Comments
 (0)