Fatal: Reusable trampolines

When a reusable "CORE" sub is leaked, compile and cache its trampoline
under the "Fatal" package rather than the original package[1].  This
allows autodie to trivially reuse the trampoline on leaks from other
packages as well.

[1] Note that the wrapper sub is compiled into "Fatal" as well when
the "CORE" sub is reusable.

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Call _install_subs once per {,un}import

Call $class->_install_subs exactly once instead of once per sub being
{,un}imported.

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Move compilation of wrappers into its own sub

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Restructure %Cached_fatalised_sub table

Remove one level of the cache and replace the keys in the "deepest"
level with named constants (selected based on $lexical and $void).

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Lazily compile wrapped CORE:: subs

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Smarter handling of CORE subs in nested autodie

Previously, when nesting autodie with itself, autodie would wrap its
own wrapper.  With this patch, autodie properly detects it is dealing
with a "wrapped CORE sub" and simply generates a normal CORE wrapper.

Besides removing one level of indirection, it also removes the
overhead of checking for hints for the CORE sub (which was somewhat
counterintuitive, since autodie normally ignores hints for CORE subs).

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Remove unused local of $" and $! under autodie

The use of local on this variables have no apparent visible effect at
all (except hiding $! for callers).  We retain it for Fatal, where at
least the modified value of $" is still used by the wrapper.

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Expand $TAGS{':all'} immediately

_expand_tags is not really suited for expanding ":all" due to how it
was constructed.  However, it turns out that it is quite trivial to
expand ":all"-case is a reasonably more efficient manner.

Since ":all" is now always expanded, we can abuse this to reuse the
value in %tag_cache (_expand_tag).

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Remove dead assignment and re-factor another variable

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Fix typo in comments

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Remove redundant variable in the leak-guard

As a side-effect, we can avoid two hash-look ups on every leaky call
on CORE subs (after the trampoline has been generated).

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Reduce the overhead of import and _make_fatal

Refactor import and _make_fatal so they "use less 'CPU';".  In
particular, many calls to prototype("CORE::sub") has been replaced
with a cache, which turns out to be cheaper in the long run.

Combined these changes appear to reduce the runtime of benchmark.pl by
about 1/8 (~4.0s to ~3.5s).

Signed-off-by: Niels Thykier <niels@thykier.net>
Fatal: Fix return value of _expand_tags

Commit 9ab09599 missed the "CORE::" prefix in the for the "all"-tag.

Signed-off-by: Niels Thykier <niels@thykier.net>
Merge pull request #28 from nthykier/lazy-compile

Optimizations and refactoring for 2.20