Skip to content
Permalink
Browse files

Remove $CORE_METAOP_ASSIGN from CORE::

Basically make &METAOP_ASSIGN a front for R:I.METAOP_ASSIGN, on the
assumption that current optimizing techniques will inline that call
pretty quickly when needed.  Also, maybe we should codegen a call to
R:I.METAOP_ASSIGN directly, rather than to &METAOP_ASSIGN.
  • Loading branch information...
lizmat committed Mar 20, 2019
1 parent 6599998 commit 801850319ac5f8e3ff2c439783b85773e459e508
Showing with 18 additions and 17 deletions.
  1. +17 −5 src/core/Rakudo/Internals.pm6
  2. +1 −11 src/core/metaops.pm6
  3. +0 −1 t/08-performance/03-corekeys.t
@@ -15,7 +15,6 @@ my class X::Str::Sprintf::Directives::Count { ... }
my class X::Str::Sprintf::Directives::Unsupported { ... }
my class X::TypeCheck { ... }

my $CORE_METAOP_ASSIGN := nqp::null; # lazy storage for core METAOP_ASSIGN ops

my class Rakudo::Internals {

@@ -1640,13 +1639,26 @@ implementation detail and has no serviceable parts inside"
)
}

my $METAOP_ASSIGN := nqp::null; # lazy storage for core METAOP_ASSIGN ops
method METAOP_ASSIGN(\op) {
my \op-is := nqp::ifnull(
nqp::atkey( # is it a core op?
nqp::ifnull($METAOP_ASSIGN,INSTALL-CORE-METAOPS()),
nqp::objectid(op)
),
-> Mu \a, Mu \b { a = op.( ( a.DEFINITE ?? a !! op.() ), b) }
);
op-is.set_name(op.name ~ ' + {assigning}'); # checked for in Hyper.new
op-is
}

# Method for lazily installing fast versions of METAOP_ASSIGN ops for
# core infix ops. Since the compilation of &[op] happens at build time
# of the setting, we're sure we're referring to the core ops and not one
# that has been locally installed. Called by METAOP_ASSIGN. Please add
# any other core ops that seem to be necessary.
method INSTALL-CORE-METAOPS() {
$CORE_METAOP_ASSIGN := nqp::create(Rakudo::Internals::IterationSet);
sub INSTALL-CORE-METAOPS() {
$METAOP_ASSIGN := nqp::create(Rakudo::Internals::IterationSet);
for (
&[+], -> Mu \a, Mu \b { a = a.DEFINITE ?? a + b !! +b },
&[%], -> Mu \a, Mu \b { a = a.DEFINITE ?? a % b !! Failure.new("No zero-arg meaning for infix:<%>")},
@@ -1655,9 +1667,9 @@ implementation detail and has no serviceable parts inside"
&[~], -> Mu \a, Mu \b { a = a.DEFINITE ?? a ~ b !! ~b },
) -> \op, \metaop {
metaop.set_name(op.name ~ ' + {assigning}');
nqp::bindkey($CORE_METAOP_ASSIGN,nqp::objectid(op),metaop);
nqp::bindkey($METAOP_ASSIGN,nqp::objectid(op),metaop);
}
$CORE_METAOP_ASSIGN
$METAOP_ASSIGN
}

# handle parameterization by just adding a "keyof" method
@@ -1,15 +1,5 @@

sub METAOP_ASSIGN(\op) {
my \op-is := nqp::ifnull(
nqp::atkey( # is it a core op?
nqp::ifnull($CORE_METAOP_ASSIGN,Rakudo::Internals.INSTALL-CORE-METAOPS),
nqp::objectid(op)
),
-> Mu \a, Mu \b { a = op.( ( a.DEFINITE ?? a !! op.() ), b) }
);
op-is.set_name(op.name ~ ' + {assigning}'); # checked for in Hyper.new
op-is
}
sub METAOP_ASSIGN(\op) { Rakudo::Internals.METAOP_ASSIGN(op) }

sub METAOP_TEST_ASSIGN:<//>(\lhs, $rhs) is raw { lhs // (lhs = $rhs()) }
sub METAOP_TEST_ASSIGN:<||>(\lhs, $rhs) is raw { lhs || (lhs = $rhs()) }
@@ -12,7 +12,6 @@ my %allowed = (
Q{$?COMPILATION-ID},
Q{$?NL},
Q{$?TABSTOP},
Q{$CORE_METAOP_ASSIGN},
Q{$_},
Q{%DEPRECATIONS},
Q{&CLONE-HASH-DECONTAINERIZED},

0 comments on commit 8018503

Please sign in to comment.
You can’t perform that action at this time.