cmp VTABLE & MULTI
Allison Randal
allison at parrot.org
Mon Oct 13 23:36:18 UTC 2008
François Perrad wrote:
>
> Since ppd27mmd merge, this shortcut removes the ability to call the
> specific Lua code (with the expected exception generation).
>
> Since r31890, it's fixed.
> The VTABLE 'cmp' is overloaded in LuaNil PMC without the shortcut
> presents in Default PMC. But it isn't the right place, I want overload
> VTABLE 'cmp' in LuaAny, the abstract PMC of all Lua types. LuaAny PMC
> contains some MULTI 'cmp' and it seems not possible (with current tool)
> to define VTABLE and MULTI in the same file.
> I think the tool/generator must be improved.
It is possible to define VTABLE and MULTI in the same file, they are
parsed completely independently and don't conflict. Now, if you do that,
and your VTABLE 'cmp' doesn't call
'Parrot_mmd_multi_dispatch_from_c_args' (maybe as the default after
checking some conditions), then the MULTI 'cmp's will never be called,
because the VTABLE one has priority over them.
It sounds like LuaAny is the right place to define your custom VTABLE
'cmp'. What was the error you encountered when you tried it?
> The shortcut in Default PMC looks like a premature optimization.
> I suggest a VTABLE 'cmp' without the shortcut in Default PMC and
> with the shortcut in Scalar PMC.
It's an optimization that holds true for the majority of cases and gave
a significant speedup on PGE, which uses 'cmp' heavily. It's also an
optimization that's very easy to override, by sticking an alternate
VTABLE for 'cmp' anywhere in the inheritance hierarchy of a PMC.
Allison
More information about the parrot-dev
mailing list