@@ -109,6 +109,8 @@ let stack_slot slot ty =
109109
110110(* Calling conventions *)
111111
112+ let size_domainstate_args = 64 * size_int
113+
112114let loc_int last_int make_stack int ofs =
113115 if ! int < = last_int then begin
114116 let l = phys_reg ! int in
@@ -149,41 +151,49 @@ let loc_int_pair last_int make_stack int ofs =
149151 [| stack_lower; stack_upper |]
150152 end
151153
152- let calling_conventions first_int last_int first_float last_float make_stack
153- arg =
154+ let calling_conventions first_int last_int first_float last_float
155+ make_stack first_stack arg =
154156 let loc = Array. make (Array. length arg) Reg. dummy in
155157 let int = ref first_int in
156158 let float = ref first_float in
157- let ofs = ref 0 in
159+ let ofs = ref first_stack in
158160 for i = 0 to Array. length arg - 1 do
159161 match arg.(i) with
160162 | Val | Int | Addr ->
161163 loc.(i) < - loc_int last_int make_stack int ofs
162164 | Float ->
163165 loc.(i) < - loc_float last_float make_stack float ofs
164166 done ;
165- (loc, Misc. align ! ofs 8 ) (* keep stack 8-aligned *)
166-
167- let incoming ofs = Incoming ofs
168- let outgoing ofs = Outgoing ofs
167+ (loc, Misc. align (max 0 ! ofs) 8 ) (* keep stack 8-aligned *)
168+
169+ let incoming ofs =
170+ if ofs > = 0
171+ then Incoming ofs
172+ else Domainstate (ofs + size_domainstate_args)
173+ let outgoing ofs =
174+ if ofs > = 0
175+ then Outgoing ofs
176+ else Domainstate (ofs + size_domainstate_args)
169177let not_supported _ofs = fatal_error " Proc.loc_results: cannot call"
170178
171179(* OCaml calling convention:
172180 first integer args in r0...r7
173181 first float args in d0...d15 (EABI+VFP)
174- remaining args on stack.
182+ remaining args in domain state area, then on stack.
175183 Return values in r0...r7 or d0...d15. *)
176184
177- let max_arguments_for_tailcalls = 8
185+ let max_arguments_for_tailcalls = 8 (* in regs *) + 64 (* in domain state *)
178186
179187let loc_arguments arg =
180- calling_conventions 0 7 100 115 outgoing arg
188+ calling_conventions 0 7 100 115 outgoing ( - size_domainstate_args) arg
181189
182190let loc_parameters arg =
183- let (loc, _) = calling_conventions 0 7 100 115 incoming arg in loc
191+ let (loc, _) =
192+ calling_conventions 0 7 100 115 incoming (- size_domainstate_args) arg
193+ in loc
184194
185195let loc_results res =
186- let (loc, _) = calling_conventions 0 7 100 115 not_supported res in loc
196+ let (loc, _) = calling_conventions 0 7 100 115 not_supported 0 res in loc
187197
188198(* C calling convention:
189199 first integer args in r0...r3
@@ -218,7 +228,7 @@ let loc_external_arguments ty_args =
218228 external_calling_conventions 0 3 100 107 outgoing ty_args
219229
220230let loc_external_results res =
221- let (loc, _) = calling_conventions 0 1 100 100 not_supported res
231+ let (loc, _) = calling_conventions 0 1 100 100 not_supported 0 res
222232 in loc
223233
224234let loc_exn_bucket = phys_reg 0
0 commit comments