develooper Front page | perl.perl6.internals | Postings from July 2002

pmc RECALL command for preprocessor

Thread Next
From:
Tanton Gibbs
Date:
July 20, 2002 19:25
Subject:
pmc RECALL command for preprocessor
Message ID:
003701c2305d$a3e3c3e0$f8ffa8c0@brooklyn
I implemented a RECALL preprocessor directive for the pmc classes.
Basically, if you have the following function

void
set_number_native(PMC* value) {
  CHANGE_TYPE(pmc, PerlNum);
  RECALL;
}

it will change the function to:

void
set_number_native( PMC* value) {
  CHANGE_TYPE(pmc, PerlNum);
  SELF->vtable->set_number_native(INTERP, SELF, value);
}

Thus ensuring that the correct semantics always occur.  However, this extra
function call slows things down somewhat.  I looped over the following code
10,000,000 times:

new P0, .PerlInt
set P0, 3.75    # converts to PerlNum

without the recall it performs in: 16.055 seconds
with the recall it performs in: 16.722 seconds

So, it slowed it down 6.5 tenths of a second after 10,000,000 times.  That
is not too bad for ensuring correct semantics.

What do you all think, should we pursue the function call
and accept a minor slowdown, should we attempt to automatically inline the
call, or should we abandon the RECALL idea altogether as a waste of time?

I have attached a modified pmc2c.pl and a modified
perlint.pmc for your enjoyment.  I also attached
my mops_p2.pasm test program.

Thanks!
Tanton

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About