Skip to content

Instantly share code, notes, and snippets.

Created July 31, 2015 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/be8272afe09047875f16 to your computer and use it in GitHub Desktop.
Save anonymous/be8272afe09047875f16 to your computer and use it in GitHub Desktop.
The code below seems ok on simple tests but there's spectest
fallout and one of my modules (Data::Selector) also breaks.
Seems the return has changed somehow but I can't figure it
out. I had to change line 241 of lib/Data/Selector.pm like
so:
- make $/.<selector_group>>>.ast.hash;
+ make $/.<selector_group>>>.ast.[0].hash;
to make it work again.
I'm using:
[jdv@wieldy rakudo]$ perl6 -v
This is perl6 version 2015.07.1-45-g31a083f built on MoarVM version 2015.07-5-gbbe6231
[jdv@wieldy rakudo]$
with this patch:
[jdv@wieldy rakudo]$ git diff
diff --git a/src/core/metaops.pm b/src/core/metaops.pm
index 3bf9fe5..bababde 100644
--- a/src/core/metaops.pm
+++ b/src/core/metaops.pm
@@ -425,37 +425,39 @@ multi sub HYPER(\op, \obj) {
proto sub deepmap(|) { * }
multi sub deepmap(\op, \obj) {
+ my $lock = nqp::create(Lock);
+ my $cond = $lock.condition;
+ my int $todo = 0;
+ my int $done = 0;
+ my Exception $ex;
+ my int $batch_size = (%*ENV<RAKUDO_HYPER_BATCH_SIZE> // 10).Int;
+
my Mu $rpa := nqp::list();
my Mu $items := nqp::p6listitems(obj.flat.eager);
- my Mu $o;
- # We process the elements in two passes, end to start, to
- # prevent users from relying on a sequential ordering of hyper.
- # Also, starting at the end pre-allocates $rpa for us.
+
my int $i = nqp::elems($items) - 1;
- nqp::while(
- nqp::isge_i($i, 0),
- nqp::stmts(
- ($o := nqp::atpos($items, $i)),
- nqp::bindpos($rpa, $i,
- nqp::if(nqp::istype($o, Iterable),
- $o.new(deepmap(op, $o)).item,
- op.($o))),
- $i = nqp::sub_i($i, 2)
- )
- );
- $i = nqp::elems($items) - 2;
- nqp::while(
- nqp::isge_i($i, 0),
- nqp::stmts(
- ($o := nqp::atpos($items, $i)),
- nqp::bindpos($rpa, $i,
- nqp::if(nqp::istype($o, Iterable),
- $o.new(deepmap(op, $o)).item,
- op.($o))),
- $i = nqp::sub_i($i, 2)
- )
- );
- nqp::p6parcel($rpa, Nil);
+ while $i > -1 {
+ my int $from = $i;
+ my int $to = $i -= $batch_size;
+ $to = -1 if $to < -1;
+ $*SCHEDULER.cue( {
+ while $from > $to {
+ my Mu $o := nqp::atpos($items, $from);
+ my Mu $r = nqp::if(nqp::istype($o, Iterable),
+ $o.new(deepmap(op, $o)).item,
+ op.($o));
+ $lock.protect: { nqp::bindpos($rpa, $from, $r) }
+ $from--;
+ }
+ $lock.protect: { $cond.signal if ++$done == $todo }
+ }, catch => sub ($e) { $ex = $e; $cond.signal } );
+ $lock.protect: { $todo++ }
+ }
+
+ $lock.protect: { $cond.wait unless $done == $todo || $ex }
+ die $ex if $ex;
+
+ nqp::p6parcel(nqp::decont($rpa), Nil);
}
multi sub deepmap(\op, Associative \h) {
diff --git a/tools/build/moar_core_sources b/tools/build/moar_core_sources
index f283053..ae20c33 100644
--- a/tools/build/moar_core_sources
+++ b/tools/build/moar_core_sources
@@ -115,11 +115,11 @@ src/core/ObjAt.pm
src/core/Version.pm
src/core/ForeignCode.pm
src/core/operators.pm
-src/core/metaops.pm
src/core/precedence.pm
src/core/Deprecations.pm
src/core/Thread.pm
src/core/Lock.pm
+src/core/metaops.pm
src/core/Semaphore.pm
src/core/Cancellation.pm
src/core/Scheduler.pm
[jdv@wieldy rakudo]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment