The Never Ending Story ... Part (Int_t)341514

From: Jacek M. Holeczek (holeczek@us.edu.pl)
Date: Wed May 12 1999 - 17:02:49 MEST


Hi,
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"
-----------------------
The compiled ntuple::Loop function looks like :
-----------------------
Int_t ntuple::Loop(Int_t (*p2f)(ntuple *))
{
  ...
  switch(G__isinterpretedp2f(((void *)p2f)) {
  case G__INTERPRETEDFUNC:
    Char_t temp[200];
    sprintf(temp,"(*%s)(((ntuple *)%ld))",(char*)p2f,((long)this));
    for (Int_t i=0; i<nentries; i++) {
      nevents += GetEvent(i);
      if (G__int(G__calc(temp))) break;
    }
    break;
  case G__COMPILEDINTERFACEMETHOD:
    ...
  ...
  }
  return nevents;
}
-----------------------
The interpreted test function looks like :
-----------------------
Int_t test(ntuple *n)
{
  ...
  h_test->Fill(n->x()); // both h_test histogram and n::x() exist
  ...
  return 0;
}
-----------------------
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 :
-----------------------
Int_t ntuple::Loop(Int_t (*p2f)(ntuple *))
{
  ...
  Int_t result;
  for (Int_t i=0; i<nentries; i++) {
    nevents += GetEvent(i);
    result = (*p2f)(this);
    if (result) break;
  }
}
-----------------------
And instead of ".L ntuple.so" I loaded ".L ntuple.cxx".
The result was ... it was MUCH MORE slowly.
Thus, the conclusion is - CINT cannot "byte compile" functions if they are
used as "pointers" ???
On this occasion I have also met a CINT error. If in "interpreted" version
of ntuple::Loop I say :
	if ((*p2f)(this)) break;
instead of :
	result = (*p2f)(this);
	if (result) break;
the CINT cries :
-----------------------
root [4] n->Loop(test)
Error: No symbol p2f)(this in current scope FILE:/.../ntuple.cxx LINE:96
Error: Illegal pointer operation (tovalue) FILE:/.../ntuple.cxx LINE:96
*** Interpreter error recovered ***
-----------------------
Can I somehow convince CINT to give me "byte compiled" function(s) ?
Thanks in advance,
Jacek.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:32 MET