Commit 34003b86 authored by Robert Lemmen's avatar Robert Lemmen

New upstream version 2018.05

parent 04ca86fb
......@@ -634,7 +634,7 @@ N: Paul Cochrane
U: paultcochrane
E: paul@liekut.de
N: Pawel Murias
N: Paweł Murias
U: pmurias
E: pawelmurias@gmail.com
......
......@@ -150,7 +150,7 @@ MAIN: {
my $make = 'make';
if ($^O eq 'solaris') {
if (not -X '/usr/bin/gmake') {
if (-z `which gmake`) {
die "gmake is required to compile rakudo. Please install by 'pkg install gnu-make'";
}
$make = 'gmake';
......
......@@ -122,6 +122,7 @@ docs/announce/2018.02.md
docs/announce/2018.03.md
docs/announce/2018.04.1.md
docs/announce/2018.04.md
docs/announce/2018.05.md
docs/architecture.html
docs/architecture.svg
docs/archive/2017-IO-Grant--Action-Plan.md
......
New in 2018.05:
+ SPECIAL NOTES:
+ Corresponding MoarVM release introduces hash randomization to
prevent DoS attacks. Among other things, this may affect user
tests that expect keys or values returned from a Hash object to
be in the same order every run.
+ Fixes:
+ Made .assuming available in WhateverCodes [6e8dc6f1]
+ Fixed truncation of seconds in DateTime.later/.earlier [656ff77b]
+ Fixed spurious unhandled Failures caused by require [666eb3ab]
+ Made IO::Handle.seek to always return True [24a90774]
+ Made CallFrame skip over thunk-like things [0d216bef]
+ Fixed unwanted warnings in X::NYI when $.feature is omitted [a7c03101]
+ Fixed WHICH of non-reduced Rats [8cd70d1e]
+ Fixed smartmatch exception explosion [97d5d83e]
+ Made code detection in subsets more robust [ede507b7][febcb917]
+ Made build of BOOTSTRAP.moarvm reproducible [39227d54][56c03572][6ae0526f]
+ Simplified Signature.perl/gist for unnamed invocants [71159bed][f14dc6bd]
+ Made it possible to call .perl on uninitialized native strings [b12fba38]
+ Made .gist on native / non-native arrays similar [4e88fa15]
+ Fixed overzealous X::Syntax::NoSelf throwage [9b915f09]
+ Fixed smartmatching an Iterable type object [385308d3]
+ Fixed unexpected POD table failures [2cda7a19]
+ Made pass() and flunk() more consistent [82b3a894]
+ Fixed distribution path format on windows [4cacbf66]
+ Various fixes for the JVM backend [7d2940ee][cc57d06a][be35160d]
+ Various improvements to produced messages [7b336519][0de80523]
[b4973115][22d08069]
+ Additions:
+ Added shapes support for HAS scoped attributes [4c3807c5][7847768c]
+ Added NativeCall CArray.allocate method [a02131d5]
+ Added "use p5isms" pragma to stop complaints about Perl 5 traps [8ae82a55]
[8ccda189][7bde26fc]
+ Removals:
+ Removed some 5to6 error messages [3f350912][4ac9915e]
[5ce24929][cf35764d][44538f50]
+ Build system:
+ Fixed Configure script to not assume gmake location [abd88a94]
+ Efficiency:
+ Made Int.lsb 2x faster [9e2dacd4]
+ Made Int.msb 2x faster [775a42ee]
+ Made Range slices on native arrays about 23x faster [67a31600]
[f038e12d][09cbe679][c69179cc]
+ Made .splice on native arrays up to 2x faster [ee1ba153]
[4ab2f2cd][da646aa2][e0ad668e]
+ Made Rat / FatRat stringification up to 200x faster [e0dca0cc]
+ Made creation of regexes up to 30% faster [32a78996]
+ Made @a.splice(offset) about 20% faster [8d12d5b4][a5d46b42][8bde96d2]
+ Made module loading 10ms faster by avoiding IO::relative [849ba56d]
+ Other minor optimizations [d53fe90a][aa18140e][776ff354]
[ac6e26e8][073a7f50][54e390f5]
+ Internal:
+ Introduced nqp::slice op [090432bb]
New in 2018.04.1:
+ Fixes:
+ Fixed hang in parsing of nums with huge exponents [4e38bc1f]
......
# Announce: Rakudo Perl 6 compiler, Release #123 (2018.05)
On behalf of the Rakudo development team, I’m very happy to announce the
May 2018 release of Rakudo Perl 6 #123. Rakudo is an implementation of
Perl 6 on the Moar Virtual Machine[^1].
This release implements the 6.c version of the Perl 6 specifications.
It includes bugfixes and optimizations on top of
the 2015.12 release of Rakudo.
Upcoming releases in 2018 will include new functionality that is not
part of the 6.c specification, available with a lexically scoped
pragma. Our goal is to ensure that anything that is tested as part of the
6.c specification will continue to work unchanged. There may be incremental
spec releases this year as well.
The tarball for this release is available from <https://rakudo.org/files/rakudo>.
Please note: This announcement is not for the Rakudo Star
distribution[^2] — it’s announcing a new release of the compiler
only. For the latest Rakudo Star release, see
<https://rakudo.org/files/star>.
The changes in this release are outlined below:
New in 2018.05:
+ SPECIAL NOTES:
+ Corresponding MoarVM release introduces hash randomization to
prevent DoS attacks. Among other things, this may affect user
tests that expect keys or values returned from a Hash object to
be in the same order every run.
+ Fixes:
+ Made .assuming available in WhateverCodes [6e8dc6f1]
+ Fixed truncation of seconds in DateTime.later/.earlier [656ff77b]
+ Fixed spurious unhandled Failures caused by require [666eb3ab]
+ Made IO::Handle.seek to always return True [24a90774]
+ Made CallFrame skip over thunk-like things [0d216bef]
+ Fixed unwanted warnings in X::NYI when $.feature is omitted [a7c03101]
+ Fixed WHICH of non-reduced Rats [8cd70d1e]
+ Fixed smartmatch exception explosion [97d5d83e]
+ Made code detection in subsets more robust [ede507b7][febcb917]
+ Made build of BOOTSTRAP.moarvm reproducible [39227d54][56c03572][6ae0526f]
+ Simplified Signature.perl/gist for unnamed invocants [71159bed][f14dc6bd]
+ Made it possible to call .perl on uninitialized native strings [b12fba38]
+ Made .gist on native / non-native arrays similar [4e88fa15]
+ Fixed overzealous X::Syntax::NoSelf throwage [9b915f09]
+ Fixed smartmatching an Iterable type object [385308d3]
+ Fixed unexpected POD table failures [2cda7a19]
+ Made pass() and flunk() more consistent [82b3a894]
+ Fixed distribution path format on windows [4cacbf66]
+ Various fixes for the JVM backend [7d2940ee][cc57d06a][be35160d]
+ Various improvements to produced messages [7b336519][0de80523]
[b4973115][22d08069]
+ Additions:
+ Added shapes support for HAS scoped attributes [4c3807c5][7847768c]
+ Added NativeCall CArray.allocate method [a02131d5]
+ Added "use p5isms" pragma to stop complaints about Perl 5 traps [8ae82a55]
[8ccda189][7bde26fc]
+ Removals:
+ Removed some 5to6 error messages [3f350912][4ac9915e]
[5ce24929][cf35764d][44538f50]
+ Build system:
+ Fixed Configure script to not assume gmake location [abd88a94]
+ Efficiency:
+ Made Int.lsb 2x faster [9e2dacd4]
+ Made Int.msb 2x faster [775a42ee]
+ Made Range slices on native arrays about 23x faster [67a31600]
[f038e12d][09cbe679][c69179cc]
+ Made .splice on native arrays up to 2x faster [ee1ba153]
[4ab2f2cd][da646aa2][e0ad668e]
+ Made Rat / FatRat stringification up to 200x faster [e0dca0cc]
+ Made creation of regexes up to 30% faster [32a78996]
+ Made @a.splice(offset) about 20% faster [8d12d5b4][a5d46b42][8bde96d2]
+ Made module loading 10ms faster by avoiding IO::relative [849ba56d]
+ Other minor optimizations [d53fe90a][aa18140e][776ff354]
[ac6e26e8][073a7f50][54e390f5]
+ Internal:
+ Introduced nqp::slice op [090432bb]
The following people contributed to this release:
Juan Julián Merelo Guervós, Elizabeth Mattijsen, Zoffix Znet,
Will "Coke" Coleda, Aleks-Daniel Jakimenko-Aleksejev, Luca Ferrari,
Christian Bartolomäus, 陈梓立, Samantha McVey, Stefan Seifert,
Brian S. Julin, Ben Davies, Elena Merelo, Jeremy Studer, Paweł Murias,
Daniel Green, Itsuki Toyota, Fritz Zaucker, Nick Logan, cfa, Steve Mynott,
Moritz Lenz, Cecilia, Tom Browder, Timo Paulssen, Tobias Leich,
Lucas Buchala, Paula, Reko98, Jonathan Worthington, Ronald Schmidt,
COMBORICO, thundergnat, Martin Ryan, Claudio Ramirez,
Wenzel P. P. Peppmeyer, Christian Sánchez, antoniogamiz, Jonas Kramer,
Luis F. Uceta, Oleksii Varianyk, Jan-Olof Hendig, Martin Barth,
Julien Simonet, brian d foy, Matt Oates, allan
If you would like to contribute or find out more information, visit
<https://perl6.org>, <https://rakudo.org/how-to-help>, ask on the
<perl6-compiler@perl.org> mailing list, or ask on IRC #perl6 on freenode.
Additionally, we invite you to make a donation to The Perl Foundation
to sponsor Perl 6 development: <https://donate.perlfoundation.org/>
(put “Perl 6 Core Development Fund” in the ‘Purpose’ text field)
The next release of Rakudo (#124), is tentatively scheduled for 2018-06-16.
A list of the other planned release dates is available in the
“docs/release_guide.pod” file.
The development team appreciates feedback! If you’re using Rakudo, do
get back to us. Questions, comments, suggestions for improvements, cool
discoveries, incredible hacks, or any other feedback – get in touch with
us through (the above-mentioned) mailing list or IRC channel. Enjoy!
Please note that recent releases have known issues running on the JVM.
We are working to get the JVM backend working again but do not yet have
an estimated delivery date.
[^1]: See <http://moarvm.org/>
[^2]: What’s the difference between the Rakudo compiler and the Rakudo
Star distribution?
The Rakudo compiler is a compiler for the Perl 6 language.
Not much more.
The Rakudo Star distribution is the Rakudo compiler plus a selection
of useful Perl 6 modules, a module installer, Perl 6 introductory
documentation, and other software that can be used with the Rakudo
compiler to enhance its utility.
......@@ -18,8 +18,7 @@ Note that we are trying very hard to ensure there are no backward
compatibility issues post Christmas. As such, we may end up delaying
some releases to ensure any compatibility issues are resolved.
2018-05-19 Rakudo #123 (AlexDaniel + Releasable)
2018-06-16 Rakudo #124
2018-06-16 Rakudo #124 (AlexDaniel + Releasable)
2018-07-21 Rakudo #125
2018-08-18 Rakudo #126
2018-09-15 Rakudo #127
......@@ -73,7 +72,7 @@ any occurrences, remove the code and make sure the spectest is still ok.
=item *
Review the RT queue for tickets that might need resolving
Review the issue tracker for tickets that might need resolving
prior to the release, addressing them as needed. “Tickets
that need resolving” is left to your discretion. Any problem
that has a large impact on users is worth addressing either
......@@ -318,7 +317,7 @@ and L<https://rakudo.perl6.org/downloads/rakudo/>:
If you do not have permissions for that, ask one of (pmichaud, jnthn, FROGGS,
masak, tadzik, moritz, PerlJam/perlpilot, [Coke], lizmat, timotimo, fsergot,
hoelzro, Zoffix) on #perl6 or #perl6-dev to do it for you.
hoelzro, Zoffix, AlexDaniel) on #perl6 or #perl6-dev to do it for you.
=item 19.
......@@ -469,6 +468,7 @@ Previous releases were bundled as part of monthly Parrot releases.
2018-03-19 Rakudo #121 "2018.03" (AlexDaniel + Releasable)
2018-04-25 Rakudo #122 "2018.04" (AlexDaniel + Releasable)
2018-04-30 2018.04.1 (AlexDaniel + Releasable)
2018-05-24 Rakudo #123 "2018.05" (AlexDaniel + Releasable)
=head1 COPYRIGHT
......
......@@ -582,7 +582,7 @@ our role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distributi
}
}
multi sub postcircumfix:<[ ]>(CArray:D \array, $pos) is export(:DEFAULT, :types) {
multi sub postcircumfix:<[ ]>(CArray:D \array, $pos) is export(:DEFAULT, :types) is default {
$pos ~~ Iterable ?? $pos.map: { array.AT-POS($_) } !! array.AT-POS($pos);
}
multi sub postcircumfix:<[ ]>(CArray:D \array, *@pos) is export(:DEFAULT, :types) {
......
......@@ -90,7 +90,7 @@ our class Pointer is repr('CPointer') {
# CArray class, used to represent C arrays.
our class CArray is repr('CArray') is array_type(Pointer) {
method AT-POS(CArray:D: $pos) { die "CArray cannot be used without a type" }
method AT-POS(::?CLASS:D: $pos) { die "CArray cannot be used without a type" }
my role IntTypedCArray[::TValue] does Positional[TValue] is array_type(TValue) {
multi method AT-POS(::?CLASS:D \arr: $pos) is raw {
......@@ -111,6 +111,17 @@ our class CArray is repr('CArray') is array_type(Pointer) {
multi method ASSIGN-POS(::?CLASS:D \arr: int $pos, Int $assignee) {
nqp::bindpos_i(nqp::decont(arr), $pos, nqp::unbox_i($assignee));
}
multi method allocate(::?CLASS:U \type: int $elems) {
my $arr := nqp::create(type);
nqp::bindpos_i($arr, $_, nqp::create(Int)) for ^$elems;
$arr;
}
multi method allocate(::?CLASS:U \type: Int:D $elems) {
my $arr := nqp::create(type);
nqp::bindpos_i($arr, $_, nqp::create(Int)) for ^$elems;
$arr;
}
}
my role NumTypedCArray[::TValue] does Positional[TValue] is array_type(TValue) {
......@@ -132,6 +143,17 @@ our class CArray is repr('CArray') is array_type(Pointer) {
multi method ASSIGN-POS(::?CLASS:D \arr: int $pos, Num $assignee) {
nqp::bindpos_n(nqp::decont(arr), $pos, nqp::unbox_n($assignee));
}
multi method allocate(::?CLASS:U \type: int $elems) {
my $arr := nqp::create(type);
nqp::bindpos_n($arr, $_, nqp::create(Num)) for ^$elems;
$arr;
}
multi method allocate(::?CLASS:U \type: Int:D $elems) {
my $arr := nqp::create(type);
nqp::bindpos_n($arr, $_, nqp::create(Num)) for ^$elems;
$arr;
}
}
my role TypedCArray[::TValue] does Positional[TValue] is array_type(TValue) {
......@@ -161,6 +183,19 @@ our class CArray is repr('CArray') is array_type(Pointer) {
multi method ASSIGN-POS(::?CLASS:D \arr: Int $pos, \assignee) {
nqp::bindpos(nqp::decont(arr), nqp::unbox_i($pos), nqp::decont(assignee));
}
multi method allocate(::?CLASS:U: int $elems) {
my $arr := nqp::create(self);
my $type := ::?CLASS.^array_type;
nqp::bindpos($arr, $_, nqp::create($type)) for ^$elems;
$arr;
}
multi method allocate(::?CLASS:U: Int:D $elems) {
my $arr := nqp::create(self);
my $type := ::?CLASS.^array_type;
nqp::bindpos($arr, $_, nqp::create($type)) for ^$elems;
$arr;
}
}
method ^parameterize(Mu:U \arr, Mu:U \t) {
my $mixin;
......
......@@ -116,8 +116,9 @@ multi sub plan($number_of_tests) is export {
multi sub pass($desc = '') is export {
$time_after = nqp::time_n;
proclaim(1, $desc);
my $ok = proclaim(1, $desc);
$time_before = nqp::time_n;
$ok;
}
multi sub ok(Mu $cond, $desc = '') is export {
......@@ -444,7 +445,7 @@ sub _diag(Mu $message, :$force-stderr) {
}
# In earlier Perls, this is spelled "sub fail"
multi sub flunk($reason) is export {
multi sub flunk($reason = '') is export {
$time_after = nqp::time_n;
my $ok = proclaim(0, $reason);
$time_before = nqp::time_n;
......
......@@ -2151,10 +2151,15 @@ class Perl6::Actions is HLL::Actions does STDActions {
}
}
$past.push($require_past);
my $unwanted := $past.shallow_clone();
$past.push($<module_name>
?? self.make_indirect_lookup($longname.components())
!! $<file>.ast);
make $past;
make QAST::Want.new(
$past,
'v',
$unwanted
);
}
method statement_control:sym<given>($/) {
......@@ -3199,6 +3204,18 @@ class Perl6::Actions is HLL::Actions does STDActions {
if nqp::objprimspec($attr.type) != 0 {
$/.worry('Useless use of HAS scope on ' ~ $attr.type.HOW.name($attr.type) ~ ' typed attribute.');
}
if $attr.type.REPR eq 'CArray' {
if $<scoped><DECL><declarator><variable_declarator><semilist> -> $semilist {
my @dimensions := nqp::list_i();
for $semilist -> $dimension {
my $elems := nqp::unbox_i($*W.compile_time_evaluate($/, $dimension.ast, :mark-wanted));
nqp::push_i(@dimensions, $elems);
}
nqp::bindattr($attr, $attr.WHAT, '$!dimensions', @dimensions);
}
}
# Mark $attr as inlined, that's why we do all this.
nqp::bindattr_i($attr, $attr.WHAT, '$!inlined', 1);
make $scoped;
......@@ -9083,7 +9100,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
my $var-qast := QAST::Var.new: :$name, :scope<local>;
my $wval := QAST::WVal.new: :value($_);
my $what := nqp::what($_);
my $isCode := nqp::istype($_,
my $isCode := nqp::defined($_) && nqp::istype($_,
$*W.find_symbol: ['Code'], :setting-only);
my $param := QAST::ParamTypeCheck.new(
nqp::eqaddr($what, $wInt)
......
......@@ -359,30 +359,38 @@ role STD {
}
# "when" arg assumes more things will become obsolete after Perl 6 comes out...
method obs($old, $new, $when = 'in Perl 6') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
method obs($old, $new, $when = 'in Perl 6', :$always) {
unless $*LANG.pragma('p5isms') && !$always {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
}
}
method obsvar($name, $identifier-name?) {
$*W.throw(self.MATCH(), ['X', 'Syntax', 'Perl5Var'],
:$name, :$identifier-name);
unless $*LANG.pragma('p5isms') {
$*W.throw(self.MATCH(), ['X', 'Syntax', 'Perl5Var'],
:$name, :$identifier-name);
}
}
method sorryobs($old, $new, $when = 'in Perl 6') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
unless $*LANG.pragma('p5isms') {
$*W.throw(self.MATCH(), ['X', 'Obsolete'],
old => $old,
replacement => $new,
when => $when,
);
}
}
method worryobs($old, $new, $when = 'in Perl 6') {
self.typed_worry('X::Obsolete',
old => $old,
replacement => $new,
when => $when,
);
unless $*LANG.pragma('p5isms') {
self.typed_worry('X::Obsolete',
old => $old,
replacement => $new,
when => $when,
);
}
}
method dupprefix($prefixes) {
......@@ -1935,6 +1943,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}
token term:sym<undef> {
<!{ $*LANG.pragma('p5isms') }>
<sym> >> {}
[ <?before \h*'$/' >
<.obs('$/ variable as input record separator',
......@@ -1947,7 +1956,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}
token term:sym<new> {
'new' \h+ <longname> \h* <![:]> <.obs("C++ constructor syntax", "method call syntax")>
'new' \h+ <longname> \h* <![:]> <.obs("C++ constructor syntax", "method call syntax", :always)>
}
token fatarrow {
......@@ -2024,11 +2033,6 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<.obsvar('%!')>
}
token special_variable:sym<$~> {
<sym> <?before \h* '='>
<.obsvar('$~')>
}
token special_variable:sym<$`> {
<sym> <?before \s | ',' | <.terminator> >
<.obsvar('$`')>
......@@ -2040,42 +2044,21 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}
token special_variable:sym<$#> {
<sym> [<identifier>]?
<sym> <identifier>
{}
<.obsvar('$#', $<identifier> && ~$<identifier>)>
<.obsvar('$#', ~$<identifier>)>
}
token special_variable:sym<$$> {
<sym> \W
<.obsvar('$$')>
}
token special_variable:sym<$%> {
<sym> <?before \h* '='>
<.obsvar('$%')>
}
# TODO: $^X and other "caret" variables
token special_variable:sym<$^> {
<sym> <?before \h* '='>
<.obsvar('$^')>
}
token special_variable:sym<$&> {
<sym> <?before \s | ',' | <.terminator> >
<.obsvar('$&')>
}
token special_variable:sym<$*> {
<sym> <?before \h* '='>
<.obsvar('$*')>
}
token special_variable:sym<$=> {
<sym> <?before \h+ '='>
<.obsvar('$=')>
}
token special_variable:sym<@+> {
<sym> <?before \s | ',' | <.terminator> >
<.obsvar('@+')>
......@@ -2141,11 +2124,6 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<.obsvar('$|')>
}
token special_variable:sym<$:> {
<sym> <?before \h* '='>
<.obsvar('$:')>
}
token special_variable:sym<$;> {
<sym> <?before \h* '='>
<.obsvar('$;')>
......@@ -2761,9 +2739,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
]?
[ <.ws> <trait>+ ]?
[ <.ws> :my $*HAS_SELF :=
$*SCOPE eq 'has' ?? nqp::null !! nqp::getlexdyn('$*HAS_SELF')
; <post_constraint('var')>+ ]?
[ <.ws> <post_constraint('var')>+ ]?
}
proto token routine_declarator { <...> }
......@@ -3185,6 +3161,8 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
rule post_constraint($*CONSTRAINT_USAGE) {
:my $*IN_DECL := '';
:my $*HAS_SELF := $*CONSTRAINT_USAGE eq 'var' && $*SCOPE eq 'has'
?? nqp::null !! nqp::getlexdyn('$*HAS_SELF');
:dba('constraint')
[
| '[' ~ ']' <signature>
......
......@@ -22,11 +22,13 @@ my class BOOTSTRAPATTR {
has $!box_target;
has $!package;
has $!inlined;
has $!dimensions;
method name() { $!name }
method type() { $!type }
method box_target() { $!box_target }
method package() { $!package }
method inlined() { $!inlined }
method dimensions() { $!dimensions }
method has_accessor() { 0 }
method positional_delegate() { 0 }
method associative_delegate() { 0 }
......@@ -1145,6 +1147,8 @@ BEGIN {
# has Mu $!auto_viv_container;
# has Mu $!build_closure;
# has Mu $!package;
# has int $!inlined;
# has Mu $!dimensions;
# has int $!positional_delegate;
# has int $!associative_delegate;
# has Mu $!why;
......@@ -1161,6 +1165,7 @@ BEGIN {
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!build_closure>, :type(Mu), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!package>, :type(Mu), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!inlined>, :type(int), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!dimensions>, :type(Mu), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!box_target>, :type(int), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!positional_delegate>, :type(int), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!associative_delegate>, :type(int), :package(Attribute)));
......
......@@ -113,8 +113,10 @@ role Perl6::Metamodel::BUILDPLAN {
}
# Add vivify instructions.
for %attrs_untouched {
nqp::push(@plan,[10, $obj, $_.key]);
for @attrs { # iterate over the array to get a consistent order
if nqp::existskey(%attrs_untouched, $_.name) {
nqp::push(@plan,[10, $obj, $_.name]);
}
}
# Does it have a TWEAK?
......
......@@ -49,6 +49,9 @@ role Perl6::Metamodel::REPRComposeProtocol {
if nqp::can($attr, 'inlined') {
%attr_info<inlined> := $attr.inlined;
}
if nqp::can($attr, 'dimensions') {
%attr_info<dimensions> := $attr.dimensions;
}
nqp::push(@attrs, %attr_info);
}
......
......@@ -274,6 +274,7 @@ my class Symbols {
if +%sym {
return %!SETTING_CACHE{$symbol} := self.force_value(%sym, $symbol, 1);
}
nqp::die("Optimizer couldn't find $symbol in SETTING.");
}
}
......@@ -1350,6 +1351,24 @@ class Perl6::Optimizer {
@!block_var_stack[nqp::elems(@!block_var_stack) - 1].register_takedispatcher($op);
}
# Make array variable initialization cheaper
elsif
$!level > 0
&& $optype eq 'callmethod'
&& $op.name eq 'STORE'
&& nqp::elems($op.list()) == 3
&& nqp::istype($op[0], QAST::Var)
&& nqp::substr($op[0].name, 0, 1) eq '@'
&& nqp::istype($op[1], QAST::Op)
&& ($op[1].op eq 'call' || $op[1].op eq 'callstatic')
&& $op[1].name eq '&infix:<,>'
&& $!symbols.is_from_core($op[1].name)
&& nqp::istype($op[2], QAST::WVal)
&& nqp::istype($op[2], QAST::SpecialArg)
{
return self.optimize_array_variable_initialization($op);
}
# Calls are especially interesting as we may wish to do some
# kind of inlining.
elsif $optype eq 'call' {
......@@ -1448,6 +1467,106 @@ class Perl6::Optimizer {
}
}
method optimize_array_variable_initialization($op) {
my $Positional := $!symbols.find_in_setting('Positional');
if $op[0].returns =:= $Positional {
# Turns the @var.STORE(infix:<,>(...)) into:
# nqp::getattr(
# nqp::p6bindattrinvres(
# nqp::p6bindattrinvres(
# @var,
# List,
# $!reified,
# nqp::create(IterationBuffer),
# ),
# List,
# $!todo,
# nqp::p6bindattrinvres(
# nqp::p6bindattrinvres(
# nqp::p6bindattrinvres(
# $reifier,
# List::Reifier,
# '$!reified',
# nqp::getattr(@var, List, $!reified),
# ),
# List::Reifier,
# '$!reification-target',
# @var.reification-target()
# ),
# List::Reifier,
# '$!future',
# nqp::list(...),
# ),
# ),
# List,
# '$!todo'
# ).reify-until-lazy();
$op.op('callmethod');
$op.name('reify-until-lazy');
my $array_var := $op[0];
my $comma_op := $op[1];
$comma_op.op('getattr');
$comma_op.name(NQPMu);
my $List := $!symbols.find_in_setting('List');
my $Reifier := $!symbols.find_in_setting('List').WHO<Reifier>;
my $IterationBuffer := $!symbols.find_in_setting('IterationBuffer');
my $list := QAST::Op.new(:op<list>);
$list.set_children(@($comma_op));
$comma_op.set_children([
QAST::Op.new(
:op<p6bindattrinvres>,
QAST::Op.new(
:op<p6bindattrinvres>,
$array_var,
QAST::WVal.new(:value($List)),
QAST::SVal.new(:value('$!reified')),
QAST::Op.new(:op<create>, QAST::WVal.new(:value($IterationBuffer))),
),
QAST::WVal.new(:value($List)),
QAST::SVal.new(:value('$!todo')),
QAST::Op.new(
:op<p6bindattrinvres>,
QAST::Op.new(
:op<p6bindattrinvres>,
QAST::Op.new(
:op<p6bindattrinvres>,
QAST::Op.new(:op<create>, QAST::WVal.new(:value($Reifier))),
QAST::WVal.new(:value($Reifier)),
QAST::SVal.new(:value('$!reified')),
QAST::Op.new(
:op<getattr>,
$array_var,
QAST::WVal.new(:value($List)),
QAST::SVal.new(:value('$!reified')),
)
),
QAST::WVal.new(:value($Reifier)),
QAST::SVal.new(:value('$!reification-target')),
QAST::Op.new(
:op<callmethod>,
:name('reification-target'),
$array_var,
)
),
QAST::WVal.new(:value($Reifier)),
QAST::SVal.new(:value('$!future')),
$list,
),
),
QAST::WVal.new(:value($List)),
QAST::SVal.new(:value('$!todo')),
]);
$op.set_children([$comma_op]);
return QAST::Stmts.new: $op, $array_var;
}
$op
}