I have found out what the block handler was for... This following piece of code is miscompiled. The issue is that the OCaml bytecode program does not allocate a reference but update the stack in place. But we no longer keep track of this update.
let x = ref 0 in
try
incr x;
raise Exit
with Exit ->
Format.eprintf "%d@." !x
You have to compile it without the -g option. For instance:
ocamlc bug.ml -o bug.byte && js_of_ocaml bug.byte && ./bug.byte && node bug.js
The above command outputs 1 (correct) then 0 (wrong):