>I have met a CINT problem which I cannot seem to be able to resolve.
>I try to call an "interpreted" function ( loaded interactively by ".L" in
>root ) from a "compiled" shared library. Something like :
>-----------------------
>root [0] .L ntuple.so <- load the "compiled" shared library
>root [1] ntuple *n=new ntuple() <- create an "ntuple" object n
>root [2] .L test.cxx <- load the "interpreted" function
>root [3] n->Loop(test) <- "compiled" code calls "interpreted"
>-----------------------
>-----------------------
>On principle it works, but ... EXTREMELY slowly.
>The problem is that the G__isinterpretedp2f returns G__INTERPRETEDFUNC,
>instead of G__BYTECODEFUNC. The test.cxx does NOT seem to be "byte
>compiled" when loaded ( ".L" ), and used.
>Then I tried to test how it behaves in case everything is run as an
>"interpreted" code, so I modified the ntuple::Loop :
Your observation about bytecode and function to pointer is correct.
In order to compile test() function, you can try 2 things.
1) You include dummy compile function in order to compile test function.
test() {
// your staff
}
compile() {
for(int i=0;i<2;i++) test();
}
Then
root[0] .L test.cxx
root[1] compile()
root[2] test() <<< this is already bytecode
Drawback is that you need to run the function for nothing a couple of times.
2) Use .O10 command. .O10 command enforces function to be bytecoded at load
time.
root[0] .O10
root[1] .L test.cxx
root[2] .O4
root[2] test() <<< this is already bytecoded
Drawback is that this option is still premature. You may find bugs and
problems. Please get it back to .O4 after using it for test.cxx.
Thank you
Masaharu Goto