File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ let rec combine i allocstate =
7070 i.arg i.res i.dbg next, allocstate)
7171 end
7272 | Iop (Icall_ind | Icall_imm _ | Iextcall _ |
73- Itailcall_ind | Itailcall_imm _ ) ->
73+ Itailcall_ind | Itailcall_imm _ |
74+ Iintop Icheckbound | Iintop_imm (Icheckbound, _ )) ->
7475 let newnext = combine_restart i.next in
7576 (instr_cons_debug i.desc i.arg i.res i.dbg newnext,
7677 allocstate)
Original file line number Diff line number Diff line change @@ -343,12 +343,13 @@ method is_simple_expr = function
343343 | Cop (op , args , _ ) ->
344344 begin match op with
345345 (* The following may have side effects *)
346- | Capply _ | Cextcall _ | Calloc _ | Cstore _ | Craise _ -> false
346+ | Capply _ | Cextcall _ | Calloc _ | Cstore _
347+ | Craise _ | Ccheckbound -> false
347348 (* The remaining operations are simple if their args are *)
348349 | Cload _ | Caddi | Csubi | Cmuli | Cmulhi | Cdivi | Cmodi | Cand | Cor
349350 | Cxor | Clsl | Clsr | Casr | Ccmpi _ | Caddv | Cadda | Ccmpa _ | Cnegf
350351 | Cabsf | Caddf | Csubf | Cmulf | Cdivf | Cfloatofint | Cintoffloat
351- | Ccmpf _ | Ccheckbound -> List. for_all self#is_simple_expr args
352+ | Ccmpf _ -> List. for_all self#is_simple_expr args
352353 end
353354 | Cassign _ | Cifthenelse _ | Cswitch _ | Ccatch _ | Cexit _
354355 | Ctrywith _ | Cregion _ | Ctail _ -> false
Original file line number Diff line number Diff line change 1+ (* TEST
2+ * native *)
3+
4+ let glob = ref (1 , 2 )
5+ let [@ inline never] combine1 x a =
6+ begin try
7+ glob := (2 , x);
8+ glob := (3 , a.(4 ));
9+ with
10+ | Invalid_argument _ -> ()
11+ end ;
12+ ! glob
13+
14+ let [@ inline never] combine2 x a =
15+ let loc = ref (1 , 2 ) in
16+ begin try
17+ loc := (2 , x);
18+ loc := (3 , a.(4 ));
19+ with
20+ | Invalid_argument _ -> ()
21+ end ;
22+ ! loc
23+
24+ let [@ inline never] measure f =
25+ let empty_array = [| |] in
26+ let prebefore = Gc. minor_words () in
27+ let before = Gc. minor_words () in
28+ let r = f 42 empty_array in
29+ assert (r = (2 , 42 ));
30+ let after = Gc. minor_words () in
31+ ((after -. before) -. (before -. prebefore))
32+
33+
34+ let () =
35+ Printf. printf " %10s: %.0f\n " " combine1" (measure combine1);
36+ Printf. printf " %10s: %.0f\n " " combine2" (measure combine2)
Original file line number Diff line number Diff line change 1+ combine1: 3
2+ combine2: 3
You can’t perform that action at this time.
0 commit comments