On Mon, 2005-05-02 at 08:58 +0200, Leopold Toetsch wrote: > Nicholas Clark <[EMAIL PROTECTED]> wrote:
> > 1 bit for SVf_IOK > > 1 bit for SVf_NOK > > 1 bit for SVf_POK > > 1 bit for SVf_ROK > > I'd not mess around with (or introduce) flag bits. The more that this > would only cover perl5 PMCs. Presuming that the Perl5 PMCs are subtypes > of Parrot core PMCs, I'd do ... [... code doing a string "isa" check on the type ...] > The vtable functions C<isa> and C<does>, which take now a string, are a > bit heavy-weighted and might get an extension in the log run that take > an integer flag. Unless this happens, this would be a HUGE performance hit. After all, Sv*OK is called all over the place in the Perl 5 code, including many places where performance is an issue. [...] > > 2 bits to say what we're storing in the union > > The vtable is that information: > > INTVAL i = VTABLE_get_integer(interpreter, pmc); > FLOATVAL n = VTABLE_get_number(interpreter, pmc); Here is some example P5 source from pp_pow in pp.c: if (SvIOK(TOPm1s)) { bool baseuok = SvUOK(TOPm1s); UV baseuv; if (baseuok) { baseuv = SvUVX(TOPm1s); } else { IV iv = SvIVX(TOPm1s); and here that is, run through the C pre-processor: pre-processor: if ((((*(sp-1)))->sv_flags & 0x00010000)) { char baseuok = ((((*(sp-1)))->sv_flags & (0x00010000|0x80000000)) == (0x00010000|0x80000000)); UV baseuv; if (baseuok) { baseuv = ((XPVUV*) ((*(sp-1)))->sv_any)->xuv_uv; } else { IV iv = ((XPVIV*) ((*(sp-1)))->sv_any)->xiv_iv; Notice that there is exactly no function calling going on there. To change that to (pseudocode): if (isa_int_test(TOPm1s)) { bool baseuok = isa_uint_test(TOPm1s); UV baseuv; if (baseuok) { baseuv = invoke_uint_vtable_get(TOPm1s); } else { IV iv = invoke_int_vtable_get(TOPm1s); Well... even after JIT compilation, function call overhead is function call overhead, no? > just do the right thing. Usually there is no need to query the PMC what > it is. If you're writing a compiler from scratch, I can see that being mostly true. However, in trying to port Perl 5 guts over to Parrot, there's a lot of code that relies on knowing what's going on (e.g. if a value has ever been a number, etc.)