John Porter wrote:
> Huh? What did I say?::
you said there would be no performance hit in rewriting
defined|exists to store the pointer to the thing that was
found to be defined or exist somewhere.
After looking at the source code for what might have been the
wrong part of /usr/src/perl/perl-5.6.1/Perlapi.c (or something
like that) I determined that adding this feature would cause
two writes to static variables per function invocation that found
something and one or perhaps zero writes per invocation that found
nothing.
These writes would dirty a code page, which might result in a stall
as the modification is propagated up from the CPU.
Since the rest of the variables local to that routine are declared
as registers, the routine (at least the one I looked at) currently
uses only the stack and registers, and very little of the stack.
There would be a slight performance hit, caused by the two extra
assignments. (one to zero the pointer on entry, one to set it on found.)
pp_exists, found in pp.c, is a wrapper for special cases
involving subroutines -- no comment on what
if (PL_op->op_private & OPpEXISTS_SUB) {
is testing for --
and then is a wrapper for the three kinds of container lookup,
hv_exists_ent, av_exists, and avhv_exists_ent
I examined hv_exists_ent. Its arguments are
HV *hv, SV *keysv, U32 hash
which appear to be sufficent to describe the location of
an item, directly.
something like
struct IT_EXISTS_STASH_TYPE {
HV *hv;
SV *sv;
U32 hash;
}
should be sufficient for the
static IT_EXISTS_STASH_TYPE IT_exists;
definition which would have to appear somewhere.
I really don't know enough about perl 5 internals to go on; I
am certain that this feature is a no-brainer though and will try
to refrain from responding further about it
--
David Nicol 816.235.1187