File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
testsuite/tests/typing-local Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -145,8 +145,8 @@ let may_allocate_in_region lam =
145
145
let rec loop_region lam =
146
146
shallow_iter ~tail: (function
147
147
| Lexclave body -> loop body
148
- | _ -> ()
149
- ) ~non_tail: (fun _ -> () ) lam
148
+ | lam -> loop_region lam
149
+ ) ~non_tail: (fun lam -> loop_region lam ) lam
150
150
and loop = function
151
151
| Lvar _ | Lmutvar _ | Lconst _ -> ()
152
152
Original file line number Diff line number Diff line change 1
1
(* TEST
2
+ include ocamlcommon
2
3
* native *)
3
4
4
5
external local_stack_offset : unit -> int = " caml_local_stack_offset"
@@ -246,4 +247,30 @@ let () =
246
247
create_and_ignore () ;
247
248
check_empty " mode-crossed region"
248
249
250
+ let [@ inline never] allocate_in_exclave a =
251
+ (* This needs to be a [while] so that we're allowed to have an [exclave_] *)
252
+ while
253
+ let pair = local_ opaque_identity (a, a) in
254
+ let b, _ = pair in
255
+ let b : int = b in
256
+ exclave_ (
257
+ (* This should allocate in the function's region - in particular, the
258
+ function needs to have one *)
259
+ let pair = local_ opaque_identity (b, b) in
260
+ let c, _ = pair in
261
+ c = 42 )
262
+ do
263
+ ()
264
+ done
265
+
266
+ let () =
267
+ let () =
268
+ (* Temporarily disable this test for flambda1 until it's fixed there *)
269
+ if not Config. flambda then
270
+ allocate_in_exclave 1
271
+ in
272
+ (* If [allocate_in_exclave] had its region elided, the allocation will have
273
+ happened in our region instead *)
274
+ check_empty " allocation from exclave"
275
+
249
276
let () = Gc. compact ()
Original file line number Diff line number Diff line change 27
27
dynamic/partial overapply: OK
28
28
method overapply: OK
29
29
mode-crossed region: OK
30
+ allocation from exclave: OK
You can’t perform that action at this time.
0 commit comments