From 656b763d8d818fc703c54d69e896d23a4cc486c1 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 7 Aug 2018 17:36:50 +0200 Subject: [PATCH 1/6] Generalize attribute default mechanism So that we'll be able to use it for cases that are not Scalar, e.g. making the storage of Hash automatically be an nqp::hash instead of having to do repeated checks of that. --- src/Perl6/Metamodel/BOOTSTRAP.nqp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Perl6/Metamodel/BOOTSTRAP.nqp b/src/Perl6/Metamodel/BOOTSTRAP.nqp index 21615d08a7d..0700c38c0b1 100644 --- a/src/Perl6/Metamodel/BOOTSTRAP.nqp +++ b/src/Perl6/Metamodel/BOOTSTRAP.nqp @@ -1407,7 +1407,11 @@ BEGIN { nqp::bindattr_i($attr, Attribute, '$!has_accessor', $has_accessor); nqp::bindattr($attr, Attribute, '$!package', $package); nqp::bindattr_i($attr, Attribute, '$!inlined', $inlined); - if nqp::existskey(%other, 'container_descriptor') { + if nqp::existskey(%other, 'auto_viv_primitive') { + nqp::bindattr($attr, Attribute, '$!auto_viv_container', + %other); + } + elsif nqp::existskey(%other, 'container_descriptor') { nqp::bindattr($attr, Attribute, '$!container_descriptor', %other); if nqp::existskey(%other, 'auto_viv_container') { nqp::bindattr($attr, Attribute, '$!auto_viv_container', @@ -1738,6 +1742,13 @@ BEGIN { } } + # Helper for creating an attribute that vivifies to a clone of some VM + # storage type; used for the storage slots of arrays and hashes. + sub storage_attr($name, $type, $package, $clonee, :$associative_delegate) { + return Attribute.new( :$name, :$type, :$package, :auto_viv_primitive($clonee), + :$associative_delegate ); + } + # class Signature is Any{ # has @!params; # has Mu $!returns; From 0b1e6d54f72ff40f5bf64d746435eb146a4f9ef1 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 7 Aug 2018 17:38:09 +0200 Subject: [PATCH 2/6] Make Map/Hash $!storage always init to nqp::hash --- src/Perl6/Metamodel/BOOTSTRAP.nqp | 3 ++- src/Perl6/World.nqp | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Perl6/Metamodel/BOOTSTRAP.nqp b/src/Perl6/Metamodel/BOOTSTRAP.nqp index 0700c38c0b1..77a95d593aa 100644 --- a/src/Perl6/Metamodel/BOOTSTRAP.nqp +++ b/src/Perl6/Metamodel/BOOTSTRAP.nqp @@ -3249,7 +3249,8 @@ BEGIN { # my class Map is Cool { # has Mu $!storage; Map.HOW.add_parent(Map, Cool); - Map.HOW.add_attribute(Map, scalar_attr('$!storage', Mu, Map, :associative_delegate)); + Map.HOW.add_attribute(Map, storage_attr('$!storage', Mu, Map, nqp::hash(), + :associative_delegate)); Map.HOW.compose_repr(Map); nqp::settypehllrole(Map, 5); diff --git a/src/Perl6/World.nqp b/src/Perl6/World.nqp index b4bd70cbedf..ac6500702fa 100644 --- a/src/Perl6/World.nqp +++ b/src/Perl6/World.nqp @@ -1604,9 +1604,6 @@ class Perl6::World is HLL::World { elsif nqp::istype($cont_type, self.find_symbol(['Hash'], :setting-only)) { $cont := nqp::create($cont_type); nqp::bindattr($cont, %cont_info, '$!descriptor', $descriptor); - my $Map := self.find_symbol(['Map'], :setting-only); - my $Mu := self.find_symbol(['Mu'], :setting-only); - nqp::bindattr($cont, $Map, '$!storage', $Mu); } else { $cont := $cont_type.new; From 99f7f4cc85599e7da87541ce45d1c59bf26c1e40 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 7 Aug 2018 18:22:14 +0200 Subject: [PATCH 3/6] Tune Map/Hash for $!storage changes, and more This is mostly a case of kicking out nqp::isconcrete instructions, but we can also use some the new and cheaper instruction for making a Scalar container with an initial value. --- src/core/Hash.pm6 | 96 ++++++++++++++--------------------------------- src/core/Map.pm6 | 8 ++-- 2 files changed, 33 insertions(+), 71 deletions(-) diff --git a/src/core/Hash.pm6 b/src/core/Hash.pm6 index 6753d66dfa0..bb3b9191184 100644 --- a/src/core/Hash.pm6 +++ b/src/core/Hash.pm6 @@ -33,22 +33,14 @@ my class Hash { # declared in BOOTSTRAP } multi method AT-KEY(Hash:D: Str:D \key) is raw { - nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')), - nqp::ifnull( - nqp::atkey(nqp::getattr(self,Map,'$!storage'),key), - self!AT_KEY_CONTAINER(key) - ), + nqp::ifnull( + nqp::atkey(nqp::getattr(self,Map,'$!storage'),key), self!AT_KEY_CONTAINER(key) ) } multi method AT-KEY(Hash:D: \key) is raw { - nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')), - nqp::ifnull( - nqp::atkey(nqp::getattr(self,Map,'$!storage'),key.Str), - self!AT_KEY_CONTAINER(key.Str) - ), + nqp::ifnull( + nqp::atkey(nqp::getattr(self,Map,'$!storage'),key.Str), self!AT_KEY_CONTAINER(key.Str) ) } @@ -58,14 +50,14 @@ my class Hash { # declared in BOOTSTRAP nqp::bindkey( nqp::getattr(self,Map,'$!storage'), nqp::unbox_s(key), - (nqp::p6scalarfromdesc($!descriptor) = x), + nqp::p6scalarwithvalue($!descriptor, x), ) } multi method STORE_AT_KEY(\key, Mu \x --> Nil) { nqp::bindkey( nqp::getattr(self,Map,'$!storage'), nqp::unbox_s(key.Str), - (nqp::p6scalarfromdesc($!descriptor) = x), + nqp::p6scalarwithvalue($!descriptor, x), ) } method !STORE_MAP(\map --> Nil) { @@ -124,67 +116,40 @@ my class Hash { # declared in BOOTSTRAP } multi method ASSIGN-KEY(Hash:D: Str:D \key, Mu \assignval) is raw { - nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')), - (nqp::ifnull( - nqp::atkey( - nqp::getattr(self,Map,'$!storage'), - nqp::unbox_s(key) - ), - nqp::bindkey( - nqp::getattr(self,Map,'$!storage'), - nqp::unbox_s(key), - nqp::p6scalarfromdesc($!descriptor) - ) - ) = assignval), - nqp::bindkey( - nqp::bindattr(self,Map,'$!storage',nqp::hash), - nqp::unbox_s(key), - nqp::p6scalarfromdesc($!descriptor) = assignval - ) - ) + my \storage := nqp::getattr(self,Map,'$!storage'); + my \target := nqp::atkey(storage, nqp::unbox_s(key)); + nqp::isnull(target) + ?? nqp::bindkey( + storage, + nqp::unbox_s(key), + nqp::p6scalarwithvalue($!descriptor, assignval) + ) + !! nqp::p6assign(target, assignval) } multi method ASSIGN-KEY(Hash:D: \key, Mu \assignval) is raw { - nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')), - (nqp::ifnull( - nqp::atkey( - nqp::getattr(self,Map,'$!storage'), - nqp::unbox_s(key.Str) - ), - nqp::bindkey( - nqp::getattr(self,Map,'$!storage'), - nqp::unbox_s(key.Str), - nqp::p6scalarfromdesc($!descriptor) - ) - ) = assignval), - nqp::bindkey( - nqp::bindattr(self,Map,'$!storage',nqp::hash), - nqp::unbox_s(key.Str), - nqp::p6scalarfromdesc($!descriptor) = assignval - ) - ) + my \key_s = key.Str; + my \storage := nqp::getattr(self,Map,'$!storage'); + my \target := nqp::atkey(storage, nqp::unbox_s(key_s)); + nqp::isnull(target) + ?? nqp::bindkey( + storage, + nqp::unbox_s(key_s), + nqp::p6scalarwithvalue($!descriptor, assignval) + ) + !! nqp::p6assign(target, assignval) } proto method BIND-KEY(|) {*} multi method BIND-KEY(Hash:D: \key, Mu \bindval) is raw { nqp::bindkey( - nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')), - nqp::getattr(self,Map,'$!storage'), - nqp::bindattr(self,Map,'$!storage',nqp::hash) - ), + nqp::getattr(self,Map,'$!storage'), key.Str, bindval ) } multi method BIND-KEY(Hash:D: Str:D \key, Mu \bindval) is raw { nqp::bindkey( - nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')), - nqp::getattr(self,Map,'$!storage'), - nqp::bindattr(self,Map,'$!storage',nqp::hash) - ), + nqp::getattr(self,Map,'$!storage'), key, bindval ) @@ -193,9 +158,7 @@ my class Hash { # declared in BOOTSTRAP multi method DELETE-KEY(Hash:U: --> Nil) { } multi method DELETE-KEY(Hash:D: Str:D \key) { nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')) - && nqp::existskey(nqp::getattr(self,Map,'$!storage'), - nqp::unbox_s(key)), + nqp::existskey(nqp::getattr(self,Map,'$!storage'), nqp::unbox_s(key)), nqp::stmts( (my $value = nqp::atkey(nqp::getattr(self,Map,'$!storage'), nqp::unbox_s(key))), @@ -210,8 +173,7 @@ my class Hash { # declared in BOOTSTRAP nqp::stmts( (my str $key = nqp::unbox_s(key.Str)), nqp::if( - nqp::isconcrete(nqp::getattr(self,Map,'$!storage')) - && nqp::existskey(nqp::getattr(self,Map,'$!storage'),$key), + nqp::existskey(nqp::getattr(self,Map,'$!storage'),$key), nqp::stmts( (my $value = nqp::atkey(nqp::getattr(self,Map,'$!storage'),$key)), nqp::deletekey(nqp::getattr(self,Map,'$!storage'),$key), diff --git a/src/core/Map.pm6 b/src/core/Map.pm6 index 9c318dbb76b..38fd7ca70ef 100644 --- a/src/core/Map.pm6 +++ b/src/core/Map.pm6 @@ -112,7 +112,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP multi method head(Map:D:) { nqp::if( - nqp::isconcrete($!storage) && nqp::elems($!storage), + nqp::elems($!storage), Pair.new( nqp::iterkey_s( nqp::shift(my $iterator := nqp::iterator($!storage)) @@ -307,7 +307,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP # to do, is to decontainerize the values. method !STORE_MAP_FROM_MAP(\map --> Nil) { nqp::if( - nqp::isconcrete(my $other := nqp::getattr(map,Map,'$!storage')), + nqp::elems(my $other := nqp::getattr(map,Map,'$!storage')), nqp::stmts( (my $iter := nqp::iterator($other)), nqp::while( @@ -327,7 +327,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP # the object key and a value that we need to decontainerize. method !STORE_MAP_FROM_OBJECT_HASH(\map --> Nil) { nqp::if( - nqp::isconcrete(my $other := nqp::getattr(map,Map,'$!storage')), + nqp::elems(my $other := nqp::getattr(map,Map,'$!storage')), nqp::stmts( (my $iter := nqp::iterator($other)), nqp::while( @@ -412,7 +412,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP nqp::if( nqp::eqaddr(map.keyof,Str(Any)), # is it not an Object Hash? nqp::if( - nqp::isconcrete(my $other := nqp::getattr(map,Map,'$!storage')), + nqp::elems(my $other := nqp::getattr(map,Map,'$!storage')), nqp::if( nqp::eqaddr(self.WHAT,Map), nqp::p6bindattrinvres( From 1f65bf243f130ec49e5ea33c527d363d9dcc9750 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 7 Aug 2018 18:31:13 +0200 Subject: [PATCH 4/6] Don't have p6scalarfromvalue check for definedness Since we now always promise we will always provide a descriptor that is defined to it. Results in rather more compact code. --- src/Perl6/Actions.nqp | 39 ++++++++++++++++++++----------- src/Perl6/Metamodel/BOOTSTRAP.nqp | 6 +++-- src/core/Array.pm6 | 4 ++-- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp index b792f81b4bc..c16787ecd54 100644 --- a/src/Perl6/Actions.nqp +++ b/src/Perl6/Actions.nqp @@ -720,10 +720,12 @@ register_op_desugar('p6scalarfromdesc', -> $qast { ) ) }); -register_op_desugar('p6scalarwithvalue', -> $qast { +# The "certain" variant is allowed to assume the container descriptor is +# reliably provided, so need not map it to the default one. Ideally, we'll +# eventually have everything using this version of the op. +register_op_desugar('p6scalarfromcertaindesc', -> $qast { my $desc := QAST::Node.unique('descriptor'); my $Scalar := QAST::WVal.new( :value(nqp::gethllsym('perl6', 'Scalar')) ); - my $default_cont_spec := nqp::gethllsym('perl6', 'default_cont_spec'); QAST::Stmt.new( QAST::Op.new( :op('bind'), @@ -731,26 +733,37 @@ register_op_desugar('p6scalarwithvalue', -> $qast { $qast[0] ), QAST::Op.new( - :op('p6assign'), + :op('p6bindattrinvres'), QAST::Op.new( :op('p6bindattrinvres'), QAST::Op.new( :op('create'), $Scalar ), $Scalar, QAST::SVal.new( :value('$!descriptor') ), - QAST::Op.new( - :op('if'), - QAST::Op.new( - :op('isconcrete'), - QAST::Var.new( :name($desc), :scope('local') ), - ), - QAST::Var.new( :name($desc), :scope('local') ), - QAST::WVal.new( :value($default_cont_spec) ) - ) + QAST::Var.new( :name($desc), :scope('local') ) ), - $qast[1] + $Scalar, + QAST::SVal.new( :value('$!value') ), + QAST::Op.new( + :op('callmethod'), :name('default'), + QAST::Var.new( :name($desc), :scope('local') ) + ) ) ) }); +register_op_desugar('p6scalarwithvalue', -> $qast { + my $Scalar := QAST::WVal.new( :value(nqp::gethllsym('perl6', 'Scalar')) ); + QAST::Op.new( + :op('p6assign'), + QAST::Op.new( + :op('p6bindattrinvres'), + QAST::Op.new( :op('create'), $Scalar ), + $Scalar, + QAST::SVal.new( :value('$!descriptor') ), + $qast[0] + ), + $qast[1] + ) +}); register_op_desugar('p6recont_ro', -> $qast { my $result := QAST::Node.unique('result'); my $Scalar := QAST::WVal.new( :value(nqp::gethllsym('perl6', 'Scalar')) ); diff --git a/src/Perl6/Metamodel/BOOTSTRAP.nqp b/src/Perl6/Metamodel/BOOTSTRAP.nqp index 77a95d593aa..2d16dab9ad0 100644 --- a/src/Perl6/Metamodel/BOOTSTRAP.nqp +++ b/src/Perl6/Metamodel/BOOTSTRAP.nqp @@ -3243,7 +3243,8 @@ BEGIN { # class Array is List { # has Mu $!descriptor; Array.HOW.add_parent(Array, List); - Array.HOW.add_attribute(Array, scalar_attr('$!descriptor', Mu, Array, :!auto_viv_container)); + Array.HOW.add_attribute(Array, storage_attr('$!descriptor', Mu, Array, + Scalar.HOW.cache_get(Scalar, 'default_cont_spec'))); Array.HOW.compose_repr(Array); # my class Map is Cool { @@ -3257,7 +3258,8 @@ BEGIN { # my class Hash is Map { # has Mu $!descriptor; Hash.HOW.add_parent(Hash, Map); - Hash.HOW.add_attribute(Hash, scalar_attr('$!descriptor', Mu, Hash, :!auto_viv_container)); + Hash.HOW.add_attribute(Hash, storage_attr('$!descriptor', Mu, Hash, + Scalar.HOW.cache_get(Scalar, 'default_cont_spec'))); Hash.HOW.compose_repr(Hash); nqp::settypehllrole(Hash, 5); diff --git a/src/core/Array.pm6 b/src/core/Array.pm6 index 53ae2ebf229..1cf06a7053c 100644 --- a/src/core/Array.pm6 +++ b/src/core/Array.pm6 @@ -76,7 +76,7 @@ my class Array { # declared in BOOTSTRAP iter.push-until-lazy: my \target := ArrayReificationTarget.new( (my \buffer := nqp::create(IterationBuffer)), - nqp::isnull($!descriptor) ?? (nqp::null) !! nqp::clone($!descriptor))), + nqp::clone($!descriptor))), nqp::p6bindattrinvres(result, List, '$!reified', buffer), nqp::stmts( nqp::bindattr(result, List, '$!reified', buffer), @@ -200,7 +200,7 @@ my class Array { # declared in BOOTSTRAP $iter.push-until-lazy( my \target := ArrayReificationTarget.new( (my \buffer := nqp::create(IterationBuffer)), - nqp::null + nqp::getcurhllsym('perl6', 'default_cont_spec') ) ), IterationEnd From 37c7e6e5587860e36615f435d39cd3619e348b3e Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 7 Aug 2018 18:44:09 +0200 Subject: [PATCH 5/6] Further redundant check removals in Map/Hash --- src/core/Hash.pm6 | 6 +++--- src/core/Map.pm6 | 40 +++++++++++++--------------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/core/Hash.pm6 b/src/core/Hash.pm6 index bb3b9191184..6843e9f5dd5 100644 --- a/src/core/Hash.pm6 +++ b/src/core/Hash.pm6 @@ -29,7 +29,7 @@ my class Hash { # declared in BOOTSTRAP } method !AT_KEY_CONTAINER(Str:D \key) is raw { - nqp::p6scalarfromdesc(ContainerDescriptor::BindHashPos.new($!descriptor, self, key)) + nqp::p6scalarfromcertaindesc(ContainerDescriptor::BindHashPos.new($!descriptor, self, key)) } multi method AT-KEY(Hash:D: Str:D \key) is raw { @@ -166,7 +166,7 @@ my class Hash { # declared in BOOTSTRAP nqp::unbox_s(key)), $value ), - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ) } multi method DELETE-KEY(Hash:D: \key) { @@ -179,7 +179,7 @@ my class Hash { # declared in BOOTSTRAP nqp::deletekey(nqp::getattr(self,Map,'$!storage'),$key), $value ), - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ) ) } diff --git a/src/core/Map.pm6 b/src/core/Map.pm6 index 38fd7ca70ef..b8d106c0196 100644 --- a/src/core/Map.pm6 +++ b/src/core/Map.pm6 @@ -52,16 +52,15 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP multi method Hash(Map:U:) { Hash } multi method Hash(Map:D:) { - if nqp::defined($!storage) && nqp::elems($!storage) { + if nqp::elems($!storage) { my $hash := nqp::create(Hash); my $storage := nqp::bindattr($hash,Map,'$!storage',nqp::hash); - my $descriptor := nqp::null; + my $descriptor := nqp::getcurhllsym('default_cont_spec'); my $iter := nqp::iterator(nqp::getattr(self,Map,'$!storage')); nqp::while( $iter, nqp::bindkey($storage,nqp::iterkey_s(nqp::shift($iter)), - nqp::p6scalarfromdesc($descriptor) = - nqp::decont(nqp::iterval($iter)) + nqp::p6scalarwithvalue($descriptor, nqp::decont(nqp::iterval($iter))) ) ); $hash @@ -72,10 +71,10 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP } multi method Bool(Map:D:) { - nqp::p6bool(nqp::defined($!storage) && nqp::elems($!storage)); + nqp::p6bool(nqp::elems($!storage)); } method elems(Map:D:) { - nqp::p6box_i(nqp::defined($!storage) && nqp::elems($!storage)); + nqp::p6box_i(nqp::elems($!storage)); } multi method Int(Map:D:) { self.elems } multi method Numeric(Map:D:) { self.elems } @@ -85,7 +84,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP nqp::stmts( (my $buffer := nqp::create(IterationBuffer)), nqp::if( - nqp::defined($!storage) && nqp::elems($!storage), + nqp::elems($!storage), nqp::stmts( (my $iterator := nqp::iterator($!storage)), nqp::setelems($buffer,nqp::elems($!storage)), @@ -157,14 +156,10 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP } multi method EXISTS-KEY(Map:D: Str:D \key) { - nqp::p6bool( - nqp::defined($!storage) && nqp::existskey($!storage,key) - ) + nqp::p6bool(nqp::existskey($!storage,key)) } multi method EXISTS-KEY(Map:D: \key) { - nqp::p6bool( - nqp::defined($!storage) && nqp::existskey($!storage,key.Str) - ) + nqp::p6bool(nqp::existskey($!storage,key.Str)) } multi method gist(Map:D:) { @@ -287,18 +282,14 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP } multi method AT-KEY(Map:D: Str:D \key) is raw { - nqp::defined($!storage) - ?? nqp::ifnull(nqp::atkey($!storage,nqp::unbox_s(key)),Nil) - !! Nil + nqp::ifnull(nqp::atkey($!storage,nqp::unbox_s(key)),Nil) } multi method AT-KEY(Map:D: \key) is raw { - nqp::defined($!storage) - ?? nqp::ifnull(nqp::atkey($!storage,nqp::unbox_s(key.Str)),Nil) - !! Nil + nqp::ifnull(nqp::atkey($!storage,nqp::unbox_s(key.Str)),Nil) } multi method ASSIGN-KEY(Map:D: \key, Mu \value) { - die nqp::defined($!storage) && nqp::existskey($!storage,key.Str) + die nqp::existskey($!storage,key.Str) ?? "Cannot change key '{key}' in an immutable {self.^name}" !! "Cannot add key '{key}' to an immutable {self.^name}" } @@ -452,17 +443,12 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP } method Capture(Map:D:) { - nqp::defined($!storage) - ?? nqp::p6bindattrinvres( - nqp::create(Capture),Capture,'%!hash',$!storage) - !! nqp::create(Capture) + nqp::p6bindattrinvres(nqp::create(Capture),Capture,'%!hash',$!storage) } method FLATTENABLE_LIST() { nqp::list() } method FLATTENABLE_HASH() { - nqp::defined($!storage) - ?? $!storage - !! nqp::bindattr(self,Map,'$!storage',nqp::hash) + $!storage } method fmt(Map: Cool $format = "%s\t\%s", $sep = "\n") { From 90f678f3da2f5a726469a6f9ec33bc551eb25520 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Tue, 7 Aug 2018 18:56:34 +0200 Subject: [PATCH 6/6] Avoid more unrequired descriptor checks --- src/core/Any.pm6 | 6 +++--- src/core/Array.pm6 | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/Any.pm6 b/src/core/Any.pm6 index 68458a7ccae..d91f5d5b601 100644 --- a/src/core/Any.pm6 +++ b/src/core/Any.pm6 @@ -251,10 +251,10 @@ my class Any { # declared in BOOTSTRAP proto method AT-POS(|) is nodal {*} multi method AT-POS(Any:U \SELF: int \pos) is raw { - nqp::p6scalarfromdesc(ContainerDescriptor::VivifyArray.new(SELF, pos)) + nqp::p6scalarfromcertaindesc(ContainerDescriptor::VivifyArray.new(SELF, pos)) } multi method AT-POS(Any:U \SELF: Int:D \pos) is raw { - nqp::p6scalarfromdesc(ContainerDescriptor::VivifyArray.new(SELF, pos)) + nqp::p6scalarfromcertaindesc(ContainerDescriptor::VivifyArray.new(SELF, pos)) } multi method AT-POS(Any:U: Num:D \pos) is raw { nqp::isnanorinf(pos) @@ -385,7 +385,7 @@ my class Any { # declared in BOOTSTRAP ) } multi method AT-KEY(Any:U \SELF: \key) is raw { - nqp::p6scalarfromdesc(ContainerDescriptor::VivifyHash.new(SELF, key)) + nqp::p6scalarfromcertaindesc(ContainerDescriptor::VivifyHash.new(SELF, key)) } proto method BIND-KEY(|) is nodal {*} diff --git a/src/core/Array.pm6 b/src/core/Array.pm6 index 1cf06a7053c..14b6e707a2a 100644 --- a/src/core/Array.pm6 +++ b/src/core/Array.pm6 @@ -137,7 +137,7 @@ my class Array { # declared in BOOTSTRAP ) } method hole(int $i) { - nqp::p6scalarfromdesc(ContainerDescriptor::BindArrayPos.new( + nqp::p6scalarfromcertaindesc(ContainerDescriptor::BindArrayPos.new( $!descriptor, $!reified, $i)) } method done() is raw { @@ -331,7 +331,7 @@ my class Array { # declared in BOOTSTRAP multi method AT-POS(Int:D \pos) { nqp::ifnull( nqp::atpos(nqp::getattr(self,List,'$!reified'),pos), - nqp::p6scalarfromdesc(ContainerDescriptor::BindArrayPos.new( + nqp::p6scalarfromcertaindesc(ContainerDescriptor::BindArrayPos.new( $!descriptor, nqp::getattr(self,List,'$!reified'), pos)) ) } @@ -386,7 +386,7 @@ my class Array { # declared in BOOTSTRAP nqp::bindpos( $reified, $i, - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ) ) ) @@ -551,7 +551,7 @@ my class Array { # declared in BOOTSTRAP nqp::bindpos( nqp::getattr(self,List,'$!reified'), $pos, - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ), nqp::if( nqp::isconcrete(nqp::getattr(self,List,'$!todo')), @@ -566,14 +566,14 @@ my class Array { # declared in BOOTSTRAP nqp::bindpos( # outlander nqp::getattr(self,List,'$!reified'), $pos, - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ) ) ), nqp::bindpos( # outlander without todo nqp::getattr(self,List,'$!reified'), $pos, - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ) ) ) @@ -581,7 +581,7 @@ my class Array { # declared in BOOTSTRAP nqp::bindpos( # new outlander nqp::bindattr(self,List,'$!reified',nqp::create(IterationBuffer)), $pos, - nqp::p6scalarfromdesc($!descriptor) + nqp::p6scalarfromcertaindesc($!descriptor) ) ) = assignee )