When compiled with debug information enabled (option -g
), the bytecode carries so-called "event" structures marking for example the function entry and return point, which provide source location and typing information.
As a proof of concept of how to inspect this information, I have created a small branch of the ocamlpp tool (a small utility by Benoît Vaugon to inspect bytecode files) that prints this debug information alongside the bytecode instructions.
I have no idea whether js_of_ocaml
takes the necessary steps to preserve this location information throughout the compilation process. You should probably contact the maintainer, Jérôme Vouillon, to ask for more information.