Skip to content

Commit

Permalink
Incorporate $!onlystar into Routine $!flags
Browse files Browse the repository at this point in the history
It was a separate attribute before because the legacy multi-dispatch
caching strategy needed that. Now that is gone, and it can go into
flags, saving another 8 bytes off every Routine (and clone of one).
  • Loading branch information
jnthn committed Sep 22, 2021
1 parent 02480f3 commit 14b1600
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/Perl6/bootstrap.c/BOOTSTRAP.nqp
Expand Up @@ -2247,7 +2247,6 @@ BEGIN {
# has int $!flags;
# has Mu $!inline_info;
# has Mu $!package;
# has int $!onlystar;
# has @!dispatch_order;
# has Mu $!dispatch_cache;
Routine.HOW.add_parent(Routine, Block);
Expand All @@ -2256,7 +2255,6 @@ BEGIN {
Routine.HOW.add_attribute(Routine, Attribute.new(:name<$!flags>, :type(int), :package(Routine)));
Routine.HOW.add_attribute(Routine, Attribute.new(:name<$!inline_info>, :type(Mu), :package(Routine)));
Routine.HOW.add_attribute(Routine, Attribute.new(:name<$!package>, :type(Mu), :package(Routine)));
Routine.HOW.add_attribute(Routine, Attribute.new(:name<$!onlystar>, :type(int), :package(Routine)));
Routine.HOW.add_attribute(Routine, scalar_attr('@!dispatch_order', List, Routine, :!auto_viv_container));
#?if !moar
Routine.HOW.add_attribute(Routine, Attribute.new(:name<$!dispatch_cache>, :type(Mu), :package(Routine)));
Expand Down Expand Up @@ -3266,9 +3264,10 @@ BEGIN {
nqp::getattr($dcself, Routine, '$!inline_info')
}));
Routine.HOW.add_method(Routine, 'set_onlystar', nqp::getstaticcode(sub ($self) {
my $dcself := nqp::decont($self);
nqp::bindattr_i($dcself, Routine, '$!onlystar', 1);
$dcself
$self.set_flag(0x04)
}));
Routine.HOW.add_method(Routine, 'onlystar', nqp::getstaticcode(sub ($self) {
$self.get_flag(0x04)
}));
Routine.HOW.compose_repr(Routine);
#?if !moar
Expand Down
4 changes: 0 additions & 4 deletions src/core.c/Routine.pm6
Expand Up @@ -14,12 +14,9 @@ my class Routine { # declared in BOOTSTRAP
# has int $!flags;
# has Mu $!inline_info;
# has Mu $!package;
# has int $!onlystar;
# has @!dispatch_order;
# has Mu $!dispatch_cache;

method onlystar() { nqp::hllbool($!onlystar) }

method candidates() {
self.is_dispatcher ??
nqp::hllize(@!dispatchees) !!
Expand Down Expand Up @@ -121,7 +118,6 @@ my class Routine { # declared in BOOTSTRAP
unless nqp::istype(self, Wrapped) {
my $orig = self.clone();
self does Wrapped;
$!onlystar = 0; # disable optimization if no body there
self.UNSHIFT_WRAPPER($orig);
}

Expand Down
2 changes: 1 addition & 1 deletion src/vm/moar/dispatchers.nqp
Expand Up @@ -1144,7 +1144,7 @@ nqp::dispatch('boot-syscall', 'dispatcher-register', 'raku-multi',
# proto.
-> $capture {
my $callee := nqp::captureposarg($capture, 0);
my int $onlystar := nqp::getattr_i($callee, Routine, '$!onlystar');
my int $onlystar := $callee.onlystar;
my int $simple := $onlystar && simple-args-proto($callee, $capture);
if $simple {
# Don't need to invoke the proto itself, so just get on with the
Expand Down

0 comments on commit 14b1600

Please sign in to comment.