Dear Pietro, as far as I remember the bytecode is on the outer level a sequence of functions/definitions, and some of them can be recursive, as if the whole program looked like a sequence let rec f1 = ... and f2 = ... and f3 = ... let rec g1 = ... and g2 = ... and g3 = ... and so on. Closures are transformed into such functions, as well as higher-level stuff like modules. You could take these let rec clusters as your chunks. For analyzing the structure of the bytecode, have also a look at the js_of_ocaml sources, which is restoring the functional structure from the bytecode. Gerd On 26.04.18 14:22, pietro braione wrote: > Dear all, > I am building a toy implementation of a JIT compiler for the ocaml interpreter, but I am clueless about how to define the compilation units. The compiler is on the trivial-but-fast side (remember, it’s just a toy), so I would avoid the complexity of a tracing jit, at least by now. This means: statically divide the bytecode into chunks and profile/compile at the granularity of these chunks. The problem is, I have no idea what a decent criterion for chunking the bytecode could be. Does anyone have an idea at the regard? > Thank you > Pietro > -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de My OCaml site: http://www.camlcity.org Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------