Version française
Home     About     Download     Resources     Contact us    
Browse thread
R: Ocaml VM and bytecode
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Fabrice Le Fessant <fabrice.le_fessant@i...>
Subject: Re: R: Ocaml VM and bytecode

The -dinstr instruction causes the ocamlc compiler to output
(pretty-print) the list of bytecode instructions used to compile a
module. For example,

# cat > test.ml
let x = 3;;
^D
# ocamlc -c -dinstr test.ml
        const 3
        push
        acc 0
        makeblock 1, 0
        pop 1
        setglobal Test!

where the last 6 lines are the instructions generated for test.ml in
test.cmo. My patch allows to give such a file (in .ocb) to ocamlc to 
directly generate the .cmo file. By compiling to these instructions,
you will be able to generate .cmo files for any languages (the problem
of interfaces is not solved yet however).

For more information on the bytecode, you should have a look to the
ZINC paper of Xavier Leroy, and to sources of ocaml (such as
byterun/interp.c and bytecomp/printinstr.ml).

Regards,

- Fabrice