@@ -698,6 +698,21 @@ test_opcount(0, "multiconcat: local assign",
698
698
699
699
# builtin:: function calls should be replaced with efficient op implementations
700
700
no warnings ' experimental::builtin' ;
701
+ use builtin qw(
702
+ blessed
703
+ ceil
704
+ false
705
+ floor
706
+ indexed
707
+ is_bool
708
+ is_tainted
709
+ is_weak
710
+ refaddr
711
+ reftype
712
+ true
713
+ unweaken
714
+ weaken
715
+ ) ;
701
716
702
717
test_opcount(0, " builtin::true/false are replaced with constants" ,
703
718
sub { my $x = builtin::true(); my $y = builtin::false() },
@@ -706,6 +721,13 @@ test_opcount(0, "builtin::true/false are replaced with constants",
706
721
const => 2,
707
722
});
708
723
724
+ test_opcount(0, " imported true/false are replaced with constants" ,
725
+ sub { my $x = true(); my $y = false() },
726
+ {
727
+ entersub => 0,
728
+ const => 2,
729
+ });
730
+
709
731
test_opcount(0, " builtin::is_bool is replaced with direct opcode" ,
710
732
sub { my $x ; my $y ; $y = builtin::is_bool($x ); 1; },
711
733
{
@@ -715,6 +737,15 @@ test_opcount(0, "builtin::is_bool is replaced with direct opcode",
715
737
padsv_store => 1,
716
738
});
717
739
740
+ test_opcount(0, " imported is_bool is replaced with direct opcode" ,
741
+ sub { my $x ; my $y ; $y = is_bool($x ); 1; },
742
+ {
743
+ entersub => 0,
744
+ is_bool => 1,
745
+ padsv => 3,
746
+ padsv_store => 1,
747
+ });
748
+
718
749
test_opcount(0, " builtin::is_bool gets constant-folded" ,
719
750
sub { builtin::is_bool(123); },
720
751
{
@@ -723,48 +754,98 @@ test_opcount(0, "builtin::is_bool gets constant-folded",
723
754
const => 1,
724
755
});
725
756
757
+ test_opcount(0, " imported is_bool gets constant-folded" ,
758
+ sub { is_bool(123); },
759
+ {
760
+ entersub => 0,
761
+ is_bool => 0,
762
+ const => 1,
763
+ });
764
+
726
765
test_opcount(0, " builtin::weaken is replaced with direct opcode" ,
727
766
sub { my $x = []; builtin::weaken($x ); },
728
767
{
729
768
entersub => 0,
730
769
weaken => 1,
731
770
});
732
771
772
+ test_opcount(0, " imported weaken is replaced with direct opcode" ,
773
+ sub { my $x = []; weaken($x ); },
774
+ {
775
+ entersub => 0,
776
+ weaken => 1,
777
+ });
778
+
733
779
test_opcount(0, " builtin::unweaken is replaced with direct opcode" ,
734
780
sub { my $x = []; builtin::unweaken($x ); },
735
781
{
736
782
entersub => 0,
737
783
unweaken => 1,
738
784
});
739
785
786
+ test_opcount(0, " imported unweaken is replaced with direct opcode" ,
787
+ sub { my $x = []; unweaken($x ); },
788
+ {
789
+ entersub => 0,
790
+ unweaken => 1,
791
+ });
792
+
740
793
test_opcount(0, " builtin::is_weak is replaced with direct opcode" ,
741
794
sub { builtin::is_weak([]); },
742
795
{
743
796
entersub => 0,
744
797
is_weak => 1,
745
798
});
746
799
800
+ test_opcount(0, " imported is_weak is replaced with direct opcode" ,
801
+ sub { is_weak([]); },
802
+ {
803
+ entersub => 0,
804
+ is_weak => 1,
805
+ });
806
+
747
807
test_opcount(0, " builtin::blessed is replaced with direct opcode" ,
748
808
sub { builtin::blessed([]); },
749
809
{
750
810
entersub => 0,
751
811
blessed => 1,
752
812
});
753
813
814
+ test_opcount(0, " imported blessed is replaced with direct opcode" ,
815
+ sub { blessed([]); },
816
+ {
817
+ entersub => 0,
818
+ blessed => 1,
819
+ });
820
+
754
821
test_opcount(0, " builtin::refaddr is replaced with direct opcode" ,
755
822
sub { builtin::refaddr([]); },
756
823
{
757
824
entersub => 0,
758
825
refaddr => 1,
759
826
});
760
827
828
+ test_opcount(0, " imported refaddr is replaced with direct opcode" ,
829
+ sub { refaddr([]); },
830
+ {
831
+ entersub => 0,
832
+ refaddr => 1,
833
+ });
834
+
761
835
test_opcount(0, " builtin::reftype is replaced with direct opcode" ,
762
836
sub { builtin::reftype([]); },
763
837
{
764
838
entersub => 0,
765
839
reftype => 1,
766
840
});
767
841
842
+ test_opcount(0, " imported reftype is replaced with direct opcode" ,
843
+ sub { reftype([]); },
844
+ {
845
+ entersub => 0,
846
+ reftype => 1,
847
+ });
848
+
768
849
my $one_point_five = 1.5; # Prevent const-folding.
769
850
test_opcount(0, " builtin::ceil is replaced with direct opcode" ,
770
851
sub { builtin::ceil($one_point_five ); },
@@ -773,20 +854,41 @@ test_opcount(0, "builtin::ceil is replaced with direct opcode",
773
854
ceil => 1,
774
855
});
775
856
857
+ test_opcount(0, " imported ceil is replaced with direct opcode" ,
858
+ sub { ceil($one_point_five ); },
859
+ {
860
+ entersub => 0,
861
+ ceil => 1,
862
+ });
863
+
776
864
test_opcount(0, " builtin::floor is replaced with direct opcode" ,
777
865
sub { builtin::floor($one_point_five ); },
778
866
{
779
867
entersub => 0,
780
868
floor => 1,
781
869
});
782
870
871
+ test_opcount(0, " imported floor is replaced with direct opcode" ,
872
+ sub { floor($one_point_five ); },
873
+ {
874
+ entersub => 0,
875
+ floor => 1,
876
+ });
877
+
783
878
test_opcount(0, " builtin::is_tainted is replaced with direct opcode" ,
784
879
sub { builtin::is_tainted($0 ); },
785
880
{
786
881
entersub => 0,
787
882
is_tainted => 1,
788
883
});
789
884
885
+ test_opcount(0, " imported is_tainted is replaced with direct opcode" ,
886
+ sub { is_tainted($0 ); },
887
+ {
888
+ entersub => 0,
889
+ is_tainted => 1,
890
+ });
891
+
790
892
# void sassign + padsv combinations are replaced by padsv_store
791
893
test_opcount(0, " sassign + padsv replaced by padsv_store" ,
792
894
sub { my $y ; my $z = $y = 3; 1; },
@@ -1014,18 +1116,35 @@ test_opcount(0, "Empty anonhash ref and direct lexical assignment",
1014
1116
test_opcount(0, " foreach 2 lexicals on builtin::indexed ARRAY" ,
1015
1117
sub { my @input = (); foreach my ($i , $x ) (builtin::indexed @input ) { } },
1016
1118
{
1017
- entersub => 0, # no call to builtin::indexed
1119
+ entersub => 0, # no call to builtin::indexed
1018
1120
enteriter => 1,
1019
- iter => 1,
1020
- padav => 2,
1121
+ iter => 1,
1122
+ padav => 2,
1123
+ });
1124
+
1125
+ test_opcount(0, " foreach 2 lexicals on imported indexed ARRAY" ,
1126
+ sub { my @input = (); foreach my ($i , $x ) (indexed @input ) { } },
1127
+ {
1128
+ entersub => 0, # no call to builtin::indexed
1129
+ enteriter => 1,
1130
+ iter => 1,
1131
+ padav => 2,
1021
1132
});
1022
1133
1023
1134
test_opcount(0, " foreach 2 lexicals on builtin::indexed LIST" ,
1024
1135
sub { foreach my ($i , $x ) (builtin::indexed qw( x y z ) ) { } },
1025
1136
{
1026
- entersub => 0, # no call to builtin::indexed
1137
+ entersub => 0, # no call to builtin::indexed
1138
+ enteriter => 1,
1139
+ iter => 1,
1140
+ });
1141
+
1142
+ test_opcount(0, " foreach 2 lexicals on imported indexed LIST" ,
1143
+ sub { foreach my ($i , $x ) (indexed qw( x y z ) ) { } },
1144
+ {
1145
+ entersub => 0, # no call to builtin::indexed
1027
1146
enteriter => 1,
1028
- iter => 1,
1147
+ iter => 1,
1029
1148
});
1030
1149
1031
1150
# substr with const zero offset and "" replacements
0 commit comments