Skip to content

Commit

Permalink
streamline native array shift/pop exception handling
Browse files Browse the repository at this point in the history
the subroutine call "die" turns into a "getlexstatic",
which prevents inlining in moarvm's spesh; having caused
the exception to be raised a couple of times before the
inline attempt could solve this problem in some cases,
which surely is a little surprising.
  • Loading branch information
timo committed Aug 13, 2019
1 parent 15e0601 commit 01b86fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/core/native_array.pm6
Expand Up @@ -93,7 +93,7 @@ my class array does Iterable {

my role strarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of strarray role -----------------------------------
#- Generated on 2019-05-27T14:46:22+02:00 by tools/build/makeNATIVE_ARRAY.p6
#- Generated on 2019-08-12T21:36:23+02:00 by tools/build/makeNATIVE_ARRAY.p6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

multi method AT-POS(strarray:D: int $idx --> str) is raw {
Expand Down Expand Up @@ -224,13 +224,13 @@ my class array does Iterable {
method pop(strarray:D: --> str) {
nqp::elems(self)
?? nqp::pop_s(self)
!! die X::Cannot::Empty.new(:action<pop>, :what(self.^name));
!! X::Cannot::Empty.new(:action<pop>, :what(self.^name)).throw;
}

method shift(strarray:D: --> str) {
nqp::elems(self)
?? nqp::shift_s(self)
!! die X::Cannot::Empty.new(:action<shift>, :what(self.^name));
!! X::Cannot::Empty.new(:action<shift>, :what(self.^name)).throw;
}

multi method unshift(strarray:D: str $value --> strarray:D) {
Expand Down Expand Up @@ -594,7 +594,7 @@ my class array does Iterable {

my role intarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of intarray role -----------------------------------
#- Generated on 2019-05-27T14:46:22+02:00 by tools/build/makeNATIVE_ARRAY.p6
#- Generated on 2019-08-12T21:36:23+02:00 by tools/build/makeNATIVE_ARRAY.p6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

multi method AT-POS(intarray:D: int $idx --> int) is raw {
Expand Down Expand Up @@ -725,13 +725,13 @@ my class array does Iterable {
method pop(intarray:D: --> int) {
nqp::elems(self)
?? nqp::pop_i(self)
!! die X::Cannot::Empty.new(:action<pop>, :what(self.^name));
!! X::Cannot::Empty.new(:action<pop>, :what(self.^name)).throw;
}

method shift(intarray:D: --> int) {
nqp::elems(self)
?? nqp::shift_i(self)
!! die X::Cannot::Empty.new(:action<shift>, :what(self.^name));
!! X::Cannot::Empty.new(:action<shift>, :what(self.^name)).throw;
}

multi method unshift(intarray:D: int $value --> intarray:D) {
Expand Down Expand Up @@ -1147,7 +1147,7 @@ my class array does Iterable {

my role numarray[::T] does Positional[T] is array_type(T) {
#- start of generated part of numarray role -----------------------------------
#- Generated on 2019-05-27T14:46:22+02:00 by tools/build/makeNATIVE_ARRAY.p6
#- Generated on 2019-08-12T21:36:23+02:00 by tools/build/makeNATIVE_ARRAY.p6
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

multi method AT-POS(numarray:D: int $idx --> num) is raw {
Expand Down Expand Up @@ -1278,13 +1278,13 @@ my class array does Iterable {
method pop(numarray:D: --> num) {
nqp::elems(self)
?? nqp::pop_n(self)
!! die X::Cannot::Empty.new(:action<pop>, :what(self.^name));
!! X::Cannot::Empty.new(:action<pop>, :what(self.^name)).throw;
}

method shift(numarray:D: --> num) {
nqp::elems(self)
?? nqp::shift_n(self)
!! die X::Cannot::Empty.new(:action<shift>, :what(self.^name));
!! X::Cannot::Empty.new(:action<shift>, :what(self.^name)).throw;
}

multi method unshift(numarray:D: num $value --> numarray:D) {
Expand Down
4 changes: 2 additions & 2 deletions tools/build/makeNATIVE_ARRAY.p6
Expand Up @@ -178,13 +178,13 @@ for $*IN.lines -> $line {
method pop(#type#array:D: --> #type#) {
nqp::elems(self)
?? nqp::pop_#postfix#(self)
!! die X::Cannot::Empty.new(:action<pop>, :what(self.^name));
!! X::Cannot::Empty.new(:action<pop>, :what(self.^name)).throw;
}
method shift(#type#array:D: --> #type#) {
nqp::elems(self)
?? nqp::shift_#postfix#(self)
!! die X::Cannot::Empty.new(:action<shift>, :what(self.^name));
!! X::Cannot::Empty.new(:action<shift>, :what(self.^name)).throw;
}
multi method unshift(#type#array:D: #type# $value --> #type#array:D) {
Expand Down

0 comments on commit 01b86fa

Please sign in to comment.