@@ -279,6 +279,19 @@ let emit_call_gc gc =
279
279
def_label gc.gc_frame;
280
280
I.jmp (label gc.gc_return_lbl)
281
281
282
+ (* Record calls to local stack reallocation *)
283
+
284
+ type local_realloc_call =
285
+ { lr_lbl: label;
286
+ lr_return_lbl: label; }
287
+
288
+ let local_realloc_sites = ref ([] : local_realloc_call list)
289
+
290
+ let emit_local_realloc lr =
291
+ def_label lr.lr_lbl;
292
+ emit_call "caml_call_local_realloc";
293
+ I.jmp (label lr.lr_return_lbl)
294
+
282
295
(* Record calls to caml_ml_array_bound_error.
283
296
In -g mode we maintain one call to
284
297
caml_ml_array_bound_error per bound check site. Without -g, we can share
@@ -657,12 +670,15 @@ let emit_instr fallthrough i =
657
670
(* FIXME: before or after check? Calling conv w/ realloc *)
658
671
I.mov r (domain_field Domainstate.Domain_local_sp);
659
672
I.cmp (domain_field Domainstate.Domain_local_limit) r;
660
- let lbl_ok = new_label () in
661
- I.j GE (label lbl_ok );
662
- emit_call "caml_call_local_realloc";
663
- def_label lbl_ok ;
673
+ let lbl_call = new_label () in
674
+ I.j L (label lbl_call );
675
+ let lbl_after_alloc = new_label () in
676
+ def_label lbl_after_alloc ;
664
677
I.add (domain_field Domainstate.Domain_local_top) r;
665
678
I.add (int 8) r;
679
+ local_realloc_sites :=
680
+ { lr_lbl = lbl_call;
681
+ lr_return_lbl = lbl_after_alloc } :: !local_realloc_sites
666
682
| Lop(Iintop(Icomp cmp)) ->
667
683
I.cmp (arg i 1) (arg i 0);
668
684
I.set (cond cmp) al;
@@ -885,6 +901,7 @@ let fundecl fundecl =
885
901
tailrec_entry_point := fundecl.fun_tailrec_entry_point_label;
886
902
stack_offset := 0;
887
903
call_gc_sites := [];
904
+ local_realloc_sites := [];
888
905
bound_error_sites := [];
889
906
bound_error_call := 0;
890
907
for i = 0 to Proc.num_register_classes - 1 do
@@ -908,6 +925,7 @@ let fundecl fundecl =
908
925
cfi_startproc ();
909
926
emit_all true fundecl.fun_body;
910
927
List.iter emit_call_gc !call_gc_sites;
928
+ List.iter emit_local_realloc !local_realloc_sites;
911
929
emit_call_bound_errors ();
912
930
if !frame_required then begin
913
931
let n = frame_size() - 8 - (if fp then 8 else 0) in
0 commit comments