You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In OCaml 4.13 or later, including the latest 5.1.1, Unnecessarily calling caml_call_gc is inserted in inside of loops, both of for-loops and recursive functions.
For example:
let f s = (
let result = ref 0 in
for i = 0 to String.length s do
result := !result + 1
done;
!result
)
Note, ocamlopt can eliminate the allocation for ref that is not taken out of the function.
What triggers is code that might have done this allocation, but did not as a result, like this.
e.g. inlined and removed closures.
Edited: The above trigger is my misunderstanding. The exact trigger is explained at #10039 (comment).
As you can see, (%r14) and %r15 are checked each time in the loop, and caml_call_gc may be called depending on the condition, even though they are not used.
It also can be reproduced in recursive functions.
Especially it is corresponds to most of the nested functions defined for recursion, even if they are inlined.
Is this the intended behavior?
The text was updated successfully, but these errors were encountered:
In OCaml 4.13 or later, including the latest 5.1.1, Unnecessarily calling caml_call_gc is inserted in inside of loops, both of for-loops and recursive functions.
For example:
Note, ocamlopt can eliminate the allocation forref
that is not taken out of the function.What triggers is code that might have done this allocation, but did not as a result, like this.
e.g. inlined and removed closures.
Edited: The above trigger is my misunderstanding. The exact trigger is explained at #10039 (comment).
Compile this with OCaml 4.12.1, in amd64 Linux:
Until this version, those were outputting efficient code.
OCaml 4.13.1:
As you can see,
(%r14)
and%r15
are checked each time in the loop, andcaml_call_gc
may be called depending on the condition, even though they are not used.OCaml 5.1.1:
Same as 4.13.1.
It also can be reproduced in recursive functions.
Especially it is corresponds to most of the nested functions defined for recursion, even if they are inlined.
Is this the intended behavior?
The text was updated successfully, but these errors were encountered: