-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure allocations are initialised, even dead ones
(See #405)
- Loading branch information
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(* TEST | ||
* native *) | ||
|
||
let glob = ref (1, 2) | ||
let[@inline never] combine1 x a = | ||
begin try | ||
glob := (2, x); | ||
glob := (3, a.(4)); | ||
with | ||
| Invalid_argument _ -> () | ||
end; | ||
!glob | ||
|
||
let[@inline never] combine2 x a = | ||
let loc = ref (1, 2) in | ||
begin try | ||
loc := (2, x); | ||
loc := (3, a.(4)); | ||
with | ||
| Invalid_argument _ -> () | ||
end; | ||
!loc | ||
|
||
let[@inline never] measure f = | ||
let empty_array = [| |] in | ||
let prebefore = Gc.minor_words () in | ||
let before = Gc.minor_words () in | ||
let r = f 42 empty_array in | ||
assert (r = (2, 42)); | ||
let after = Gc.minor_words () in | ||
((after -. before) -. (before -. prebefore)) | ||
|
||
|
||
let () = | ||
Printf.printf "%10s: %.0f\n" "combine1" (measure combine1); | ||
Printf.printf "%10s: %.0f\n" "combine2" (measure combine2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
combine1: 3 | ||
combine2: 3 |