Skip to content

Instantly share code, notes, and snippets.

View jnthn's full-sized avatar

Jonathan Worthington jnthn

View GitHub Profile
@jnthn
jnthn / ffs.c
Created March 8, 2017 12:09 — forked from bdw/ffs.c
cross-platform first set bit
#include <stdio.h>
#include <stdlib.h>
#define MVMint32 int
#ifdef __GNUC__
#define FFS(x) __builtin_ffs(x)
#elif defined(_MSC_VER)
static __inline MVMint32 FFS(MVMint32 x) {
MVMint32 i = 0;
@jnthn
jnthn / eval.p6
Last active March 23, 2017 11:14
use Test;
lives-ok {
await Promise.allof((^3).map: {
start {
for ^200 {
EVAL "True";
}
}
});
Slide 3: Cross Compiler
- The NQP and Rakudo compilers are also cross-compilers by this definition,
since their output works on any platform
Slide 9: sysroot
- So if I follow, this is only relevant to compiling native code, and it says
where the headers etc. for that target platform live?
Slide 14:
- The MoarVM build process builds itself a minilua as a build tool. If I
@jnthn
jnthn / answers.md
Last active February 25, 2016 20:48
Answers to some concurrency questions
  1. Should two different taps of a a serial supply be run simultaneuosly?

$ perl6 -e 'my $p = Supplier.new; my $s = $p.Supply; $s.serial.say; $s.tap({ sleep 1; "42 {now}".say; }); $s.tap({ sleep 1; "43 {now}".say }); $p.emit(42); sleep 3;' True 42 Instant:1449454902.847377 43 Instant:1449454903.854135

No. Supplies do not introduce concurrency, at least not unless you explicitly ask for it with something like the start method. So the emit here is doing no more than a loop through the taps, calling the closures passed to tap one

class BoundedChannel is Channel {
has $!lock = Lock.new;
has $!send-cond = $!lock.condition;
has $.limit is required;
method send(|c) {
$!lock.lock();
LEAVE $!lock.unlock();
while $!limit == 0 {
$!send-cond.wait();
C:\consulting\rakudo>type flunk.pm
sub fail($a?) is export { use Test }
C:\consulting\rakudo>perl6-m -Ilib --target=mbc --output=flunk.moarvm flunk.pm
C:\consulting\rakudo>perl6-m -Ilib -I. -e "use flunk;"
C:\consulting\rakudo>perl6-m -Ilib -I. -e "use flunk; say 'ok'"
ok
diff --git a/src/core/interp.c b/src/core/interp.c
index a650dc2..89a5909 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
@@ -3316,7 +3316,10 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 4;
goto NEXT;
OP(readlineint_fh):
- GET_REG(cur_op, 0).s = MVM_file_readline_interactive_fh(tc, GET_REG(cur_op, 2).o, GET_REG(cur_op, 4).s);
+ /* XXX Avoid readline for now; spews infinite prompts on some
diff --git a/3rdparty/libuv b/3rdparty/libuv
--- a/3rdparty/libuv
+++ b/3rdparty/libuv
@@ -1 +1 @@
-Subproject commit 3e054c36294f9d8fc197c9d1b715ea2db334f6bf
+Subproject commit 3e054c36294f9d8fc197c9d1b715ea2db334f6bf-dirty
diff --git a/src/core/interp.c b/src/core/interp.c
index 5d8f0d5..d9ae539 100644
--- a/src/core/interp.c
+++ b/src/core/interp.c
diff --git a/src/vm/jvm/core/Supply.pm b/src/vm/jvm/core/Supply.pm
index d52519e..2de8ce9 100644
--- a/src/vm/jvm/core/Supply.pm
+++ b/src/vm/jvm/core/Supply.pm
@@ -127,15 +127,15 @@ sub on(&setup) {
$source.tap(
-> \val {
$lock.protect({ more(val) });
- CATCH { self.quit($_) }
+ CATCH { default { self.quit($_) } }