OCaml bytecode instructions

Where can I find documentation for the OCaml bytecode instructions ?

In The Compiler Backend: Bytecode and Native code - Real World OCaml, it is explained how to output the bytecode using ocamlc -dinstr (which is not mentioned in OCaml - Batch compilation (ocamlc)) and they point for details to http://cadmium.x9c.fr/distrib/caml-instructions.pdf but that document is from 2010, and it does not mention the instruction I am interested in.

Indeed, some of my code generates the bytecode instruction strictbranchif, for which I cannot find any information.

If I understand the code correctly, ocaml/bytecomp/emitcode.ml seems to imply that it has the same meaning as branchif(?) and ocaml/bytecomp/bytegen.ml seems to imply that it is generated in specific conditions involving && and ||(?)

This makes me think that the instruction strictbranchif is currently a synonym to branchif, and maybe it was created to be used for future optimizations ?

The instructions strictbranchif and straictbranchifnot are identical to branchif and branchifnot as far as the virtual machine is concerned. The difference is that they disable certain optimizations of the bytecode peephole optimizer necessary to correctly compile short-circuit operators && and ||.

This is explained in page 73 and 74 of the ZINC paper.

Cheers,
Nicolas

3 Likes