@@ -236,6 +236,19 @@ let emit_call_gc gc =
236
236
def_label gc.gc_frame;
237
237
I.jmp (label gc.gc_return_lbl)
238
238
239
+ (* Record calls to local stack reallocation *)
240
+
241
+ type local_realloc_call =
242
+ { lr_lbl: label;
243
+ lr_return_lbl: label; }
244
+
245
+ let local_realloc_sites = ref ([] : local_realloc_call list)
246
+
247
+ let emit_local_realloc lr =
248
+ def_label lr.lr_lbl;
249
+ emit_call "caml_call_local_realloc";
250
+ I.jmp (label lr.lr_return_lbl)
251
+
239
252
(* Record calls to caml_ml_array_bound_error.
240
253
In -g mode, we maintain one call to caml_ml_array_bound_error
241
254
per bound check site. Without -g, we can share a single call. *)
@@ -608,7 +621,7 @@ let emit_instr fallthrough i =
608
621
I.fstp (addressing addr REAL8 i 1)
609
622
end
610
623
end
611
- | Lop(Ialloc { bytes = n; dbginfo }) ->
624
+ | Lop(Ialloc { bytes = n; dbginfo; mode = Alloc_heap }) ->
612
625
if !fastcode_flag then begin
613
626
load_domain_state ebx;
614
627
I.mov (domain_field Domain_young_ptr RBX) eax;
@@ -643,6 +656,21 @@ let emit_instr fallthrough i =
643
656
def_label label;
644
657
I.lea (mem32 NONE 4 RAX) (reg i.res.(0))
645
658
end
659
+ | Lop(Ialloc {bytes = n; dbginfo=_; mode = Alloc_local }) ->
660
+ load_domain_state ebx;
661
+ I.mov (domain_field Domainstate.Domain_local_sp RBX) eax;
662
+ I.sub (int n) eax;
663
+ I.mov eax (domain_field Domainstate.Domain_local_sp RBX);
664
+ I.cmp (domain_field Domainstate.Domain_local_limit RBX) eax;
665
+ let lbl_call = new_label () in
666
+ I.j L (label lbl_call);
667
+ let lbl_after_alloc = new_label () in
668
+ def_label lbl_after_alloc;
669
+ I.add (domain_field Domainstate.Domain_local_top RBX) eax;
670
+ I.lea (mem32 NONE 4 RAX) (reg i.res.(0));
671
+ local_realloc_sites :=
672
+ { lr_lbl = lbl_call;
673
+ lr_return_lbl = lbl_after_alloc } :: !local_realloc_sites
646
674
| Lop(Iintop(Icomp cmp)) ->
647
675
I.cmp (reg i.arg.(1)) (reg i.arg.(0));
648
676
I.set (cond cmp) al;
@@ -799,6 +827,16 @@ let emit_instr fallthrough i =
799
827
if Array.length i.arg = 2 && is_tos i.arg.(1) then
800
828
I.fxch st1;
801
829
emit_floatspecial s
830
+ | Lop (Ibeginregion) ->
831
+ load_domain_state ebx;
832
+ I.mov (domain_field Domainstate.Domain_local_sp RBX) (reg i.res.(0))
833
+ | Lop (Iendregion) ->
834
+ I.mov (reg i.arg.(0)) eax;
835
+ load_domain_state ebx;
836
+ I.sub (domain_field Domainstate.Domain_local_sp RBX) eax;
837
+ I.add eax (domain_field Domainstate.Domain_local_total RBX);
838
+ I.add (domain_field Domainstate.Domain_local_sp RBX) eax;
839
+ I.mov eax (domain_field Domainstate.Domain_local_sp RBX)
802
840
| Lop (Iname_for_debugger _) -> ()
803
841
| Lreloadretaddr ->
804
842
()
@@ -922,6 +960,7 @@ let fundecl fundecl =
922
960
tailrec_entry_point := fundecl.fun_tailrec_entry_point_label;
923
961
stack_offset := 0;
924
962
call_gc_sites := [];
963
+ local_realloc_sites := [];
925
964
bound_error_sites := [];
926
965
bound_error_call := 0;
927
966
for i = 0 to Proc.num_register_classes - 1 do
@@ -937,6 +976,7 @@ let fundecl fundecl =
937
976
cfi_startproc ();
938
977
emit_all true fundecl.fun_body;
939
978
List.iter emit_call_gc !call_gc_sites;
979
+ List.iter emit_local_realloc !local_realloc_sites;
940
980
emit_call_bound_errors ();
941
981
cfi_endproc ();
942
982
begin match system with
0 commit comments