Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Merge branch 'precomp-singleprocess' into nom"
This reverts commit 459a418, reversing
changes made to 3172033.
  • Loading branch information
lizmat committed Dec 6, 2015
1 parent 459a418 commit ccf15ec
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 33 deletions.
54 changes: 30 additions & 24 deletions src/core/CompUnit/PrecompilationRepository.pm
Expand Up @@ -17,8 +17,6 @@ BEGIN CompUnit::PrecompilationRepository::<None> := CompUnit::PrecompilationRepo

class CompUnit { ... }
class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationRepository {
use nqp;

has CompUnit::PrecompilationStore $.store;

method !check-dependencies(IO::Path $path, Instant $since) {
Expand Down Expand Up @@ -67,32 +65,40 @@ class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationR

my Mu $opts := nqp::atkey(%*COMPILING, '%?OPTIONS');
my $lle = !nqp::isnull($opts) && !nqp::isnull(nqp::atkey($opts, 'll-exception'))
?? True
!! False;
my @*PRECOMP-WITH = $*REPO.repo-chain>>.path-spec;
my @*PRECOMP-LOADING = @*MODULES;
my $*PRECOMP-DIST = $*RESOURCES if $*RESOURCES !~~ Failure;

RAKUDO_MODULE_DEBUG("Precomping with @*PRECOMP-WITH.join(',')")
if $*RAKUDO_MODULE_DEBUG;
?? '--ll-exception'
!! Empty;
%*ENV<RAKUDO_PRECOMP_WITH> = $*REPO.repo-chain>>.path-spec.join(',');
%*ENV<RAKUDO_PRECOMP_LOADING> = to-json @*MODULES;
my $current_dist = %*ENV<RAKUDO_PRECOMP_DIST>;
%*ENV<RAKUDO_PRECOMP_DIST> = $*RESOURCES ?? $*RESOURCES.Str !! '{}';

my @dependencies;
my $*ADD-DEPENDENCY = -> $id, $src { @dependencies.push: [$id, $src] };
my $proc = run($*EXECUTABLE, $lle, "--target={$*VM.precomp-target}", "--output=$io", $path, :out);
%*ENV<RAKUDO_PRECOMP_WITH>:delete;
%*ENV<RAKUDO_PRECOMP_LOADING>:delete;
%*ENV<RAKUDO_PRECOMP_DIST> = $current_dist;

my $compiler := nqp::getcomp('perl6');
$compiler.evalfiles: $path, :ll-exception($lle), :target($*VM.precomp-target), :output($io),
:encoding('utf8'), :transcode('ascii iso-8859-1');

my $compiler-id = $*PERL.compiler.id;
for @dependencies -> ($dependency-id, $dependency-src) {
my $path = self.store.path($compiler-id, $dependency-id);
if $path.e {
spurt(($path ~ '.rev-deps').IO, "$id\n", :append);
my @result = $proc.out.lines;
if not $proc.out.close or $proc.status { # something wrong
self.store.unlock;
push @result, "Return status { $proc.status }\n";
RAKUDO_MODULE_DEBUG("Precomping $path failed: {@result}") if $*RAKUDO_MODULE_DEBUG;
fail @result if @result;
}
else {
my @dependencies;
my $compiler-id = $*PERL.compiler.id;
for @result -> $dependency {
my ($dependency-id, $dependency-src) = $dependency.words;
my $path = self.store.path($compiler-id, $dependency-id);
if $path.e {
push @dependencies, $dependency;
spurt(($path ~ '.rev-deps').IO, "$id\n", :append);
}
}
spurt(($io ~ '.deps').IO, @dependencies.map(* ~ "\n").join(''));
self.store.unlock;
True
}
spurt ($io ~ '.deps').IO, @dependencies.map({"$_[0] $_[1]\n"}).join('');
self.store.unlock;
True
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/CompUnit/Repository/FileSystem.pm
Expand Up @@ -50,7 +50,7 @@ class CompUnit::Repository::FileSystem does CompUnit::Repository::Locally does C

if $found {
my $id = nqp::sha1($name ~ $*REPO.id);
$*ADD-DEPENDENCY($id, $found) if $*W and $*W.is_precompilation_mode;
say "$id $found" if $*W and $*W.is_precompilation_mode;
my $*RESOURCES = Distribution::Resources.new(:repo(self), :dist-id(''));
my $handle = (
$precomp.may-precomp and (
Expand Down
2 changes: 1 addition & 1 deletion src/core/CompUnit/Repository/Installation.pm
Expand Up @@ -251,7 +251,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {
my $handle;
my $id = self!precomp-id($loader.Str);
if $precomp.may-precomp {
$*ADD-DEPENDENCY($id, $loader) if $*W and $*W.is_precompilation_mode;
say "$id $loader" if $*W and $*W.is_precompilation_mode;
$handle = (
$precomp.load($id, :since($loader.modified)) # already precompiled?
or $precomp.precompile($loader, $id) and $precomp.load($id) # if not do it now
Expand Down
5 changes: 2 additions & 3 deletions src/core/CompUnitRepo.pm
Expand Up @@ -69,10 +69,9 @@ RAKUDO_MODULE_DEBUG("Looking in $spec for $name")

{
my @*MODULES := @MODULES;
if +@*MODULES == 0 and @*PRECOMP-LOADING !~~ Failure {
@*MODULES = @*PRECOMP-LOADING;
if +@*MODULES == 0 and %*ENV<RAKUDO_PRECOMP_LOADING> -> $loading {
@*MODULES := from-json $loading;
}
RAKUDO_MODULE_DEBUG("\@*MODULES = @*MODULES.join(', ')") if $*RAKUDO_MODULE_DEBUG;
for @*MODULES.list -> $m {
if $m eq $module_name {
nqp::die("Circular module loading detected involving module '$module_name'");
Expand Down
5 changes: 3 additions & 2 deletions src/core/Distribution.pm
Expand Up @@ -54,8 +54,9 @@ class Distribution::Resources does Associative {
}

method from-precomp() {
return unless %*PRECOMP-DIST;
self.new(:repo($*PRECOMP-DIST<repo>), :dist-id($*PRECOMP-DIST<dist-id>))
return unless %*ENV<RAKUDO_PRECOMP_DIST>;
my %data := from-json %*ENV<RAKUDO_PRECOMP_DIST>;
self.new(:repo(%data<repo>), :dist-id(%data<dist-id>))
}

method AT-KEY($key) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/Process.pm
Expand Up @@ -46,8 +46,8 @@ multi sub INITIALIZE_DYNAMIC('$*REPO') {
my %ENV := %*ENV; # only look up environment once

# starting up for creating precomp
if @*PRECOMP-WITH !~~ Failure {
@INC = @*PRECOMP-WITH; # assume well formed strings
if %ENV<RAKUDO_PRECOMP_WITH> -> \specs {
@INC = specs.split(','); # assume well formed strings
}

# normal start up
Expand Down

0 comments on commit ccf15ec

Please sign in to comment.