Skip to content

Commit

Permalink
Merge pull request #3138 from vrurg/problem_solving_94
Browse files Browse the repository at this point in the history
Improve multi-revision support

- `core/` is now `core.c/`
- each core gets its own BOOTSTRAP and EXPORTHOW.
- bootstrap is now compiled into Perl6/BOOTSTRAP/v6<rev>
- whereas words `CORE` and `NULL` were used for `6.c`, they now have
  `.c` suffix as other revisions do.

Raku/problem-solving#94
  • Loading branch information
vrurg committed Aug 27, 2019
2 parents 636888c + fa3d168 commit 3f699e2
Show file tree
Hide file tree
Showing 247 changed files with 4,236 additions and 1,116 deletions.
8 changes: 4 additions & 4 deletions blib/Perl6/.gitignore
@@ -1,5 +1,5 @@
# Don't remove this file and dir.
# They are needed to host the bytecode files during the build process
for any VM.
*.pbc
*.class
# They are needed to host the bytecode files during the build process for any VM.
*.moarvm
*.class
*.jar
5 changes: 5 additions & 0 deletions blib/Perl6/BOOTSTRAP/.gitignore
@@ -0,0 +1,5 @@
# Don't remove this file and dir.
# They are needed to host the bytecode files during the build process for any VM.
*.moarvm
*.class
*.jar
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -1886,7 +1886,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
# isn't already declared.
my $BLOCK := $*W.cur_lexpad();
my $type := $BLOCK.ann('IN_DECL');
if $type eq 'mainline' && %*COMPILING<%?OPTIONS><setting> eq 'NULL' {
if $type eq 'mainline' && %*COMPILING<%?OPTIONS><setting> eq 'NULL.c' {
# Don't do anything in the case where we are in the mainline of
# the setting; we don't have any symbols (Scalar, etc.) yet.
return 1;
Expand Down
12 changes: 6 additions & 6 deletions src/Perl6/ModuleLoader.nqp
Expand Up @@ -43,12 +43,12 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {

method load_module($module_name, %opts, *@GLOBALish, :$line, :$file, :%chosen) {
DEBUG("going to load $module_name") if $DEBUG;
if $module_name eq 'Perl6::BOOTSTRAP' {
if nqp::eqat($module_name, 'Perl6::BOOTSTRAP::v6', 0) {
my $preserve_global := nqp::ifnull(nqp::gethllsym('perl6', 'GLOBAL'), NQPMu);
my %*COMPILING := {};
my $*CTXSAVE := self;
my $*MAIN_CTX;
my $file := 'Perl6/BOOTSTRAP' ~ self.file-extension;
my $file := nqp::join('/', nqp::split('::', $module_name)) ~ self.file-extension;

my @prefixes := self.search_path();
for @prefixes -> $prefix {
Expand Down Expand Up @@ -215,10 +215,10 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {

# Transforms NULL.<release> into CORE.<previous-release>
method previous_setting_name ($setting_name, :$base = 'CORE') {
my $m := $setting_name ~~ /$base '.' ( <[c..z]> )/;
my $m := $setting_name ~~ /$base '.' ( <[d..z]> )/;
if $m {
my $rev := ~nqp::atpos($m, 0);
$setting_name := 'CORE' ~ ($rev le 'd' ?? '' !! '.' ~ nqp::chr(nqp::ord($rev) - 1));
$setting_name := 'CORE' ~ '.' ~ nqp::chr(nqp::ord($rev) - 1);
}
$setting_name
}
Expand All @@ -230,15 +230,15 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
method load_setting($setting_name) {
my $setting;

if $setting_name ne 'NULL' {
if $setting_name ne 'NULL.c' {
DEBUG("Requested for settings $setting_name") if $DEBUG;
# XXX TODO: see https://github.com/rakudo/rakudo/issues/2432
$setting_name := self.transform_setting_name($setting_name);

# First, pre-load previous setting.
my $prev_setting_name := self.previous_setting_name($setting_name);
my $prev_setting;
# Don't do this for .c which is just CORE.
# Don't do this for .c for which $setting_name doesn't change
unless nqp::iseq_s($prev_setting_name, $setting_name) {
$prev_setting := self.load_setting($prev_setting_name);
}
Expand Down
27 changes: 11 additions & 16 deletions src/Perl6/World.nqp
Expand Up @@ -596,8 +596,8 @@ class Perl6::World is HLL::World {
# fast-path the common cases
if $revision eq 'c' {
$*CAN_LOWER_TOPIC := 0;
# CORE.c is currently our lowest core, which we don't "load"
$!setting_name := 'CORE';
# # CORE.c is currently our lowest core, which we don't "load"
$!setting_name := 'CORE.c';
return;
}

Expand Down Expand Up @@ -640,10 +640,7 @@ class Perl6::World is HLL::World {
$*CAN_LOWER_TOPIC := 0;
# CORE.c is our lowest core, which we don't "load"
}
else {
$!setting_name := 'CORE.' ~ $can_rev;
# self.load_setting: $ver-match, 'CORE.' ~ $can_rev;
}
$!setting_name := 'CORE.' ~ $can_rev;
return;
}

Expand Down Expand Up @@ -680,13 +677,10 @@ class Perl6::World is HLL::World {
}
else {
$!setting_name := %*COMPILING<%?OPTIONS><setting> // $default_setting_name;
if nqp::eqat($!setting_name, 'NULL', 0) {
if nqp::eqat($!setting_name, 'NULL.', 0) {
$*COMPILING_CORE_SETTING := 1;
$*SET_DEFAULT_LANG_VER := 0;
my $lang_ver := nqp::iseq_s($!setting_name, 'NULL')
?? '6.c'
!! '6.' ~ nqp::substr($!setting_name, 5, 1);
nqp::getcomp('perl6').set_language_version: $lang_ver;
nqp::getcomp('perl6').set_language_version: '6.' ~ nqp::substr($!setting_name, 5, 1);

}
$*UNIT.annotate('IN_DECL', 'mainline');
Expand Down Expand Up @@ -769,8 +763,9 @@ class Perl6::World is HLL::World {
}

# Bootstrap
if $!setting_name eq 'NULL' {
my $name := "Perl6::BOOTSTRAP";
# if $!setting_name eq 'NULL' {
if nqp::eqat($!setting_name, 'NULL.', 0) {
my $name := "Perl6::BOOTSTRAP::v6" ~ nqp::substr($!setting_name, 5, 1) ;
my $module := self.load_module_early($/, $name, $*GLOBALish);
my $EXPORT := $module<EXPORT>.WHO;
my @to_import := ['MANDATORY', 'DEFAULT'];
Expand Down Expand Up @@ -937,8 +932,8 @@ class Perl6::World is HLL::World {
if $*INSIDE-EVAL && $!have_outer {
return
}
# Do nothing for the NULL setting.
if $setting_name ne 'NULL' {
# Do nothing for the NULL.c setting.
if $setting_name ne 'NULL.c' {
# XXX TODO: see https://github.com/rakudo/rakudo/issues/2432
$setting_name := Perl6::ModuleLoader.transform_setting_name($setting_name);
# Load it immediately, so the compile time info is available.
Expand Down Expand Up @@ -4824,7 +4819,7 @@ class Perl6::World is HLL::World {
if nqp::chars($rev) == 1 && nqp::existskey(nqp::getcomp('perl6').language_revisions,$rev) {
$no-outers := 1; # you don't see other COREs!
nqp::shift(@name);
$setting_name := 'CORE' ~ (nqp::iseq_s($rev, 'c') ?? '' !! ".$rev");
$setting_name := 'CORE' ~ '.' ~ $rev;
}
}
}
Expand Down
Expand Up @@ -3608,7 +3608,7 @@ BEGIN {
EXPORT::DEFAULT.WHO<List> := List;
EXPORT::DEFAULT.WHO<Slip> := Slip;
EXPORT::DEFAULT.WHO<Array> := Array;
EXPORT::DEFAULT.WHO<Map> := Map;
EXPORT::DEFAULT.WHO<Map> := Map;
EXPORT::DEFAULT.WHO<Hash> := Hash;
EXPORT::DEFAULT.WHO<Capture> := Capture;
EXPORT::DEFAULT.WHO<ObjAt> := ObjAt;
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/Perl6/bootstrap.d/BOOTSTRAP.nqp
@@ -0,0 +1 @@
# 6.d doesn't neeed a bootstrap. This file is here for consistency only.
4 changes: 4 additions & 0 deletions src/Perl6/bootstrap.d/EXPORTHOW.nqp
@@ -0,0 +1,4 @@
# v6.d EXPORTHOW
# It's used for consistency only
my module EXPORTHOW {
}
4 changes: 4 additions & 0 deletions src/Perl6/bootstrap.e/BOOTSTRAP.nqp
@@ -0,0 +1,4 @@
# v6.e bootstrap file
use QRegex;

# vim: expandtab shiftwidth=4
4 changes: 4 additions & 0 deletions src/Perl6/bootstrap.e/EXPORTHOW.nqp
@@ -0,0 +1,4 @@
# v6.e EXPORTHOW
# It's used for consistency only
my module EXPORTHOW {
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 5 additions & 14 deletions t/08-performance/03-corekeys-6c.t → t/02-rakudo/03-corekeys-6c.t
@@ -1,9 +1,11 @@
use v6.c;
use lib 't/packages';
use Test;
use Test::Helpers;
plan 1;

# output of "perl6 -e '.say for CORE::.keys.sort.map: { qq:!c/ Q{$_},/ }'"
my %allowed = (
my @expected = (
Q{!INIT_VALUES},
Q{$!},
Q{$/},
Expand All @@ -13,7 +15,6 @@ my %allowed = (
Q{$?NL},
Q{$?TABSTOP},
Q{$_},
Q{%DEPRECATIONS},
Q{&CLONE-HASH-DECONTAINERIZED},
Q{&CLONE-LIST-DECONTAINERIZED},
Q{&CMP-SLOW},
Expand Down Expand Up @@ -500,7 +501,6 @@ my %allowed = (
Q{Broken},
Q{Buf},
Q{CX},
Q{CachedIterator},
Q{CallFrame},
Q{Callable},
Q{Cancellation},
Expand Down Expand Up @@ -757,15 +757,6 @@ my %allowed = (
Q{π},
Q{τ},
Q{𝑒},
Q{$=finish},
Q{$?PACKAGE},
Q{::?PACKAGE},
Q{GLOBALish},
Q{},
Q{EXPORT},
).map: { $_ => 1 };
);

my @unknown;
@unknown.push($_) unless %allowed{$_}:exists for CORE::.keys;
diag "Found {+@unknown} unexpected entries: { @unknown.sort }" unless
ok @unknown == 0, "No unexpected entries in CORE::";
has-symbols CORE::, @expected, "Symbols in 6.c CORE::";

0 comments on commit 3f699e2

Please sign in to comment.