Skip to content

Instantly share code, notes, and snippets.

use nqp;
my %type-map = ('QAST::IVal' => 'I', 'QAST::Var' => 'V', 'QAST::Op' => 'O', 'QAST::Stmts' => 'S');
my $prog = 'my $aa = 4; say "([$aa]" ~ (3 + $aa);';
my @hl = ' ' xx $prog.chars;
sub traverse($indent, Mu $item) {
if $item.^name eq "QAST::SVal" {
say (" " x $indent) ~ $item.^name ~ " '" ~ $item.value ~ "' ";
/usr/bin/perl -MExtUtils::Command -e mkpath gen/moar/stage1/gen
/usr/bin/perl tools/build/gen-cat.pl moar src/core/NativeTypes.nqp src/core/NQPRoutine.nqp src/core/NQPMu.nqp src/core/NQPCapture.nqp src/core/IO.nqp src/core/Regex.nqp src/core/Hash.nqp src/core/NQPLock.nqp src/core/testing.nqp src/core/YOUAREHERE.nqp > gen/moar/stage1/NQPCORE.setting
/home/robertle/target/bin/moar --libpath=src/vm/moar/stage0 src/vm/moar/stage0/nqp.moarvm --bootstrap --module-path=gen/moar/stage1 --setting=NULL --no-regex-lib --target=mbc --stable-sc=stage1 \
--output=gen/moar/stage1/NQPCORE.setting.moarvm gen/moar/stage1/NQPCORE.setting
Bytecode stream version too high
at src/vm/moar/ModuleLoader.nqp:51 (src/vm/moar/stage0/ModuleLoader.moarvm:)
from src/vm/moar/ModuleLoader.nqp:41 (src/vm/moar/stage0/ModuleLoader.moarvm:load_module)
from gen/moar/stage2/NQP.nqp:269 (src/vm/moar/stage0/nqp.moarvm:load_module)
from gen/moar/stage2/NQP.nqp:2420 (src/vm/moar/stage0/nqp.moarvm:statement_control:sym<use>)
from gen/mo
This is Rakudo version 2018.08-95-g213e3282b built on MoarVM version
2018.08-63-ga8dfd4793
code in question:
https://github.com/robertlemmen/p6bench/blob/cb5ad52/03-backend
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f09d021750b in MVM_interp_run (tc=tc@entry=0x7f09b408fb20,
initial_invoke=0x7f0990e0ac70,
invoke_data=0x0, invoke_data@entry=0x7f09b408d470) at src/core/interp.c:3913
@robertlemmen
robertlemmen / asyc-io-golf.pl6
Created August 19, 2018 20:15
IO::Socket::Async is async, but not parallel
#!/usr/bin/env perl6
# start this and then run e.g. ab -n 100 -c 25 http://127.0.0.1:6060
# you can also try by hand with telnet or so
my $h = '0.0.0.0';
my $p = 6060;
say "starting tcp server on $h:$p";
my $server-socket = IO::Socket::Async.listen($h, $p);
my $done = Promise.new();
my $time = DateTime.new(1534447684).utc + Duration.new(0.002);
for ^100 -> $i {
$time = $time + Duration.new(2.rand);
say "$i $time";
}

A less Stern Look of Disapproval

A while ago a great person callen Karen wrote a Perl 5 Module called Acme::LookOfDisapproval (http://search.cpan.org/~ether/Acme-LookOfDisapproval-0.006/lib/Acme/LookOfDisapproval.pm). It allows you to use a well known and visually clear character sequence instead of the somewhat cryptic Perl "warn" method:

    ಠ_ಠ 'cannot handle request due to missing foobricator';

While this module probably has not found it's way into too many production systems, I want to argue that it is a very useful module line-for-line:

Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007f8d68c74349 in uv.write () from //home/robertle/perl6source/target/lib/libmoar.so
[Current thread is 1 (Thread 0x7f8d6938e700 (LWP 22608))]
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7f8d6938e700 (LWP 22608) 0x00007f8d68c74349 in uv.write ()
from //home/robertle/perl6source/target/lib/libmoar.so
2 Thread 0x7f8d65848700 (LWP 22609) pthread_cond_wait@@GLIBC_2.3.2 ()
at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
3 Thread 0x7f8d373fd700 (LWP 22655) 0x00007f8d68ba7ce7 in MVM_frame_invoke (tc=0x7f8d3001cc70,
*** Error in `/home/robertle/perl6env/rakudobrew/moar-nom/install/bin/moar': munmap_chunk(): invalid pointer: 0x00007fb9c408acc0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bcb)[0x7fb9cf001bcb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76f96)[0x7fb9cf007f96]
//home/robertle/perl6env/rakudobrew/moar-nom/install/lib/libmoar.so(+0x1d1649)[0x7fb9cf501649]
//home/robertle/perl6env/rakudobrew/moar-nom/install/lib/libmoar.so(MVM_gc_collect_free_nursery_uncopied+0xd9)[0x7fb9cf4db099]
//home/robertle/perl6env/rakudobrew/moar-nom/install/lib/libmoar.so(+0x1a6f1f)[0x7fb9cf4d6f1f]
//home/robertle/perl6env/rakudobrew/moar-nom/install/lib/libmoar.so(MVM_gc_enter_from_interrupt+0xdc)[0x7fb9cf4d731c]
//home/robertle/perl6env/rakudobrew/moar-nom/install/lib/libmoar.so(MVM_gc_allocate_nursery+0x55)[0x7fb9cf4d79c5]
//home/robertle/perl6env/rakudobrew/moar-nom/install/lib/libmoar.so(MVM_gc_allocate_object+0x44)[0x7fb9cf4d7be4]
my $done = Promise.new();
my $listener = IO::Socket::Async.listen('127.0.0.1', 8080);
my $tap = $listener.tap( -> $client {
say "acepted on " ~ $*THREAD.id;
$client.Supply().tap(-> $input {
say "read input on " ~ $*THREAD.id;
$client.print($input);
sleep-until now+10;
say "/read $*THREAD.id;
});